WordPress File Upload - Version 2.2.1

Version Description

  • added file browser in Dashboard for admins
  • added attribute medialink to allow uploaded files to be shown in Media
  • serious bug fixed that was breaking the plugin because of preg_replace_callback function
  • corrected error in first attempt to upload file when captcha is enabled
Download this release

Release Info

Developer nickboss
Plugin Icon 128x128 WordPress File Upload
Version 2.2.1
Comparing to
See all releases

Code changes from version 2.1.3 to 2.2.1

css/wordpress_file_upload_adminstyle.css CHANGED
@@ -1,532 +1,532 @@
1
- div.wfu_shortcode_container
2
- {
3
- display: inline-block;
4
- position: relative;
5
- width: 50%;
6
- padding: 0;
7
- margin: 0;
8
- background: none;
9
- border: none;
10
- }
11
-
12
- textarea.wfu_shortcode
13
- {
14
- width: 100%;
15
- }
16
-
17
- div.wfu_container
18
- {
19
- margin-top: 10px;
20
- }
21
-
22
- div.wfu_help_container
23
- {
24
- display: inline-block;
25
- position: relative;
26
- top: 4px;
27
- padding: 0;
28
- margin: 0;
29
- background: none;
30
- border: none;
31
- }
32
-
33
- div.wfu_td_div
34
- {
35
- display: block;
36
- position: relative;
37
- width: 100%;
38
- height: 100%;
39
- padding: 0;
40
- margin: 0;
41
- background: none;
42
- border: none;
43
- }
44
-
45
- div.wfu_container input.wfu_long_text { width: 100%; }
46
- div.wfu_container input.wfu_short_text { width: 60px; }
47
- div.wfu_container input { width: 200px; }
48
- div.wfu_container input[type="checkbox"] { width: auto; }
49
-
50
- table.wfu_main_table { table-layout: fixed; }
51
-
52
- table.wfu_inner_table { }
53
-
54
- table.wfu_main_table tr:nth-child(odd) { background-color: #f4f4f4; }
55
-
56
- table.wfu_main_table tr:nth-child(even) { background-color: transparent; }
57
-
58
- table.wfu_main_table table.wfu_inner_table tr { background-color: transparent; }
59
-
60
- table.wfu_main_table th { width: 17%; }
61
-
62
- table.wfu_main_table td:nth-child(2) { width: 33%; }
63
-
64
- table.wfu_main_table td:nth-child(3) { width: 50%; }
65
-
66
- table.wfu_main_table table.wfu_inner_table th { width: 34%; }
67
-
68
- table.wfu_main_table table.wfu_inner_table td:nth-child(2) { width: 66%; }
69
-
70
- table.wfu_main_table tr.wfu_subcategory { background-color: #ddd; }
71
-
72
- table.wfu_main_table tr.wfu_subcategory > th { padding-top: 0; padding-bottom: 0; }
73
-
74
- select.wfu_variable
75
- {
76
- padding: 0px;
77
- margin: 0px;
78
- height: auto;
79
- font-size: smaller;
80
- background-color: #ddd;
81
- border: 1px solid #ccc;
82
- color: rgb(51, 51, 51);
83
- -webkit-border-radius: 5px;
84
- -moz-border-radius: 5px;
85
- -khtml-border-radius: 5px;
86
- border-radius: 5px;
87
- -webkit-touch-callout: none;
88
- -webkit-user-select: none;
89
- -khtml-user-select: none;
90
- -moz-user-select: none;
91
- -ms-user-select: none;
92
- user-select: none;
93
- cursor: default;
94
- }
95
-
96
- span.wfu_variable
97
- {
98
- padding: 1px;
99
- margin: 0px;
100
- font-size: smaller;
101
- background-color: #ddd;
102
- border: 1px solid #ccc;
103
- color: rgb(51, 51, 51);
104
- -webkit-border-radius: 5px;
105
- -moz-border-radius: 5px;
106
- -khtml-border-radius: 5px;
107
- border-radius: 5px;
108
- -webkit-touch-callout: none;
109
- -webkit-user-select: none;
110
- -khtml-user-select: none;
111
- -moz-user-select: none;
112
- -ms-user-select: none;
113
- user-select: none;
114
- cursor: default;
115
- }
116
-
117
- span.wfu_ptext_span
118
- {
119
- display: inline-block;
120
- width: 60px;
121
- }
122
-
123
- div.wfu_rolelist_checkall
124
- {
125
- display: inline-block;
126
- vertical-align: top;
127
- margin: 0px 0px 0px 10px;
128
- }
129
-
130
- div.wfu_shadow
131
- {
132
- position: absolute;
133
- width: 100%;
134
- height: 100%;
135
- left: 0;
136
- top: 0;
137
- margin: 0;
138
- padding: 0;
139
- background-color: white;
140
- z-index: 10;
141
- -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=60)";
142
- filter: alpha(opacity=60);
143
- -moz-opacity: 0.6;
144
- -khtml-opacity: 0.6;
145
- opacity: 0.6;
146
- }
147
-
148
- table.wfu_main_table tr:nth-child(odd) div.wfu_shadow { background-color: #f4f4f4; }
149
-
150
- div.wfu_onoff_container_on, div.wfu_onoff_container_off
151
- {
152
- display: inline-block;
153
- position: relative;
154
- padding: 2px;
155
- border: 1px solid #aaa;
156
- -webkit-border-radius: 3px;
157
- -moz-border-radius: 3px;
158
- -khtml-border-radius: 3px;
159
- border-radius: 3px;
160
- background: rgb(6,109,171);
161
- background: -moz-linear-gradient(top, rgba(6,109,171,1) 0%, rgba(197,222,234,1) 100%);
162
- background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(6,109,171,1)), color-stop(100%,rgba(197,222,234,1)));
163
- background: -webkit-linear-gradient(top, rgba(6,109,171,1) 0%,rgba(197,222,234,1) 100%);
164
- background: -o-linear-gradient(top, rgba(6,109,171,1) 0%,rgba(197,222,234,1) 100%);
165
- background: -ms-linear-gradient(top, rgba(6,109,171,1) 0%,rgba(197,222,234,1) 100%);
166
- background: linear-gradient(to bottom, rgba(6,109,171,1) 0%,rgba(197,222,234,1) 100%);
167
- filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#066dab', endColorstr='#c5deea',GradientType=0 );
168
- }
169
-
170
- span.wfu_onoff_text
171
- {
172
- width: 30px;
173
- display: inline-block;
174
- text-align: center;
175
- color: #FFF;
176
- }
177
-
178
- div.wfu_onoff_slider
179
- {
180
- position: absolute;
181
- margin: 0;
182
- width: 31px;
183
- top: 0px;
184
- bottom: 0px;
185
- border: 1px solid #fff;
186
- -webkit-border-radius: 2px;
187
- -moz-border-radius: 2px;
188
- -khtml-border-radius: 2px;
189
- border-radius: 2px;
190
- -moz-box-shadow: 0px 0px 2px;
191
- -webkit-box-shadow: 0px 0px 2px;
192
- box-shadow: 0px 0px 2px;
193
- background: rgb(204,204,204);
194
- background: -moz-linear-gradient(top, rgba(204,204,204,1) 0%, rgba(255,255,255,1) 100%);
195
- background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(204,204,204,1)), color-stop(100%,rgba(255,255,255,1)));
196
- background: -webkit-linear-gradient(top, rgba(204,204,204,1) 0%,rgba(255,255,255,1) 100%);
197
- background: -o-linear-gradient(top, rgba(204,204,204,1) 0%,rgba(255,255,255,1) 100%);
198
- background: -ms-linear-gradient(top, rgba(204,204,204,1) 0%,rgba(255,255,255,1) 100%);
199
- background: linear-gradient(to bottom, rgba(204,204,204,1) 0%,rgba(255,255,255,1) 100%);
200
- filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#cccccc', endColorstr='#ffffff',GradientType=0 );
201
- }
202
-
203
- div.wfu_onoff_container_on div.wfu_onoff_slider
204
- {
205
- left: 50%;
206
- /* -webkit-animation: set_on 0.1s linear;
207
- -moz-animation: set_on 0.1s linear;
208
- -o-animation: set_on 0.1s linear;
209
- animation: set_on 0.1s linear; */
210
- }
211
-
212
- div.wfu_onoff_container_off div.wfu_onoff_slider
213
- {
214
- left: 0%;
215
- /* -webkit-animation: set_on 0.1s linear reverse;
216
- -moz-animation: set_on 0.1s linear reverse;
217
- -o-animation: set_on 0.1s linear reverse;
218
- animation: set_on 0.1s linear reverse; */
219
- }
220
-
221
- @-webkit-keyframes set_on { from { left: 0%; } to { left: 50%; } }
222
- @-moz-keyframes set_on { from { left: 0%; } to { left: 50%; } }
223
- @-o-keyframes set_on { from { left: 0%; } to { left: 50%; } }
224
- @keyframes set_on { from { left: 0%; } to { left: 50%; } }
225
-
226
- div.wfu_placements_wrapper
227
- {
228
- display: block;
229
- position: relative;
230
- margin: 0;
231
- padding: 0;
232
- background: none;
233
- border: none;
234
- }
235
-
236
- div.wfu_placements_container
237
- {
238
- display: inline-block;
239
- position: relative;
240
- width: 100%;
241
- height: 300px;
242
- background-color: white;
243
- border: 1px solid #ccc;
244
- -webkit-border-radius: 3px;
245
- -moz-border-radius: 3px;
246
- -khtml-border-radius: 3px;
247
- border-radius: 3px;
248
- padding: 0;
249
- overflow: scroll;
250
- font-size: 0;
251
- line-height: 0;
252
- white-space: nowrap;
253
- }
254
-
255
- div.wfu_componentlist_container
256
- {
257
- display: inline-block;
258
- position: absolute;
259
- width: auto;
260
- height: auto;
261
- top: 0;
262
- left: 100%;
263
- background: none;
264
- border: none;
265
- margin: 0 0 0 20px;
266
- padding: 0;
267
- z-index: 1;
268
- white-space: nowrap;
269
- }
270
-
271
- div.wfu_component_box_container
272
- {
273
- display: inline-block;
274
- position: relative;
275
- width: 80px;
276
- height: 30px;
277
- background-color: transparent;
278
- border: 1px solid transparent;
279
- padding: 4px;
280
- margin: 0;
281
- cursor: default;
282
- }
283
-
284
- div.wfu_component_box_base
285
- {
286
- display: block;
287
- position: absolute;
288
- width: 80px;
289
- height: 30px;
290
- left: -1px;
291
- top: -1px;
292
- background-color: #ddd;
293
- border: 1px solid #bbb;
294
- -webkit-border-radius: 3px;
295
- -moz-border-radius: 3px;
296
- -khtml-border-radius: 3px;
297
- border-radius: 3px;
298
- padding: 4px;
299
- cursor: default;
300
- font-size: 12px;
301
- line-height: 1;
302
- -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=40)";
303
- filter: alpha(opacity=40);
304
- -moz-opacity: 0.4;
305
- -khtml-opacity: 0.4;
306
- opacity: 0.4;
307
- white-space: normal;
308
- }
309
-
310
- div.wfu_component_box
311
- {
312
- display: inline-block;
313
- position: relative;
314
- width: 80px;
315
- height: 30px;
316
- background-color: #ddd;
317
- border: 1px solid #bbb;
318
- -webkit-border-radius: 3px;
319
- -moz-border-radius: 3px;
320
- -khtml-border-radius: 3px;
321
- border-radius: 3px;
322
- padding: 4px;
323
- cursor: default;
324
- font-size: 12px;
325
- line-height: 1;
326
- z-index: 1;
327
- white-space: normal;
328
- }
329
-
330
- div.wfu_inbase
331
- {
332
- display: block;
333
- position: absolute;
334
- left: -1px;
335
- top: -1px;
336
- }
337
-
338
- div.wfu_component_box:hover
339
- {
340
- background-color: #eee;
341
- border: 1px solid #bbb;
342
- }
343
-
344
- div.wfu_component_box_selected
345
- {
346
- background-color: #aaa;
347
- border: 1px solid #bbb;
348
- }
349
-
350
- div.wfu_component_box_dragged
351
- {
352
- -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=40)";
353
- filter: alpha(opacity=40);
354
- -moz-opacity: 0.4;
355
- -khtml-opacity: 0.4;
356
- opacity: 0.4;
357
- }
358
-
359
- div.wfu_component_separator_ver
360
- {
361
- display: inline-block;
362
- position: relative;
363
- width: 8px;
364
- height: 26px;
365
- background-color: transparent;
366
- border: 1px solid transparent;
367
- margin: 6px -8px;
368
- padding: 0 8px;
369
- cursor: default;
370
- z-index: 1;
371
- }
372
-
373
- div.wfu_component_separator_hor
374
- {
375
- display: block;
376
- position: relative;
377
- width: 100%;
378
- height: 8px;
379
- background-color: transparent;
380
- border: 1px solid transparent;
381
- margin: -8px 0;
382
- padding: 8px 0;
383
- cursor: default;
384
- z-index: 1;
385
- }
386
-
387
- div.wfu_component_bar_hor
388
- {
389
- position: absolute;
390
- width: auto;
391
- height: 4px;
392
- left: 10px;
393
- right: 0;
394
- background-color: silver;
395
- border: none;
396
- margin: 11px 0 0 0;
397
- padding: 0;
398
- display: none;
399
- }
400
-
401
- div.wfu_component_bar_ver
402
- {
403
- position: absolute;
404
- width: 4px;
405
- height: 40px;
406
- background-color: silver;
407
- border: none;
408
- margin: -6px 0 0 11px;
409
- padding: 0;
410
- display: none;
411
- }
412
-
413
- div.wfu_componentlist_dragdrop
414
- {
415
- position: absolute;
416
- width: 100%;
417
- height: 100%;
418
- left: 0;
419
- top: 0;
420
- background-color: #f8f8f8;
421
- border: 4px dashed #aaa;
422
- -webkit-box-sizing: border-box;
423
- -moz-box-sizing: border-box;
424
- box-sizing: border-box;
425
- margin: 0;
426
- padding: 0;
427
- z-index: 2;
428
- -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";
429
- filter: alpha(opacity=70);
430
- -moz-opacity: 0.7;
431
- -khtml-opacity: 0.7;
432
- opacity: 0.7;
433
- }
434
-
435
- div.wfu_componentlist_dragdrop_dragover
436
- {
437
- border: 4px dashed #555;
438
- }
439
-
440
- div.wfu_userdata_container
441
- {
442
- display: block;
443
- position: relative;
444
- width: 100%;
445
- height: 100%;
446
- padding: 0;
447
- margin: 0;
448
- background: none;
449
- border: none;
450
- }
451
-
452
- div.wfu_userdata_action
453
- {
454
- display: inline-block;
455
- position: relative;
456
- top: 2px;
457
- width: 16px;
458
- height: 16px;
459
- padding: 0;
460
- margin: 0;
461
- background: none;
462
- text-align: center;
463
- border: 1px solid transparent;
464
- -webkit-border-radius: 3px;
465
- -moz-border-radius: 3px;
466
- -khtml-border-radius: 3px;
467
- border-radius: 3px;
468
- }
469
-
470
- div.wfu_userdata_action:hover { border: 1px solid #aaa; }
471
-
472
- div.wfu_userdata_action.wfu_userdata_action_disabled:hover { border: 1px solid transparent; }
473
-
474
- div.wfu_userdata_action > img { width: 12px; height: 12px; }
475
-
476
- div.wfu_userdata_action_disabled > img
477
- {
478
- -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=40)";
479
- filter: alpha(opacity=40);
480
- -moz-opacity: 0.4;
481
- -khtml-opacity: 0.4;
482
- opacity: 0.4;
483
- }
484
-
485
- div.wfu_userdata_line
486
- {
487
- display: block;
488
- position: relative;
489
- padding: 0;
490
- margin: 0;
491
- background: none;
492
- border: none;
493
- white-space: nowrap;
494
- }
495
-
496
- /* ColorPicker Styles */
497
- div.wfu_color_container
498
- {
499
- display: block;
500
- position: relative;
501
- padding: 0;
502
- margin: 0;
503
- background: none;
504
- border: none;
505
- white-space: nowrap;
506
- z-index: 1;
507
- }
508
- input[type="text"].wp-color-picker { width: 75px; }
509
- input[type="button"].wp-picker-clear { width: 62px; }
510
-
511
- /* Shortcode Styles */
512
- span.wfu_save_label
513
- {
514
- background-color: aliceblue;
515
- color: limegreen;
516
- border-radius: 6px;
517
- padding: 1px 2px;
518
- box-shadow: 1px 1px 1px;
519
- font-size: smaller;
520
- opacity: 0;
521
- }
522
-
523
- span.wfu_save_label_fail
524
- {
525
- background-color: beige;
526
- color: lightcoral;
527
- border-radius: 6px;
528
- padding: 1px 2px;
529
- box-shadow: 1px 1px 1px;
530
- font-size: smaller;
531
- opacity: 0;
532
- }
1
+ div.wfu_shortcode_container
2
+ {
3
+ display: inline-block;
4
+ position: relative;
5
+ width: 50%;
6
+ padding: 0;
7
+ margin: 0;
8
+ background: none;
9
+ border: none;
10
+ }
11
+
12
+ textarea.wfu_shortcode
13
+ {
14
+ width: 100%;
15
+ }
16
+
17
+ div.wfu_container
18
+ {
19
+ margin-top: 10px;
20
+ }
21
+
22
+ div.wfu_help_container
23
+ {
24
+ display: inline-block;
25
+ position: relative;
26
+ top: 4px;
27
+ padding: 0;
28
+ margin: 0;
29
+ background: none;
30
+ border: none;
31
+ }
32
+
33
+ div.wfu_td_div
34
+ {
35
+ display: block;
36
+ position: relative;
37
+ width: 100%;
38
+ height: 100%;
39
+ padding: 0;
40
+ margin: 0;
41
+ background: none;
42
+ border: none;
43
+ }
44
+
45
+ div.wfu_container input.wfu_long_text { width: 100%; }
46
+ div.wfu_container input.wfu_short_text { width: 60px; }
47
+ div.wfu_container input { width: 200px; }
48
+ div.wfu_container input[type="checkbox"] { width: auto; }
49
+
50
+ table.wfu_main_table { table-layout: fixed; }
51
+
52
+ table.wfu_inner_table { }
53
+
54
+ table.wfu_main_table tr:nth-child(odd) { background-color: #f4f4f4; }
55
+
56
+ table.wfu_main_table tr:nth-child(even) { background-color: transparent; }
57
+
58
+ table.wfu_main_table table.wfu_inner_table tr { background-color: transparent; }
59
+
60
+ table.wfu_main_table th { width: 17%; }
61
+
62
+ table.wfu_main_table td:nth-child(2) { width: 33%; }
63
+
64
+ table.wfu_main_table td:nth-child(3) { width: 50%; }
65
+
66
+ table.wfu_main_table table.wfu_inner_table th { width: 34%; }
67
+
68
+ table.wfu_main_table table.wfu_inner_table td:nth-child(2) { width: 66%; }
69
+
70
+ table.wfu_main_table tr.wfu_subcategory { background-color: #ddd; }
71
+
72
+ table.wfu_main_table tr.wfu_subcategory > th { padding-top: 0; padding-bottom: 0; }
73
+
74
+ select.wfu_variable
75
+ {
76
+ padding: 0px;
77
+ margin: 0px;
78
+ height: auto;
79
+ font-size: smaller;
80
+ background-color: #ddd;
81
+ border: 1px solid #ccc;
82
+ color: rgb(51, 51, 51);
83
+ -webkit-border-radius: 5px;
84
+ -moz-border-radius: 5px;
85
+ -khtml-border-radius: 5px;
86
+ border-radius: 5px;
87
+ -webkit-touch-callout: none;
88
+ -webkit-user-select: none;
89
+ -khtml-user-select: none;
90
+ -moz-user-select: none;
91
+ -ms-user-select: none;
92
+ user-select: none;
93
+ cursor: default;
94
+ }
95
+
96
+ span.wfu_variable
97
+ {
98
+ padding: 1px;
99
+ margin: 0px;
100
+ font-size: smaller;
101
+ background-color: #ddd;
102
+ border: 1px solid #ccc;
103
+ color: rgb(51, 51, 51);
104
+ -webkit-border-radius: 5px;
105
+ -moz-border-radius: 5px;
106
+ -khtml-border-radius: 5px;
107
+ border-radius: 5px;
108
+ -webkit-touch-callout: none;
109
+ -webkit-user-select: none;
110
+ -khtml-user-select: none;
111
+ -moz-user-select: none;
112
+ -ms-user-select: none;
113
+ user-select: none;
114
+ cursor: default;
115
+ }
116
+
117
+ span.wfu_ptext_span
118
+ {
119
+ display: inline-block;
120
+ width: 60px;
121
+ }
122
+
123
+ div.wfu_rolelist_checkall
124
+ {
125
+ display: inline-block;
126
+ vertical-align: top;
127
+ margin: 0px 0px 0px 10px;
128
+ }
129
+
130
+ div.wfu_shadow
131
+ {
132
+ position: absolute;
133
+ width: 100%;
134
+ height: 100%;
135
+ left: 0;
136
+ top: 0;
137
+ margin: 0;
138
+ padding: 0;
139
+ background-color: white;
140
+ z-index: 10;
141
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=60)";
142
+ filter: alpha(opacity=60);
143
+ -moz-opacity: 0.6;
144
+ -khtml-opacity: 0.6;
145
+ opacity: 0.6;
146
+ }
147
+
148
+ table.wfu_main_table tr:nth-child(odd) div.wfu_shadow { background-color: #f4f4f4; }
149
+
150
+ div.wfu_onoff_container_on, div.wfu_onoff_container_off
151
+ {
152
+ display: inline-block;
153
+ position: relative;
154
+ padding: 2px;
155
+ border: 1px solid #aaa;
156
+ -webkit-border-radius: 3px;
157
+ -moz-border-radius: 3px;
158
+ -khtml-border-radius: 3px;
159
+ border-radius: 3px;
160
+ background: rgb(6,109,171);
161
+ background: -moz-linear-gradient(top, rgba(6,109,171,1) 0%, rgba(197,222,234,1) 100%);
162
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(6,109,171,1)), color-stop(100%,rgba(197,222,234,1)));
163
+ background: -webkit-linear-gradient(top, rgba(6,109,171,1) 0%,rgba(197,222,234,1) 100%);
164
+ background: -o-linear-gradient(top, rgba(6,109,171,1) 0%,rgba(197,222,234,1) 100%);
165
+ background: -ms-linear-gradient(top, rgba(6,109,171,1) 0%,rgba(197,222,234,1) 100%);
166
+ background: linear-gradient(to bottom, rgba(6,109,171,1) 0%,rgba(197,222,234,1) 100%);
167
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#066dab', endColorstr='#c5deea',GradientType=0 );
168
+ }
169
+
170
+ span.wfu_onoff_text
171
+ {
172
+ width: 30px;
173
+ display: inline-block;
174
+ text-align: center;
175
+ color: #FFF;
176
+ }
177
+
178
+ div.wfu_onoff_slider
179
+ {
180
+ position: absolute;
181
+ margin: 0;
182
+ width: 31px;
183
+ top: 0px;
184
+ bottom: 0px;
185
+ border: 1px solid #fff;
186
+ -webkit-border-radius: 2px;
187
+ -moz-border-radius: 2px;
188
+ -khtml-border-radius: 2px;
189
+ border-radius: 2px;
190
+ -moz-box-shadow: 0px 0px 2px;
191
+ -webkit-box-shadow: 0px 0px 2px;
192
+ box-shadow: 0px 0px 2px;
193
+ background: rgb(204,204,204);
194
+ background: -moz-linear-gradient(top, rgba(204,204,204,1) 0%, rgba(255,255,255,1) 100%);
195
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(204,204,204,1)), color-stop(100%,rgba(255,255,255,1)));
196
+ background: -webkit-linear-gradient(top, rgba(204,204,204,1) 0%,rgba(255,255,255,1) 100%);
197
+ background: -o-linear-gradient(top, rgba(204,204,204,1) 0%,rgba(255,255,255,1) 100%);
198
+ background: -ms-linear-gradient(top, rgba(204,204,204,1) 0%,rgba(255,255,255,1) 100%);
199
+ background: linear-gradient(to bottom, rgba(204,204,204,1) 0%,rgba(255,255,255,1) 100%);
200
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#cccccc', endColorstr='#ffffff',GradientType=0 );
201
+ }
202
+
203
+ div.wfu_onoff_container_on div.wfu_onoff_slider
204
+ {
205
+ left: 50%;
206
+ /* -webkit-animation: set_on 0.1s linear;
207
+ -moz-animation: set_on 0.1s linear;
208
+ -o-animation: set_on 0.1s linear;
209
+ animation: set_on 0.1s linear; */
210
+ }
211
+
212
+ div.wfu_onoff_container_off div.wfu_onoff_slider
213
+ {
214
+ left: 0%;
215
+ /* -webkit-animation: set_on 0.1s linear reverse;
216
+ -moz-animation: set_on 0.1s linear reverse;
217
+ -o-animation: set_on 0.1s linear reverse;
218
+ animation: set_on 0.1s linear reverse; */
219
+ }
220
+
221
+ @-webkit-keyframes set_on { from { left: 0%; } to { left: 50%; } }
222
+ @-moz-keyframes set_on { from { left: 0%; } to { left: 50%; } }
223
+ @-o-keyframes set_on { from { left: 0%; } to { left: 50%; } }
224
+ @keyframes set_on { from { left: 0%; } to { left: 50%; } }
225
+
226
+ div.wfu_placements_wrapper
227
+ {
228
+ display: block;
229
+ position: relative;
230
+ margin: 0;
231
+ padding: 0;
232
+ background: none;
233
+ border: none;
234
+ }
235
+
236
+ div.wfu_placements_container
237
+ {
238
+ display: inline-block;
239
+ position: relative;
240
+ width: 100%;
241
+ height: 300px;
242
+ background-color: white;
243
+ border: 1px solid #ccc;
244
+ -webkit-border-radius: 3px;
245
+ -moz-border-radius: 3px;
246
+ -khtml-border-radius: 3px;
247
+ border-radius: 3px;
248
+ padding: 0;
249
+ overflow: scroll;
250
+ font-size: 0;
251
+ line-height: 0;
252
+ white-space: nowrap;
253
+ }
254
+
255
+ div.wfu_componentlist_container
256
+ {
257
+ display: inline-block;
258
+ position: absolute;
259
+ width: auto;
260
+ height: auto;
261
+ top: 0;
262
+ left: 100%;
263
+ background: none;
264
+ border: none;
265
+ margin: 0 0 0 20px;
266
+ padding: 0;
267
+ z-index: 1;
268
+ white-space: nowrap;
269
+ }
270
+
271
+ div.wfu_component_box_container
272
+ {
273
+ display: inline-block;
274
+ position: relative;
275
+ width: 80px;
276
+ height: 30px;
277
+ background-color: transparent;
278
+ border: 1px solid transparent;
279
+ padding: 4px;
280
+ margin: 0;
281
+ cursor: default;
282
+ }
283
+
284
+ div.wfu_component_box_base
285
+ {
286
+ display: block;
287
+ position: absolute;
288
+ width: 80px;
289
+ height: 30px;
290
+ left: -1px;
291
+ top: -1px;
292
+ background-color: #ddd;
293
+ border: 1px solid #bbb;
294
+ -webkit-border-radius: 3px;
295
+ -moz-border-radius: 3px;
296
+ -khtml-border-radius: 3px;
297
+ border-radius: 3px;
298
+ padding: 4px;
299
+ cursor: default;
300
+ font-size: 12px;
301
+ line-height: 1;
302
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=40)";
303
+ filter: alpha(opacity=40);
304
+ -moz-opacity: 0.4;
305
+ -khtml-opacity: 0.4;
306
+ opacity: 0.4;
307
+ white-space: normal;
308
+ }
309
+
310
+ div.wfu_component_box
311
+ {
312
+ display: inline-block;
313
+ position: relative;
314
+ width: 80px;
315
+ height: 30px;
316
+ background-color: #ddd;
317
+ border: 1px solid #bbb;
318
+ -webkit-border-radius: 3px;
319
+ -moz-border-radius: 3px;
320
+ -khtml-border-radius: 3px;
321
+ border-radius: 3px;
322
+ padding: 4px;
323
+ cursor: default;
324
+ font-size: 12px;
325
+ line-height: 1;
326
+ z-index: 1;
327
+ white-space: normal;
328
+ }
329
+
330
+ div.wfu_inbase
331
+ {
332
+ display: block;
333
+ position: absolute;
334
+ left: -1px;
335
+ top: -1px;
336
+ }
337
+
338
+ div.wfu_component_box:hover
339
+ {
340
+ background-color: #eee;
341
+ border: 1px solid #bbb;
342
+ }
343
+
344
+ div.wfu_component_box_selected
345
+ {
346
+ background-color: #aaa;
347
+ border: 1px solid #bbb;
348
+ }
349
+
350
+ div.wfu_component_box_dragged
351
+ {
352
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=40)";
353
+ filter: alpha(opacity=40);
354
+ -moz-opacity: 0.4;
355
+ -khtml-opacity: 0.4;
356
+ opacity: 0.4;
357
+ }
358
+
359
+ div.wfu_component_separator_ver
360
+ {
361
+ display: inline-block;
362
+ position: relative;
363
+ width: 8px;
364
+ height: 26px;
365
+ background-color: transparent;
366
+ border: 1px solid transparent;
367
+ margin: 6px -8px;
368
+ padding: 0 8px;
369
+ cursor: default;
370
+ z-index: 1;
371
+ }
372
+
373
+ div.wfu_component_separator_hor
374
+ {
375
+ display: block;
376
+ position: relative;
377
+ width: 100%;
378
+ height: 8px;
379
+ background-color: transparent;
380
+ border: 1px solid transparent;
381
+ margin: -8px 0;
382
+ padding: 8px 0;
383
+ cursor: default;
384
+ z-index: 1;
385
+ }
386
+
387
+ div.wfu_component_bar_hor
388
+ {
389
+ position: absolute;
390
+ width: auto;
391
+ height: 4px;
392
+ left: 10px;
393
+ right: 0;
394
+ background-color: silver;
395
+ border: none;
396
+ margin: 11px 0 0 0;
397
+ padding: 0;
398
+ display: none;
399
+ }
400
+
401
+ div.wfu_component_bar_ver
402
+ {
403
+ position: absolute;
404
+ width: 4px;
405
+ height: 40px;
406
+ background-color: silver;
407
+ border: none;
408
+ margin: -6px 0 0 11px;
409
+ padding: 0;
410
+ display: none;
411
+ }
412
+
413
+ div.wfu_componentlist_dragdrop
414
+ {
415
+ position: absolute;
416
+ width: 100%;
417
+ height: 100%;
418
+ left: 0;
419
+ top: 0;
420
+ background-color: #f8f8f8;
421
+ border: 4px dashed #aaa;
422
+ -webkit-box-sizing: border-box;
423
+ -moz-box-sizing: border-box;
424
+ box-sizing: border-box;
425
+ margin: 0;
426
+ padding: 0;
427
+ z-index: 2;
428
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";
429
+ filter: alpha(opacity=70);
430
+ -moz-opacity: 0.7;
431
+ -khtml-opacity: 0.7;
432
+ opacity: 0.7;
433
+ }
434
+
435
+ div.wfu_componentlist_dragdrop_dragover
436
+ {
437
+ border: 4px dashed #555;
438
+ }
439
+
440
+ div.wfu_userdata_container
441
+ {
442
+ display: block;
443
+ position: relative;
444
+ width: 100%;
445
+ height: 100%;
446
+ padding: 0;
447
+ margin: 0;
448
+ background: none;
449
+ border: none;
450
+ }
451
+
452
+ div.wfu_userdata_action
453
+ {
454
+ display: inline-block;
455
+ position: relative;
456
+ top: 2px;
457
+ width: 16px;
458
+ height: 16px;
459
+ padding: 0;
460
+ margin: 0;
461
+ background: none;
462
+ text-align: center;
463
+ border: 1px solid transparent;
464
+ -webkit-border-radius: 3px;
465
+ -moz-border-radius: 3px;
466
+ -khtml-border-radius: 3px;
467
+ border-radius: 3px;
468
+ }
469
+
470
+ div.wfu_userdata_action:hover { border: 1px solid #aaa; }
471
+
472
+ div.wfu_userdata_action.wfu_userdata_action_disabled:hover { border: 1px solid transparent; }
473
+
474
+ div.wfu_userdata_action > img { width: 12px; height: 12px; }
475
+
476
+ div.wfu_userdata_action_disabled > img
477
+ {
478
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=40)";
479
+ filter: alpha(opacity=40);
480
+ -moz-opacity: 0.4;
481
+ -khtml-opacity: 0.4;
482
+ opacity: 0.4;
483
+ }
484
+
485
+ div.wfu_userdata_line
486
+ {
487
+ display: block;
488
+ position: relative;
489
+ padding: 0;
490
+ margin: 0;
491
+ background: none;
492
+ border: none;
493
+ white-space: nowrap;
494
+ }
495
+
496
+ /* ColorPicker Styles */
497
+ div.wfu_color_container
498
+ {
499
+ display: block;
500
+ position: relative;
501
+ padding: 0;
502
+ margin: 0;
503
+ background: none;
504
+ border: none;
505
+ white-space: nowrap;
506
+ z-index: 1;
507
+ }
508
+ input[type="text"].wp-color-picker { width: 75px; }
509
+ input[type="button"].wp-picker-clear { width: 62px; }
510
+
511
+ /* Shortcode Styles */
512
+ span.wfu_save_label
513
+ {
514
+ background-color: aliceblue;
515
+ color: limegreen;
516
+ border-radius: 6px;
517
+ padding: 1px 2px;
518
+ box-shadow: 1px 1px 1px;
519
+ font-size: smaller;
520
+ opacity: 0;
521
+ }
522
+
523
+ span.wfu_save_label_fail
524
+ {
525
+ background-color: beige;
526
+ color: lightcoral;
527
+ border-radius: 6px;
528
+ padding: 1px 2px;
529
+ box-shadow: 1px 1px 1px;
530
+ font-size: smaller;
531
+ opacity: 0;
532
+ }
css/wordpress_file_upload_reset.css CHANGED
@@ -1,47 +1,47 @@
1
- /**
2
- * Eric Meyer's Reset CSS v2.0 (http://meyerweb.com/eric/tools/css/reset/)
3
- * http://cssreset.com
4
- */
5
- html, body, div, span, applet, object, iframe,
6
- h1, h2, h3, h4, h5, h6, p, blockquote, pre,
7
- a, abbr, acronym, address, big, cite, code,
8
- del, dfn, em, img, ins, kbd, q, s, samp,
9
- small, strike, strong, sub, sup, tt, var,
10
- b, u, i, center,
11
- dl, dt, dd, ol, ul, li,
12
- fieldset, form, label, legend,
13
- table, caption, tbody, tfoot, thead, tr, th, td,
14
- article, aside, canvas, details, embed,
15
- figure, figcaption, footer, header, hgroup,
16
- menu, nav, output, ruby, section, summary,
17
- time, mark, audio, video {
18
- margin: 0;
19
- padding: 0;
20
- border: 0;
21
- font-size: 100%;
22
- /* font: inherit;*/
23
- vertical-align: baseline;
24
- }
25
- /* HTML5 display-role reset for older browsers */
26
- article, aside, details, figcaption, figure,
27
- footer, header, hgroup, menu, nav, section {
28
- display: block;
29
- }
30
- body {
31
- line-height: 1;
32
- }
33
- ol, ul {
34
- list-style: none;
35
- }
36
- blockquote, q {
37
- quotes: none;
38
- }
39
- blockquote:before, blockquote:after,
40
- q:before, q:after {
41
- content: '';
42
- content: none;
43
- }
44
- table {
45
- border-collapse: collapse;
46
- border-spacing: 0;
47
- }
1
+ /**
2
+ * Eric Meyer's Reset CSS v2.0 (http://meyerweb.com/eric/tools/css/reset/)
3
+ * http://cssreset.com
4
+ */
5
+ html, body, div, span, applet, object, iframe,
6
+ h1, h2, h3, h4, h5, h6, p, blockquote, pre,
7
+ a, abbr, acronym, address, big, cite, code,
8
+ del, dfn, em, img, ins, kbd, q, s, samp,
9
+ small, strike, strong, sub, sup, tt, var,
10
+ b, u, i, center,
11
+ dl, dt, dd, ol, ul, li,
12
+ fieldset, form, label, legend,
13
+ table, caption, tbody, tfoot, thead, tr, th, td,
14
+ article, aside, canvas, details, embed,
15
+ figure, figcaption, footer, header, hgroup,
16
+ menu, nav, output, ruby, section, summary,
17
+ time, mark, audio, video {
18
+ margin: 0;
19
+ padding: 0;
20
+ border: 0;
21
+ font-size: 100%;
22
+ /* font: inherit;*/
23
+ vertical-align: baseline;
24
+ }
25
+ /* HTML5 display-role reset for older browsers */
26
+ article, aside, details, figcaption, figure,
27
+ footer, header, hgroup, menu, nav, section {
28
+ display: block;
29
+ }
30
+ body {
31
+ line-height: 1;
32
+ }
33
+ ol, ul {
34
+ list-style: none;
35
+ }
36
+ blockquote, q {
37
+ quotes: none;
38
+ }
39
+ blockquote:before, blockquote:after,
40
+ q:before, q:after {
41
+ content: '';
42
+ content: none;
43
+ }
44
+ table {
45
+ border-collapse: collapse;
46
+ border-spacing: 0;
47
+ }
css/wordpress_file_upload_style.css CHANGED
@@ -1,722 +1,722 @@
1
- /* File Textbox Styles */
2
- input[type="text"].file_input_textbox
3
- {
4
- position: relative;
5
- width: 150px;
6
- height: 25px;
7
- margin: 0px;
8
- padding: 0px;
9
- border: 1px solid;
10
- border-color: #BBBBBB;
11
- background-color: white;
12
- color: black;
13
- }
14
-
15
- input[type="text"].file_input_textbox:disabled
16
- {
17
- position: relative;
18
- width: 150px;
19
- height: 25px;
20
- margin: 0px;
21
- padding: 0px;
22
- border: 1px solid;
23
- border-color: #BBBBBB;
24
- background-color: white;
25
- color: silver;
26
- }
27
-
28
- input[type="text"].file_input_textbox_nofile
29
- {
30
- position: relative;
31
- width: 150px;
32
- height: 25px;
33
- margin: 0px;
34
- padding: 0px;
35
- border: 1px solid;
36
- border-color: #BBBBBB;
37
- background-color: red;
38
- color: black;
39
- }
40
-
41
- /* Upload Form and Button Styles */
42
- form.file_input_uploadform
43
- {
44
- position: relative;
45
- width: 100px;
46
- height: 27px;
47
- overflow: hidden;
48
- margin: 0px;
49
- padding: 0px;
50
- }
51
-
52
- input[type="button"].file_input_button
53
- {
54
- width: 100px;
55
- height: 27px;
56
- position: absolute;
57
- top: 0px;
58
- margin: 0px;
59
- padding: 0px;
60
- background-color: #EEEEEE;
61
- color: #555555;
62
- /* background-attachment: scroll; */
63
- background-image: url("../images/white-grad-active.png");
64
- background-position: left top;
65
- background-repeat: repeat-x;
66
- border-style: solid;
67
- border-width: 1px;
68
- border-color: #BBBBBB;
69
- -webkit-border-radius: 2px;
70
- -moz-border-radius: 2px;
71
- -khtml-border-radius: 2px;
72
- border-radius: 2px;
73
- }
74
-
75
- input[type="button"].file_input_button_hover
76
- {
77
- width: 100px;
78
- height: 27px;
79
- position: absolute;
80
- top: 0px;
81
- margin: 0px;
82
- padding: 0px;
83
- background-color: #EEEEEE;
84
- color: #111111;
85
- /* background-attachment: scroll; */
86
- background-image: url("../images/white-grad-active.png");
87
- background-position: left top;
88
- background-repeat: repeat-x;
89
- border-style: solid;
90
- border-width: 1px;
91
- border-color: #333333;
92
- -webkit-border-radius: 2px;
93
- -moz-border-radius: 2px;
94
- -khtml-border-radius: 2px;
95
- border-radius: 2px;
96
- }
97
-
98
- input[type="button"].file_input_button:disabled, input[type="button"].file_input_button_hover:disabled
99
- {
100
- width: 100px;
101
- height: 27px;
102
- position: absolute;
103
- top: 0px;
104
- margin: 0px;
105
- padding: 0px;
106
- background-color: #EEEEEE;
107
- color: silver;
108
- /* background-attachment: scroll; */
109
- background-image: url("../images/white-grad-active.png");
110
- background-position: left top;
111
- background-repeat: repeat-x;
112
- border-style: solid;
113
- border-width: 1px;
114
- border-color: #BBBBBB;
115
- -webkit-border-radius: 2px;
116
- -moz-border-radius: 2px;
117
- -khtml-border-radius: 2px;
118
- border-radius: 2px;
119
- }
120
-
121
- input[type="button"].file_input_submit
122
- {
123
- width: 100px;
124
- height: 27px;
125
- position: relative;
126
- margin: 0px;
127
- padding: 0px;
128
- background-color: #EEEEEE;
129
- color: #555555;
130
- /* background-attachment: scroll; */
131
- background-image: url("../images/white-grad-active.png");
132
- background-position: left top;
133
- background-repeat: repeat-x;
134
- border-style: solid;
135
- border-width: 1px;
136
- border-color: #BBBBBB;
137
- -webkit-border-radius: 2px;
138
- -moz-border-radius: 2px;
139
- -khtml-border-radius: 2px;
140
- border-radius: 2px;
141
- }
142
-
143
- input[type="button"].file_input_submit:hover, input[type="button"].file_input_submit:focus
144
- {
145
- width: 100px;
146
- height: 27px;
147
- position: relative;
148
- margin: 0px;
149
- padding: 0px;
150
- background-color: #EEEEEE;
151
- color: #111111;
152
- /* background-attachment: scroll; */
153
- background-image: url("../images/white-grad-active.png");
154
- background-position: left top;
155
- background-repeat: repeat-x;
156
- border-style: solid;
157
- border-width: 1px;
158
- border-color: #333333;
159
- -webkit-border-radius: 2px;
160
- -moz-border-radius: 2px;
161
- -khtml-border-radius: 2px;
162
- border-radius: 2px;
163
- }
164
-
165
- input[type="button"].file_input_submit:disabled
166
- {
167
- width: 100px;
168
- height: 27px;
169
- position: relative;
170
- margin: 0px;
171
- padding: 0px;
172
- background-color: #EEEEEE;
173
- color: silver;
174
- /* background-attachment: scroll; */
175
- background-image: url("../images/white-grad-active.png");
176
- background-position: left top;
177
- background-repeat: repeat-x;
178
- border-style: solid;
179
- border-width: 1px;
180
- border-color: #BBBBBB;
181
- -webkit-border-radius: 2px;
182
- -moz-border-radius: 2px;
183
- -khtml-border-radius: 2px;
184
- border-radius: 2px;
185
- }
186
-
187
- input[type="file"].file_input_hidden
188
- {
189
- font-size: 45px;
190
- position: absolute;
191
- right: 0px;
192
- top: 0px;
193
- margin: 0px;
194
- padding: 0px;
195
- -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
196
- filter: alpha(opacity=0);
197
- -moz-opacity: 0;
198
- -khtml-opacity: 0;
199
- opacity: 0;
200
- }
201
-
202
- /* Simple Progressbar Styles */
203
- div.file_progress_bar
204
- {
205
- display: block;
206
- position: relative;
207
- width: auto;
208
- border: 1px solid #333333;
209
- margin: 0;
210
- padding: 4px;
211
- }
212
-
213
- div.file_progress_inner
214
- {
215
- display: block;
216
- width: 100%;
217
- height: 6px;
218
- margin: 0;
219
- padding: 0;
220
- border: 1px solid silver;
221
- background-color: white;
222
- }
223
-
224
- img.file_progress_imagesafe
225
- {
226
- width: 100%;
227
- height: 6px;
228
- }
229
-
230
- span.file_progress_noanimation
231
- {
232
- display: block;
233
- width: 0%;
234
- height: 6px;
235
- margin: 0;
236
- padding: 0;
237
- border-style: none;
238
- background-color: rgb(43,194,83);
239
- position: relative;
240
- overflow: hidden;
241
- }
242
-
243
- span.file_progress_progressive
244
- {
245
- display: block;
246
- width: auto;
247
- height: 6px;
248
- margin: 0;
249
- padding: 0;
250
- border-style: none;
251
- background-color: rgb(43,194,83);
252
- position: relative;
253
- overflow: hidden;
254
- }
255
-
256
- span.file_progress_shuffle
257
- {
258
- display: block;
259
- width: 25%;
260
- height: 6px;
261
- margin: 0;
262
- padding: 0;
263
- border-style: none;
264
- background-color: rgb(43,194,83);
265
- position: relative;
266
- -webkit-animation: shuffle 1s linear infinite alternate;
267
- -moz-animation: shuffle 1s linear infinite alternate;
268
- -o-animation: shuffle 1s linear infinite alternate;
269
- animation: shuffle 1s linear infinite alternate;
270
- overflow: hidden;
271
- }
272
-
273
- span.file_progress_progressive:after
274
- {
275
- content: "";
276
- position: absolute;
277
- top: 0;
278
- left: 0;
279
- bottom: 0;
280
- right: 0;
281
- background-image: -webkit-gradient(linear, 0 0, 100% 100%, color-stop(.25, rgba(255, 255, 255, .2)), color-stop(.25, transparent), color-stop(.5, transparent), color-stop(.5, rgba(255, 255, 255, .2)), color-stop(.75, rgba(255, 255, 255, .2)), color-stop(.75, transparent), to(transparent) );
282
- background-image: -moz-linear-gradient( -45deg, rgba(255, 255, 255, .2) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .2) 50%, rgba(255, 255, 255, .2) 75%, transparent 75%, transparent );
283
- z-index: 1;
284
- -webkit-background-size: 30px 30px;
285
- -moz-background-size: 30px 30px;
286
- background-size: 30px 30px;
287
- -webkit-animation: lengthen 2s linear infinite;
288
- -moz-animation: lengthen 2s linear infinite;
289
- -o-animation: lengthen 2s linear infinite;
290
- animation: lengthen 2s linear infinite;
291
- overflow: hidden;
292
- }
293
-
294
- @-webkit-keyframes shuffle { from { left: 0%; } to { left: 75%; } }
295
-
296
- @-moz-keyframes shuffle { from { left: 0%; } to { left: 75%; } }
297
-
298
- @-o-keyframes shuffle { from { left: 0%; } to { left: 75%; } }
299
-
300
- @keyframes shuffle { from { left: 0%; } to { left: 75%; } }
301
-
302
- @-webkit-keyframes lengthen { from { background-position: 0 0; } to { background-position: 30px 30px; } }
303
-
304
- @-moz-keyframes lengthen { from { background-position: 0 0; } to { background-position: 30px 30px; } }
305
-
306
- @-o-keyframes lengthen { from { background-position: 0 0; } to { background-position: 30px 30px; } }
307
-
308
- @keyframes lengthen { from { background-position: 0 0; } to { background-position: 30px 30px; } }
309
-
310
- /* SImple Message Styles */
311
- span.file_messagebox_inner
312
- {
313
- display: block;
314
- width: 340px;
315
- margin: 0px;
316
- font-size: small;
317
- padding: 10px;
318
- border-style: solid;
319
- border-width: 1px;
320
- border-color: #D3D3D3;
321
- background-color: #F5F5F5;
322
- color: black;
323
- line-height: 1.2;
324
- }
325
-
326
- /* General Styles */
327
- div.file_div_clean
328
- {
329
- display: table;
330
- position: relative;
331
- margin: 0px;
332
- padding: 0px;
333
- border-style: none;
334
- background: none;
335
- color: black;
336
- line-height: 1;
337
- }
338
-
339
- div.file_space_clean
340
- {
341
- display: block;
342
- margin: 0 0 2px 0;
343
- padding: 0px;
344
- border-style: none;
345
- background: none;
346
- color: black;
347
- }
348
-
349
- table.file_table_clean
350
- {
351
- margin: 0px;
352
- padding: 0px;
353
- border: none;
354
- border-spacing: 0px;
355
- background: none;
356
- color: black;
357
- width: auto;
358
- }
359
-
360
- td.file_td_clean
361
- {
362
- margin: 0px;
363
- padding: 0px;
364
- border: none;
365
- border-spacing: 0px;
366
- background: none;
367
- color: black;
368
- vertical-align: middle;
369
- }
370
-
371
- span.file_item_clean
372
- {
373
- margin: 0px;
374
- padding: 0px;
375
- border-style: none;
376
- background: none;
377
- color: black;
378
- }
379
-
380
- select.file_item_clean
381
- {
382
- margin: 0px;
383
- padding: 0px;
384
- height: 25px;
385
- border-style: none;
386
- background: none;
387
- color: black;
388
- }
389
-
390
- select.file_item_clean:disabled
391
- {
392
- margin: 0px;
393
- padding: 0px;
394
- height: 25px;
395
- border-style: none;
396
- background: none;
397
- color: silver;
398
- }
399
-
400
- span.file_title_clean
401
- {
402
- margin: 0px;
403
- padding: 0px;
404
- border-style: none;
405
- background: none;
406
- color: black;
407
- }
408
-
409
- /* Userdata styles */
410
- div.file_userdata_container
411
- {
412
- margin: 0;
413
- padding: 0;
414
- white-space: nowrap;
415
- }
416
-
417
- label.file_userdata_label
418
- {
419
- margin: 0;
420
- width: 40%;
421
- }
422
-
423
- input[type="text"].file_userdata_message, input[type="text"].file_userdata_message_required
424
- {
425
- width: 60% !important;
426
- height: 25px;
427
- margin: 0px;
428
- padding: 0px;
429
- border: 1px solid;
430
- border-color: #BBBBBB;
431
- background: none;
432
- color: black;
433
- }
434
-
435
- input[type="text"].file_userdata_message:disabled, input[type="text"].file_userdata_message_required:disabled
436
- {
437
- width: 60% !important;
438
- height: 25px;
439
- margin: 0px;
440
- padding: 0px;
441
- border: 1px solid;
442
- border-color: #BBBBBB;
443
- background: none;
444
- color: silver;
445
- }
446
-
447
- input[type="text"].file_userdata_message_required_empty
448
- {
449
- width: 60% !important;
450
- height: 25px;
451
- margin: 0px;
452
- padding: 0px;
453
- border: 1px solid;
454
- border-color: #BBBBBB;
455
- background-color: red;
456
- color: black;
457
- }
458
-
459
- /* Message Block Styles */
460
- table.file_messageblock_table
461
- {
462
- margin: 0;
463
- padding: 0;
464
- border: none;
465
- }
466
-
467
- tr.file_messageblock_header_tr
468
- {
469
- }
470
-
471
- td.file_messageblock_header_td
472
- {
473
- border: 1px solid #dddddd;
474
- margin: 0;
475
- padding: 0;
476
- }
477
-
478
- div.file_messageblock_header
479
- {
480
- margin: 0;
481
- padding: 2px;
482
- }
483
-
484
- label.file_messageblock_header_label
485
- {
486
- font-weight: bold;
487
- font-size: 12px;
488
- line-height: 1;
489
- }
490
-
491
- td.file_messageblock_arrow_td
492
- {
493
- border: 1px solid #dddddd;
494
- margin: 0;
495
- padding: 0;
496
- width: 20px;
497
- vertical-align: middle;
498
- }
499
-
500
- div.file_messageblock_header_arrow_up
501
- {
502
- width: 0;
503
- height: 0;
504
- border-left: 5px solid transparent;
505
- border-right: 5px solid transparent;
506
- border-bottom: 5px solid #555555;
507
- margin: 5px 1px 1px 5px;
508
- /* ie6 height fix */
509
- font-size: 0;
510
- line-height: 0;
511
- /* ie6 transparent fix */
512
- _border-right-color: pink;
513
- _border-left-color: pink;
514
- _filter: chroma(color=pink);
515
- }
516
-
517
- div.file_messageblock_header_arrow_down
518
- {
519
- width: 0;
520
- height: 0;
521
- border-left: 5px solid transparent;
522
- border-right: 5px solid transparent;
523
- border-top: 5px solid #555555;
524
- margin: 5px 1px 1px 5px;
525
- /* ie6 height fix */
526
- font-size: 0;
527
- line-height: 0;
528
- /* ie6 transparent fix */
529
- _border-right-color: pink;
530
- _border-left-color: pink;
531
- _filter: chroma(color=pink);
532
- }
533
-
534
- tr.file_messageblock_subheader_tr
535
- {
536
- }
537
-
538
- td.file_messageblock_subheader_td
539
- {
540
- margin: 0;
541
- padding: 0;
542
- border: 1px solid #dddddd;
543
- }
544
-
545
- div.file_messageblock_subheader_message
546
- {
547
- margin: 0;
548
- padding: 2px;
549
- background: none;
550
- }
551
-
552
- label.file_messageblock_subheader_messagelabel
553
- {
554
- font-weight: normal;
555
- font-size: 12px;
556
- line-height: 1;
557
- }
558
-
559
- div.file_messageblock_subheader_adminmessage
560
- {
561
- margin: 0;
562
- padding: 2px;
563
- background-color: #F7F7F7;
564
- overflow: scroll;
565
- }
566
-
567
- label.file_messageblock_subheader_debugmessage_label
568
- {
569
- margin: 0;
570
- padding: 0;
571
- background: none;
572
- border: none;
573
- font-weight: bold;
574
- }
575
-
576
- div.file_messageblock_subheader_debugmessage_container
577
- {
578
- margin: 0 0 0 20px;
579
- padding: 0px;
580
- background: none;
581
- border: none;
582
- font-size: 10px;
583
- }
584
-
585
- label.file_messageblock_subheader_adminmessagelabel
586
- {
587
- font-weight: normal;
588
- font-size: 12px;
589
- font-style: italic;
590
- line-height: 1;
591
- }
592
-
593
- tr.file_messageblock_fileheader_tr
594
- {
595
- }
596
-
597
- td.file_messageblock_filenumber_td
598
- {
599
- width: 30px;
600
- margin: 0;
601
- padding: 2px;
602
- text-align: center;
603
- vertical-align: middle;
604
- font-weight: bold;
605
- font-size: 11px;
606
- line-height: 1;
607
- border: 1px solid #dddddd;
608
- }
609
-
610
- td.file_messageblock_fileheader_td
611
- {
612
- margin: 0;
613
- padding: 0;
614
- border: 1px solid #dddddd;
615
- }
616
-
617
- div.file_messageblock_fileheader
618
- {
619
- margin: 0;
620
- padding: 2px;
621
- }
622
-
623
- label.file_messageblock_fileheader_label
624
- {
625
- font-weight: bold;
626
- font-size: 11px;
627
- line-height: 1;
628
- }
629
-
630
- td.file_messageblock_filearrow_td
631
- {
632
- border: 1px solid #dddddd;
633
- margin: 0;
634
- padding: 0;
635
- width: 20px;
636
- border: 1px solid #dddddd;
637
- vertical-align: middle;
638
- }
639
-
640
- div.file_messageblock_file_arrow_up
641
- {
642
- width: 0;
643
- height: 0;
644
- border-left: 4px solid transparent;
645
- border-right: 4px solid transparent;
646
- border-bottom: 4px solid #555555;
647
- margin: 5px 1px 1px 6px;
648
- /* ie6 height fix */
649
- font-size: 0;
650
- line-height: 0;
651
- /* ie6 transparent fix */
652
- _border-right-color: pink;
653
- _border-left-color: pink;
654
- _filter: chroma(color=pink);
655
- }
656
-
657
- div.file_messageblock_file_arrow_down
658
- {
659
- width: 0;
660
- height: 0;
661
- border-left: 4px solid transparent;
662
- border-right: 4px solid transparent;
663
- border-top: 4px solid #555555;
664
- margin: 5px 1px 1px 6px;
665
- /* ie6 height fix */
666
- font-size: 0;
667
- line-height: 0;
668
- /* ie6 transparent fix */
669
- _border-right-color: pink;
670
- _border-left-color: pink;
671
- _filter: chroma(color=pink);
672
- }
673
-
674
- tr.file_messageblock_filesubheader_tr
675
- {
676
- }
677
-
678
- td.file_messageblock_filesubheaderempty_td
679
- {
680
- width: 30px;
681
- margin: 0;
682
- padding: 0;
683
- border: 1px solid #dddddd;
684
- }
685
-
686
- td.file_messageblock_filesubheader_td
687
- {
688
- margin: 0;
689
- padding: 0;
690
- border: 1px solid #dddddd;
691
- }
692
-
693
- div.file_messageblock_filesubheader_message
694
- {
695
- margin: 0;
696
- padding: 2px;
697
- background: none;
698
- }
699
-
700
- label.file_messageblock_filesubheader_messagelabel
701
- {
702
- font-weight: normal;
703
- font-size: 11px;
704
- line-height: 1;
705
- }
706
-
707
- div.file_messageblock_filesubheader_adminmessage
708
- {
709
- margin: 0;
710
- padding: 2px;
711
- background-color: #F7F7F7;
712
- }
713
-
714
- label.file_messageblock_filesubheader_adminmessagelabel
715
- {
716
- font-weight: normal;
717
- font-size: 11px;
718
- font-style: italic;
719
- line-height: 1;
720
- }
721
-
722
-
1
+ /* File Textbox Styles */
2
+ input[type="text"].file_input_textbox
3
+ {
4
+ position: relative;
5
+ width: 150px;
6
+ height: 25px;
7
+ margin: 0px;
8
+ padding: 0px;
9
+ border: 1px solid;
10
+ border-color: #BBBBBB;
11
+ background-color: white;
12
+ color: black;
13
+ }
14
+
15
+ input[type="text"].file_input_textbox:disabled
16
+ {
17
+ position: relative;
18
+ width: 150px;
19
+ height: 25px;
20
+ margin: 0px;
21
+ padding: 0px;
22
+ border: 1px solid;
23
+ border-color: #BBBBBB;
24
+ background-color: white;
25
+ color: silver;
26
+ }
27
+
28
+ input[type="text"].file_input_textbox_nofile
29
+ {
30
+ position: relative;
31
+ width: 150px;
32
+ height: 25px;
33
+ margin: 0px;
34
+ padding: 0px;
35
+ border: 1px solid;
36
+ border-color: #BBBBBB;
37
+ background-color: red;
38
+ color: black;
39
+ }
40
+
41
+ /* Upload Form and Button Styles */
42
+ form.file_input_uploadform
43
+ {
44
+ position: relative;
45
+ width: 100px;
46
+ height: 27px;
47
+ overflow: hidden;
48
+ margin: 0px;
49
+ padding: 0px;
50
+ }
51
+
52
+ input[type="button"].file_input_button
53
+ {
54
+ width: 100px;
55
+ height: 27px;
56
+ position: absolute;
57
+ top: 0px;
58
+ margin: 0px;
59
+ padding: 0px;
60
+ background-color: #EEEEEE;
61
+ color: #555555;
62
+ /* background-attachment: scroll; */
63
+ background-image: url("../images/white-grad-active.png");
64
+ background-position: left top;
65
+ background-repeat: repeat-x;
66
+ border-style: solid;
67
+ border-width: 1px;
68
+ border-color: #BBBBBB;
69
+ -webkit-border-radius: 2px;
70
+ -moz-border-radius: 2px;
71
+ -khtml-border-radius: 2px;
72
+ border-radius: 2px;
73
+ }
74
+
75
+ input[type="button"].file_input_button_hover
76
+ {
77
+ width: 100px;
78
+ height: 27px;
79
+ position: absolute;
80
+ top: 0px;
81
+ margin: 0px;
82
+ padding: 0px;
83
+ background-color: #EEEEEE;
84
+ color: #111111;
85
+ /* background-attachment: scroll; */
86
+ background-image: url("../images/white-grad-active.png");
87
+ background-position: left top;
88
+ background-repeat: repeat-x;
89
+ border-style: solid;
90
+ border-width: 1px;
91
+ border-color: #333333;
92
+ -webkit-border-radius: 2px;
93
+ -moz-border-radius: 2px;
94
+ -khtml-border-radius: 2px;
95
+ border-radius: 2px;
96
+ }
97
+
98
+ input[type="button"].file_input_button:disabled, input[type="button"].file_input_button_hover:disabled
99
+ {
100
+ width: 100px;
101
+ height: 27px;
102
+ position: absolute;
103
+ top: 0px;
104
+ margin: 0px;
105
+ padding: 0px;
106
+ background-color: #EEEEEE;
107
+ color: silver;
108
+ /* background-attachment: scroll; */
109
+ background-image: url("../images/white-grad-active.png");
110
+ background-position: left top;
111
+ background-repeat: repeat-x;
112
+ border-style: solid;
113
+ border-width: 1px;
114
+ border-color: #BBBBBB;
115
+ -webkit-border-radius: 2px;
116
+ -moz-border-radius: 2px;
117
+ -khtml-border-radius: 2px;
118
+ border-radius: 2px;
119
+ }
120
+
121
+ input[type="button"].file_input_submit
122
+ {
123
+ width: 100px;
124
+ height: 27px;
125
+ position: relative;
126
+ margin: 0px;
127
+ padding: 0px;
128
+ background-color: #EEEEEE;
129
+ color: #555555;
130
+ /* background-attachment: scroll; */
131
+ background-image: url("../images/white-grad-active.png");
132
+ background-position: left top;
133
+ background-repeat: repeat-x;
134
+ border-style: solid;
135
+ border-width: 1px;
136
+ border-color: #BBBBBB;
137
+ -webkit-border-radius: 2px;
138
+ -moz-border-radius: 2px;
139
+ -khtml-border-radius: 2px;
140
+ border-radius: 2px;
141
+ }
142
+
143
+ input[type="button"].file_input_submit:hover, input[type="button"].file_input_submit:focus
144
+ {
145
+ width: 100px;
146
+ height: 27px;
147
+ position: relative;
148
+ margin: 0px;
149
+ padding: 0px;
150
+ background-color: #EEEEEE;
151
+ color: #111111;
152
+ /* background-attachment: scroll; */
153
+ background-image: url("../images/white-grad-active.png");
154
+ background-position: left top;
155
+ background-repeat: repeat-x;
156
+ border-style: solid;
157
+ border-width: 1px;
158
+ border-color: #333333;
159
+ -webkit-border-radius: 2px;
160
+ -moz-border-radius: 2px;
161
+ -khtml-border-radius: 2px;
162
+ border-radius: 2px;
163
+ }
164
+
165
+ input[type="button"].file_input_submit:disabled
166
+ {
167
+ width: 100px;
168
+ height: 27px;
169
+ position: relative;
170
+ margin: 0px;
171
+ padding: 0px;
172
+ background-color: #EEEEEE;
173
+ color: silver;
174
+ /* background-attachment: scroll; */
175
+ background-image: url("../images/white-grad-active.png");
176
+ background-position: left top;
177
+ background-repeat: repeat-x;
178
+ border-style: solid;
179
+ border-width: 1px;
180
+ border-color: #BBBBBB;
181
+ -webkit-border-radius: 2px;
182
+ -moz-border-radius: 2px;
183
+ -khtml-border-radius: 2px;
184
+ border-radius: 2px;
185
+ }
186
+
187
+ input[type="file"].file_input_hidden
188
+ {
189
+ font-size: 45px;
190
+ position: absolute;
191
+ right: 0px;
192
+ top: 0px;
193
+ margin: 0px;
194
+ padding: 0px;
195
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
196
+ filter: alpha(opacity=0);
197
+ -moz-opacity: 0;
198
+ -khtml-opacity: 0;
199
+ opacity: 0;
200
+ }
201
+
202
+ /* Simple Progressbar Styles */
203
+ div.file_progress_bar
204
+ {
205
+ display: block;
206
+ position: relative;
207
+ width: auto;
208
+ border: 1px solid #333333;
209
+ margin: 0;
210
+ padding: 4px;
211
+ }
212
+
213
+ div.file_progress_inner
214
+ {
215
+ display: block;
216
+ width: 100%;
217
+ height: 6px;
218
+ margin: 0;
219
+ padding: 0;
220
+ border: 1px solid silver;
221
+ background-color: white;
222
+ }
223
+
224
+ img.file_progress_imagesafe
225
+ {
226
+ width: 100%;
227
+ height: 6px;
228
+ }
229
+
230
+ span.file_progress_noanimation
231
+ {
232
+ display: block;
233
+ width: 0%;
234
+ height: 6px;
235
+ margin: 0;
236
+ padding: 0;
237
+ border-style: none;
238
+ background-color: rgb(43,194,83);
239
+ position: relative;
240
+ overflow: hidden;
241
+ }
242
+
243
+ span.file_progress_progressive
244
+ {
245
+ display: block;
246
+ width: auto;
247
+ height: 6px;
248
+ margin: 0;
249
+ padding: 0;
250
+ border-style: none;
251
+ background-color: rgb(43,194,83);
252
+ position: relative;
253
+ overflow: hidden;
254
+ }
255
+
256
+ span.file_progress_shuffle
257
+ {
258
+ display: block;
259
+ width: 25%;
260
+ height: 6px;
261
+ margin: 0;
262
+ padding: 0;
263
+ border-style: none;
264
+ background-color: rgb(43,194,83);
265
+ position: relative;
266
+ -webkit-animation: shuffle 1s linear infinite alternate;
267
+ -moz-animation: shuffle 1s linear infinite alternate;
268
+ -o-animation: shuffle 1s linear infinite alternate;
269
+ animation: shuffle 1s linear infinite alternate;
270
+ overflow: hidden;
271
+ }
272
+
273
+ span.file_progress_progressive:after
274
+ {
275
+ content: "";
276
+ position: absolute;
277
+ top: 0;
278
+ left: 0;
279
+ bottom: 0;
280
+ right: 0;
281
+ background-image: -webkit-gradient(linear, 0 0, 100% 100%, color-stop(.25, rgba(255, 255, 255, .2)), color-stop(.25, transparent), color-stop(.5, transparent), color-stop(.5, rgba(255, 255, 255, .2)), color-stop(.75, rgba(255, 255, 255, .2)), color-stop(.75, transparent), to(transparent) );
282
+ background-image: -moz-linear-gradient( -45deg, rgba(255, 255, 255, .2) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .2) 50%, rgba(255, 255, 255, .2) 75%, transparent 75%, transparent );
283
+ z-index: 1;
284
+ -webkit-background-size: 30px 30px;
285
+ -moz-background-size: 30px 30px;
286
+ background-size: 30px 30px;
287
+ -webkit-animation: lengthen 2s linear infinite;
288
+ -moz-animation: lengthen 2s linear infinite;
289
+ -o-animation: lengthen 2s linear infinite;
290
+ animation: lengthen 2s linear infinite;
291
+ overflow: hidden;
292
+ }
293
+
294
+ @-webkit-keyframes shuffle { from { left: 0%; } to { left: 75%; } }
295
+
296
+ @-moz-keyframes shuffle { from { left: 0%; } to { left: 75%; } }
297
+
298
+ @-o-keyframes shuffle { from { left: 0%; } to { left: 75%; } }
299
+
300
+ @keyframes shuffle { from { left: 0%; } to { left: 75%; } }
301
+
302
+ @-webkit-keyframes lengthen { from { background-position: 0 0; } to { background-position: 30px 30px; } }
303
+
304
+ @-moz-keyframes lengthen { from { background-position: 0 0; } to { background-position: 30px 30px; } }
305
+
306
+ @-o-keyframes lengthen { from { background-position: 0 0; } to { background-position: 30px 30px; } }
307
+
308
+ @keyframes lengthen { from { background-position: 0 0; } to { background-position: 30px 30px; } }
309
+
310
+ /* SImple Message Styles */
311
+ span.file_messagebox_inner
312
+ {
313
+ display: block;
314
+ width: 340px;
315
+ margin: 0px;
316
+ font-size: small;
317
+ padding: 10px;
318
+ border-style: solid;
319
+ border-width: 1px;
320
+ border-color: #D3D3D3;
321
+ background-color: #F5F5F5;
322
+ color: black;
323
+ line-height: 1.2;
324
+ }
325
+
326
+ /* General Styles */
327
+ div.file_div_clean
328
+ {
329
+ display: table;
330
+ position: relative;
331
+ margin: 0px;
332
+ padding: 0px;
333
+ border-style: none;
334
+ background: none;
335
+ color: black;
336
+ line-height: 1;
337
+ }
338
+
339
+ div.file_space_clean
340
+ {
341
+ display: block;
342
+ margin: 0 0 2px 0;
343
+ padding: 0px;
344
+ border-style: none;
345
+ background: none;
346
+ color: black;
347
+ }
348
+
349
+ table.file_table_clean
350
+ {
351
+ margin: 0px;
352
+ padding: 0px;
353
+ border: none;
354
+ border-spacing: 0px;
355
+ background: none;
356
+ color: black;
357
+ width: auto;
358
+ }
359
+
360
+ td.file_td_clean
361
+ {
362
+ margin: 0px;
363
+ padding: 0px;
364
+ border: none;
365
+ border-spacing: 0px;
366
+ background: none;
367
+ color: black;
368
+ vertical-align: middle;
369
+ }
370
+
371
+ span.file_item_clean
372
+ {
373
+ margin: 0px;
374
+ padding: 0px;
375
+ border-style: none;
376
+ background: none;
377
+ color: black;
378
+ }
379
+
380
+ select.file_item_clean
381
+ {
382
+ margin: 0px;
383
+ padding: 0px;
384
+ height: 25px;
385
+ border-style: none;
386
+ background: none;
387
+ color: black;
388
+ }
389
+
390
+ select.file_item_clean:disabled
391
+ {
392
+ margin: 0px;
393
+ padding: 0px;
394
+ height: 25px;
395
+ border-style: none;
396
+ background: none;
397
+ color: silver;
398
+ }
399
+
400
+ span.file_title_clean
401
+ {
402
+ margin: 0px;
403
+ padding: 0px;
404
+ border-style: none;
405
+ background: none;
406
+ color: black;
407
+ }
408
+
409
+ /* Userdata styles */
410
+ div.file_userdata_container
411
+ {
412
+ margin: 0;
413
+ padding: 0;
414
+ white-space: nowrap;
415
+ }
416
+
417
+ label.file_userdata_label
418
+ {
419
+ margin: 0;
420
+ width: 40%;
421
+ }
422
+
423
+ input[type="text"].file_userdata_message, input[type="text"].file_userdata_message_required
424
+ {
425
+ width: 60% !important;
426
+ height: 25px;
427
+ margin: 0px;
428
+ padding: 0px;
429
+ border: 1px solid;
430
+ border-color: #BBBBBB;
431
+ background: none;
432
+ color: black;
433
+ }
434
+
435
+ input[type="text"].file_userdata_message:disabled, input[type="text"].file_userdata_message_required:disabled
436
+ {
437
+ width: 60% !important;
438
+ height: 25px;
439
+ margin: 0px;
440
+ padding: 0px;
441
+ border: 1px solid;
442
+ border-color: #BBBBBB;
443
+ background: none;
444
+ color: silver;
445
+ }
446
+
447
+ input[type="text"].file_userdata_message_required_empty
448
+ {
449
+ width: 60% !important;
450
+ height: 25px;
451
+ margin: 0px;
452
+ padding: 0px;
453
+ border: 1px solid;
454
+ border-color: #BBBBBB;
455
+ background-color: red;
456
+ color: black;
457
+ }
458
+
459
+ /* Message Block Styles */
460
+ table.file_messageblock_table
461
+ {
462
+ margin: 0;
463
+ padding: 0;
464
+ border: none;
465
+ }
466
+
467
+ tr.file_messageblock_header_tr
468
+ {
469
+ }
470
+
471
+ td.file_messageblock_header_td
472
+ {
473
+ border: 1px solid #dddddd;
474
+ margin: 0;
475
+ padding: 0;
476
+ }
477
+
478
+ div.file_messageblock_header
479
+ {
480
+ margin: 0;
481
+ padding: 2px;
482
+ }
483
+
484
+ label.file_messageblock_header_label
485
+ {
486
+ font-weight: bold;
487
+ font-size: 12px;
488
+ line-height: 1;
489
+ }
490
+
491
+ td.file_messageblock_arrow_td
492
+ {
493
+ border: 1px solid #dddddd;
494
+ margin: 0;
495
+ padding: 0;
496
+ width: 20px;
497
+ vertical-align: middle;
498
+ }
499
+
500
+ div.file_messageblock_header_arrow_up
501
+ {
502
+ width: 0;
503
+ height: 0;
504
+ border-left: 5px solid transparent;
505
+ border-right: 5px solid transparent;
506
+ border-bottom: 5px solid #555555;
507
+ margin: 5px 1px 1px 5px;
508
+ /* ie6 height fix */
509
+ font-size: 0;
510
+ line-height: 0;
511
+ /* ie6 transparent fix */
512
+ _border-right-color: pink;
513
+ _border-left-color: pink;
514
+ _filter: chroma(color=pink);
515
+ }
516
+
517
+ div.file_messageblock_header_arrow_down
518
+ {
519
+ width: 0;
520
+ height: 0;
521
+ border-left: 5px solid transparent;
522
+ border-right: 5px solid transparent;
523
+ border-top: 5px solid #555555;
524
+ margin: 5px 1px 1px 5px;
525
+ /* ie6 height fix */
526
+ font-size: 0;
527
+ line-height: 0;
528
+ /* ie6 transparent fix */
529
+ _border-right-color: pink;
530
+ _border-left-color: pink;
531
+ _filter: chroma(color=pink);
532
+ }
533
+
534
+ tr.file_messageblock_subheader_tr
535
+ {
536
+ }
537
+
538
+ td.file_messageblock_subheader_td
539
+ {
540
+ margin: 0;
541
+ padding: 0;
542
+ border: 1px solid #dddddd;
543
+ }
544
+
545
+ div.file_messageblock_subheader_message
546
+ {
547
+ margin: 0;
548
+ padding: 2px;
549
+ background: none;
550
+ }
551
+
552
+ label.file_messageblock_subheader_messagelabel
553
+ {
554
+ font-weight: normal;
555
+ font-size: 12px;
556
+ line-height: 1;
557
+ }
558
+
559
+ div.file_messageblock_subheader_adminmessage
560
+ {
561
+ margin: 0;
562
+ padding: 2px;
563
+ background-color: #F7F7F7;
564
+ overflow: scroll;
565
+ }
566
+
567
+ label.file_messageblock_subheader_debugmessage_label
568
+ {
569
+ margin: 0;
570
+ padding: 0;
571
+ background: none;
572
+ border: none;
573
+ font-weight: bold;
574
+ }
575
+
576
+ div.file_messageblock_subheader_debugmessage_container
577
+ {
578
+ margin: 0 0 0 20px;
579
+ padding: 0px;
580
+ background: none;
581
+ border: none;
582
+ font-size: 10px;
583
+ }
584
+
585
+ label.file_messageblock_subheader_adminmessagelabel
586
+ {
587
+ font-weight: normal;
588
+ font-size: 12px;
589
+ font-style: italic;
590
+ line-height: 1;
591
+ }
592
+
593
+ tr.file_messageblock_fileheader_tr
594
+ {
595
+ }
596
+
597
+ td.file_messageblock_filenumber_td
598
+ {
599
+ width: 30px;
600
+ margin: 0;
601
+ padding: 2px;
602
+ text-align: center;
603
+ vertical-align: middle;
604
+ font-weight: bold;
605
+ font-size: 11px;
606
+ line-height: 1;
607
+ border: 1px solid #dddddd;
608
+ }
609
+
610
+ td.file_messageblock_fileheader_td
611
+ {
612
+ margin: 0;
613
+ padding: 0;
614
+ border: 1px solid #dddddd;
615
+ }
616
+
617
+ div.file_messageblock_fileheader
618
+ {
619
+ margin: 0;
620
+ padding: 2px;
621
+ }
622
+
623
+ label.file_messageblock_fileheader_label
624
+ {
625
+ font-weight: bold;
626
+ font-size: 11px;
627
+ line-height: 1;
628
+ }
629
+
630
+ td.file_messageblock_filearrow_td
631
+ {
632
+ border: 1px solid #dddddd;
633
+ margin: 0;
634
+ padding: 0;
635
+ width: 20px;
636
+ border: 1px solid #dddddd;
637
+ vertical-align: middle;
638
+ }
639
+
640
+ div.file_messageblock_file_arrow_up
641
+ {
642
+ width: 0;
643
+ height: 0;
644
+ border-left: 4px solid transparent;
645
+ border-right: 4px solid transparent;
646
+ border-bottom: 4px solid #555555;
647
+ margin: 5px 1px 1px 6px;
648
+ /* ie6 height fix */
649
+ font-size: 0;
650
+ line-height: 0;
651
+ /* ie6 transparent fix */
652
+ _border-right-color: pink;
653
+ _border-left-color: pink;
654
+ _filter: chroma(color=pink);
655
+ }
656
+
657
+ div.file_messageblock_file_arrow_down
658
+ {
659
+ width: 0;
660
+ height: 0;
661
+ border-left: 4px solid transparent;
662
+ border-right: 4px solid transparent;
663
+ border-top: 4px solid #555555;
664
+ margin: 5px 1px 1px 6px;
665
+ /* ie6 height fix */
666
+ font-size: 0;
667
+ line-height: 0;
668
+ /* ie6 transparent fix */
669
+ _border-right-color: pink;
670
+ _border-left-color: pink;
671
+ _filter: chroma(color=pink);
672
+ }
673
+
674
+ tr.file_messageblock_filesubheader_tr
675
+ {
676
+ }
677
+
678
+ td.file_messageblock_filesubheaderempty_td
679
+ {
680
+ width: 30px;
681
+ margin: 0;
682
+ padding: 0;
683
+ border: 1px solid #dddddd;
684
+ }
685
+
686
+ td.file_messageblock_filesubheader_td
687
+ {
688
+ margin: 0;
689
+ padding: 0;
690
+ border: 1px solid #dddddd;
691
+ }
692
+
693
+ div.file_messageblock_filesubheader_message
694
+ {
695
+ margin: 0;
696
+ padding: 2px;
697
+ background: none;
698
+ }
699
+
700
+ label.file_messageblock_filesubheader_messagelabel
701
+ {
702
+ font-weight: normal;
703
+ font-size: 11px;
704
+ line-height: 1;
705
+ }
706
+
707
+ div.file_messageblock_filesubheader_adminmessage
708
+ {
709
+ margin: 0;
710
+ padding: 2px;
711
+ background-color: #F7F7F7;
712
+ }
713
+
714
+ label.file_messageblock_filesubheader_adminmessagelabel
715
+ {
716
+ font-weight: normal;
717
+ font-size: 11px;
718
+ font-style: italic;
719
+ line-height: 1;
720
+ }
721
+
722
+
css/wordpress_file_upload_style_safe.css CHANGED
@@ -1,229 +1,229 @@
1
- /* File Textbox Styles */
2
- input.file_input_textbox
3
- {
4
- position: relative;
5
- width: 150px;
6
- height: 25px;
7
- margin: 0px;
8
- padding: 0px;
9
- border: 1px solid;
10
- border-color: #BBBBBB;
11
- background-color: white;
12
- color: black;
13
- }
14
-
15
- input.file_input_textbox:disabled
16
- {
17
- position: relative;
18
- width: 150px;
19
- height: 25px;
20
- margin: 0px;
21
- padding: 0px;
22
- border: 1px solid;
23
- border-color: #BBBBBB;
24
- background-color: white;
25
- color: silver;
26
- }
27
-
28
- input.file_input_textbox_nofile
29
- {
30
- position: relative;
31
- width: 150px;
32
- height: 25px;
33
- margin: 0px;
34
- padding: 0px;
35
- border: 1px solid;
36
- border-color: #BBBBBB;
37
- background-color: red;
38
- color: black;
39
- }
40
-
41
- /* Upload Form and Button Styles */
42
- input.file_input_button
43
- {
44
- width: 100px;
45
- height: 27px;
46
- position: absolute;
47
- top: 0px;
48
- margin: 0px;
49
- padding: 0px;
50
- background-color: #EEEEEE;
51
- color: #555555;
52
- /* background-attachment: scroll; */
53
- background-image: url("../images/white-grad-active.png");
54
- background-position: left top;
55
- background-repeat: repeat-x;
56
- border-style: solid;
57
- border-width: 1px;
58
- border-color: #BBBBBB;
59
- -webkit-border-radius: 2px;
60
- -moz-border-radius: 2px;
61
- -khtml-border-radius: 2px;
62
- border-radius: 2px;
63
- }
64
-
65
- input.file_input_button_hover
66
- {
67
- width: 100px;
68
- height: 27px;
69
- position: absolute;
70
- top: 0px;
71
- margin: 0px;
72
- padding: 0px;
73
- background-color: #EEEEEE;
74
- color: #111111;
75
- /* background-attachment: scroll; */
76
- background-image: url("../images/white-grad-active.png");
77
- background-position: left top;
78
- background-repeat: repeat-x;
79
- border-style: solid;
80
- border-width: 1px;
81
- border-color: #333333;
82
- -webkit-border-radius: 2px;
83
- -moz-border-radius: 2px;
84
- -khtml-border-radius: 2px;
85
- border-radius: 2px;
86
- }
87
-
88
- input.file_input_button:disabled, input.file_input_button_hover:disabled
89
- {
90
- width: 100px;
91
- height: 27px;
92
- position: absolute;
93
- top: 0px;
94
- margin: 0px;
95
- padding: 0px;
96
- background-color: #EEEEEE;
97
- color: silver;
98
- /* background-attachment: scroll; */
99
- background-image: url("../images/white-grad-active.png");
100
- background-position: left top;
101
- background-repeat: repeat-x;
102
- border-style: solid;
103
- border-width: 1px;
104
- border-color: #BBBBBB;
105
- -webkit-border-radius: 2px;
106
- -moz-border-radius: 2px;
107
- -khtml-border-radius: 2px;
108
- border-radius: 2px;
109
- }
110
-
111
- input.file_input_submit
112
- {
113
- width: 100px;
114
- height: 27px;
115
- position: relative;
116
- margin: 0px;
117
- padding: 0px;
118
- background-color: #EEEEEE;
119
- color: #555555;
120
- /* background-attachment: scroll; */
121
- background-image: url("../images/white-grad-active.png");
122
- background-position: left top;
123
- background-repeat: repeat-x;
124
- border-style: solid;
125
- border-width: 1px;
126
- border-color: #BBBBBB;
127
- -webkit-border-radius: 2px;
128
- -moz-border-radius: 2px;
129
- -khtml-border-radius: 2px;
130
- border-radius: 2px;
131
- }
132
-
133
- input.file_input_submit:hover, input.file_input_submit:focus
134
- {
135
- width: 100px;
136
- height: 27px;
137
- position: relative;
138
- margin: 0px;
139
- padding: 0px;
140
- background-color: #EEEEEE;
141
- color: #111111;
142
- /* background-attachment: scroll; */
143
- background-image: url("../images/white-grad-active.png");
144
- background-position: left top;
145
- background-repeat: repeat-x;
146
- border-style: solid;
147
- border-width: 1px;
148
- border-color: #333333;
149
- -webkit-border-radius: 2px;
150
- -moz-border-radius: 2px;
151
- -khtml-border-radius: 2px;
152
- border-radius: 2px;
153
- }
154
-
155
- input.file_input_submit:disabled
156
- {
157
- width: 100px;
158
- height: 27px;
159
- position: relative;
160
- margin: 0px;
161
- padding: 0px;
162
- background-color: #EEEEEE;
163
- color: silver;
164
- /* background-attachment: scroll; */
165
- background-image: url("../images/white-grad-active.png");
166
- background-position: left top;
167
- background-repeat: repeat-x;
168
- border-style: solid;
169
- border-width: 1px;
170
- border-color: #BBBBBB;
171
- -webkit-border-radius: 2px;
172
- -moz-border-radius: 2px;
173
- -khtml-border-radius: 2px;
174
- border-radius: 2px;
175
- }
176
-
177
- input.file_input_hidden
178
- {
179
- font-size: 45px;
180
- position: absolute;
181
- right: 0px;
182
- top: 0px;
183
- margin: 0px;
184
- padding: 0px;
185
- -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
186
- filter: alpha(opacity=0);
187
- -moz-opacity: 0;
188
- -khtml-opacity: 0;
189
- opacity: 0;
190
- }
191
-
192
- /* Userdata styles */
193
- input.file_userdata_message, input.file_userdata_message_required
194
- {
195
- width: 60% !important;
196
- height: 25px;
197
- margin: 0px;
198
- padding: 0px;
199
- border: 1px solid;
200
- border-color: #BBBBBB;
201
- background: none;
202
- color: black;
203
- }
204
-
205
- input.file_userdata_message:disabled, input.file_userdata_message_required:disabled
206
- {
207
- width: 60% !important;
208
- height: 25px;
209
- margin: 0px;
210
- padding: 0px;
211
- border: 1px solid;
212
- border-color: #BBBBBB;
213
- background: none;
214
- color: silver;
215
- }
216
-
217
- input.file_userdata_message_required_empty
218
- {
219
- width: 60% !important;
220
- height: 25px;
221
- margin: 0px;
222
- padding: 0px;
223
- border: 1px solid;
224
- border-color: #BBBBBB;
225
- background-color: red;
226
- color: black;
227
- }
228
-
229
-
1
+ /* File Textbox Styles */
2
+ input.file_input_textbox
3
+ {
4
+ position: relative;
5
+ width: 150px;
6
+ height: 25px;
7
+ margin: 0px;
8
+ padding: 0px;
9
+ border: 1px solid;
10
+ border-color: #BBBBBB;
11
+ background-color: white;
12
+ color: black;
13
+ }
14
+
15
+ input.file_input_textbox:disabled
16
+ {
17
+ position: relative;
18
+ width: 150px;
19
+ height: 25px;
20
+ margin: 0px;
21
+ padding: 0px;
22
+ border: 1px solid;
23
+ border-color: #BBBBBB;
24
+ background-color: white;
25
+ color: silver;
26
+ }
27
+
28
+ input.file_input_textbox_nofile
29
+ {
30
+ position: relative;
31
+ width: 150px;
32
+ height: 25px;
33
+ margin: 0px;
34
+ padding: 0px;
35
+ border: 1px solid;
36
+ border-color: #BBBBBB;
37
+ background-color: red;
38
+ color: black;
39
+ }
40
+
41
+ /* Upload Form and Button Styles */
42
+ input.file_input_button
43
+ {
44
+ width: 100px;
45
+ height: 27px;
46
+ position: absolute;
47
+ top: 0px;
48
+ margin: 0px;
49
+ padding: 0px;
50
+ background-color: #EEEEEE;
51
+ color: #555555;
52
+ /* background-attachment: scroll; */
53
+ background-image: url("../images/white-grad-active.png");
54
+ background-position: left top;
55
+ background-repeat: repeat-x;
56
+ border-style: solid;
57
+ border-width: 1px;
58
+ border-color: #BBBBBB;
59
+ -webkit-border-radius: 2px;
60
+ -moz-border-radius: 2px;
61
+ -khtml-border-radius: 2px;
62
+ border-radius: 2px;
63
+ }
64
+
65
+ input.file_input_button_hover
66
+ {
67
+ width: 100px;
68
+ height: 27px;
69
+ position: absolute;
70
+ top: 0px;
71
+ margin: 0px;
72
+ padding: 0px;
73
+ background-color: #EEEEEE;
74
+ color: #111111;
75
+ /* background-attachment: scroll; */
76
+ background-image: url("../images/white-grad-active.png");
77
+ background-position: left top;
78
+ background-repeat: repeat-x;
79
+ border-style: solid;
80
+ border-width: 1px;
81
+ border-color: #333333;
82
+ -webkit-border-radius: 2px;
83
+ -moz-border-radius: 2px;
84
+ -khtml-border-radius: 2px;
85
+ border-radius: 2px;
86
+ }
87
+
88
+ input.file_input_button:disabled, input.file_input_button_hover:disabled
89
+ {
90
+ width: 100px;
91
+ height: 27px;
92
+ position: absolute;
93
+ top: 0px;
94
+ margin: 0px;
95
+ padding: 0px;
96
+ background-color: #EEEEEE;
97
+ color: silver;
98
+ /* background-attachment: scroll; */
99
+ background-image: url("../images/white-grad-active.png");
100
+ background-position: left top;
101
+ background-repeat: repeat-x;
102
+ border-style: solid;
103
+ border-width: 1px;
104
+ border-color: #BBBBBB;
105
+ -webkit-border-radius: 2px;
106
+ -moz-border-radius: 2px;
107
+ -khtml-border-radius: 2px;
108
+ border-radius: 2px;
109
+ }
110
+
111
+ input.file_input_submit
112
+ {
113
+ width: 100px;
114
+ height: 27px;
115
+ position: relative;
116
+ margin: 0px;
117
+ padding: 0px;
118
+ background-color: #EEEEEE;
119
+ color: #555555;
120
+ /* background-attachment: scroll; */
121
+ background-image: url("../images/white-grad-active.png");
122
+ background-position: left top;
123
+ background-repeat: repeat-x;
124
+ border-style: solid;
125
+ border-width: 1px;
126
+ border-color: #BBBBBB;
127
+ -webkit-border-radius: 2px;
128
+ -moz-border-radius: 2px;
129
+ -khtml-border-radius: 2px;
130
+ border-radius: 2px;
131
+ }
132
+
133
+ input.file_input_submit:hover, input.file_input_submit:focus
134
+ {
135
+ width: 100px;
136
+ height: 27px;
137
+ position: relative;
138
+ margin: 0px;
139
+ padding: 0px;
140
+ background-color: #EEEEEE;
141
+ color: #111111;
142
+ /* background-attachment: scroll; */
143
+ background-image: url("../images/white-grad-active.png");
144
+ background-position: left top;
145
+ background-repeat: repeat-x;
146
+ border-style: solid;
147
+ border-width: 1px;
148
+ border-color: #333333;
149
+ -webkit-border-radius: 2px;
150
+ -moz-border-radius: 2px;
151
+ -khtml-border-radius: 2px;
152
+ border-radius: 2px;
153
+ }
154
+
155
+ input.file_input_submit:disabled
156
+ {
157
+ width: 100px;
158
+ height: 27px;
159
+ position: relative;
160
+ margin: 0px;
161
+ padding: 0px;
162
+ background-color: #EEEEEE;
163
+ color: silver;
164
+ /* background-attachment: scroll; */
165
+ background-image: url("../images/white-grad-active.png");
166
+ background-position: left top;
167
+ background-repeat: repeat-x;
168
+ border-style: solid;
169
+ border-width: 1px;
170
+ border-color: #BBBBBB;
171
+ -webkit-border-radius: 2px;
172
+ -moz-border-radius: 2px;
173
+ -khtml-border-radius: 2px;
174
+ border-radius: 2px;
175
+ }
176
+
177
+ input.file_input_hidden
178
+ {
179
+ font-size: 45px;
180
+ position: absolute;
181
+ right: 0px;
182
+ top: 0px;
183
+ margin: 0px;
184
+ padding: 0px;
185
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
186
+ filter: alpha(opacity=0);
187
+ -moz-opacity: 0;
188
+ -khtml-opacity: 0;
189
+ opacity: 0;
190
+ }
191
+
192
+ /* Userdata styles */
193
+ input.file_userdata_message, input.file_userdata_message_required
194
+ {
195
+ width: 60% !important;
196
+ height: 25px;
197
+ margin: 0px;
198
+ padding: 0px;
199
+ border: 1px solid;
200
+ border-color: #BBBBBB;
201
+ background: none;
202
+ color: black;
203
+ }
204
+
205
+ input.file_userdata_message:disabled, input.file_userdata_message_required:disabled
206
+ {
207
+ width: 60% !important;
208
+ height: 25px;
209
+ margin: 0px;
210
+ padding: 0px;
211
+ border: 1px solid;
212
+ border-color: #BBBBBB;
213
+ background: none;
214
+ color: silver;
215
+ }
216
+
217
+ input.file_userdata_message_required_empty
218
+ {
219
+ width: 60% !important;
220
+ height: 25px;
221
+ margin: 0px;
222
+ padding: 0px;
223
+ border: 1px solid;
224
+ border-color: #BBBBBB;
225
+ background-color: red;
226
+ color: black;
227
+ }
228
+
229
+
js/getElementsByClassName-1.0.1.js CHANGED
@@ -1,78 +1,78 @@
1
- /*
2
- Developed by Robert Nyman, http://www.robertnyman.com
3
- Code/licensing: http://code.google.com/p/getelementsbyclassname/
4
- */
5
- var getElementsByClassName = function (className, tag, elm){
6
- if (document.getElementsByClassName) {
7
- getElementsByClassName = function (className, tag, elm) {
8
- elm = elm || document;
9
- var elements = elm.getElementsByClassName(className),
10
- nodeName = (tag)? new RegExp("\\b" + tag + "\\b", "i") : null,
11
- returnElements = [],
12
- current;
13
- for(var i=0, il=elements.length; i<il; i+=1){
14
- current = elements[i];
15
- if(!nodeName || nodeName.test(current.nodeName)) {
16
- returnElements.push(current);
17
- }
18
- }
19
- return returnElements;
20
- };
21
- }
22
- else if (document.evaluate) {
23
- getElementsByClassName = function (className, tag, elm) {
24
- tag = tag || "*";
25
- elm = elm || document;
26
- var classes = className.split(" "),
27
- classesToCheck = "",
28
- xhtmlNamespace = "http://www.w3.org/1999/xhtml",
29
- namespaceResolver = (document.documentElement.namespaceURI === xhtmlNamespace)? xhtmlNamespace : null,
30
- returnElements = [],
31
- elements,
32
- node;
33
- for(var j=0, jl=classes.length; j<jl; j+=1){
34
- classesToCheck += "[contains(concat(' ', @class, ' '), ' " + classes[j] + " ')]";
35
- }
36
- try {
37
- elements = document.evaluate(".//" + tag + classesToCheck, elm, namespaceResolver, 0, null);
38
- }
39
- catch (e) {
40
- elements = document.evaluate(".//" + tag + classesToCheck, elm, null, 0, null);
41
- }
42
- while ((node = elements.iterateNext())) {
43
- returnElements.push(node);
44
- }
45
- return returnElements;
46
- };
47
- }
48
- else {
49
- getElementsByClassName = function (className, tag, elm) {
50
- tag = tag || "*";
51
- elm = elm || document;
52
- var classes = className.split(" "),
53
- classesToCheck = [],
54
- elements = (tag === "*" && elm.all)? elm.all : elm.getElementsByTagName(tag),
55
- current,
56
- returnElements = [],
57
- match;
58
- for(var k=0, kl=classes.length; k<kl; k+=1){
59
- classesToCheck.push(new RegExp("(^|\\s)" + classes[k] + "(\\s|$)"));
60
- }
61
- for(var l=0, ll=elements.length; l<ll; l+=1){
62
- current = elements[l];
63
- match = false;
64
- for(var m=0, ml=classesToCheck.length; m<ml; m+=1){
65
- match = classesToCheck[m].test(current.className);
66
- if (!match) {
67
- break;
68
- }
69
- }
70
- if (match) {
71
- returnElements.push(current);
72
- }
73
- }
74
- return returnElements;
75
- };
76
- }
77
- return getElementsByClassName(className, tag, elm);
78
  };
1
+ /*
2
+ Developed by Robert Nyman, http://www.robertnyman.com
3
+ Code/licensing: http://code.google.com/p/getelementsbyclassname/
4
+ */
5
+ var getElementsByClassName = function (className, tag, elm){
6
+ if (document.getElementsByClassName) {
7
+ getElementsByClassName = function (className, tag, elm) {
8
+ elm = elm || document;
9
+ var elements = elm.getElementsByClassName(className),
10
+ nodeName = (tag)? new RegExp("\\b" + tag + "\\b", "i") : null,
11
+ returnElements = [],
12
+ current;
13
+ for(var i=0, il=elements.length; i<il; i+=1){
14
+ current = elements[i];
15
+ if(!nodeName || nodeName.test(current.nodeName)) {
16
+ returnElements.push(current);
17
+ }
18
+ }
19
+ return returnElements;
20
+ };
21
+ }
22
+ else if (document.evaluate) {
23
+ getElementsByClassName = function (className, tag, elm) {
24
+ tag = tag || "*";
25
+ elm = elm || document;
26
+ var classes = className.split(" "),
27
+ classesToCheck = "",
28
+ xhtmlNamespace = "http://www.w3.org/1999/xhtml",
29
+ namespaceResolver = (document.documentElement.namespaceURI === xhtmlNamespace)? xhtmlNamespace : null,
30
+ returnElements = [],
31
+ elements,
32
+ node;
33
+ for(var j=0, jl=classes.length; j<jl; j+=1){
34
+ classesToCheck += "[contains(concat(' ', @class, ' '), ' " + classes[j] + " ')]";
35
+ }
36
+ try {
37
+ elements = document.evaluate(".//" + tag + classesToCheck, elm, namespaceResolver, 0, null);
38
+ }
39
+ catch (e) {
40
+ elements = document.evaluate(".//" + tag + classesToCheck, elm, null, 0, null);
41
+ }
42
+ while ((node = elements.iterateNext())) {
43
+ returnElements.push(node);
44
+ }
45
+ return returnElements;
46
+ };
47
+ }
48
+ else {
49
+ getElementsByClassName = function (className, tag, elm) {
50
+ tag = tag || "*";
51
+ elm = elm || document;
52
+ var classes = className.split(" "),
53
+ classesToCheck = [],
54
+ elements = (tag === "*" && elm.all)? elm.all : elm.getElementsByTagName(tag),
55
+ current,
56
+ returnElements = [],
57
+ match;
58
+ for(var k=0, kl=classes.length; k<kl; k+=1){
59
+ classesToCheck.push(new RegExp("(^|\\s)" + classes[k] + "(\\s|$)"));
60
+ }
61
+ for(var l=0, ll=elements.length; l<ll; l+=1){
62
+ current = elements[l];
63
+ match = false;
64
+ for(var m=0, ml=classesToCheck.length; m<ml; m+=1){
65
+ match = classesToCheck[m].test(current.className);
66
+ if (!match) {
67
+ break;
68
+ }
69
+ }
70
+ if (match) {
71
+ returnElements.push(current);
72
+ }
73
+ }
74
+ return returnElements;
75
+ };
76
+ }
77
+ return getElementsByClassName(className, tag, elm);
78
  };
js/json2.js CHANGED
@@ -1,480 +1,480 @@
1
- /*
2
- http://www.JSON.org/json2.js
3
- 2011-02-23
4
-
5
- Public Domain.
6
-
7
- NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
8
-
9
- See http://www.JSON.org/js.html
10
-
11
-
12
- This code should be minified before deployment.
13
- See http://javascript.crockford.com/jsmin.html
14
-
15
- USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
16
- NOT CONTROL.
17
-
18
-
19
- This file creates a global JSON object containing two methods: stringify
20
- and parse.
21
-
22
- JSON.stringify(value, replacer, space)
23
- value any JavaScript value, usually an object or array.
24
-
25
- replacer an optional parameter that determines how object
26
- values are stringified for objects. It can be a
27
- function or an array of strings.
28
-
29
- space an optional parameter that specifies the indentation
30
- of nested structures. If it is omitted, the text will
31
- be packed without extra whitespace. If it is a number,
32
- it will specify the number of spaces to indent at each
33
- level. If it is a string (such as '\t' or '&nbsp;'),
34
- it contains the characters used to indent at each level.
35
-
36
- This method produces a JSON text from a JavaScript value.
37
-
38
- When an object value is found, if the object contains a toJSON
39
- method, its toJSON method will be called and the result will be
40
- stringified. A toJSON method does not serialize: it returns the
41
- value represented by the name/value pair that should be serialized,
42
- or undefined if nothing should be serialized. The toJSON method
43
- will be passed the key associated with the value, and this will be
44
- bound to the value
45
-
46
- For example, this would serialize Dates as ISO strings.
47
-
48
- Date.prototype.toJSON = function (key) {
49
- function f(n) {
50
- // Format integers to have at least two digits.
51
- return n < 10 ? '0' + n : n;
52
- }
53
-
54
- return this.getUTCFullYear() + '-' +
55
- f(this.getUTCMonth() + 1) + '-' +
56
- f(this.getUTCDate()) + 'T' +
57
- f(this.getUTCHours()) + ':' +
58
- f(this.getUTCMinutes()) + ':' +
59
- f(this.getUTCSeconds()) + 'Z';
60
- };
61
-
62
- You can provide an optional replacer method. It will be passed the
63
- key and value of each member, with this bound to the containing
64
- object. The value that is returned from your method will be
65
- serialized. If your method returns undefined, then the member will
66
- be excluded from the serialization.
67
-
68
- If the replacer parameter is an array of strings, then it will be
69
- used to select the members to be serialized. It filters the results
70
- such that only members with keys listed in the replacer array are
71
- stringified.
72
-
73
- Values that do not have JSON representations, such as undefined or
74
- functions, will not be serialized. Such values in objects will be
75
- dropped; in arrays they will be replaced with null. You can use
76
- a replacer function to replace those with JSON values.
77
- JSON.stringify(undefined) returns undefined.
78
-
79
- The optional space parameter produces a stringification of the
80
- value that is filled with line breaks and indentation to make it
81
- easier to read.
82
-
83
- If the space parameter is a non-empty string, then that string will
84
- be used for indentation. If the space parameter is a number, then
85
- the indentation will be that many spaces.
86
-
87
- Example:
88
-
89
- text = JSON.stringify(['e', {pluribus: 'unum'}]);
90
- // text is '["e",{"pluribus":"unum"}]'
91
-
92
-
93
- text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
94
- // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
95
-
96
- text = JSON.stringify([new Date()], function (key, value) {
97
- return this[key] instanceof Date ?
98
- 'Date(' + this[key] + ')' : value;
99
- });
100
- // text is '["Date(---current time---)"]'
101
-
102
-
103
- JSON.parse(text, reviver)
104
- This method parses a JSON text to produce an object or array.
105
- It can throw a SyntaxError exception.
106
-
107
- The optional reviver parameter is a function that can filter and
108
- transform the results. It receives each of the keys and values,
109
- and its return value is used instead of the original value.
110
- If it returns what it received, then the structure is not modified.
111
- If it returns undefined then the member is deleted.
112
-
113
- Example:
114
-
115
- // Parse the text. Values that look like ISO date strings will
116
- // be converted to Date objects.
117
-
118
- myData = JSON.parse(text, function (key, value) {
119
- var a;
120
- if (typeof value === 'string') {
121
- a =
122
- /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
123
- if (a) {
124
- return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
125
- +a[5], +a[6]));
126
- }
127
- }
128
- return value;
129
- });
130
-
131
- myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
132
- var d;
133
- if (typeof value === 'string' &&
134
- value.slice(0, 5) === 'Date(' &&
135
- value.slice(-1) === ')') {
136
- d = new Date(value.slice(5, -1));
137
- if (d) {
138
- return d;
139
- }
140
- }
141
- return value;
142
- });
143
-
144
-
145
- This is a reference implementation. You are free to copy, modify, or
146
- redistribute.
147
- */
148
-
149
- /*jslint evil: true, strict: false, regexp: false */
150
-
151
- /*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
152
- call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
153
- getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
154
- lastIndex, length, parse, prototype, push, replace, slice, stringify,
155
- test, toJSON, toString, valueOf
156
- */
157
-
158
-
159
- // Create a JSON object only if one does not already exist. We create the
160
- // methods in a closure to avoid creating global variables.
161
-
162
- var JSON;
163
- if (!JSON) {
164
- JSON = {};
165
- }
166
-
167
- (function () {
168
- "use strict";
169
-
170
- function f(n) {
171
- // Format integers to have at least two digits.
172
- return n < 10 ? '0' + n : n;
173
- }
174
-
175
- if (typeof Date.prototype.toJSON !== 'function') {
176
-
177
- Date.prototype.toJSON = function (key) {
178
-
179
- return isFinite(this.valueOf()) ?
180
- this.getUTCFullYear() + '-' +
181
- f(this.getUTCMonth() + 1) + '-' +
182
- f(this.getUTCDate()) + 'T' +
183
- f(this.getUTCHours()) + ':' +
184
- f(this.getUTCMinutes()) + ':' +
185
- f(this.getUTCSeconds()) + 'Z' : null;
186
- };
187
-
188
- String.prototype.toJSON =
189
- Number.prototype.toJSON =
190
- Boolean.prototype.toJSON = function (key) {
191
- return this.valueOf();
192
- };
193
- }
194
-
195
- var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
196
- escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
197
- gap,
198
- indent,
199
- meta = { // table of character substitutions
200
- '\b': '\\b',
201
- '\t': '\\t',
202
- '\n': '\\n',
203
- '\f': '\\f',
204
- '\r': '\\r',
205
- '"' : '\\"',
206
- '\\': '\\\\'
207
- },
208
- rep;
209
-
210
-
211
- function quote(string) {
212
-
213
- // If the string contains no control characters, no quote characters, and no
214
- // backslash characters, then we can safely slap some quotes around it.
215
- // Otherwise we must also replace the offending characters with safe escape
216
- // sequences.
217
-
218
- escapable.lastIndex = 0;
219
- return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
220
- var c = meta[a];
221
- return typeof c === 'string' ? c :
222
- '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
223
- }) + '"' : '"' + string + '"';
224
- }
225
-
226
-
227
- function str(key, holder) {
228
-
229
- // Produce a string from holder[key].
230
-
231
- var i, // The loop counter.
232
- k, // The member key.
233
- v, // The member value.
234
- length,
235
- mind = gap,
236
- partial,
237
- value = holder[key];
238
-
239
- // If the value has a toJSON method, call it to obtain a replacement value.
240
-
241
- if (value && typeof value === 'object' &&
242
- typeof value.toJSON === 'function') {
243
- value = value.toJSON(key);
244
- }
245
-
246
- // If we were called with a replacer function, then call the replacer to
247
- // obtain a replacement value.
248
-
249
- if (typeof rep === 'function') {
250
- value = rep.call(holder, key, value);
251
- }
252
-
253
- // What happens next depends on the value's type.
254
-
255
- switch (typeof value) {
256
- case 'string':
257
- return quote(value);
258
-
259
- case 'number':
260
-
261
- // JSON numbers must be finite. Encode non-finite numbers as null.
262
-
263
- return isFinite(value) ? String(value) : 'null';
264
-
265
- case 'boolean':
266
- case 'null':
267
-
268
- // If the value is a boolean or null, convert it to a string. Note:
269
- // typeof null does not produce 'null'. The case is included here in
270
- // the remote chance that this gets fixed someday.
271
-
272
- return String(value);
273
-
274
- // If the type is 'object', we might be dealing with an object or an array or
275
- // null.
276
-
277
- case 'object':
278
-
279
- // Due to a specification blunder in ECMAScript, typeof null is 'object',
280
- // so watch out for that case.
281
-
282
- if (!value) {
283
- return 'null';
284
- }
285
-
286
- // Make an array to hold the partial results of stringifying this object value.
287
-
288
- gap += indent;
289
- partial = [];
290
-
291
- // Is the value an array?
292
-
293
- if (Object.prototype.toString.apply(value) === '[object Array]') {
294
-
295
- // The value is an array. Stringify every element. Use null as a placeholder
296
- // for non-JSON values.
297
-
298
- length = value.length;
299
- for (i = 0; i < length; i += 1) {
300
- partial[i] = str(i, value) || 'null';
301
- }
302
-
303
- // Join all of the elements together, separated with commas, and wrap them in
304
- // brackets.
305
-
306
- v = partial.length === 0 ? '[]' : gap ?
307
- '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' :
308
- '[' + partial.join(',') + ']';
309
- gap = mind;
310
- return v;
311
- }
312
-
313
- // If the replacer is an array, use it to select the members to be stringified.
314
-
315
- if (rep && typeof rep === 'object') {
316
- length = rep.length;
317
- for (i = 0; i < length; i += 1) {
318
- if (typeof rep[i] === 'string') {
319
- k = rep[i];
320
- v = str(k, value);
321
- if (v) {
322
- partial.push(quote(k) + (gap ? ': ' : ':') + v);
323
- }
324
- }
325
- }
326
- } else {
327
-
328
- // Otherwise, iterate through all of the keys in the object.
329
-
330
- for (k in value) {
331
- if (Object.prototype.hasOwnProperty.call(value, k)) {
332
- v = str(k, value);
333
- if (v) {
334
- partial.push(quote(k) + (gap ? ': ' : ':') + v);
335
- }
336
- }
337
- }
338
- }
339
-
340
- // Join all of the member texts together, separated with commas,
341
- // and wrap them in braces.
342
-
343
- v = partial.length === 0 ? '{}' : gap ?
344
- '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' :
345
- '{' + partial.join(',') + '}';
346
- gap = mind;
347
- return v;
348
- }
349
- }
350
-
351
- // If the JSON object does not yet have a stringify method, give it one.
352
-
353
- if (typeof JSON.stringify !== 'function') {
354
- JSON.stringify = function (value, replacer, space) {
355
-
356
- // The stringify method takes a value and an optional replacer, and an optional
357
- // space parameter, and returns a JSON text. The replacer can be a function
358
- // that can replace values, or an array of strings that will select the keys.
359
- // A default replacer method can be provided. Use of the space parameter can
360
- // produce text that is more easily readable.
361
-
362
- var i;
363
- gap = '';
364
- indent = '';
365
-
366
- // If the space parameter is a number, make an indent string containing that
367
- // many spaces.
368
-
369
- if (typeof space === 'number') {
370
- for (i = 0; i < space; i += 1) {
371
- indent += ' ';
372
- }
373
-
374
- // If the space parameter is a string, it will be used as the indent string.
375
-
376
- } else if (typeof space === 'string') {
377
- indent = space;
378
- }
379
-
380
- // If there is a replacer, it must be a function or an array.
381
- // Otherwise, throw an error.
382
-
383
- rep = replacer;
384
- if (replacer && typeof replacer !== 'function' &&
385
- (typeof replacer !== 'object' ||
386
- typeof replacer.length !== 'number')) {
387
- throw new Error('JSON.stringify');
388
- }
389
-
390
- // Make a fake root object containing our value under the key of ''.
391
- // Return the result of stringifying the value.
392
-
393
- return str('', {'': value});
394
- };
395
- }
396
-
397
-
398
- // If the JSON object does not yet have a parse method, give it one.
399
-
400
- if (typeof JSON.parse !== 'function') {
401
- JSON.parse = function (text, reviver) {
402
-
403
- // The parse method takes a text and an optional reviver function, and returns
404
- // a JavaScript value if the text is a valid JSON text.
405
-
406
- var j;
407
-
408
- function walk(holder, key) {
409
-
410
- // The walk method is used to recursively walk the resulting structure so
411
- // that modifications can be made.
412
-
413
- var k, v, value = holder[key];
414
- if (value && typeof value === 'object') {
415
- for (k in value) {
416
- if (Object.prototype.hasOwnProperty.call(value, k)) {
417
- v = walk(value, k);
418
- if (v !== undefined) {
419
- value[k] = v;
420
- } else {
421
- delete value[k];
422
- }
423
- }
424
- }
425
- }
426
- return reviver.call(holder, key, value);
427
- }
428
-
429
-
430
- // Parsing happens in four stages. In the first stage, we replace certain
431
- // Unicode characters with escape sequences. JavaScript handles many characters
432
- // incorrectly, either silently deleting them, or treating them as line endings.
433
-
434
- text = String(text);
435
- cx.lastIndex = 0;
436
- if (cx.test(text)) {
437
- text = text.replace(cx, function (a) {
438
- return '\\u' +
439
- ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
440
- });
441
- }
442
-
443
- // In the second stage, we run the text against regular expressions that look
444
- // for non-JSON patterns. We are especially concerned with '()' and 'new'
445
- // because they can cause invocation, and '=' because it can cause mutation.
446
- // But just to be safe, we want to reject all unexpected forms.
447
-
448
- // We split the second stage into 4 regexp operations in order to work around
449
- // crippling inefficiencies in IE's and Safari's regexp engines. First we
450
- // replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
451
- // replace all simple value tokens with ']' characters. Third, we delete all
452
- // open brackets that follow a colon or comma or that begin the text. Finally,
453
- // we look to see that the remaining characters are only whitespace or ']' or
454
- // ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
455
-
456
- if (/^[\],:{}\s]*$/
457
- .test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
458
- .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
459
- .replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
460
-
461
- // In the third stage we use the eval function to compile the text into a
462
- // JavaScript structure. The '{' operator is subject to a syntactic ambiguity
463
- // in JavaScript: it can begin a block or an object literal. We wrap the text
464
- // in parens to eliminate the ambiguity.
465
-
466
- j = eval('(' + text + ')');
467
-
468
- // In the optional fourth stage, we recursively walk the new structure, passing
469
- // each name/value pair to a reviver function for possible transformation.
470
-
471
- return typeof reviver === 'function' ?
472
- walk({'': j}, '') : j;
473
- }
474
-
475
- // If the text is not JSON parseable, then a SyntaxError is thrown.
476
-
477
- throw new SyntaxError('JSON.parse');
478
- };
479
- }
480
- }());
1
+ /*
2
+ http://www.JSON.org/json2.js
3
+ 2011-02-23
4
+
5
+ Public Domain.
6
+
7
+ NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
8
+
9
+ See http://www.JSON.org/js.html
10
+
11
+
12
+ This code should be minified before deployment.
13
+ See http://javascript.crockford.com/jsmin.html
14
+
15
+ USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
16
+ NOT CONTROL.
17
+
18
+
19
+ This file creates a global JSON object containing two methods: stringify
20
+ and parse.
21
+
22
+ JSON.stringify(value, replacer, space)
23
+ value any JavaScript value, usually an object or array.
24
+
25
+ replacer an optional parameter that determines how object
26
+ values are stringified for objects. It can be a
27
+ function or an array of strings.
28
+
29
+ space an optional parameter that specifies the indentation
30
+ of nested structures. If it is omitted, the text will
31
+ be packed without extra whitespace. If it is a number,
32
+ it will specify the number of spaces to indent at each
33
+ level. If it is a string (such as '\t' or '&nbsp;'),
34
+ it contains the characters used to indent at each level.
35
+
36
+ This method produces a JSON text from a JavaScript value.
37
+
38
+ When an object value is found, if the object contains a toJSON
39
+ method, its toJSON method will be called and the result will be
40
+ stringified. A toJSON method does not serialize: it returns the
41
+ value represented by the name/value pair that should be serialized,
42
+ or undefined if nothing should be serialized. The toJSON method
43
+ will be passed the key associated with the value, and this will be
44
+ bound to the value
45
+
46
+ For example, this would serialize Dates as ISO strings.
47
+
48
+ Date.prototype.toJSON = function (key) {
49
+ function f(n) {
50
+ // Format integers to have at least two digits.
51
+ return n < 10 ? '0' + n : n;
52
+ }
53
+
54
+ return this.getUTCFullYear() + '-' +
55
+ f(this.getUTCMonth() + 1) + '-' +
56
+ f(this.getUTCDate()) + 'T' +
57
+ f(this.getUTCHours()) + ':' +
58
+ f(this.getUTCMinutes()) + ':' +
59
+ f(this.getUTCSeconds()) + 'Z';
60
+ };
61
+
62
+ You can provide an optional replacer method. It will be passed the
63
+ key and value of each member, with this bound to the containing
64
+ object. The value that is returned from your method will be
65
+ serialized. If your method returns undefined, then the member will
66
+ be excluded from the serialization.
67
+
68
+ If the replacer parameter is an array of strings, then it will be
69
+ used to select the members to be serialized. It filters the results
70
+ such that only members with keys listed in the replacer array are
71
+ stringified.
72
+
73
+ Values that do not have JSON representations, such as undefined or
74
+ functions, will not be serialized. Such values in objects will be
75
+ dropped; in arrays they will be replaced with null. You can use
76
+ a replacer function to replace those with JSON values.
77
+ JSON.stringify(undefined) returns undefined.
78
+
79
+ The optional space parameter produces a stringification of the
80
+ value that is filled with line breaks and indentation to make it
81
+ easier to read.
82
+
83
+ If the space parameter is a non-empty string, then that string will
84
+ be used for indentation. If the space parameter is a number, then
85
+ the indentation will be that many spaces.
86
+
87
+ Example:
88
+
89
+ text = JSON.stringify(['e', {pluribus: 'unum'}]);
90
+ // text is '["e",{"pluribus":"unum"}]'
91
+
92
+
93
+ text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
94
+ // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
95
+
96
+ text = JSON.stringify([new Date()], function (key, value) {
97
+ return this[key] instanceof Date ?
98
+ 'Date(' + this[key] + ')' : value;
99
+ });
100
+ // text is '["Date(---current time---)"]'
101
+
102
+
103
+ JSON.parse(text, reviver)
104
+ This method parses a JSON text to produce an object or array.
105
+ It can throw a SyntaxError exception.
106
+
107
+ The optional reviver parameter is a function that can filter and
108
+ transform the results. It receives each of the keys and values,
109
+ and its return value is used instead of the original value.
110
+ If it returns what it received, then the structure is not modified.
111
+ If it returns undefined then the member is deleted.
112
+
113
+ Example:
114
+
115
+ // Parse the text. Values that look like ISO date strings will
116
+ // be converted to Date objects.
117
+
118
+ myData = JSON.parse(text, function (key, value) {
119
+ var a;
120
+ if (typeof value === 'string') {
121
+ a =
122
+ /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
123
+ if (a) {
124
+ return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
125
+ +a[5], +a[6]));
126
+ }
127
+ }
128
+ return value;
129
+ });
130
+
131
+ myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
132
+ var d;
133
+ if (typeof value === 'string' &&
134
+ value.slice(0, 5) === 'Date(' &&
135
+ value.slice(-1) === ')') {
136
+ d = new Date(value.slice(5, -1));
137
+ if (d) {
138
+ return d;
139
+ }
140
+ }
141
+ return value;
142
+ });
143
+
144
+
145
+ This is a reference implementation. You are free to copy, modify, or
146
+ redistribute.
147
+ */
148
+
149
+ /*jslint evil: true, strict: false, regexp: false */
150
+
151
+ /*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
152
+ call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
153
+ getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
154
+ lastIndex, length, parse, prototype, push, replace, slice, stringify,
155
+ test, toJSON, toString, valueOf
156
+ */
157
+
158
+
159
+ // Create a JSON object only if one does not already exist. We create the
160
+ // methods in a closure to avoid creating global variables.
161
+
162
+ var JSON;
163
+ if (!JSON) {
164
+ JSON = {};
165
+ }
166
+
167
+ (function () {
168
+ "use strict";
169
+
170
+ function f(n) {
171
+ // Format integers to have at least two digits.
172
+ return n < 10 ? '0' + n : n;
173
+ }
174
+
175
+ if (typeof Date.prototype.toJSON !== 'function') {
176
+
177
+ Date.prototype.toJSON = function (key) {
178
+
179
+ return isFinite(this.valueOf()) ?
180
+ this.getUTCFullYear() + '-' +
181
+ f(this.getUTCMonth() + 1) + '-' +
182
+ f(this.getUTCDate()) + 'T' +
183
+ f(this.getUTCHours()) + ':' +
184
+ f(this.getUTCMinutes()) + ':' +
185
+ f(this.getUTCSeconds()) + 'Z' : null;
186
+ };
187
+
188
+ String.prototype.toJSON =
189
+ Number.prototype.toJSON =
190
+ Boolean.prototype.toJSON = function (key) {
191
+ return this.valueOf();
192
+ };
193
+ }
194
+
195
+ var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
196
+ escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
197
+ gap,
198
+ indent,
199
+ meta = { // table of character substitutions
200
+ '\b': '\\b',
201
+ '\t': '\\t',
202
+ '\n': '\\n',
203
+ '\f': '\\f',
204
+ '\r': '\\r',
205
+ '"' : '\\"',
206
+ '\\': '\\\\'
207
+ },
208
+ rep;
209
+
210
+
211
+ function quote(string) {
212
+
213
+ // If the string contains no control characters, no quote characters, and no
214
+ // backslash characters, then we can safely slap some quotes around it.
215
+ // Otherwise we must also replace the offending characters with safe escape
216
+ // sequences.
217
+
218
+ escapable.lastIndex = 0;
219
+ return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
220
+ var c = meta[a];
221
+ return typeof c === 'string' ? c :
222
+ '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
223
+ }) + '"' : '"' + string + '"';
224
+ }
225
+
226
+
227
+ function str(key, holder) {
228
+
229
+ // Produce a string from holder[key].
230
+
231
+ var i, // The loop counter.
232
+ k, // The member key.
233
+ v, // The member value.
234
+ length,
235
+ mind = gap,
236
+ partial,
237
+ value = holder[key];
238
+
239
+ // If the value has a toJSON method, call it to obtain a replacement value.
240
+
241
+ if (value && typeof value === 'object' &&
242
+ typeof value.toJSON === 'function') {
243
+ value = value.toJSON(key);
244
+ }
245
+
246
+ // If we were called with a replacer function, then call the replacer to
247
+ // obtain a replacement value.
248
+
249
+ if (typeof rep === 'function') {
250
+ value = rep.call(holder, key, value);
251
+ }
252
+
253
+ // What happens next depends on the value's type.
254
+
255
+ switch (typeof value) {
256
+ case 'string':
257
+ return quote(value);
258
+
259
+ case 'number':
260
+
261
+ // JSON numbers must be finite. Encode non-finite numbers as null.
262
+
263
+ return isFinite(value) ? String(value) : 'null';
264
+
265
+ case 'boolean':
266
+ case 'null':
267
+
268
+ // If the value is a boolean or null, convert it to a string. Note:
269
+ // typeof null does not produce 'null'. The case is included here in
270
+ // the remote chance that this gets fixed someday.
271
+
272
+ return String(value);
273
+
274
+ // If the type is 'object', we might be dealing with an object or an array or
275
+ // null.
276
+
277
+ case 'object':
278
+
279
+ // Due to a specification blunder in ECMAScript, typeof null is 'object',
280
+ // so watch out for that case.
281
+
282
+ if (!value) {
283
+ return 'null';
284
+ }
285
+
286
+ // Make an array to hold the partial results of stringifying this object value.
287
+
288
+ gap += indent;
289
+ partial = [];
290
+
291
+ // Is the value an array?
292
+
293
+ if (Object.prototype.toString.apply(value) === '[object Array]') {
294
+
295
+ // The value is an array. Stringify every element. Use null as a placeholder
296
+ // for non-JSON values.
297
+
298
+ length = value.length;
299
+ for (i = 0; i < length; i += 1) {
300
+ partial[i] = str(i, value) || 'null';
301
+ }
302
+
303
+ // Join all of the elements together, separated with commas, and wrap them in
304
+ // brackets.
305
+
306
+ v = partial.length === 0 ? '[]' : gap ?
307
+ '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' :
308
+ '[' + partial.join(',') + ']';
309
+ gap = mind;
310
+ return v;
311
+ }
312
+
313
+ // If the replacer is an array, use it to select the members to be stringified.
314
+
315
+ if (rep && typeof rep === 'object') {
316
+ length = rep.length;
317
+ for (i = 0; i < length; i += 1) {
318
+ if (typeof rep[i] === 'string') {
319
+ k = rep[i];
320
+ v = str(k, value);
321
+ if (v) {
322
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
323
+ }
324
+ }
325
+ }
326
+ } else {
327
+
328
+ // Otherwise, iterate through all of the keys in the object.
329
+
330
+ for (k in value) {
331
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
332
+ v = str(k, value);
333
+ if (v) {
334
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
335
+ }
336
+ }
337
+ }
338
+ }
339
+
340
+ // Join all of the member texts together, separated with commas,
341
+ // and wrap them in braces.
342
+
343
+ v = partial.length === 0 ? '{}' : gap ?
344
+ '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' :
345
+ '{' + partial.join(',') + '}';
346
+ gap = mind;
347
+ return v;
348
+ }
349
+ }
350
+
351
+ // If the JSON object does not yet have a stringify method, give it one.
352
+
353
+ if (typeof JSON.stringify !== 'function') {
354
+ JSON.stringify = function (value, replacer, space) {
355
+
356
+ // The stringify method takes a value and an optional replacer, and an optional
357
+ // space parameter, and returns a JSON text. The replacer can be a function
358
+ // that can replace values, or an array of strings that will select the keys.
359
+ // A default replacer method can be provided. Use of the space parameter can
360
+ // produce text that is more easily readable.
361
+
362
+ var i;
363
+ gap = '';
364
+ indent = '';
365
+
366
+ // If the space parameter is a number, make an indent string containing that
367
+ // many spaces.
368
+
369
+ if (typeof space === 'number') {
370
+ for (i = 0; i < space; i += 1) {
371
+ indent += ' ';
372
+ }
373
+
374
+ // If the space parameter is a string, it will be used as the indent string.
375
+
376
+ } else if (typeof space === 'string') {
377
+ indent = space;
378
+ }
379
+
380
+ // If there is a replacer, it must be a function or an array.
381
+ // Otherwise, throw an error.
382
+
383
+ rep = replacer;
384
+ if (replacer && typeof replacer !== 'function' &&
385
+ (typeof replacer !== 'object' ||
386
+ typeof replacer.length !== 'number')) {
387
+ throw new Error('JSON.stringify');
388
+ }
389
+
390
+ // Make a fake root object containing our value under the key of ''.
391
+ // Return the result of stringifying the value.
392
+
393
+ return str('', {'': value});
394
+ };
395
+ }
396
+
397
+
398
+ // If the JSON object does not yet have a parse method, give it one.
399
+
400
+ if (typeof JSON.parse !== 'function') {
401
+ JSON.parse = function (text, reviver) {
402
+
403
+ // The parse method takes a text and an optional reviver function, and returns
404
+ // a JavaScript value if the text is a valid JSON text.
405
+
406
+ var j;
407
+
408
+ function walk(holder, key) {
409
+
410
+ // The walk method is used to recursively walk the resulting structure so
411
+ // that modifications can be made.
412
+
413
+ var k, v, value = holder[key];
414
+ if (value && typeof value === 'object') {
415
+ for (k in value) {
416
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
417
+ v = walk(value, k);
418
+ if (v !== undefined) {
419
+ value[k] = v;
420
+ } else {
421
+ delete value[k];
422
+ }
423
+ }
424
+ }
425
+ }
426
+ return reviver.call(holder, key, value);
427
+ }
428
+
429
+
430
+ // Parsing happens in four stages. In the first stage, we replace certain
431
+ // Unicode characters with escape sequences. JavaScript handles many characters
432
+ // incorrectly, either silently deleting them, or treating them as line endings.
433
+
434
+ text = String(text);
435
+ cx.lastIndex = 0;
436
+ if (cx.test(text)) {
437
+ text = text.replace(cx, function (a) {
438
+ return '\\u' +
439
+ ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
440
+ });
441
+ }
442
+
443
+ // In the second stage, we run the text against regular expressions that look
444
+ // for non-JSON patterns. We are especially concerned with '()' and 'new'
445
+ // because they can cause invocation, and '=' because it can cause mutation.
446
+ // But just to be safe, we want to reject all unexpected forms.
447
+
448
+ // We split the second stage into 4 regexp operations in order to work around
449
+ // crippling inefficiencies in IE's and Safari's regexp engines. First we
450
+ // replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
451
+ // replace all simple value tokens with ']' characters. Third, we delete all
452
+ // open brackets that follow a colon or comma or that begin the text. Finally,
453
+ // we look to see that the remaining characters are only whitespace or ']' or
454
+ // ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
455
+
456
+ if (/^[\],:{}\s]*$/
457
+ .test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
458
+ .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
459
+ .replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
460
+
461
+ // In the third stage we use the eval function to compile the text into a
462
+ // JavaScript structure. The '{' operator is subject to a syntactic ambiguity
463
+ // in JavaScript: it can begin a block or an object literal. We wrap the text
464
+ // in parens to eliminate the ambiguity.
465
+
466
+ j = eval('(' + text + ')');
467
+
468
+ // In the optional fourth stage, we recursively walk the new structure, passing
469
+ // each name/value pair to a reviver function for possible transformation.
470
+
471
+ return typeof reviver === 'function' ?
472
+ walk({'': j}, '') : j;
473
+ }
474
+
475
+ // If the text is not JSON parseable, then a SyntaxError is thrown.
476
+
477
+ throw new SyntaxError('JSON.parse');
478
+ };
479
+ }
480
+ }());
js/wordpress_file_upload_adminfunctions.js CHANGED
@@ -1,694 +1,694 @@
1
- var DraggedItem = null;
2
- var ShortcodeNextSave = 0;
3
- var ShortcodeTimeOut = null;
4
- var ShortcodeString = "";
5
-
6
- jQuery(document).ready(function($){
7
- $('.wfu_color_field').wpColorPicker({
8
- change: function(event, ui) {
9
- event.target.value = ui.color.toString();
10
- if (event.target.name == "wfu_text_elements") wfu_update_text_value(event);
11
- else if (event.target.name == "wfu_triplecolor_elements") wfu_update_triplecolor_value(event);
12
- }
13
- });
14
- });
15
-
16
- function wfu_admin_activate_tab(key) {
17
- var tabs = document.getElementById("wfu_tab_container");
18
- var tab, tabkey;
19
- for (var i = 0; i < tabs.childNodes.length; i++) {
20
- tab = tabs.childNodes[i];
21
- if (tab.nodeType === 1) {
22
- tabkey = tab.id.substr(8);
23
- if (tab.className.indexOf("nav-tab-active") > -1) {
24
- tab.className = "nav-tab";
25
- document.getElementById("wfu_container_" + tabkey).style.display = "none";
26
- }
27
- }
28
- }
29
- document.getElementById("wfu_tab_" + key).className = "nav-tab nav-tab-active";
30
- document.getElementById("wfu_container_" + key).style.display = "block";
31
- }
32
-
33
- function wfu_admin_onoff_clicked(key) {
34
- var onoff = document.getElementById("wfu_attribute_" + key);
35
- var container = document.getElementById("wfu_wrapper");
36
- var shadows = document.getElementsByClassName("wfu_shadow_" + key, "div", container);
37
- var shadows_inv = document.getElementsByClassName("wfu_shadow_" + key + "_inv", "div", container);
38
- var status = (onoff.className.substr(onoff.className.length - 2) == "on");
39
- status = !status;
40
- if (status) {
41
- document.getElementById("wfu_attribute_value_" + key).value = "true";
42
- onoff.className = "wfu_onoff_container_on";
43
- for (var i = 0; i < shadows.length; i++) shadows[i].style.display = "none";
44
- for (var i = 0; i < shadows_inv.length; i++) shadows_inv[i].style.display = "block";
45
- }
46
- else {
47
- document.getElementById("wfu_attribute_value_" + key).value = "false";
48
- onoff.className = "wfu_onoff_container_off";
49
- for (var i = 0; i < shadows.length; i++) shadows[i].style.display = "block";
50
- for (var i = 0; i < shadows_inv.length; i++) shadows_inv[i].style.display = "none";
51
- }
52
- wfu_generate_shortcode();
53
- if (key == "userdata") wfu_update_userfield_variables();
54
- }
55
-
56
- function wfu_admin_radio_clicked(key) {
57
- var radios = document.getElementsByName("wfu_radioattribute_" + key);
58
- var container = document.getElementById("wfu_wrapper");
59
- var shadows = document.getElementsByClassName("wfu_shadow_" + key, "div", container);
60
- var shadows_inv = document.getElementsByClassName("wfu_shadow_" + key + "_inv", "div", container);
61
- var val = "";
62
- for (i = 0; i < radios.length; i++)
63
- if (radios[i].checked) val = radios[i].value;
64
- var status = (val.substr(0, 1) == "*");
65
- if (status) {
66
- val = val.substr(1);
67
- for (var i = 0; i < shadows.length; i++) shadows[i].style.display = "none";
68
- for (var i = 0; i < shadows_inv.length; i++) shadows_inv[i].style.display = "block";
69
- }
70
- else {
71
- for (var i = 0; i < shadows.length; i++) shadows[i].style.display = "block";
72
- for (var i = 0; i < shadows_inv.length; i++) shadows_inv[i].style.display = "none";
73
- }
74
- document.getElementById("wfu_attribute_value_" + key).value = val;
75
- wfu_generate_shortcode();
76
- }
77
-
78
- function wfu_addEventHandler(obj, evt, handler) {
79
- if(obj.addEventListener) {
80
- // W3C method
81
- obj.addEventListener(evt, handler, false);
82
- }
83
- else if(obj.attachEvent) {
84
- // IE method.
85
- obj.attachEvent('on'+evt, handler);
86
- }
87
- else {
88
- // Old school method.
89
- obj['on'+evt] = handler;
90
- }
91
- }
92
-
93
- function wfu_attach_separator_dragdrop_events() {
94
- var container = document.getElementById('wfu_placements_container');
95
- var item;
96
- for (var i = 0; i < container.childNodes.length; i++) {
97
- item = container.childNodes[i];
98
- if (item.className == "wfu_component_separator_hor" || item.className == "wfu_component_separator_ver") {
99
- wfu_addEventHandler(item, 'dragenter', wfu_separator_dragenter);
100
- wfu_addEventHandler(item, 'dragover', wfu_default_dragover);
101
- wfu_addEventHandler(item, 'dragleave', wfu_separator_dragleave);
102
- wfu_addEventHandler(item, 'drop', wfu_separator_drop);
103
- }
104
- }
105
- }
106
-
107
- function wfu_Attach_Admin_DragDrop_Events() {
108
- if (window.FileReader) {
109
- var container = document.getElementById('wfu_placements_container');
110
- var available_container = document.getElementById('wfu_componentlist_container');
111
- var item;
112
- for (var i = 0; i < container.childNodes.length; i++) {
113
- item = container.childNodes[i];
114
- if (item.className == "wfu_component_box") {
115
- wfu_addEventHandler(item, 'dragstart', wfu_component_dragstart);
116
- wfu_addEventHandler(item, 'dragend', wfu_component_dragend);
117
- }
118
- }
119
- for (var i = 0; i < available_container.childNodes.length; i++) {
120
- item = available_container.childNodes[i];
121
- if (item.className == "wfu_component_box_container") {
122
- for (var ii = 0; ii < item.childNodes.length; ii++) {
123
- if (item.childNodes[ii].className == "wfu_component_box wfu_inbase") {
124
- wfu_addEventHandler(item.childNodes[ii], 'dragstart', wfu_component_dragstart);
125
- wfu_addEventHandler(item.childNodes[ii], 'dragend', wfu_component_dragend);
126
- }
127
- }
128
- }
129
- }
130
- item = document.getElementById('wfu_componentlist_dragdrop');
131
- wfu_addEventHandler(item, 'dragenter', wfu_componentlist_dragenter);
132
- wfu_addEventHandler(item, 'dragover', wfu_default_dragover);
133
- wfu_addEventHandler(item, 'dragleave', wfu_componentlist_dragleave);
134
- wfu_addEventHandler(item, 'drop', wfu_componentlist_drop);
135
- wfu_attach_separator_dragdrop_events();
136
- }
137
- }
138
-
139
- function wfu_componentlist_dragenter(e) {
140
- e = e || window.event;
141
- if (e.preventDefault) { e.preventDefault(); }
142
- if (!DraggedItem) return false;
143
- var item = document.getElementById('wfu_componentlist_dragdrop');
144
- if (item.className.indexOf("wfu_componentlist_dragdrop_dragover") == -1)
145
- item.className += " wfu_componentlist_dragdrop_dragover";
146
- return false;
147
- }
148
-
149
- function wfu_componentlist_dragleave(e) {
150
- e = e || window.event;
151
- if (e.preventDefault) { e.preventDefault(); }
152
- if (!DraggedItem) return false;
153
- var item = document.getElementById('wfu_componentlist_dragdrop');
154
- item.className = item.className.replace(" wfu_componentlist_dragdrop_dragover", "");
155
- return false;
156
- }
157
-
158
- function wfu_componentlist_drop(e) {
159
- e = e || window.event;
160
- if (e.preventDefault) { e.preventDefault(); }
161
- var component = e.dataTransfer.getData("Component");
162
- if (!component) return false;
163
- //move dragged component to base
164
- var item = document.getElementById('wfu_component_box_' + component);
165
- item.className = "wfu_component_box wfu_inbase";
166
- item.style.display = "block";
167
- document.getElementById('wfu_component_box_container_' + component).appendChild(item);
168
- //recreate placements panel
169
- var placements = wfu_admin_recreate_placements_text(null, "");
170
- wfu_admin_recreate_placements_panel(placements);
171
- document.getElementById("wfu_attribute_value_placements").value = placements;
172
- wfu_generate_shortcode();
173
- return false;
174
- }
175
-
176
- function wfu_separator_dragenter(e) {
177
- e = e || window.event;
178
- if (e.preventDefault) { e.preventDefault(); }
179
- if (!DraggedItem) return false;
180
- if (e.target.className == "wfu_component_separator_hor") {
181
- var bar = document.getElementById('wfu_component_bar_hor');
182
- bar.style.top = e.target.offsetTop + "px";
183
- bar.style.display = "block";
184
- }
185
- else if (e.target.className == "wfu_component_separator_ver") {
186
- var bar = document.getElementById('wfu_component_bar_ver');
187
- bar.style.top = e.target.offsetTop + "px";
188
- bar.style.left = e.target.offsetLeft + "px";
189
- bar.style.display = "block";
190
- }
191
- return false;
192
- }
193
-
194
- function wfu_default_dragover(e) {
195
- e = e || window.event;
196
- if (e.preventDefault) { e.preventDefault(); }
197
- return false;
198
- }
199
-
200
- function wfu_separator_dragleave(e) {
201
- e = e || window.event;
202
- if (e.preventDefault) { e.preventDefault(); }
203
- if (!DraggedItem) return false;
204
- if (e.target.className == "wfu_component_separator_hor") {
205
- var bar = document.getElementById('wfu_component_bar_hor');
206
- bar.style.display = "none";
207
- }
208
- else if (e.target.className == "wfu_component_separator_ver") {
209
- var bar = document.getElementById('wfu_component_bar_ver');
210
- bar.style.display = "none";
211
- }
212
- return false;
213
- }
214
-
215
- function wfu_separator_drop(e) {
216
- e = e || window.event;
217
- if (e.preventDefault) { e.preventDefault(); }
218
- var component = e.dataTransfer.getData("Component");
219
- if (!component) return false;
220
- //first move dragged component to base otherwise we may lose it during recreation of placements panel
221
- var item = document.getElementById('wfu_component_box_' + component);
222
- item.style.display = "none";
223
- item.className = "wfu_component_box wfu_inbase";
224
- document.getElementById('wfu_component_box_container_' + component).appendChild(item);
225
- //recreate placements panel
226
- var placements = wfu_admin_recreate_placements_text(e.target, component);
227
- wfu_admin_recreate_placements_panel(placements);
228
- document.getElementById("wfu_attribute_value_placements").value = placements;
229
- wfu_generate_shortcode();
230
- return false;
231
- }
232
-
233
- function wfu_component_dragstart(e) {
234
- e = e || window.event;
235
- e.dataTransfer.setData("Component", e.target.id.replace("wfu_component_box_", ""));
236
- if (e.target.className.indexOf("wfu_component_box_dragged") == -1) {
237
- e.target.className += " wfu_component_box_dragged";
238
- DraggedItem = e.target;
239
- }
240
- e.target.style.zIndex = 3;
241
- var item = document.getElementById('wfu_componentlist_dragdrop');
242
- item.className = "wfu_componentlist_dragdrop wfu_componentlist_dragdrop_dragover";
243
- item.style.display = "block";
244
- return false;
245
- }
246
-
247
- function wfu_component_dragend(e) {
248
- e = e || window.event;
249
- DraggedItem = null;
250
- e.target.style.zIndex = 1;
251
- var item = document.getElementById('wfu_componentlist_dragdrop');
252
- item.style.display = "none";
253
- item.className = "wfu_componentlist_dragdrop";
254
- e.target.className = e.target.className.replace(" wfu_component_box_dragged", "");
255
- document.getElementById('wfu_component_bar_ver').style.display = "none";
256
- document.getElementById('wfu_component_bar_hor').style.display = "none";
257
- return false;
258
- }
259
-
260
- function wfu_admin_recreate_placements_text(place, new_component) {
261
- function add_item(component) {
262
- if (placements != "") placements += delim;
263
- placements += component;
264
- delim = "";
265
- }
266
-
267
- var container = document.getElementById('wfu_placements_container');
268
- var delim = "";
269
- var placements = "";
270
- var component = "";
271
- for (var i = 0; i < container.childNodes.length; i++) {
272
- item = container.childNodes[i];
273
- if (item.className == "wfu_component_separator_ver") {
274
- if (delim == "" ) delim = "+";
275
- if (item == place) { add_item(new_component); delim = "+"; }
276
- }
277
- else if (item.className == "wfu_component_separator_hor") {
278
- delim = "/";
279
- if (item == place) { add_item(new_component); delim = "/"; }
280
- }
281
- else if (item.className == "wfu_component_box") add_item(item.id.replace("wfu_component_box_", ""));
282
- }
283
- return placements;
284
- }
285
-
286
- function wfu_admin_recreate_placements_panel(placements_text) {
287
- var container = document.getElementById('wfu_placements_container');
288
- var item, placements, sections;
289
- var itemname = "";
290
- for (var i = 0; i < container.childNodes.length; i++) {
291
- item = container.childNodes[i];
292
- if (item.className == "wfu_component_box") {
293
- itemname = item.id.replace("wfu_component_box_", "");
294
- item.style.display = "none";
295
- item.className = "wfu_component_box wfu_inbase";
296
- document.getElementById('wfu_component_box_container_' + itemname).appendChild(item);
297
- }
298
- }
299
- container.innerHTML = "";
300
- placements = placements_text.split("/");
301
- for (var i = 0; i < placements.length; i++) {
302
- item = document.createElement("DIV");
303
- item.className = "wfu_component_separator_hor";
304
- item.setAttribute("draggable", true);
305
- container.appendChild(item);
306
- item = document.createElement("DIV");
307
- item.className = "wfu_component_separator_ver";
308
- item.setAttribute("draggable", true);
309
- container.appendChild(item);
310
- sections = placements[i].split("+");
311
- for (var ii = 0; ii < sections.length; ii++) {
312
- item = document.getElementById('wfu_component_box_' + sections[ii]);
313
- if (item) {
314
- container.appendChild(item);
315
- item.className = "wfu_component_box";
316
- item.style.display = "inline-block";
317
- item = document.createElement("DIV");
318
- item.className = "wfu_component_separator_ver";
319
- item.setAttribute("draggable", true);
320
- container.appendChild(item);
321
- }
322
- }
323
- }
324
- item = document.createElement("DIV");
325
- item.className = "wfu_component_separator_hor";
326
- item.setAttribute("draggable", true);
327
- container.appendChild(item);
328
- item = document.createElement("DIV");
329
- item.id = "wfu_component_bar_hor";
330
- item.className = "wfu_component_bar_hor";
331
- container.appendChild(item);
332
- item = document.createElement("DIV");
333
- item.id = "wfu_component_bar_ver";
334
- item.className = "wfu_component_bar_ver";
335
- container.appendChild(item);
336
- wfu_attach_separator_dragdrop_events();
337
- }
338
-
339
- function wfu_userdata_add_field(obj) {
340
- var line = obj.parentNode;
341
- var newline = line.cloneNode(true);
342
- var item;
343
- for (var i = 0; i < newline.childNodes.length; i ++) {
344
- item = newline.childNodes[i];
345
- if (item.tagName == "INPUT") {
346
- if (item.type == "text") {
347
- item.value = "";
348
- wfu_attach_element_handlers(item, wfu_update_userfield_value);
349
- }
350
- else if (item.type == "checkbox") {
351
- item.checked = false;
352
- }
353
- }
354
- else if (item.tagName == "DIV") item.className = "wfu_userdata_action";
355
- }
356
- line.parentNode.insertBefore(newline, line.nextSibling);
357
- }
358
-
359
- function wfu_userdata_remove_field(obj) {
360
- var line = obj.parentNode;
361
- var container = line.parentNode;
362
- var first = null;
363
- for (var i = 0; i < container.childNodes.length; i++)
364
- if (container.childNodes[i].nodeType === 1) {
365
- first = container.childNodes[i];
366
- break;
367
- }
368
- if (line != first) {
369
- line.parentNode.removeChild(line);
370
- for (var i = 0; i < first.childNodes.length; i++)
371
- if (first.childNodes[i].nodeType === 1) {
372
- wfu_update_userfield_value({target:first.childNodes[i]});
373
- break;
374
- }
375
- }
376
- }
377
-
378
- function wfu_generate_shortcode() {
379
- var defaults = document.getElementById("wfu_attribute_defaults");
380
- var values = document.getElementById("wfu_attribute_values");
381
- var item;
382
- var attribute = "";
383
- var value = "";
384
- var shortcode_full = "[wordpress_file_upload";
385
- var shortcode = "";
386
- for (var i = 0; i < defaults.childNodes.length; i++) {
387
- item = defaults.childNodes[i];
388
- if (item.nodeType === 1) {
389
- attribute = item.id.replace("wfu_attribute_default_", "");
390
- value = document.getElementById("wfu_attribute_value_" + attribute).value;
391
- if (item.value != value)
392
- shortcode += " " + attribute + "=\"" + value + "\"";
393
- }
394
- }
395
- shortcode_full += shortcode + "]";
396
-
397
- document.getElementById("wfu_shortcode").value = shortcode_full;
398
- ShortcodeString = shortcode.substr(1);
399
-
400
- wfu_schedule_save_shortcode();
401
- }
402
-
403
- function wfu_update_text_value(e) {
404
- e = e || window.event;
405
- var item = e.target;
406
- var attribute = item.id.replace("wfu_attribute_", "");
407
- var val = item.value;
408
- //if it is a multiline element, then replace line breaks with %n%
409
- if (item.tagName == "TEXTAREA") {
410
- val = val.replace(/(\r\n|\n|\r)/gm,"%n%");
411
- }
412
- if (val !== item.oldVal) {
413
- item.oldVal = val;
414
- document.getElementById("wfu_attribute_value_" + attribute).value = val;
415
- wfu_generate_shortcode();
416
- }
417
- }
418
-
419
- function wfu_update_triplecolor_value(e) {
420
- e = e || window.event;
421
- var item = e.target;
422
- var attribute = item.id.replace("wfu_attribute_", "");
423
- attribute = attribute.replace("_color", "");
424
- attribute = attribute.replace("_bgcolor", "");
425
- attribute = attribute.replace("_borcolor", "");
426
- item = document.getElementById("wfu_attribute_" + attribute + "_color");
427
- var val = item.value + "," +
428
- document.getElementById("wfu_attribute_" + attribute + "_bgcolor").value + "," +
429
- document.getElementById("wfu_attribute_" + attribute + "_borcolor").value;
430
- if (val !== item.oldVal) {
431
- item.oldVal = val;
432
- document.getElementById("wfu_attribute_value_" + attribute).value = val;
433
- wfu_generate_shortcode();
434
- }
435
- }
436
-
437
- function wfu_update_dimension_value(e) {
438
- e = e || window.event;
439
- var item = e.target;
440
- var attribute = item.name.replace("wfu_dimension_elements_", "");
441
- var group = document.getElementsByName(item.name);
442
- item = group[0];
443
- var val = "";
444
- var dimname = "";
445
- for (var i = 0; i < group.length; i++) {
446
- dimname = group[i].id.replace("wfu_attribute_" + attribute + "_", "");
447
- if (val != "" && group[i].value != "") val += ", ";
448
- if (group[i].value != "") val += dimname + ":" + group[i].value;
449
- }
450
- if (val !== item.oldVal) {
451
- item.oldVal = val;
452
- document.getElementById("wfu_attribute_value_" + attribute).value = val;
453
- wfu_generate_shortcode();
454
- }
455
- }
456
-
457
- function wfu_update_ptext_value(attribute) {
458
- var singular = document.getElementById("wfu_attribute_s_" + attribute).value;
459
- var plural = document.getElementById("wfu_attribute_p_" + attribute).value;
460
- document.getElementById("wfu_attribute_value_" + attribute).value = singular + "/" + plural;
461
- wfu_generate_shortcode();
462
- }
463
-
464
- function wfu_update_rolelist_value(attribute) {
465
- var value = "";
466
- var rolelist = document.getElementById("wfu_attribute_" + attribute);
467
- var checkall = document.getElementById("wfu_attribute_" + attribute + "_all");
468
- if (checkall.checked) {
469
- rolelist.disabled = true;
470
- value = "all";
471
- }
472
- else {
473
- rolelist.disabled = false;
474
- var options = rolelist.options;
475
- for (var i = 0; i < options.length; i++)
476
- if (options[i].selected) {
477
- if (value != "") value += ",";
478
- value += options[i].value;
479
- }
480
- }
481
- document.getElementById("wfu_attribute_value_" + attribute).value = value;
482
- wfu_generate_shortcode();
483
- }
484
-
485
- function wfu_update_userfield_value(e) {
486
- e = e || window.event;
487
- var item = e.target;
488
- var line = item.parentNode;
489
- var container = line.parentNode;
490
- var fieldval = "";
491
- var fieldreq = false;
492
- var val = "";
493
- for (var i = 0; i < container.childNodes.length; i++) {
494
- line = container.childNodes[i];
495
- if (line.tagName === "DIV") {
496
- for (var j = 0; j < line.childNodes.length; j++)
497
- if (line.childNodes[j].tagName == "INPUT") {
498
- if (line.childNodes[j].type == "text") {
499
- fieldval = line.childNodes[j].value;
500
- if (i == 0) item = line.childNodes[j];
501
- }
502
- else if (line.childNodes[j].type == "checkbox")
503
- fieldreq = line.childNodes[j].checked;
504
- }
505
- if (val != "" && fieldval != "") val += "/";
506
- if (fieldval != "" && fieldreq) val += "*";
507
- if (fieldval != "") val += fieldval;
508
- }
509
- }
510
- if (val !== item.oldVal) {
511
- item.oldVal = val;
512
- document.getElementById("wfu_attribute_value_userdatalabel").value = val;
513
- wfu_generate_shortcode();
514
- wfu_update_userfield_variables();
515
- }
516
- }
517
-
518
- function wfu_update_userfield_variables() {
519
- var userdata = document.getElementById("wfu_attribute_value_userdatalabel").value;
520
- var container = document.getElementById("wfu_wrapper");
521
- var shadows = document.getElementsByClassName("wfu_shadow_userdata", "div", container);
522
- var selects = document.getElementsByName("wfu_userfield_select");
523
- for (var i = 0; i < selects.length; i++) selects[i].style.display = "none";
524
- if (shadows.length == 0) return;
525
- if (shadows[0].style.display == "block") return;
526
-
527
- var options_str = '<option style="display:none;">%userdataXXX%</option>';
528
- var userfields = userdata.split("/");
529
- var field = "";
530
- for (var i = 1; i <= userfields.length; i++) {
531
- field = userfields[i - 1];
532
- if (field[0] == "*") field = field.substr(1);
533
- options_str += '<option value="%userdata' + i + '%">' + i + ': ' + field + '</option>';
534
- }
535
- for (var i = 0; i < selects.length; i++) {
536
- selects[i].innerHTML = options_str;
537
- selects[i].style.display = "inline-block";
538
- }
539
- }
540
-
541
- function wfu_attach_element_handlers(item, handler) {
542
- var elem_events = ['DOMAttrModified', 'textInput', 'input', 'change', 'keypress', 'paste', 'focus', 'propertychange'];
543
- for (var i = 0; i < elem_events.length; i++)
544
- wfu_addEventHandler(item, elem_events[i], handler);
545
- }
546
-
547
- function wfu_Attach_Admin_Events() {
548
- wfu_generate_shortcode();
549
- wfu_update_userfield_variables();
550
- wfu_Attach_Admin_DragDrop_Events();
551
- var text_elements = document.getElementsByName("wfu_text_elements");
552
- for (var i = 0; i < text_elements.length; i++) wfu_attach_element_handlers(text_elements[i], wfu_update_text_value);
553
- var triplecolor_elements = document.getElementsByName("wfu_triplecolor_elements");
554
- for (var i = 0; i < triplecolor_elements.length; i++) wfu_attach_element_handlers(triplecolor_elements[i], wfu_update_triplecolor_value);
555
- var dimension_elements = document.getElementsByName("wfu_dimension_elements_widths");
556
- for (var i = 0; i < dimension_elements.length; i++) wfu_attach_element_handlers(dimension_elements[i], wfu_update_dimension_value);
557
- dimension_elements = document.getElementsByName("wfu_dimension_elements_heights");
558
- for (var i = 0; i < dimension_elements.length; i++) wfu_attach_element_handlers(dimension_elements[i], wfu_update_dimension_value);
559
- var userfield_elements = document.getElementsByName("wfu_userfield_elements");
560
- for (var i = 0; i < userfield_elements.length; i++) wfu_attach_element_handlers(userfield_elements[i], wfu_update_userfield_value);
561
- }
562
-
563
- function wfu_insert_variable(obj) {
564
- var attr = obj.className.replace("wfu_variable wfu_variable_", "");
565
- var inp = document.getElementById("wfu_attribute_" + attr);
566
- var pos = inp.selectionStart;
567
- var prevval = inp.value;
568
- inp.value = prevval.substr(0, pos) + obj.innerHTML + prevval.substr(pos);
569
- wfu_update_text_value({target:inp});
570
- }
571
-
572
- function wfu_insert_userfield_variable(obj) {
573
- var attr = obj.className.replace("wfu_variable wfu_variable_", "");
574
- var inp = document.getElementById("wfu_attribute_" + attr);
575
- var pos = inp.selectionStart;
576
- var prevval = inp.value;
577
- inp.value = prevval.substr(0, pos) + obj.value + prevval.substr(pos);
578
- obj.value = "%userdataXXX%";
579
- wfu_update_text_value({target:inp});
580
- }
581
-
582
- //wfu_GetHttpRequestObject: function that returns XMLHttpRequest object for various browsers
583
- function wfu_GetHttpRequestObject() {
584
- var xhr = null;
585
- try {
586
- xhr = new XMLHttpRequest();
587
- }
588
- catch(e) {
589
- try {
590
- xhr = new ActiveXObject("Msxml2.XMLHTTP");
591
- }
592
- catch (e2) {
593
- try {
594
- xhr = new ActiveXObject("Microsoft.XMLHTTP");
595
- }
596
- catch (e) {}
597
- }
598
- }
599
- if (xhr == null && window.createRequest) {
600
- try {
601
- xmlhttp = window.createRequest();
602
- }
603
- catch (e) {}
604
- }
605
- return xhr;
606
- }
607
-
608
- //wfu_plugin_encode_string: function that encodes a decoded string
609
- function wfu_plugin_encode_string(str) {
610
- var i = 0;
611
- var newstr = "";
612
- var hex = "";
613
- for (i = 0; i < str.length; i++) {
614
- hex = str.charCodeAt(i).toString(16);
615
- if (hex.length == 1) hex = "0" + hex;
616
- newstr += hex;
617
- }
618
- return newstr;
619
- }
620
-
621
- function wfu_schedule_save_shortcode() {
622
- var d = new Date();
623
- var dt = ShortcodeNextSave - d.getTime();
624
- if (ShortcodeTimeOut != null) {
625
- clearTimeout(ShortcodeTimeOut);
626
- ShortcodeTimeOut = null;
627
- }
628
- if (dt <= 0) wfu_save_shortcode();
629
- else ShortcodeTimeOut = setTimeout(function() {wfu_save_shortcode();}, dt);
630
- }
631
-
632
- function wfu_save_shortcode() {
633
- var xhr = wfu_GetHttpRequestObject();
634
- if (xhr == null) return;
635
-
636
- //send request using AJAX
637
- var url = AdminParams.wfu_ajax_url;
638
- params = new Array(2);
639
- params[0] = new Array(2);
640
- params[0][0] = 'action';
641
- params[0][1] = 'wfu_ajax_action_save_shortcode';
642
- params[1] = new Array(2);
643
- params[1][0] = 'shortcode';
644
- params[1][1] = wfu_plugin_encode_string(ShortcodeString);
645
-
646
- var parameters = '';
647
- for (var i = 0; i < params.length; i++) {
648
- parameters += (i > 0 ? "&" : "") + params[i][0] + "=" + encodeURI(params[i][1]);
649
- }
650
-
651
- var d = new Date();
652
- ShortcodeNextSave = d.getTime() + 5000;
653
-
654
- xhr.open("POST", url, true);
655
- xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
656
- xhr.setRequestHeader("Content-length", parameters.length);
657
- xhr.setRequestHeader("Connection", "close");
658
- xhr.onreadystatechange = function() {
659
- if ( xhr.readyState == 4 ) {
660
- if ( xhr.status == 200 ) {
661
- if (xhr.responseText == "save_shortcode_success") {
662
- document.getElementById("wfu_save_label").innerHTML = "saved";
663
- document.getElementById("wfu_save_label").className = "wfu_save_label";
664
- document.getElementById("wfu_save_label").style.opacity = 1;
665
- wfu_fadeout_element(300);
666
- ShortcodeNextSave = d.getTime() + 1000;
667
- if (ShortcodeTimeOut != null) wfu_schedule_save_shortcode();
668
- }
669
- else {
670
- document.getElementById("wfu_save_label").innerHTML = "not saved";
671
- document.getElementById("wfu_save_label").className = "wfu_save_label_fail";
672
- document.getElementById("wfu_save_label").style.opacity = 1;
673
- wfu_fadeout_element(300);
674
- }
675
- }
676
- }
677
- };
678
- xhr.send(parameters);
679
- }
680
-
681
- function wfu_adjust_opacity(opacity) {
682
- document.getElementById("wfu_save_label").style.opacity = opacity;
683
- }
684
-
685
- function wfu_fadeout_element(interval) {
686
- var reps = 20.0;
687
- var op = 0.0;
688
- for (var i = 0; i < reps; i++) {
689
- op = 1.0 - i / reps;
690
- setTimeout('wfu_adjust_opacity("' + op.toString() + '")', i * interval / reps);
691
- }
692
-
693
- setTimeout('wfu_adjust_opacity("0.0")', i * interval / reps);
694
- }
1
+ var DraggedItem = null;
2
+ var ShortcodeNextSave = 0;
3
+ var ShortcodeTimeOut = null;
4
+ var ShortcodeString = "";
5
+
6
+ jQuery(document).ready(function($){
7
+ $('.wfu_color_field').wpColorPicker({
8
+ change: function(event, ui) {
9
+ event.target.value = ui.color.toString();
10
+ if (event.target.name == "wfu_text_elements") wfu_update_text_value(event);
11
+ else if (event.target.name == "wfu_triplecolor_elements") wfu_update_triplecolor_value(event);
12
+ }
13
+ });
14
+ });
15
+
16
+ function wfu_admin_activate_tab(key) {
17
+ var tabs = document.getElementById("wfu_tab_container");
18
+ var tab, tabkey;
19
+ for (var i = 0; i < tabs.childNodes.length; i++) {
20
+ tab = tabs.childNodes[i];
21
+ if (tab.nodeType === 1) {
22
+ tabkey = tab.id.substr(8);
23
+ if (tab.className.indexOf("nav-tab-active") > -1) {
24
+ tab.className = "nav-tab";
25
+ document.getElementById("wfu_container_" + tabkey).style.display = "none";
26
+ }
27
+ }
28
+ }
29
+ document.getElementById("wfu_tab_" + key).className = "nav-tab nav-tab-active";
30
+ document.getElementById("wfu_container_" + key).style.display = "block";
31
+ }
32
+
33
+ function wfu_admin_onoff_clicked(key) {
34
+ var onoff = document.getElementById("wfu_attribute_" + key);
35
+ var container = document.getElementById("wfu_wrapper");
36
+ var shadows = document.getElementsByClassName("wfu_shadow_" + key, "div", container);
37
+ var shadows_inv = document.getElementsByClassName("wfu_shadow_" + key + "_inv", "div", container);
38
+ var status = (onoff.className.substr(onoff.className.length - 2) == "on");
39
+ status = !status;
40
+ if (status) {
41
+ document.getElementById("wfu_attribute_value_" + key).value = "true";
42
+ onoff.className = "wfu_onoff_container_on";
43
+ for (var i = 0; i < shadows.length; i++) shadows[i].style.display = "none";
44
+ for (var i = 0; i < shadows_inv.length; i++) shadows_inv[i].style.display = "block";
45
+ }
46
+ else {
47
+ document.getElementById("wfu_attribute_value_" + key).value = "false";
48
+ onoff.className = "wfu_onoff_container_off";
49
+ for (var i = 0; i < shadows.length; i++) shadows[i].style.display = "block";
50
+ for (var i = 0; i < shadows_inv.length; i++) shadows_inv[i].style.display = "none";
51
+ }
52
+ wfu_generate_shortcode();
53
+ if (key == "userdata") wfu_update_userfield_variables();
54
+ }
55
+
56
+ function wfu_admin_radio_clicked(key) {
57
+ var radios = document.getElementsByName("wfu_radioattribute_" + key);
58
+ var container = document.getElementById("wfu_wrapper");
59
+ var shadows = document.getElementsByClassName("wfu_shadow_" + key, "div", container);
60
+ var shadows_inv = document.getElementsByClassName("wfu_shadow_" + key + "_inv", "div", container);
61
+ var val = "";
62
+ for (i = 0; i < radios.length; i++)
63
+ if (radios[i].checked) val = radios[i].value;
64
+ var status = (val.substr(0, 1) == "*");
65
+ if (status) {
66
+ val = val.substr(1);
67
+ for (var i = 0; i < shadows.length; i++) shadows[i].style.display = "none";
68
+ for (var i = 0; i < shadows_inv.length; i++) shadows_inv[i].style.display = "block";
69
+ }
70
+ else {
71
+ for (var i = 0; i < shadows.length; i++) shadows[i].style.display = "block";
72
+ for (var i = 0; i < shadows_inv.length; i++) shadows_inv[i].style.display = "none";
73
+ }
74
+ document.getElementById("wfu_attribute_value_" + key).value = val;
75
+ wfu_generate_shortcode();
76
+ }
77
+
78
+ function wfu_addEventHandler(obj, evt, handler) {
79
+ if(obj.addEventListener) {
80
+ // W3C method
81
+ obj.addEventListener(evt, handler, false);
82
+ }
83
+ else if(obj.attachEvent) {
84
+ // IE method.
85
+ obj.attachEvent('on'+evt, handler);
86
+ }
87
+ else {
88
+ // Old school method.
89
+ obj['on'+evt] = handler;
90
+ }
91
+ }
92
+
93
+ function wfu_attach_separator_dragdrop_events() {
94
+ var container = document.getElementById('wfu_placements_container');
95
+ var item;
96
+ for (var i = 0; i < container.childNodes.length; i++) {
97
+ item = container.childNodes[i];
98
+ if (item.className == "wfu_component_separator_hor" || item.className == "wfu_component_separator_ver") {
99
+ wfu_addEventHandler(item, 'dragenter', wfu_separator_dragenter);
100
+ wfu_addEventHandler(item, 'dragover', wfu_default_dragover);
101
+ wfu_addEventHandler(item, 'dragleave', wfu_separator_dragleave);
102
+ wfu_addEventHandler(item, 'drop', wfu_separator_drop);
103
+ }
104
+ }
105
+ }
106
+
107
+ function wfu_Attach_Admin_DragDrop_Events() {
108
+ if (window.FileReader) {
109
+ var container = document.getElementById('wfu_placements_container');
110
+ var available_container = document.getElementById('wfu_componentlist_container');
111
+ var item;
112
+ for (var i = 0; i < container.childNodes.length; i++) {
113
+ item = container.childNodes[i];
114
+ if (item.className == "wfu_component_box") {
115
+ wfu_addEventHandler(item, 'dragstart', wfu_component_dragstart);
116
+ wfu_addEventHandler(item, 'dragend', wfu_component_dragend);
117
+ }
118
+ }
119
+ for (var i = 0; i < available_container.childNodes.length; i++) {
120
+ item = available_container.childNodes[i];
121
+ if (item.className == "wfu_component_box_container") {
122
+ for (var ii = 0; ii < item.childNodes.length; ii++) {
123
+ if (item.childNodes[ii].className == "wfu_component_box wfu_inbase") {
124
+ wfu_addEventHandler(item.childNodes[ii], 'dragstart', wfu_component_dragstart);
125
+ wfu_addEventHandler(item.childNodes[ii], 'dragend', wfu_component_dragend);
126
+ }
127
+ }
128
+ }
129
+ }
130
+ item = document.getElementById('wfu_componentlist_dragdrop');
131
+ wfu_addEventHandler(item, 'dragenter', wfu_componentlist_dragenter);
132
+ wfu_addEventHandler(item, 'dragover', wfu_default_dragover);
133
+ wfu_addEventHandler(item, 'dragleave', wfu_componentlist_dragleave);
134
+ wfu_addEventHandler(item, 'drop', wfu_componentlist_drop);
135
+ wfu_attach_separator_dragdrop_events();
136
+ }
137
+ }
138
+
139
+ function wfu_componentlist_dragenter(e) {
140
+ e = e || window.event;
141
+ if (e.preventDefault) { e.preventDefault(); }
142
+ if (!DraggedItem) return false;
143
+ var item = document.getElementById('wfu_componentlist_dragdrop');
144
+ if (item.className.indexOf("wfu_componentlist_dragdrop_dragover") == -1)
145
+ item.className += " wfu_componentlist_dragdrop_dragover";
146
+ return false;
147
+ }
148
+
149
+ function wfu_componentlist_dragleave(e) {
150
+ e = e || window.event;
151
+ if (e.preventDefault) { e.preventDefault(); }
152
+ if (!DraggedItem) return false;
153
+ var item = document.getElementById('wfu_componentlist_dragdrop');
154
+ item.className = item.className.replace(" wfu_componentlist_dragdrop_dragover", "");
155
+ return false;
156
+ }
157
+
158
+ function wfu_componentlist_drop(e) {
159
+ e = e || window.event;
160
+ if (e.preventDefault) { e.preventDefault(); }
161
+ var component = e.dataTransfer.getData("Component");
162
+ if (!component) return false;
163
+ //move dragged component to base
164
+ var item = document.getElementById('wfu_component_box_' + component);
165
+ item.className = "wfu_component_box wfu_inbase";
166
+ item.style.display = "block";
167
+ document.getElementById('wfu_component_box_container_' + component).appendChild(item);
168
+ //recreate placements panel
169
+ var placements = wfu_admin_recreate_placements_text(null, "");
170
+ wfu_admin_recreate_placements_panel(placements);
171
+ document.getElementById("wfu_attribute_value_placements").value = placements;
172
+ wfu_generate_shortcode();
173
+ return false;
174
+ }
175
+
176
+ function wfu_separator_dragenter(e) {
177
+ e = e || window.event;
178
+ if (e.preventDefault) { e.preventDefault(); }
179
+ if (!DraggedItem) return false;
180
+ if (e.target.className == "wfu_component_separator_hor") {
181
+ var bar = document.getElementById('wfu_component_bar_hor');
182
+ bar.style.top = e.target.offsetTop + "px";
183
+ bar.style.display = "block";
184
+ }
185
+ else if (e.target.className == "wfu_component_separator_ver") {
186
+ var bar = document.getElementById('wfu_component_bar_ver');
187
+ bar.style.top = e.target.offsetTop + "px";
188
+ bar.style.left = e.target.offsetLeft + "px";
189
+ bar.style.display = "block";
190
+ }
191
+ return false;
192
+ }
193
+
194
+ function wfu_default_dragover(e) {
195
+ e = e || window.event;
196
+ if (e.preventDefault) { e.preventDefault(); }
197
+ return false;
198
+ }
199
+
200
+ function wfu_separator_dragleave(e) {
201
+ e = e || window.event;
202
+ if (e.preventDefault) { e.preventDefault(); }
203
+ if (!DraggedItem) return false;
204
+ if (e.target.className == "wfu_component_separator_hor") {
205
+ var bar = document.getElementById('wfu_component_bar_hor');
206
+ bar.style.display = "none";
207
+ }
208
+ else if (e.target.className == "wfu_component_separator_ver") {
209
+ var bar = document.getElementById('wfu_component_bar_ver');
210
+ bar.style.display = "none";
211
+ }
212
+ return false;
213
+ }
214
+
215
+ function wfu_separator_drop(e) {
216
+ e = e || window.event;
217
+ if (e.preventDefault) { e.preventDefault(); }
218
+ var component = e.dataTransfer.getData("Component");
219
+ if (!component) return false;
220
+ //first move dragged component to base otherwise we may lose it during recreation of placements panel
221
+ var item = document.getElementById('wfu_component_box_' + component);
222
+ item.style.display = "none";
223
+ item.className = "wfu_component_box wfu_inbase";
224
+ document.getElementById('wfu_component_box_container_' + component).appendChild(item);
225
+ //recreate placements panel
226
+ var placements = wfu_admin_recreate_placements_text(e.target, component);
227
+ wfu_admin_recreate_placements_panel(placements);
228
+ document.getElementById("wfu_attribute_value_placements").value = placements;
229
+ wfu_generate_shortcode();
230
+ return false;
231
+ }
232
+
233
+ function wfu_component_dragstart(e) {
234
+ e = e || window.event;
235
+ e.dataTransfer.setData("Component", e.target.id.replace("wfu_component_box_", ""));
236
+ if (e.target.className.indexOf("wfu_component_box_dragged") == -1) {
237
+ e.target.className += " wfu_component_box_dragged";
238
+ DraggedItem = e.target;
239
+ }
240
+ e.target.style.zIndex = 3;
241
+ var item = document.getElementById('wfu_componentlist_dragdrop');
242
+ item.className = "wfu_componentlist_dragdrop wfu_componentlist_dragdrop_dragover";
243
+ item.style.display = "block";
244
+ return false;
245
+ }
246
+
247
+ function wfu_component_dragend(e) {
248
+ e = e || window.event;
249
+ DraggedItem = null;
250
+ e.target.style.zIndex = 1;
251
+ var item = document.getElementById('wfu_componentlist_dragdrop');
252
+ item.style.display = "none";
253
+ item.className = "wfu_componentlist_dragdrop";
254
+ e.target.className = e.target.className.replace(" wfu_component_box_dragged", "");
255
+ document.getElementById('wfu_component_bar_ver').style.display = "none";
256
+ document.getElementById('wfu_component_bar_hor').style.display = "none";
257
+ return false;
258
+ }
259
+
260
+ function wfu_admin_recreate_placements_text(place, new_component) {
261
+ function add_item(component) {
262
+ if (placements != "") placements += delim;
263
+ placements += component;
264
+ delim = "";
265
+ }
266
+
267
+ var container = document.getElementById('wfu_placements_container');
268
+ var delim = "";
269
+ var placements = "";
270
+ var component = "";
271
+ for (var i = 0; i < container.childNodes.length; i++) {
272
+ item = container.childNodes[i];
273
+ if (item.className == "wfu_component_separator_ver") {
274
+ if (delim == "" ) delim = "+";
275
+ if (item == place) { add_item(new_component); delim = "+"; }
276
+ }
277
+ else if (item.className == "wfu_component_separator_hor") {
278
+ delim = "/";
279
+ if (item == place) { add_item(new_component); delim = "/"; }
280
+ }
281
+ else if (item.className == "wfu_component_box") add_item(item.id.replace("wfu_component_box_", ""));
282
+ }
283
+ return placements;
284
+ }
285
+
286
+ function wfu_admin_recreate_placements_panel(placements_text) {
287
+ var container = document.getElementById('wfu_placements_container');
288
+ var item, placements, sections;
289
+ var itemname = "";
290
+ for (var i = 0; i < container.childNodes.length; i++) {
291
+ item = container.childNodes[i];
292
+ if (item.className == "wfu_component_box") {
293
+ itemname = item.id.replace("wfu_component_box_", "");
294
+ item.style.display = "none";
295
+ item.className = "wfu_component_box wfu_inbase";
296
+ document.getElementById('wfu_component_box_container_' + itemname).appendChild(item);
297
+ }
298
+ }
299
+ container.innerHTML = "";
300
+ placements = placements_text.split("/");
301
+ for (var i = 0; i < placements.length; i++) {
302
+ item = document.createElement("DIV");
303
+ item.className = "wfu_component_separator_hor";
304
+ item.setAttribute("draggable", true);
305
+ container.appendChild(item);
306
+ item = document.createElement("DIV");
307
+ item.className = "wfu_component_separator_ver";
308
+ item.setAttribute("draggable", true);
309
+ container.appendChild(item);
310
+ sections = placements[i].split("+");
311
+ for (var ii = 0; ii < sections.length; ii++) {
312
+ item = document.getElementById('wfu_component_box_' + sections[ii]);
313
+ if (item) {
314
+ container.appendChild(item);
315
+ item.className = "wfu_component_box";
316
+ item.style.display = "inline-block";
317
+ item = document.createElement("DIV");
318
+ item.className = "wfu_component_separator_ver";
319
+ item.setAttribute("draggable", true);
320
+ container.appendChild(item);
321
+ }
322
+ }
323
+ }
324
+ item = document.createElement("DIV");
325
+ item.className = "wfu_component_separator_hor";
326
+ item.setAttribute("draggable", true);
327
+ container.appendChild(item);
328
+ item = document.createElement("DIV");
329
+ item.id = "wfu_component_bar_hor";
330
+ item.className = "wfu_component_bar_hor";
331
+ container.appendChild(item);
332
+ item = document.createElement("DIV");
333
+ item.id = "wfu_component_bar_ver";
334
+ item.className = "wfu_component_bar_ver";
335
+ container.appendChild(item);
336
+ wfu_attach_separator_dragdrop_events();
337
+ }
338
+
339
+ function wfu_userdata_add_field(obj) {
340
+ var line = obj.parentNode;
341
+ var newline = line.cloneNode(true);
342
+ var item;
343
+ for (var i = 0; i < newline.childNodes.length; i ++) {
344
+ item = newline.childNodes[i];
345
+ if (item.tagName == "INPUT") {
346
+ if (item.type == "text") {
347
+ item.value = "";
348
+ wfu_attach_element_handlers(item, wfu_update_userfield_value);
349
+ }
350
+ else if (item.type == "checkbox") {
351
+ item.checked = false;
352
+ }
353
+ }
354
+ else if (item.tagName == "DIV") item.className = "wfu_userdata_action";
355
+ }
356
+ line.parentNode.insertBefore(newline, line.nextSibling);
357
+ }
358
+
359
+ function wfu_userdata_remove_field(obj) {
360
+ var line = obj.parentNode;
361
+ var container = line.parentNode;
362
+ var first = null;
363
+ for (var i = 0; i < container.childNodes.length; i++)
364
+ if (container.childNodes[i].nodeType === 1) {
365
+ first = container.childNodes[i];
366
+ break;
367
+ }
368
+ if (line != first) {
369
+ line.parentNode.removeChild(line);
370
+ for (var i = 0; i < first.childNodes.length; i++)
371
+ if (first.childNodes[i].nodeType === 1) {
372
+ wfu_update_userfield_value({target:first.childNodes[i]});
373
+ break;
374
+ }
375
+ }
376
+ }
377
+
378
+ function wfu_generate_shortcode() {
379
+ var defaults = document.getElementById("wfu_attribute_defaults");
380
+ var values = document.getElementById("wfu_attribute_values");
381
+ var item;
382
+ var attribute = "";
383
+ var value = "";
384
+ var shortcode_full = "[wordpress_file_upload";
385
+ var shortcode = "";
386
+ for (var i = 0; i < defaults.childNodes.length; i++) {
387
+ item = defaults.childNodes[i];
388
+ if (item.nodeType === 1) {
389
+ attribute = item.id.replace("wfu_attribute_default_", "");
390
+ value = document.getElementById("wfu_attribute_value_" + attribute).value;
391
+ if (item.value != value)
392
+ shortcode += " " + attribute + "=\"" + value + "\"";
393
+ }
394
+ }
395
+ shortcode_full += shortcode + "]";
396
+
397
+ document.getElementById("wfu_shortcode").value = shortcode_full;
398
+ ShortcodeString = shortcode.substr(1);
399
+
400
+ wfu_schedule_save_shortcode();
401
+ }
402
+
403
+ function wfu_update_text_value(e) {
404
+ e = e || window.event;
405
+ var item = e.target;
406
+ var attribute = item.id.replace("wfu_attribute_", "");
407
+ var val = item.value;
408
+ //if it is a multiline element, then replace line breaks with %n%
409
+ if (item.tagName == "TEXTAREA") {
410
+ val = val.replace(/(\r\n|\n|\r)/gm,"%n%");
411
+ }
412
+ if (val !== item.oldVal) {
413
+ item.oldVal = val;
414
+ document.getElementById("wfu_attribute_value_" + attribute).value = val;
415
+ wfu_generate_shortcode();
416
+ }
417
+ }
418
+
419
+ function wfu_update_triplecolor_value(e) {
420
+ e = e || window.event;
421
+ var item = e.target;
422
+ var attribute = item.id.replace("wfu_attribute_", "");
423
+ attribute = attribute.replace("_color", "");
424
+ attribute = attribute.replace("_bgcolor", "");
425
+ attribute = attribute.replace("_borcolor", "");
426
+ item = document.getElementById("wfu_attribute_" + attribute + "_color");
427
+ var val = item.value + "," +
428
+ document.getElementById("wfu_attribute_" + attribute + "_bgcolor").value + "," +
429
+ document.getElementById("wfu_attribute_" + attribute + "_borcolor").value;
430
+ if (val !== item.oldVal) {
431
+ item.oldVal = val;
432
+ document.getElementById("wfu_attribute_value_" + attribute).value = val;
433
+ wfu_generate_shortcode();
434
+ }
435
+ }
436
+
437
+ function wfu_update_dimension_value(e) {
438
+ e = e || window.event;
439
+ var item = e.target;
440
+ var attribute = item.name.replace("wfu_dimension_elements_", "");
441
+ var group = document.getElementsByName(item.name);
442
+ item = group[0];
443
+ var val = "";
444
+ var dimname = "";
445
+ for (var i = 0; i < group.length; i++) {
446
+ dimname = group[i].id.replace("wfu_attribute_" + attribute + "_", "");
447
+ if (val != "" && group[i].value != "") val += ", ";
448
+ if (group[i].value != "") val += dimname + ":" + group[i].value;
449
+ }
450
+ if (val !== item.oldVal) {
451
+ item.oldVal = val;
452
+ document.getElementById("wfu_attribute_value_" + attribute).value = val;
453
+ wfu_generate_shortcode();
454
+ }
455
+ }
456
+
457
+ function wfu_update_ptext_value(attribute) {
458
+ var singular = document.getElementById("wfu_attribute_s_" + attribute).value;
459
+ var plural = document.getElementById("wfu_attribute_p_" + attribute).value;
460
+ document.getElementById("wfu_attribute_value_" + attribute).value = singular + "/" + plural;
461
+ wfu_generate_shortcode();
462
+ }
463
+
464
+ function wfu_update_rolelist_value(attribute) {
465
+ var value = "";
466
+ var rolelist = document.getElementById("wfu_attribute_" + attribute);
467
+ var checkall = document.getElementById("wfu_attribute_" + attribute + "_all");
468
+ if (checkall.checked) {
469
+ rolelist.disabled = true;
470
+ value = "all";
471
+ }
472
+ else {
473
+ rolelist.disabled = false;
474
+ var options = rolelist.options;
475
+ for (var i = 0; i < options.length; i++)
476
+ if (options[i].selected) {
477
+ if (value != "") value += ",";
478
+ value += options[i].value;
479
+ }
480
+ }
481
+ document.getElementById("wfu_attribute_value_" + attribute).value = value;
482
+ wfu_generate_shortcode();
483
+ }
484
+
485
+ function wfu_update_userfield_value(e) {
486
+ e = e || window.event;
487
+ var item = e.target;
488
+ var line = item.parentNode;
489
+ var container = line.parentNode;
490
+ var fieldval = "";
491
+ var fieldreq = false;
492
+ var val = "";
493
+ for (var i = 0; i < container.childNodes.length; i++) {
494
+ line = container.childNodes[i];
495
+ if (line.tagName === "DIV") {
496
+ for (var j = 0; j < line.childNodes.length; j++)
497
+ if (line.childNodes[j].tagName == "INPUT") {
498
+ if (line.childNodes[j].type == "text") {
499
+ fieldval = line.childNodes[j].value;
500
+ if (i == 0) item = line.childNodes[j];
501
+ }
502
+ else if (line.childNodes[j].type == "checkbox")
503
+ fieldreq = line.childNodes[j].checked;
504
+ }
505
+ if (val != "" && fieldval != "") val += "/";
506
+ if (fieldval != "" && fieldreq) val += "*";
507
+ if (fieldval != "") val += fieldval;
508
+ }
509
+ }
510
+ if (val !== item.oldVal) {
511
+ item.oldVal = val;
512
+ document.getElementById("wfu_attribute_value_userdatalabel").value = val;
513
+ wfu_generate_shortcode();
514
+ wfu_update_userfield_variables();
515
+ }
516
+ }
517
+
518
+ function wfu_update_userfield_variables() {
519
+ var userdata = document.getElementById("wfu_attribute_value_userdatalabel").value;
520
+ var container = document.getElementById("wfu_wrapper");
521
+ var shadows = document.getElementsByClassName("wfu_shadow_userdata", "div", container);
522
+ var selects = document.getElementsByName("wfu_userfield_select");
523
+ for (var i = 0; i < selects.length; i++) selects[i].style.display = "none";
524
+ if (shadows.length == 0) return;
525
+ if (shadows[0].style.display == "block") return;
526
+
527
+ var options_str = '<option style="display:none;">%userdataXXX%</option>';
528
+ var userfields = userdata.split("/");
529
+ var field = "";
530
+ for (var i = 1; i <= userfields.length; i++) {
531
+ field = userfields[i - 1];
532
+ if (field[0] == "*") field = field.substr(1);
533
+ options_str += '<option value="%userdata' + i + '%">' + i + ': ' + field + '</option>';
534
+ }
535
+ for (var i = 0; i < selects.length; i++) {
536
+ selects[i].innerHTML = options_str;
537
+ selects[i].style.display = "inline-block";
538
+ }
539
+ }
540
+
541
+ function wfu_attach_element_handlers(item, handler) {
542
+ var elem_events = ['DOMAttrModified', 'textInput', 'input', 'change', 'keypress', 'paste', 'focus', 'propertychange'];
543
+ for (var i = 0; i < elem_events.length; i++)
544
+ wfu_addEventHandler(item, elem_events[i], handler);
545
+ }
546
+
547
+ function wfu_Attach_Admin_Events() {
548
+ wfu_generate_shortcode();
549
+ wfu_update_userfield_variables();
550
+ wfu_Attach_Admin_DragDrop_Events();
551
+ var text_elements = document.getElementsByName("wfu_text_elements");
552
+ for (var i = 0; i < text_elements.length; i++) wfu_attach_element_handlers(text_elements[i], wfu_update_text_value);
553
+ var triplecolor_elements = document.getElementsByName("wfu_triplecolor_elements");
554
+ for (var i = 0; i < triplecolor_elements.length; i++) wfu_attach_element_handlers(triplecolor_elements[i], wfu_update_triplecolor_value);
555
+ var dimension_elements = document.getElementsByName("wfu_dimension_elements_widths");
556
+ for (var i = 0; i < dimension_elements.length; i++) wfu_attach_element_handlers(dimension_elements[i], wfu_update_dimension_value);
557
+ dimension_elements = document.getElementsByName("wfu_dimension_elements_heights");
558
+ for (var i = 0; i < dimension_elements.length; i++) wfu_attach_element_handlers(dimension_elements[i], wfu_update_dimension_value);
559
+ var userfield_elements = document.getElementsByName("wfu_userfield_elements");
560
+ for (var i = 0; i < userfield_elements.length; i++) wfu_attach_element_handlers(userfield_elements[i], wfu_update_userfield_value);
561
+ }
562
+
563
+ function wfu_insert_variable(obj) {
564
+ var attr = obj.className.replace("wfu_variable wfu_variable_", "");
565
+ var inp = document.getElementById("wfu_attribute_" + attr);
566
+ var pos = inp.selectionStart;
567
+ var prevval = inp.value;
568
+ inp.value = prevval.substr(0, pos) + obj.innerHTML + prevval.substr(pos);
569
+ wfu_update_text_value({target:inp});
570
+ }
571
+
572
+ function wfu_insert_userfield_variable(obj) {
573
+ var attr = obj.className.replace("wfu_variable wfu_variable_", "");
574
+ var inp = document.getElementById("wfu_attribute_" + attr);
575
+ var pos = inp.selectionStart;
576
+ var prevval = inp.value;
577
+ inp.value = prevval.substr(0, pos) + obj.value + prevval.substr(pos);
578
+ obj.value = "%userdataXXX%";
579
+ wfu_update_text_value({target:inp});
580
+ }
581
+
582
+ //wfu_GetHttpRequestObject: function that returns XMLHttpRequest object for various browsers
583
+ function wfu_GetHttpRequestObject() {
584
+ var xhr = null;
585
+ try {
586
+ xhr = new XMLHttpRequest();
587
+ }
588
+ catch(e) {
589
+ try {
590
+ xhr = new ActiveXObject("Msxml2.XMLHTTP");
591
+ }
592
+ catch (e2) {
593
+ try {
594
+ xhr = new ActiveXObject("Microsoft.XMLHTTP");
595
+ }
596
+ catch (e) {}
597
+ }
598
+ }
599
+ if (xhr == null && window.createRequest) {
600
+ try {
601
+ xmlhttp = window.createRequest();
602
+ }
603
+ catch (e) {}
604
+ }
605
+ return xhr;
606
+ }
607
+
608
+ //wfu_plugin_encode_string: function that encodes a decoded string
609
+ function wfu_plugin_encode_string(str) {
610
+ var i = 0;
611
+ var newstr = "";
612
+ var hex = "";
613
+ for (i = 0; i < str.length; i++) {
614
+ hex = str.charCodeAt(i).toString(16);
615
+ if (hex.length == 1) hex = "0" + hex;
616
+ newstr += hex;
617
+ }
618
+ return newstr;
619
+ }
620
+
621
+ function wfu_schedule_save_shortcode() {
622
+ var d = new Date();
623
+ var dt = ShortcodeNextSave - d.getTime();
624
+ if (ShortcodeTimeOut != null) {
625
+ clearTimeout(ShortcodeTimeOut);
626
+ ShortcodeTimeOut = null;
627
+ }
628
+ if (dt <= 0) wfu_save_shortcode();
629
+ else ShortcodeTimeOut = setTimeout(function() {wfu_save_shortcode();}, dt);
630
+ }
631
+
632
+ function wfu_save_shortcode() {
633
+ var xhr = wfu_GetHttpRequestObject();
634
+ if (xhr == null) return;
635
+
636
+ //send request using AJAX
637
+ var url = AdminParams.wfu_ajax_url;
638
+ params = new Array(2);
639
+ params[0] = new Array(2);
640
+ params[0][0] = 'action';
641
+ params[0][1] = 'wfu_ajax_action_save_shortcode';
642
+ params[1] = new Array(2);
643
+ params[1][0] = 'shortcode';
644
+ params[1][1] = wfu_plugin_encode_string(ShortcodeString);
645
+
646
+ var parameters = '';
647
+ for (var i = 0; i < params.length; i++) {
648
+ parameters += (i > 0 ? "&" : "") + params[i][0] + "=" + encodeURI(params[i][1]);
649
+ }
650
+
651
+ var d = new Date();
652
+ ShortcodeNextSave = d.getTime() + 5000;
653
+
654
+ xhr.open("POST", url, true);
655
+ xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
656
+ xhr.setRequestHeader("Content-length", parameters.length);
657
+ xhr.setRequestHeader("Connection", "close");
658
+ xhr.onreadystatechange = function() {
659
+ if ( xhr.readyState == 4 ) {
660
+ if ( xhr.status == 200 ) {
661
+ if (xhr.responseText == "save_shortcode_success") {
662
+ document.getElementById("wfu_save_label").innerHTML = "saved";
663
+ document.getElementById("wfu_save_label").className = "wfu_save_label";
664
+ document.getElementById("wfu_save_label").style.opacity = 1;
665
+ wfu_fadeout_element(300);
666
+ ShortcodeNextSave = d.getTime() + 1000;
667
+ if (ShortcodeTimeOut != null) wfu_schedule_save_shortcode();
668
+ }
669
+ else {
670
+ document.getElementById("wfu_save_label").innerHTML = "not saved";
671
+ document.getElementById("wfu_save_label").className = "wfu_save_label_fail";
672
+ document.getElementById("wfu_save_label").style.opacity = 1;
673
+ wfu_fadeout_element(300);
674
+ }
675
+ }
676
+ }
677
+ };
678
+ xhr.send(parameters);
679
+ }
680
+
681
+ function wfu_adjust_opacity(opacity) {
682
+ document.getElementById("wfu_save_label").style.opacity = opacity;
683
+ }
684
+
685
+ function wfu_fadeout_element(interval) {
686
+ var reps = 20.0;
687
+ var op = 0.0;
688
+ for (var i = 0; i < reps; i++) {
689
+ op = 1.0 - i / reps;
690
+ setTimeout('wfu_adjust_opacity("' + op.toString() + '")', i * interval / reps);
691
+ }
692
+
693
+ setTimeout('wfu_adjust_opacity("0.0")', i * interval / reps);
694
+ }
js/wordpress_file_upload_functions.js CHANGED
@@ -1,1233 +1,1233 @@
1
- GlobalData = {};
2
- UploadStates = {};
3
- GlobalData.filestatematch = {};
4
- GlobalData.filestatematch.success = [0, 1, 2, 2];
5
- GlobalData.filestatematch.warning = [1, 1, 2, 2];
6
- GlobalData.filestatematch.error1 = [3, 3, 2, 3];
7
- GlobalData.filestatematch.error2 = [2, 2, 2, 3];
8
- wfu_Check_Browser_Capabilities();
9
- //console.log(wfu_BrowserCaps);
10
-
11
- //wfu_Initialize_Consts: function to initialize constants passed from plugin to javascript
12
- function wfu_Initialize_Consts(consts) {
13
- if (typeof GlobalData.consts != "undefined") return;
14
- GlobalData.consts = new Object();
15
- var consts_arr = consts.split(";");
16
- var const_arr;
17
- for (var i = 0; i < consts_arr.length; i++) {
18
- const_txt = consts_arr[i].split(":");
19
- GlobalData.consts[wfu_plugin_decode_string(const_txt[0])] = wfu_plugin_decode_string(const_txt[1]);
20
- }
21
- }
22
-
23
- //wfu_Check_Browser_Capabilities: function that checks if browser supports HTML5, iframes and AJAX
24
- function wfu_Check_Browser_Capabilities() {
25
- if (typeof wfu_BrowserCaps != "undefined") return;
26
- wfu_BrowserCaps = new Object();
27
- //check AJAX
28
- var xmlhttp = wfu_GetHttpRequestObject();
29
- wfu_BrowserCaps.supportsAJAX = ( xmlhttp != null );
30
- //check Upload Progress
31
- wfu_BrowserCaps.supportsUploadProgress = !! (xmlhttp && ('upload' in xmlhttp) && ('onprogress' in xmlhttp.upload));
32
- //check HTML5
33
- var fd = null;
34
- try {
35
- var fd = new FormData();
36
- }
37
- catch(e) {}
38
- wfu_BrowserCaps.supportsHTML5 = ( fd != null );
39
- //check IFRAME
40
- var e = document.createElement("iframe");
41
- wfu_BrowserCaps.supportsIFRAME = ( e != null );
42
- //check Drag and Drop
43
- wfu_BrowserCaps.supportsDRAGDROP = (window.FileReader);
44
- //check animation
45
- wfu_BrowserCaps.supportsAnimation = wfu_check_animation();
46
- }
47
-
48
- //wfu_check_animation: function that checks if CSS3 animation is supported
49
- function wfu_check_animation() {
50
- var animation = false,
51
- animationstring = 'animation',
52
- keyframeprefix = '',
53
- domPrefixes = 'Webkit Moz O ms Khtml'.split(' '),
54
- pfx = '';
55
-
56
- var elm = document.createElement('DIV');
57
-
58
- if( elm.style.animationName ) { animation = true; }
59
-
60
- if( animation === false ) {
61
- for( var i = 0; i < domPrefixes.length; i++ ) {
62
- if( elm.style[ domPrefixes[i] + 'AnimationName' ] !== undefined ) {
63
- pfx = domPrefixes[ i ];
64
- animationstring = pfx + 'Animation';
65
- keyframeprefix = '-' + pfx.toLowerCase() + '-';
66
- animation = true;
67
- break;
68
- }
69
- }
70
- }
71
- return animation;
72
- }
73
-
74
- /* function to join two or more strings using a delimeter */
75
- function wfu_join_strings(delimeter) {
76
- var args = [].slice.call(arguments);
77
- var str = "";
78
- var delim = "";
79
- for (var i = 1; i < args.length; i++) {
80
- if (str == "" || args[i] == "" ) delim = "";
81
- else delim = delimeter;
82
- str += delim + args[i];
83
- }
84
- return str;
85
- }
86
-
87
- //wfu_plugin_decode_string: function that decodes an encoded string
88
- function wfu_plugin_decode_string(str) {
89
- var i = 0;
90
- var newstr = "";
91
- var hex = "";
92
- for (i = 0; i < str.length; i += 2) {
93
- hex = str.substr(i, 2); //IE6 fix using substr instead of str[i]+str[i+1]
94
- newstr += String.fromCharCode(parseInt(hex, 16));
95
- }
96
- return newstr;
97
- }
98
-
99
- //wfu_plugin_encode_string: function that encodes a decoded string
100
- function wfu_plugin_encode_string(str) {
101
- var i = 0;
102
- var newstr = "";
103
- var hex = "";
104
- for (i = 0; i < str.length; i++) {
105
- hex = str.charCodeAt(i).toString(16);
106
- if (hex.length == 1) hex = "0" + hex;
107
- newstr += hex;
108
- }
109
- return newstr;
110
- }
111
-
112
- //wfu_randomString: generate a random string with a length of len characters
113
- function wfu_randomString(len) {
114
- var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
115
- var string_length = len;
116
- var randomstring = '';
117
- for (var i = 0; i < string_length; i++) {
118
- var rnum = Math.floor(Math.random() * chars.length);
119
- randomstring += chars.substring(rnum, rnum + 1);
120
- }
121
- return randomstring;
122
- }
123
-
124
- //wfu_addEventHandler: attach event handler to element (cross-browser compatible)
125
- function wfu_addEventHandler(obj, evt, handler) {
126
- if(obj.addEventListener) {
127
- // W3C method
128
- obj.addEventListener(evt, handler, false);
129
- }
130
- else if(obj.attachEvent) {
131
- // IE method.
132
- obj.attachEvent('on'+evt, handler);
133
- }
134
- else {
135
- // Old school method.
136
- obj['on'+evt] = handler;
137
- }
138
- }
139
-
140
- //wfu_GetHttpRequestObject: function that returns XMLHttpRequest object for various browsers
141
- function wfu_GetHttpRequestObject() {
142
- var xhr = null;
143
- try {
144
- xhr = new XMLHttpRequest();
145
- }
146
- catch(e) {
147
- try {
148
- xhr = new ActiveXObject("Msxml2.XMLHTTP");
149
- }
150
- catch (e2) {
151
- try {
152
- xhr = new ActiveXObject("Microsoft.XMLHTTP");
153
- }
154
- catch (e) {}
155
- }
156
- }
157
- if (xhr == null && window.createRequest) {
158
- try {
159
- xmlhttp = window.createRequest();
160
- }
161
- catch (e) {}
162
- }
163
- return xhr;
164
- }
165
-
166
- //wfu_filedetails_showhide: function to show or hide file messages
167
- function wfu_filedetails_showhide(sid, fileid, show) {
168
- var item1 = document.getElementById('wfu_messageblock_arrow_' + sid + '_' + fileid);
169
- var item2 = document.getElementById('wfu_messageblock_arrow_' + sid + '_up_' + fileid);
170
- var item3 = document.getElementById('wfu_messageblock_arrow_' + sid + '_down_' + fileid);
171
- var item4 = document.getElementById('wfu_messageblock_subheader_' + sid + '_' + fileid);
172
- var item5 = document.getElementById('wfu_messageblock_header_' + sid + '_state_' + fileid);
173
- if (show) {
174
- item2.style.display = "";
175
- item3.style.display = "none";
176
- item4.style.display = "";
177
- item5.value = "";
178
- }
179
- else {
180
- item2.style.display = "none";
181
- item3.style.display = "";
182
- item4.style.display = "none";
183
- item5.value = "none";
184
- }
185
- }
186
-
187
- //wfu_get_file_ids: function to get an array with ids of files already uploaded
188
- function wfu_get_file_ids(sid) {
189
- var message_table = document.getElementById('wfu_messageblock_' + sid);
190
- var next_block = document.getElementById('wfu_messageblock_subheader_' + sid).nextSibling;
191
- var prefix = 'wfu_messageblock_' + sid + '_';
192
- var file_ids = [];
193
- while (next_block != null) {
194
- if (next_block.nodeType === 1 && next_block.id.substr(0, prefix.length) == prefix)
195
- file_ids.push(next_block.id.substr(next_block.id.lastIndexOf("_") + 1));
196
- next_block = next_block.nextSibling;
197
- }
198
- return file_ids;
199
- }
200
-
201
- //wfu_filedetails_toggle: function to toggle file messages visibility
202
- function wfu_filedetails_toggle(sid, fileid) {
203
- var item1 = document.getElementById('wfu_messageblock_arrow_' + sid + '_' + fileid);
204
- var item2 = document.getElementById('wfu_messageblock_arrow_' + sid + '_up_' + fileid);
205
- wfu_filedetails_showhide(sid, fileid, item2.style.display == "none");
206
- }
207
-
208
- //wfu_headerdetails_showhide: function to show or hide header messages and upload results for each uploaded file
209
- function wfu_headerdetails_showhide(sid, show) {
210
- var item1 = document.getElementById('wfu_messageblock_arrow_' + sid);
211
- var item2 = document.getElementById('wfu_messageblock_arrow_' + sid + '_up');
212
- var item3 = document.getElementById('wfu_messageblock_arrow_' + sid + '_down');
213
- var item4 = document.getElementById('wfu_messageblock_subheader_' + sid);
214
- var item5 = document.getElementById('wfu_messageblock_subheader_' + sid + '_message');
215
- var item6 = document.getElementById('wfu_messageblock_subheader_' + sid + '_adminmessage');
216
- var item7 = document.getElementById('wfu_messageblock_header_' + sid + '_state');
217
- var file_ids = wfu_get_file_ids(sid);
218
- if (show) {
219
- item2.style.display = "";
220
- item3.style.display = "none";
221
- if ( item5.style.display != "none" || item6.style.display != "none" ) item4.style.display = "";
222
- item7.value = "";
223
- for (var i = 0; i < file_ids.length; i++) {
224
- document.getElementById('wfu_messageblock_' + sid + '_' + file_ids[i]).style.display = "";
225
- document.getElementById('wfu_messageblock_subheader_' + sid + '_' + file_ids[i]).style.display = document.getElementById('wfu_messageblock_header_' + sid + '_state_' + file_ids[i]).value;
226
- }
227
- }
228
- else {
229
- item2.style.display = "none";
230
- item3.style.display = "";
231
- item4.style.display = "none";
232
- item7.value = "none";
233
- for (var i = 0; i < file_ids.length; i++) {
234
- document.getElementById('wfu_messageblock_' + sid + '_' + file_ids[i]).style.display = "none";
235
- document.getElementById('wfu_messageblock_subheader_' + sid + '_' + file_ids[i]).style.display = "none";
236
- }
237
- }
238
- }
239
-
240
- //wfu_headerdetails_toggle: function to toggle header messages and file results visibility
241
- function wfu_headerdetails_toggle(sid) {
242
- var item1 = document.getElementById('wfu_messageblock_arrow_' + sid);
243
- var item2 = document.getElementById('wfu_messageblock_arrow_' + sid + '_up');
244
- wfu_headerdetails_showhide(sid, item2.style.display == "none");
245
- }
246
-
247
-
248
- //wfu_selectbutton_changed: function that executes when files have been selected
249
- function wfu_selectbutton_changed(sid, usefilearray) {
250
- //if browser cannot handle HTML5 AJAX requests then deactivate use of array to store uploaded files
251
- if (!wfu_BrowserCaps.supportsAJAX || !wfu_BrowserCaps.supportsHTML5) usefilearray = 0;
252
-
253
- var inputfile = document.getElementById("upfile_" + sid);
254
- var farr = inputfile.files;
255
- //fix in case files attribute is not supported
256
- if (!farr) { if (inputfile.value) farr = [{name:inputfile.value}]; else farr = []; }
257
- //update textbox with filename of the file to be uploaded
258
- var ftext = document.getElementById("fileName_" + sid);
259
- if (ftext) ftext.value = inputfile.value.replace(/c:\\fakepath\\/i, "");
260
- //if use of array is possible to store filelist, then create it and append selected files
261
- if (usefilearray == 1) {
262
- if (typeof inputfile.filearray == "undefined") {
263
- inputfile.filearray = Array();
264
- }
265
- for (var i = 0; i < farr.length; i++) {
266
- inputfile.filearray.push(farr[i]);
267
- }
268
- }
269
- }
270
-
271
- //wfu_selectbutton_clicked: function that executes when select button is clicked
272
- function wfu_selectbutton_clicked(sid) {
273
- var message_container = document.getElementById("wordpress_file_upload_message_" + sid);
274
- if (message_container) message_container.style.display = "none";
275
- wfu_reset_message(sid);
276
- document.getElementById("upfile_" + sid).value = "";
277
- var ftext = document.getElementById("fileName_" + sid);
278
- if (ftext) {
279
- ftext.value = "";
280
- ftext.className = "file_input_textbox";
281
- }
282
- }
283
-
284
- //wfu_RunWPFileBaseHttpRequest: function to update WP-FileBase plugin
285
- function wfu_RunWPFileBaseHttpRequest(filebaseurl) {
286
- var xmlhttp = wfu_GetHttpRequestObject();
287
- if (xmlhttp == null) {
288
- //alternative way of sending GET request using IFRAME, in case AJAX is disabled
289
- var i = document.createElement("iframe");
290
- i.style.display = "none";
291
- i.src = filebaseurl;
292
- document.body.appendChild(i);
293
- return;
294
- }
295
-
296
- xmlhttp.open("GET", filebaseurl, true);
297
- xmlhttp.onreadystatechange=function() {
298
- if (xmlhttp.readyState==4) {
299
- }
300
- }
301
- xmlhttp.send(null);
302
- }
303
-
304
- //wfu_Redirect: function to redirect to another url
305
- function wfu_Redirect(link) {
306
- window.location = link;
307
- }
308
-
309
- //wfu_loadStrat: function to start upload of file
310
- function wfu_loadStart(evt) {
311
- }
312
-
313
- //wfu_uploadProgress: function to update progress bar
314
- function wfu_uploadProgress(evt) {
315
- var sid = this.xhr.shortcode_id;
316
- var percentComplete = 0;
317
- var simplebar = document.getElementById('progressbar_' + sid + '_animation');
318
- if (evt.lengthComputable) {
319
- if (this.xhr.size != evt.total && evt.total > 0) this.xhr.size = evt.total;
320
- if (simplebar) {
321
- var total = 0;
322
- var totalloaded = 0;
323
- for (var i = 0; i < GlobalData[sid].xhrs.length; i++) {
324
- total += GlobalData[sid].xhrs[i].size;
325
- totalloaded += GlobalData[sid].xhrs[i].sizeloaded;
326
- }
327
- percentComplete = Math.round((totalloaded + evt.loaded - this.xhr.sizeloaded) * 100 / total);
328
- simplebar.style.width = percentComplete.toString() + '%';
329
- }
330
- this.xhr.sizeloaded = evt.loaded;
331
- }
332
- else {
333
- if (simplebar) simplebar.style.width = '0%';
334
- }
335
- }
336
-
337
- /* wfu_notify_WPFilebase: function to notify WPFilebase plugin about file changes */
338
- function wfu_notify_WPFilebase(url) {
339
- wfu_RunWPFileBaseHttpRequest(url + "/wp-admin/tools.php?page=wpfilebase&action=sync&hash_sync=1");
340
- //addition to support newer versions of WP-Filebase
341
- wfu_RunWPFileBaseHttpRequest(url + "/wp-admin/admin.php?page=wpfilebase_manage&action=sync&hash_sync=1");
342
- }
343
-
344
- /* wfu_send_email_notification: function to send notification message as ajax request */
345
- function wfu_send_email_notification(sid, unique_id, params_index, session_token, notify_only_filename_list, notify_target_path_list, notify_attachment_list, debugmode, is_admin) {
346
- var xhr = wfu_GetHttpRequestObject();
347
- if (xhr == null) {
348
- // error sending email
349
- return;
350
- }
351
-
352
- var url = GlobalData.consts.ajax_url;
353
- var userdata_count = wfu_get_userdata_count(sid);
354
- params = new Array(7 + userdata_count);
355
- params[0] = new Array(2);
356
- params[0][0] = 'action';
357
- params[0][1] = 'wfu_ajax_action_send_email_notification';
358
- params[1] = new Array(2);
359
- params[1][0] = 'params_index';
360
- params[1][1] = params_index;
361
- params[2] = new Array(2);
362
- params[2][0] = 'session_token';
363
- params[2][1] = session_token;
364
- params[3] = new Array(2);
365
- params[3][0] = 'only_filename_list';
366
- params[3][1] = notify_only_filename_list;
367
- params[4] = new Array(2);
368
- params[4][0] = 'target_path_list';
369
- params[4][1] = notify_target_path_list;
370
- params[5] = new Array(2);
371
- params[5][0] = 'attachment_list';
372
- params[5][1] = notify_attachment_list;
373
- params[6] = new Array(2);
374
- params[6][0] = 'unique_id';
375
- params[6][1] = unique_id;
376
- for (var i = 0; i < userdata_count; i++) {
377
- params[7 + i] = new Array(2);
378
- params[7 + i][0] = 'userdata_' + i;
379
- params[7 + i][1] = document.getElementById('hiddeninput_' + sid + '_userdata_' + i).value;
380
- }
381
-
382
- var parameters = '';
383
- for (var i = 0; i < params.length; i++) {
384
- parameters += (i > 0 ? "&" : "") + params[i][0] + "=" + encodeURI(params[i][1]);
385
- }
386
-
387
- var d = new Date();
388
- xhr.shortcode_id = sid;
389
- xhr.requesttype = "email";
390
- xhr.file_id = 0;
391
- xhr.unique_id = unique_id;
392
- xhr.debugmode = debugmode;
393
- xhr.is_admin = is_admin;
394
- xhr.params_index = params_index;
395
- xhr.session_token = session_token;
396
- xhr.finish_time = d.getTime() + parseInt(GlobalData.consts.max_time_limit) * 1000;
397
- xhr.fail_colors = GlobalData.consts.fail_colors;
398
- xhr.error_message_header = "";
399
- xhr.error_message_failed = GlobalData.consts.message_failed;
400
- xhr.error_message_cancelled = GlobalData.consts.message_cancelled;
401
- xhr.error_adminmessage_unknown = "";
402
-
403
- xhr.open("POST", url, true);
404
- xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
405
- xhr.setRequestHeader("Content-length", parameters.length);
406
- xhr.setRequestHeader("Connection", "close");
407
- xhr.addEventListener("load", wfu_uploadComplete, false);
408
- xhr.addEventListener("error", wfu_uploadFailed, false);
409
- xhr.addEventListener("abort", wfu_uploadCanceled, false);
410
-
411
- xhr.send(parameters);
412
- }
413
-
414
- //wfu_format_debug_data: function to format and prepare debug data for output
415
- function wfu_format_debug_data(data, title) {
416
- output = '<label class="file_messageblock_subheader_debugmessage_label">';
417
- output += 'Debug Data' + title;
418
- output += '</label>';
419
- output += '<div class="file_messageblock_subheader_debugmessage_container">';
420
- output += data;
421
- output += '</div>';
422
- return output;
423
- }
424
-
425
- //wfu_uploadComplete: function that is called after successfull file upload
426
- function wfu_uploadComplete(evt) {
427
- var sid = this.shortcode_id;
428
- var i = this.file_id;
429
- var last = false;
430
- var upload_params = "";
431
- var safe_params = "";
432
- var debug_data = "";
433
- var result_data = evt.target.responseText;
434
- if (evt.target.responseText != -1) {
435
- var txt = evt.target.responseText;
436
- var success_txt = "wfu_fileupload_success:";
437
- var pos = txt.indexOf(success_txt);
438
- if ( pos > -1 ) {
439
- if (this.debugmode == "true") debug_data = txt.substr(0, pos);
440
- result_data = txt.substr(pos + success_txt.length);
441
- pos = result_data.indexOf(":");
442
- safe_params = result_data.substr(0, pos);
443
- upload_params = result_data.substr(pos + 1);
444
- }
445
- if (debug_data != "") {
446
- var title = "";
447
- if (this.requesttype == "fileupload") title = ' - File: ' + this.file_id;
448
- else if (this.requesttype == "email") title = ' - Email Notification';
449
- debug_data = wfu_format_debug_data(debug_data, title);
450
- }
451
- }
452
-
453
- if (upload_params == "" || safe_params == "") {
454
- var error_colors = this.fail_colors.split(",");
455
- var Params = wfu_Initialize_Params();
456
- Params.general.shortcode_id = sid;
457
- Params.general.unique_id = this.unique_id;
458
- Params.general.state = 7;
459
- Params.general.files_count = (this.requesttype == "fileupload") ? 1 : 0;
460
- Params.general.upload_finish_time = this.finish_time;
461
- Params.general.fail_message = GlobalData.consts.message_unknown;
462
- Params.general.fail_admin_message = wfu_join_strings("<br />", this.error_adminmessage_unknown, this.requesttype + ":" + result_data);
463
- if (Params.general.files_count > 0) {
464
- Params[0] = {};
465
- Params[0]['color'] = error_colors[0];
466
- Params[0]['bgcolor'] = error_colors[1];
467
- Params[0]['borcolor'] = error_colors[2];
468
- Params[0]['message_type'] = "error";
469
- Params[0]['header'] = this.error_message_header;
470
- Params[0]['message'] = GlobalData.consts.message_timelimit;
471
- Params[0]['admin_messages'] = this.is_admin == "true" ? GlobalData.consts.message_admin_timelimit : "";
472
- }
473
- else Params.general.admin_messages.other = this.is_admin == "true" ? GlobalData.consts.message_admin_timelimit : "";
474
- //check if we have a failed upload probably due to exceeded upload time limit
475
- if (Params.general.upload_finish_time > 0) {
476
- var d = new Date();
477
- if (d.getTime() < Params.general.upload_finish_time) {
478
- if (Params.general.files_count > 0) {
479
- Params[0]['message'] = Params.general.fail_message;
480
- Params[0]['admin_messages'] = this.is_admin == "true" ? Params.general.fail_admin_message : "";
481
- }
482
- else Params.general.admin_messages.other = this.is_admin == "true" ? Params.general.fail_admin_message : "";
483
- }
484
- }
485
- // note that upload_params is passed as object, so no need to pass a safe_output string
486
- last = wfu_ProcessUploadComplete(sid, this.file_id, Params, this.unique_id, this.params_index, this.session_token, "", [this.debugmode, debug_data, this.is_admin]);
487
- }
488
- else {
489
- last = wfu_ProcessUploadComplete(sid, this.file_id, upload_params, this.unique_id, this.params_index, this.session_token, safe_params, [this.debugmode, debug_data, this.is_admin]);
490
- }
491
- if (last) {
492
- wfu_unlock_upload(evt.target.shortcode_id);
493
- wfu_hide_simple_progressbar(sid);
494
- wfu_clear(evt.target.shortcode_id);
495
- }
496
- }
497
-
498
- //wfu_ProcessUploadComplete: function to perform actions after successfull upload
499
- function wfu_ProcessUploadComplete(sid, file_id, upload_params, unique_id, params_index, session_token, safe_output, debug_data) {
500
- //initial checks to process or not the data
501
- if (!sid || sid < 0) return;
502
- if (upload_params == null || upload_params == "") return;
503
- if (unique_id == "") return;
504
- if (unique_id != "no-ajax" && !GlobalData[sid]) return;
505
-
506
- var do_redirect = false;
507
-
508
- if (typeof upload_params === "string") {
509
- upload_params = wfu_plugin_decode_string(upload_params.replace(/^\s+|\s+$/g,""));
510
- var Params = null;
511
- try { Params = JSON.parse(upload_params); }
512
- catch(e) {}
513
- if (Params == null) {
514
- // JSON parse error that does not allow to read the parameters of the upload. The safe output string will be used in place.
515
- var safe_parts = safe_output.split(";");
516
- Params = wfu_Initialize_Params();
517
- Params.general.shortcode_id = sid;
518
- Params.general.unique_id = unique_id;
519
- Params.general.state = safe_parts[0];
520
- // upload state cannot be 4, because we have json warnings
521
- if (Params.general.state == 4) Params.general.state++;
522
- var default_colors = safe_parts[1].split(",");
523
- var filedata = "";
524
- var error_jsonparse_filemessage = GlobalData.consts.jsonparse_filemessage;
525
- var error_jsonparse_message = GlobalData.consts.jsonparse_message;
526
- var error_jsonparse_adminmessage = GlobalData.consts.jsonparse_adminmessage;
527
- Params.general.files_count = parseInt(safe_parts[2]);
528
- for (var i = 0; i < Params.general.files_count; i++) {
529
- Params[i] = {};
530
- Params[i]['color'] = default_colors[0];
531
- Params[i]['bgcolor'] = default_colors[1];
532
- Params[i]['borcolor'] = default_colors[2];
533
- filedata = safe_parts[i + 3].split(",");
534
- Params[i]['message_type'] = wfu_plugin_decode_string(filedata[0]);
535
- Params[i]['header'] = wfu_plugin_decode_string(filedata[1]);
536
- if (Params[i]['message_type'] == "success") {
537
- Params[i]['header'] += error_jsonparse_filemessage;
538
- Params[i]['message_type'] = "warning";
539
- }
540
- Params[i]['message'] = wfu_join_strings("<br />", error_jsonparse_message, wfu_plugin_decode_string(filedata[2]));
541
- Params[i]['admin_messages'] = wfu_join_strings("<br />", error_jsonparse_adminmessage, wfu_plugin_decode_string(filedata[3]));
542
- }
543
- }
544
- }
545
- // include case for results returned straight as object in case of error or wait state
546
- else if (typeof upload_params === "object") var Params = upload_params;
547
- else return;
548
-
549
- var message_table = document.getElementById('wfu_messageblock_' + sid);
550
-
551
- // initialize UploadStates object, if not already initialized and if message box is activated
552
- var UploadStates_Ok = true;
553
- if (!UploadStates[sid] && message_table) {
554
- var upload_states = document.getElementById('wfu_messageblock_header_' + sid + '_states').value;
555
- upload_states = wfu_plugin_decode_string(upload_states.replace(/^\s+|\s+$/g,""));
556
- UploadStates[sid] = null;
557
- try { UploadStates[sid] = JSON.parse(upload_states); }
558
- catch(e) {}
559
- if (UploadStates[sid] == null) {
560
- // JSON parse error that does not allow to show and style accordingly the header message. A generic JSON parse error message will be shown
561
- UploadStates_Ok = false;
562
- }
563
- }
564
-
565
- // pass upload parameters to GlobalData object, which is used to configure the message contents
566
- if (!GlobalData[sid]) GlobalData[sid] = Object();
567
- var G = GlobalData[sid];
568
- // in case of no-ajax method, simply pass upload parameters to GlobalData object
569
- if (unique_id == "no-ajax") {
570
- G.last = false;
571
- G.unique_id = "";
572
- G.files_count = Params.general.files_count;
573
- if (Params.general.state == 0) Params.general.files_count = 0;
574
- G.files_processed = Params.general.files_count;
575
- if (UploadStates_Ok) G.upload_state = Params.general.state;
576
- // if UploadStates could not be parsed, then set header state to JSON error (state 10)
577
- else G.upload_state = 10;
578
- G.message = Params.general.message;
579
- G.update_wpfilebase = Params.general.update_wpfilebase;
580
- G.redirect_link = Params.general.redirect_link;
581
- G.notify_only_filename_list = ""; //in the case of no-ajax method, email notification has already been executed by php, so it is suppressed here
582
- G.notify_target_path_list = "";
583
- G.notify_attachment_list = "";
584
- G.admin_messages = {};
585
- G.admin_messages.wpfilebase = Params.general.admin_messages.wpfilebase;
586
- G.admin_messages.notify = Params.general.admin_messages.notify;
587
- G.admin_messages.redirect = Params.general.admin_messages.redirect;
588
- G.admin_messages.debug = debug_data[1];
589
- G.admin_messages.other = Params.general.admin_messages.other;
590
- G.errors = {};
591
- G.errors.wpfilebase = Params.general.errors.wpfilebase;
592
- G.errors.notify = Params.general.errors.notify;
593
- G.errors.redirect = Params.general.errors.redirect;
594
- G.current_size = 0;
595
- G.total_size = 0;
596
- }
597
- else {
598
- if (G.unique_id == "" || G.unique_id != unique_id || G.unique_id != Params.general.unique_id) return;
599
- if (G.last) return;
600
- var file_status = "";
601
- for (var i = 0; i < Params.general.files_count; i++) {
602
- // define new upload state based on the status of current file
603
- if (Params[i].message_type == "error" && G.files_processed == 0) file_status = "error1";
604
- else if (Params[i].message_type == "error" && G.files_processed > 0) file_status = "error2";
605
- else file_status = Params[i].message_type;
606
- G.upload_state = GlobalData.filestatematch[file_status][G.upload_state];
607
- }
608
- // if UploadStates could not be parsed, then set header state to JSON error (state 10)
609
- if (!UploadStates_Ok) G.upload_state = 10;
610
- G.files_processed += Params.general.files_count;
611
- G.message = wfu_join_strings("<br />", G.message, Params.general.message);
612
- if (G.update_wpfilebase == "") G.update_wpfilebase = Params.general.update_wpfilebase;
613
- if (G.redirect_link == "") G.redirect_link = Params.general.redirect_link;
614
- G.notify_only_filename_list = wfu_join_strings(", ", G.notify_only_filename_list, Params.general.notify_only_filename_list);
615
- G.notify_target_path_list = wfu_join_strings(", ", G.notify_target_path_list, Params.general.notify_target_path_list);
616
- G.notify_attachment_list = wfu_join_strings(",", G.notify_attachment_list, Params.general.notify_attachment_list);
617
- G.admin_messages.debug = wfu_join_strings("<br />", G.admin_messages.debug, debug_data[1]);
618
- G.admin_messages.other = wfu_join_strings("<br />", G.admin_messages.other, Params.general.admin_messages.other);
619
- if (G.admin_messages.wpfilebase == "") G.admin_messages.wpfilebase = Params.general.admin_messages.wpfilebase;
620
- if (G.admin_messages.notify == "") G.admin_messages.notify = Params.general.admin_messages.notify;
621
- if (G.admin_messages.redirect == "") G.admin_messages.redirect = Params.general.admin_messages.redirect;
622
- if (G.errors.wpfilebase == "") G.errors.wpfilebase = Params.general.errors.wpfilebase;
623
- if (G.errors.notify == "") G.errors.notify = Params.general.errors.notify;
624
- if (G.errors.redirect == "") G.errors.redirect = Params.general.errors.redirect;
625
- }
626
- // adjust upload parameters if this is the last combined call to this function
627
- if (G.files_processed == G.files_count) {
628
- G.last = true;
629
-
630
- // prepare and execute actions related to WPFilebase, email notifications and redirection if this is the last call
631
- if (G.update_wpfilebase != "") {
632
- G.admin_messages.wpfilebase = "";
633
- wfu_notify_WPFilebase(G.update_wpfilebase);
634
- }
635
- if (G.notify_only_filename_list != "") {
636
- G.admin_messages.notify = "";
637
- wfu_send_email_notification(sid, unique_id, params_index, session_token, G.notify_only_filename_list, G.notify_target_path_list, G.notify_attachment_list, debug_data[0], debug_data[2]);
638
- // in email notification we declare that this is not the last call, because we wait for a last answer from email sending result
639
- G.last = false;
640
- G.notify_only_filename_list = ""; //reset this variable so that repetitive email messages are not sent
641
- }
642
- if (G.errors.redirect != "") G.redirect_link = "";
643
- if (G.redirect_link != "") {
644
- // if redirection is executed, then set upload state to redirecting...
645
- G.upload_state = 11;
646
- do_redirect = true;
647
- // wfu_Redirect(G.redirect_link);
648
- }
649
- }
650
-
651
- // last adjustment of header messages due to json parse error of UploadState or debug messages
652
- var nonadmin_message = G.message;
653
- var admin_message = wfu_join_strings("<br />",
654
- G.admin_messages.other,
655
- G.admin_messages.wpfilebase,
656
- G.admin_messages.notify,
657
- G.admin_messages.redirect,
658
- G.admin_messages.debug);
659
- if (!UploadStates_Ok) {
660
- var error_jsonparse_headermessage = GlobalData.consts.jsonparse_headermessage;
661
- var error_jsonparse_headeradminmessage = GlobalData.consts.jsonparse_headeradminmessage;
662
- nonadmin_message = wfu_join_strings("<br />", error_jsonparse_headermessage, nonadmin_message);
663
- admin_message = wfu_join_strings("<br />", error_jsonparse_headeradminmessage, admin_message);
664
- }
665
-
666
- if (G.last) {
667
- // update upload state
668
- if (G.files_count == 0) G.upload_state = 8;
669
- else if (G.upload_state < 4) G.upload_state += 4;
670
- // final adjust of upload state because admin messages may have been modified
671
- var admin_messages_exist = (G.admin_messages.wpfilebase != "" || G.admin_messages.notify != "" || G.admin_messages.redirect != "" || G.admin_messages.other != "");
672
- if (G.upload_state == 4 && admin_message != "") G.upload_state ++;
673
- else if (G.upload_state == 5 && !admin_message == "" && nonadmin_message == "") G.upload_state --;
674
- }
675
-
676
- // if (typeof console != "undefined") {
677
- // console.log(Params);
678
- // var GG = G;
679
- // console.log(GG);
680
- // }
681
-
682
- // section to update message box, executed only if message box is activated
683
- if (message_table) {
684
- var subheader_state = document.getElementById('wfu_messageblock_header_' + sid + '_state');
685
- var single_file_shown = (G.files_count == 1 && nonadmin_message == "" && admin_message == "" && G.last && !do_redirect);
686
- // adjust header if must be shown
687
- if (single_file_shown) {
688
- document.getElementById('wfu_messageblock_header_' + sid).style.display = "none";
689
- }
690
- else {
691
- document.getElementById('wfu_messageblock_header_' + sid).style.display = "";
692
- var header_container = document.getElementById('wfu_messageblock_header_' + sid + '_container');
693
- if (UploadStates_Ok) {
694
- var suffix = "";
695
- if (G.files_count == 1 && (G.upload_state == 5 || G.upload_state == 7)) suffix = "_singlefile";
696
- header_container.innerHTML = UploadStates[sid]["State" + G.upload_state + suffix];
697
- }
698
- else {
699
- header_container.innerHTML = "";
700
- var safe_container = document.getElementById('wfu_messageblock_header_' + sid + '_safecontainer');
701
- header_container.innerHTML = safe_container.innerHTML.replace(/_safe/g, "");
702
- }
703
-
704
- // adjust subheader message
705
- var subheader_show = false;
706
- if (nonadmin_message != "") {
707
- document.getElementById('wfu_messageblock_subheader_' + sid + '_message').style.display = "";
708
- document.getElementById('wfu_messageblock_subheader_' + sid + '_messagelabel').innerHTML = nonadmin_message;
709
- subheader_show = true;
710
- }
711
- else
712
- document.getElementById('wfu_messageblock_subheader_' + sid + '_message').style.display = "none";
713
-
714
- // adjust subheader admin message
715
- if (admin_message != "") {
716
- document.getElementById('wfu_messageblock_subheader_' + sid + '_adminmessage').style.display = "";
717
- document.getElementById('wfu_messageblock_subheader_' + sid + '_adminmessagelabel').innerHTML = admin_message;
718
- subheader_show = true;
719
- }
720
- else
721
- document.getElementById('wfu_messageblock_subheader_' + sid + '_adminmessage').style.display = "none";
722
-
723
- // adjust subheader
724
- if (subheader_show)
725
- document.getElementById('wfu_messageblock_subheader_' + sid).style.display = subheader_state.value;
726
- else
727
- document.getElementById('wfu_messageblock_subheader_' + sid).style.display = "none";
728
-
729
- // adjust header arrow
730
- if (subheader_show || G.files_processed > 0) {
731
- header_container.colSpan = 2;
732
- document.getElementById('wfu_messageblock_arrow_' + sid).style.display = "";
733
- }
734
- else {
735
- document.getElementById('wfu_messageblock_arrow_' + sid).style.display = "none";
736
- header_container.colSpan = 3;
737
- }
738
- }
739
- var next_block = document.getElementById('wfu_messageblock_subheader_' + sid);
740
- var next_block_id = 0;
741
-
742
- // insert file blocks
743
- var file_block = null;
744
- var file_template_container = document.getElementById('wfu_messageblock_' + sid + '_filetemplate');
745
- var file_contents = "";
746
- var door = document.getElementById('wfu_messageblock_' + sid + '_door');
747
- var ii = 0;
748
- var headerspan = 1;
749
- var subheaderspan = 2;
750
- var file_template = wfu_plugin_decode_string(file_template_container.value.replace(/^\s+|\s+$/g,""));
751
- for (var i = 0; i < Params.general.files_count; i++) {
752
- ii = i + file_id;
753
- // replace template variables with file data
754
- file_contents = file_template.replace(/\[file_id\]/g, ii);
755
- file_contents = file_contents.replace(/\[filenumber_display\]/g, "");
756
- file_contents = file_contents.replace(/\[fileheader_color\]/g, Params[i].color);
757
- file_contents = file_contents.replace(/\[fileheader_bgcolor\]/g, Params[i].bgcolor);
758
- file_contents = file_contents.replace(/\[fileheader_borcolor\]/g, Params[i].borcolor);
759
- file_contents = file_contents.replace(/\[fileheader_message\]/g, Params[i].header);
760
- file_contents = file_contents.replace(/\[filesubheadermessage_display\]/g, "style=\"display:none;\"");
761
- file_contents = file_contents.replace(/\[filesubheader_message\]/g, Params[i].message);
762
- file_contents = file_contents.replace(/\[filesubheaderadminmessage_display\]/g, "style=\"display:none;\"");
763
- file_contents = file_contents.replace(/\[filesubheader_adminmessage\]/g, Params[i].admin_messages);
764
- // put file contents to temp div element to convert them to HTML elements
765
- file_contents = "<table><tbody>" + file_contents + "</tbody></table>"; //IE6 fix: door is a div element so that innerHTML is writable
766
- door.innerHTML = file_contents;
767
- // post process created file block to adjust visibility of its contents
768
- headerspan = 1;
769
- subheaderspan = 2;
770
- subheader_show = false;
771
- file_block = document.getElementById('wfu_messageblock_' + sid + '_' + ii);
772
- if (G.files_count == 1) {
773
- document.getElementById('wfu_messageblock_' + sid + '_filenumber_' + ii).style.display = "none";
774
- document.getElementById('wfu_messageblock_subheader_' + sid + '_fileempty_' + ii).style.display = "none";
775
- if (single_file_shown) file_block.style.display = "";
776
- else file_block.style.display = subheader_state.value;
777
- headerspan ++;
778
- subheaderspan ++;
779
- }
780
- else file_block.style.display = subheader_state.value;
781
- if (Params[i].message != "") {
782
- document.getElementById('wfu_messageblock_subheader_' + sid + '_message_' + ii).style.display = "";
783
- subheader_show = true;
784
- }
785
- if (Params[i].admin_messages != "") {
786
- document.getElementById('wfu_messageblock_subheader_' + sid + '_adminmessage_' + ii).style.display = "";
787
- subheader_show = true;
788
- }
789
- if (!subheader_show) {
790
- document.getElementById('wfu_messageblock_arrow_' + sid + '_' + ii).style.display = "none";
791
- headerspan ++;
792
- }
793
- document.getElementById('wfu_messageblock_header_' + sid + '_container_' + ii).colSpan = headerspan;
794
- document.getElementById('wfu_messageblock_subheader_' + sid + '_container_' + ii).colSpan = subheaderspan;
795
- // move file block inside message block
796
- while (next_block_id < ii) {
797
- next_block = next_block.nextSibling;
798
- if (next_block == null) break;
799
- if (next_block.nodeType === 1) next_block_id = next_block.id.substr(next_block.id.lastIndexOf("_") + 1);
800
- }
801
- message_table.tBodies[0].insertBefore(file_block, next_block);
802
- next_block = file_block.nextSibling;
803
- file_block = document.getElementById('wfu_messageblock_subheader_' + sid + '_' + ii);
804
- message_table.tBodies[0].insertBefore(file_block, next_block);
805
- next_block = file_block;
806
- next_block_id = ii;
807
- }
808
- if (single_file_shown) document.getElementById('wfu_messageblock_' + sid + '_1').style.display = "";
809
- message_table.style.display = "";
810
- document.getElementById('wordpress_file_upload_message_' + sid).style.display = "";
811
- }
812
- if (do_redirect) wfu_Redirect(G.redirect_link);
813
-
814
- return G.last;
815
- }
816
-
817
- //wfu_uploadFailed: function that is called if uploading fails
818
- function wfu_uploadFailed(evt) {
819
- // alert(this.error_message_failed);
820
- }
821
-
822
- //wfu_uploadCanceled: function that is called if uploading is cancelled
823
- function wfu_uploadCanceled(evt) {
824
- // alert(this.error_message_cancelled);
825
- }
826
-
827
- //wfu_Initialize_Params: function that creates an object with default parameters used for generation of message box
828
- function wfu_Initialize_Params() {
829
- var params = {};
830
- params.version = "full";
831
- params.general = {};
832
- params.general.shortcode_id = 0;
833
- params.general.unique_id = "";
834
- params.general.state = 0;
835
- params.general.files_count = 0;
836
- params.general.update_wpfilebase = "";
837
- params.general.redirect_link = "";
838
- params.general.upload_finish_time = 0;
839
- params.general.message = "";
840
- params.general.message_type = "";
841
- params.general.admin_messages = {};
842
- params.general.admin_messages.wpfilebase = "";
843
- params.general.admin_messages.notify = "";
844
- params.general.admin_messages.redirect = "";
845
- params.general.admin_messages.other = "";
846
- params.general.errors = {};
847
- params.general.errors.wpfilebase = "";
848
- params.general.errors.notify = "";
849
- params.general.errors.redirect = "";
850
- params.general.color = "";
851
- params.general.bgcolor = "";
852
- params.general.borcolor = "";
853
- params.general.notify_only_filename_list = "";
854
- params.general.notify_target_path_list = "";
855
- params.general.notify_attachment_list = "";
856
- params.general.fail_message = "";
857
- params.general.fail_admin_message = "";
858
-
859
- return params;
860
- }
861
-
862
- //wfu_redirect_to_classic: function that switches to classic functionality (HTML upload form) if HTML5 is not supported
863
- function wfu_redirect_to_classic(sid, session_token, flag, adminerrorcode) {
864
-
865
- //check if file has been selected or not
866
- if (wfu_filesselected(sid) == 0) return;
867
-
868
- // check if there are empty user data fields that are required
869
- if (!wfu_check_required_userdata(sid)) return;
870
-
871
- wfu_redirect_to_classic_cont(sid, session_token, flag, adminerrorcode, [""]);
872
- }
873
-
874
- //wfu_redirect_to_classic_cont: function thatinforms the page to process the file after reloading, informs the page if this is a redirection from HTML5 to classic functionality and submits the file
875
- function wfu_redirect_to_classic_cont(sid, session_token, flag, adminerrorcode, other_params) {
876
- var process_function = function(responseText) {
877
- if (responseText.indexOf("wfu_response_success:") > -1) {
878
- // show message in wait for upload state
879
- var Params = wfu_Initialize_Params();
880
- Params.general.shortcode_id = sid;
881
- Params.general.unique_id = "";
882
- Params.general.files_count = wfu_filesselected(sid);
883
- wfu_ProcessUploadComplete(sid, 0, Params, "no-ajax", "", session_token, "", ["false", "", "false"]);
884
-
885
- if (flag == 1) {
886
- var suffice = "";
887
- document.getElementById('upfile_' + sid).name = 'uploadedfile_' + sid + '_redirected' + suffice;
888
- }
889
- if (adminerrorcode > 0) document.getElementById('adminerrorcodes_' + sid).value = adminerrorcode;
890
- else document.getElementById('adminerrorcodes_' + sid).value = "";
891
- document.getElementById('upfile_' + sid).disabled = false;
892
- document.getElementById('uploadform_' + sid).submit();
893
- }
894
- }
895
-
896
- var pass_params = "";
897
- var d = new Date();
898
- var url = GlobalData.consts.response_url + "?shortcode_id=" + sid + "&start_time=" + d.getTime() + "&session_token=" + session_token + pass_params;
899
-
900
- // disable controls
901
- wfu_lock_upload(sid);
902
-
903
- //dispatch of GET request using AJAX asynchronous call
904
- var xmlhttp = wfu_GetHttpRequestObject();
905
- if (xmlhttp == null) {
906
- //alternative way of sending GET request using IFRAME, in case AJAX is disabled
907
- var i = document.createElement("iframe");
908
- if (i) {
909
- i.style.display = "none";
910
- i.src = url;
911
- document.body.appendChild(i);
912
- i.onload = function() {
913
- process_function(i.contentDocument.body.innerHTML);
914
- }
915
- return;
916
- }
917
- else {
918
- return;
919
- }
920
- }
921
-
922
- xmlhttp.open("GET", url, true);
923
- xmlhttp.onreadystatechange=function() {
924
- if (xmlhttp.readyState==4) {
925
- if ( xmlhttp.status == 200 ) {
926
- process_function(xmlhttp.responseText);
927
- }
928
- }
929
- }
930
- xmlhttp.send(null);
931
- }
932
-
933
-
934
- function wfu_filesselected(sid) {
935
- var inputfile = document.getElementById("upfile_" + sid);
936
- var ftext = document.getElementById("fileName_" + sid);
937
- var farr = inputfile.files;
938
- //fix in case files attribute is not supported
939
- if (!farr) { if (inputfile.value) farr = [{name:inputfile.value}]; else farr = []; }
940
- if (typeof inputfile.filearray != "undefined") farr = inputfile.filearray;
941
-
942
- if (farr.length == 0) {
943
- if (ftext) {
944
- ftext.value = GlobalData.consts.nofilemessage;
945
- ftext.className = "file_input_textbox_nofile";
946
- }
947
- }
948
- return farr.length;
949
- }
950
-
951
- //wfu_check_required_userdata: check if there are required user fields that are empty
952
- function wfu_check_required_userdata(sid) {
953
- var userdata_count = wfu_get_userdata_count(sid);
954
- var req_empty = false;
955
- for (var i = 0; i < userdata_count; i++) {
956
- var msg_hid = document.getElementById('hiddeninput_' + sid + '_userdata_' + i);
957
- var msg = document.getElementById('userdata_' + sid + '_message_' + i);
958
- var req_class = "file_userdata_message_required";
959
- if (msg.className.substr(0, req_class.length) == req_class && msg_hid.value == "") {
960
- msg.className = req_class + "_empty";
961
- msg.value = GlobalData.consts.userdata_empty;
962
- req_empty = true;
963
- }
964
- }
965
- return !req_empty;
966
- }
967
-
968
- //wfu_HTML5UploadFile: function that is called if the plugin is not using classic functionality
969
- function wfu_HTML5UploadFile(sid, JSONtext, session_token) {
970
- //redirect to classic if AJAX is not supported
971
- if (!wfu_BrowserCaps.supportsAJAX) {
972
- wfu_redirect_to_classic(sid, session_token, 1, 1);
973
- return;
974
- }
975
- //redirect to classic if HTML5 is not supported
976
- if (!wfu_BrowserCaps.supportsHTML5) {
977
- wfu_redirect_to_classic(sid, session_token, 1, 2);
978
- return;
979
- }
980
- //get plugin params and redirect to classic if JSON decoding fails
981
- JSONtext = wfu_plugin_decode_string(JSONtext.replace(/^\s+|\s+$/g,""));
982
- var JSONobj = null;
983
- try {
984
- JSONobj = JSON.parse(JSONtext);
985
- }
986
- catch(e) {}
987
- if (JSONobj == null) {
988
- wfu_redirect_to_classic(sid, session_token, 1, 3);
989
- return;
990
- }
991
- var xhr = wfu_GetHttpRequestObject();
992
- if (xhr == null) return;
993
-
994
- //check if file has been selected or not
995
- var numfiles = wfu_filesselected(sid);
996
- if (numfiles == 0) return;
997
-
998
-
999
- // check if there are empty user data fields that are required
1000
- if (!wfu_check_required_userdata(sid)) return;
1001
-
1002
- wfu_HTML5UploadFile_cont(sid, JSONobj, session_token, [""]);
1003
- }
1004
-
1005
- function wfu_HTML5UploadFile_cont(sid, JSONobj, session_token, other_params) {
1006
- function sendfile(ind, file) {
1007
- // initialise AJAX and FormData objects
1008
- var xhr = wfu_GetHttpRequestObject();
1009
- if (xhr == null) return;
1010
- var fd = null;
1011
- try {
1012
- var fd = new FormData();
1013
- }
1014
- catch(e) {}
1015
- if (fd == null) return;
1016
-
1017
- // define POST parameters
1018
- fd.append("uploadedfile_" + sid + suffice, file);
1019
- fd.append("action", "wfu_ajax_action");
1020
- fd.append("params_index", JSONobj.params_index);
1021
- fd.append("subdir_sel_index", subdir_sel_index);
1022
- fd.append("session_token", session_token);
1023
- fd.append("unique_id", rand_str);
1024
- var userdata_count = wfu_get_userdata_count(sid);
1025
- for (var ii = 0; ii < userdata_count; ii++)
1026
- fd.append("hiddeninput_" + sid + "_userdata_" + ii, document.getElementById('hiddeninput_' + sid + '_userdata_' + ii).value);
1027
-
1028
- // define variables
1029
- GlobalData[sid].xhrs.push(xhr);
1030
- var d = new Date();
1031
- xhr.shortcode_id = sid;
1032
- xhr.requesttype = "fileupload";
1033
- xhr.file_id = ind + 1;
1034
- xhr.size = file.size;
1035
- xhr.sizeloaded = 0;
1036
- xhr.unique_id = rand_str;
1037
- xhr.params_index = JSONobj.params_index;
1038
- xhr.session_token = session_token;
1039
- xhr.debugmode = JSONobj.debugmode;
1040
- xhr.is_admin = JSONobj.is_admin;
1041
- xhr.finish_time = d.getTime() + parseInt(GlobalData.consts.max_time_limit) * 1000;
1042
- xhr.fail_colors = JSONobj.fail_colors;
1043
- xhr.error_message_header = GlobalData.consts.message_header.replace(/%username%/g, "no data");
1044
- xhr.error_message_header = xhr.error_message_header.replace(/%useremail%/g, "no data");
1045
- xhr.error_message_header = xhr.error_message_header.replace(/%filename%/g, file.name);
1046
- xhr.error_message_header = xhr.error_message_header.replace(/%filepath%/g, file.name);
1047
- xhr.error_message_failed = GlobalData.consts.message_failed;
1048
- xhr.error_message_cancelled = GlobalData.consts.message_cancelled;
1049
- xhr.error_adminmessage_unknown = GlobalData.consts.adminmessage_unknown.replace(/%username%/g, "no data");
1050
- xhr.error_adminmessage_unknown = xhr.error_adminmessage_unknown.replace(/%useremail%/g, "no data");
1051
- xhr.error_adminmessage_unknown = xhr.error_adminmessage_unknown.replace(/%filename%/g, file.name);
1052
- xhr.error_adminmessage_unknown = xhr.error_adminmessage_unknown.replace(/%filepath%/g, file.name);
1053
-
1054
- xhr.upload.xhr = xhr;
1055
-
1056
- // event listeners
1057
- xhr.upload.addEventListener("loadstart", wfu_loadStart, false);
1058
- xhr.upload.addEventListener("progress", wfu_uploadProgress, false);
1059
- xhr.addEventListener("load", wfu_uploadComplete, false);
1060
- xhr.addEventListener("error", wfu_uploadFailed, false);
1061
- xhr.addEventListener("abort", wfu_uploadCanceled, false);
1062
-
1063
- xhr.open("POST", GlobalData.consts.ajax_url);
1064
- xhr.send(fd);
1065
- inc ++;
1066
- }
1067
- // get index of subdirectory if subdirectory dropdown list is activated
1068
- var subdir_sel_index = -1;
1069
- if (document.getElementById('selectsubdir_' + sid) != null)
1070
- subdir_sel_index = document.getElementById('selectsubdir_' + sid).selectedIndex;
1071
-
1072
- // get file list
1073
- var inputfile = document.getElementById("upfile_" + sid);
1074
- var farr = inputfile.files;
1075
- //fix in case files attribute is not supported
1076
- if (!farr) { if (inputfile.value) farr = [{name:inputfile.value}]; else farr = []; }
1077
- if (typeof inputfile.filearray != "undefined") farr = inputfile.filearray;
1078
- var suffice = "";
1079
- /* initialize global object to hold dynamic upload status during upload */
1080
- var rand_str = wfu_randomString(10);
1081
- GlobalData[sid] = {};
1082
- GlobalData[sid].unique_id = rand_str;
1083
- GlobalData[sid].last = false;
1084
- GlobalData[sid].files_count = farr.length;
1085
- GlobalData[sid].files_processed = 0;
1086
- GlobalData[sid].upload_state = 0;
1087
- GlobalData[sid].message = "";
1088
- GlobalData[sid].update_wpfilebase = "";
1089
- GlobalData[sid].redirect_link = "";
1090
- GlobalData[sid].notify_only_filename_list = "";
1091
- GlobalData[sid].notify_target_path_list = "";
1092
- GlobalData[sid].notify_attachment_list = "";
1093
- GlobalData[sid].admin_messages = {};
1094
- GlobalData[sid].admin_messages.wpfilebase = "";
1095
- GlobalData[sid].admin_messages.notify = "";
1096
- GlobalData[sid].admin_messages.redirect = "";
1097
- GlobalData[sid].admin_messages.debug = "";
1098
- GlobalData[sid].admin_messages.other = "";
1099
- GlobalData[sid].errors = {};
1100
- GlobalData[sid].errors.wpfilebase = "";
1101
- GlobalData[sid].errors.notify = "";
1102
- GlobalData[sid].errors.redirect = "";
1103
- GlobalData[sid].xhrs = Array();
1104
-
1105
- wfu_show_simple_progressbar(JSONobj.shortcode_id, "progressive");
1106
-
1107
- // show message in wait for upload state
1108
- var Params = wfu_Initialize_Params();
1109
- Params.general.shortcode_id = sid;
1110
- Params.general.unique_id = rand_str;
1111
- wfu_ProcessUploadComplete(sid, 0, Params, rand_str, JSONobj.params_index, session_token, "", ["false", "", "false"]);
1112
-
1113
- var inc = 0;
1114
- for (var i = 0; i < farr.length; i++) {
1115
- sendfile(i, farr[i]);
1116
- }
1117
- }
1118
-
1119
- //wfu_get_userdata_count: get number of userdata fields
1120
- function wfu_get_userdata_count(sid) {
1121
- var fields_count = 0;
1122
- while (document.getElementById('userdata_' + sid + '_' + fields_count)) fields_count ++;
1123
- return fields_count;
1124
- }
1125
-
1126
- function wfu_lock_upload(sid) {
1127
- var textbox = document.getElementById('fileName_' + sid);
1128
- if (textbox) textbox.disabled = true;
1129
- document.getElementById('input_' + sid).disabled = true;
1130
- document.getElementById('upfile_' + sid).disabled = true;
1131
- var subdir = document.getElementById('selectsubdir_' + sid);
1132
- if (subdir) subdir.disabled = true;
1133
- var upload = document.getElementById('upload_' + sid);
1134
- if (upload) upload.disabled = true;
1135
- var userdata_count = wfu_get_userdata_count(sid);
1136
- for (var i = 0; i < userdata_count; i++)
1137
- document.getElementById('userdata_' + sid + '_message_' + i).disabled = true;
1138
- }
1139
-
1140
- function wfu_unlock_upload(sid) {
1141
- var textbox = document.getElementById('fileName_' + sid);
1142
- if (textbox) textbox.disabled = false;
1143
- document.getElementById('input_' + sid).disabled = false;
1144
- document.getElementById('upfile_' + sid).disabled = false;
1145
- var subdir = document.getElementById('selectsubdir_' + sid);
1146
- if (subdir) subdir.disabled = false;
1147
- var upload = document.getElementById('upload_' + sid);
1148
- if (upload) upload.disabled = false;
1149
- var userdata_count = wfu_get_userdata_count(sid);
1150
- for (var i = 0; i < userdata_count; i++)
1151
- document.getElementById('userdata_' + sid + '_message_' + i).disabled = false;
1152
- }
1153
-
1154
- function wfu_clear(sid) {
1155
- var textbox = document.getElementById('fileName_' + sid);
1156
- if (textbox) {
1157
- textbox.value = '';
1158
- textbox.className = 'file_input_textbox';
1159
- }
1160
- var subdir = document.getElementById('selectsubdir_' + sid);
1161
- if (subdir) subdir.selectedIndex = 0;
1162
- var userdata_count = wfu_get_userdata_count(sid);
1163
- for (var i = 0; i < userdata_count; i++) {
1164
- document.getElementById('userdata_' + sid + '_message_' + i).value = "";
1165
- document.getElementById('hiddeninput_' + sid + '_userdata_' + i).value = "";
1166
- }
1167
- }
1168
-
1169
- function wfu_reset_message(sid) {
1170
- var message_table = document.getElementById('wfu_messageblock_' + sid);
1171
- if (message_table) {
1172
- // reset header
1173
- document.getElementById('wfu_messageblock_header_' + sid).style.display = "";
1174
- var header_container = document.getElementById('wfu_messageblock_header_' + sid + '_container');
1175
- if (UploadStates[sid]) header_container.innerHTML = UploadStates[sid]["State0"];
1176
- document.getElementById('wfu_messageblock_header_' + sid + '_state').value = "none";
1177
- document.getElementById('wfu_messageblock_arrow_' + sid).style.display = "none";
1178
- header_container.colSpan = 3;
1179
- // reset subheader
1180
- document.getElementById('wfu_messageblock_subheader_' + sid + '_messagelabel').innerHTML = "";
1181
- document.getElementById('wfu_messageblock_subheader_' + sid + '_adminmessagelabel').innerHTML = "";
1182
- document.getElementById('wfu_messageblock_subheader_' + sid).style.display = "none";
1183
- document.getElementById('wfu_messageblock_subheader_' + sid + '_message').style.display = "none";
1184
- document.getElementById('wfu_messageblock_subheader_' + sid + '_adminmessage').style.display = "none";
1185
- // reset files
1186
- var file_array = wfu_get_file_ids(sid);
1187
- for (var i = 1; i <= file_array.length; i++) {
1188
- message_table.tBodies[0].removeChild(document.getElementById('wfu_messageblock_' + sid + '_' + i));
1189
- message_table.tBodies[0].removeChild(document.getElementById('wfu_messageblock_subheader_' + sid + '_' + i));
1190
- }
1191
- }
1192
- }
1193
-
1194
-
1195
- function wfu_show_simple_progressbar(sid, effect) {
1196
- var bar = document.getElementById('progressbar_' + sid + '_animation');
1197
- var barsafe = document.getElementById('progressbar_' + sid + '_imagesafe');
1198
- if (bar) {
1199
- if (effect == "progressive") {
1200
- bar.style.width = "0%";
1201
- bar.className = "file_progress_progressive";
1202
- barsafe.style.display = "none";
1203
- bar.style.display = "block";
1204
- }
1205
- else if (wfu_BrowserCaps.supportsAnimation) {
1206
- bar.style.width = "25%";
1207
- bar.className = "file_progress_shuffle";
1208
- barsafe.style.display = "none";
1209
- bar.style.display = "block";
1210
- }
1211
- else {
1212
- bar.style.width = "0%";
1213
- bar.className = "file_progress_noanimation";
1214
- bar.style.display = "none";
1215
- barsafe.style.display = "block";
1216
- }
1217
- document.getElementById('wordpress_file_upload_progressbar_' + sid).style.display = "block";
1218
- }
1219
- }
1220
-
1221
- function wfu_hide_simple_progressbar(sid) {
1222
- var bar = document.getElementById('progressbar_' + sid + '_animation');
1223
- var barsafe = document.getElementById('progressbar_' + sid + '_imagesafe');
1224
- if (bar) {
1225
- document.getElementById('wordpress_file_upload_progressbar_' + sid).style.display = "none";
1226
- bar.style.width = "0%";
1227
- bar.className = "file_progress_noanimation";
1228
- barsafe.style.display = "none";
1229
- bar.style.display = "block";
1230
- }
1231
- }
1232
-
1233
-
1
+ GlobalData = {};
2
+ UploadStates = {};
3
+ GlobalData.filestatematch = {};
4
+ GlobalData.filestatematch.success = [0, 1, 2, 2];
5
+ GlobalData.filestatematch.warning = [1, 1, 2, 2];
6
+ GlobalData.filestatematch.error1 = [3, 3, 2, 3];
7
+ GlobalData.filestatematch.error2 = [2, 2, 2, 3];
8
+ wfu_Check_Browser_Capabilities();
9
+ //console.log(wfu_BrowserCaps);
10
+
11
+ //wfu_Initialize_Consts: function to initialize constants passed from plugin to javascript
12
+ function wfu_Initialize_Consts(consts) {
13
+ if (typeof GlobalData.consts != "undefined") return;
14
+ GlobalData.consts = new Object();
15
+ var consts_arr = consts.split(";");
16
+ var const_arr;
17
+ for (var i = 0; i < consts_arr.length; i++) {
18
+ const_txt = consts_arr[i].split(":");
19
+ GlobalData.consts[wfu_plugin_decode_string(const_txt[0])] = wfu_plugin_decode_string(const_txt[1]);
20
+ }
21
+ }
22
+
23
+ //wfu_Check_Browser_Capabilities: function that checks if browser supports HTML5, iframes and AJAX
24
+ function wfu_Check_Browser_Capabilities() {
25
+ if (typeof wfu_BrowserCaps != "undefined") return;
26
+ wfu_BrowserCaps = new Object();
27
+ //check AJAX
28
+ var xmlhttp = wfu_GetHttpRequestObject();
29
+ wfu_BrowserCaps.supportsAJAX = ( xmlhttp != null );
30
+ //check Upload Progress
31
+ wfu_BrowserCaps.supportsUploadProgress = !! (xmlhttp && ('upload' in xmlhttp) && ('onprogress' in xmlhttp.upload));
32
+ //check HTML5
33
+ var fd = null;
34
+ try {
35
+ var fd = new FormData();
36
+ }
37
+ catch(e) {}
38
+ wfu_BrowserCaps.supportsHTML5 = ( fd != null );
39
+ //check IFRAME
40
+ var e = document.createElement("iframe");
41
+ wfu_BrowserCaps.supportsIFRAME = ( e != null );
42
+ //check Drag and Drop
43
+ wfu_BrowserCaps.supportsDRAGDROP = (window.FileReader);
44
+ //check animation
45
+ wfu_BrowserCaps.supportsAnimation = wfu_check_animation();
46
+ }
47
+
48
+ //wfu_check_animation: function that checks if CSS3 animation is supported
49
+ function wfu_check_animation() {
50
+ var animation = false,
51
+ animationstring = 'animation',
52
+ keyframeprefix = '',
53
+ domPrefixes = 'Webkit Moz O ms Khtml'.split(' '),
54
+ pfx = '';
55
+
56
+ var elm = document.createElement('DIV');
57
+
58
+ if( elm.style.animationName ) { animation = true; }
59
+
60
+ if( animation === false ) {
61
+ for( var i = 0; i < domPrefixes.length; i++ ) {
62
+ if( elm.style[ domPrefixes[i] + 'AnimationName' ] !== undefined ) {
63
+ pfx = domPrefixes[ i ];
64
+ animationstring = pfx + 'Animation';
65
+ keyframeprefix = '-' + pfx.toLowerCase() + '-';
66
+ animation = true;
67
+ break;
68
+ }
69
+ }
70
+ }
71
+ return animation;
72
+ }
73
+
74
+ /* function to join two or more strings using a delimeter */
75
+ function wfu_join_strings(delimeter) {
76
+ var args = [].slice.call(arguments);
77
+ var str = "";
78
+ var delim = "";
79
+ for (var i = 1; i < args.length; i++) {
80
+ if (str == "" || args[i] == "" ) delim = "";
81
+ else delim = delimeter;
82
+ str += delim + args[i];
83
+ }
84
+ return str;
85
+ }
86
+
87
+ //wfu_plugin_decode_string: function that decodes an encoded string
88
+ function wfu_plugin_decode_string(str) {
89
+ var i = 0;
90
+ var newstr = "";
91
+ var hex = "";
92
+ for (i = 0; i < str.length; i += 2) {
93
+ hex = str.substr(i, 2); //IE6 fix using substr instead of str[i]+str[i+1]
94
+ newstr += String.fromCharCode(parseInt(hex, 16));
95
+ }
96
+ return newstr;
97
+ }
98
+
99
+ //wfu_plugin_encode_string: function that encodes a decoded string
100
+ function wfu_plugin_encode_string(str) {
101
+ var i = 0;
102
+ var newstr = "";
103
+ var hex = "";
104
+ for (i = 0; i < str.length; i++) {
105
+ hex = str.charCodeAt(i).toString(16);
106
+ if (hex.length == 1) hex = "0" + hex;
107
+ newstr += hex;
108
+ }
109
+ return newstr;
110
+ }
111
+
112
+ //wfu_randomString: generate a random string with a length of len characters
113
+ function wfu_randomString(len) {
114
+ var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
115
+ var string_length = len;
116
+ var randomstring = '';
117
+ for (var i = 0; i < string_length; i++) {
118
+ var rnum = Math.floor(Math.random() * chars.length);
119
+ randomstring += chars.substring(rnum, rnum + 1);
120
+ }
121
+ return randomstring;
122
+ }
123
+
124
+ //wfu_addEventHandler: attach event handler to element (cross-browser compatible)
125
+ function wfu_addEventHandler(obj, evt, handler) {
126
+ if(obj.addEventListener) {
127
+ // W3C method
128
+ obj.addEventListener(evt, handler, false);
129
+ }
130
+ else if(obj.attachEvent) {
131
+ // IE method.
132
+ obj.attachEvent('on'+evt, handler);
133
+ }
134
+ else {
135
+ // Old school method.
136
+ obj['on'+evt] = handler;
137
+ }
138
+ }
139
+
140
+ //wfu_GetHttpRequestObject: function that returns XMLHttpRequest object for various browsers
141
+ function wfu_GetHttpRequestObject() {
142
+ var xhr = null;
143
+ try {
144
+ xhr = new XMLHttpRequest();
145
+ }
146
+ catch(e) {
147
+ try {
148
+ xhr = new ActiveXObject("Msxml2.XMLHTTP");
149
+ }
150
+ catch (e2) {
151
+ try {
152
+ xhr = new ActiveXObject("Microsoft.XMLHTTP");
153
+ }
154
+ catch (e) {}
155
+ }
156
+ }
157
+ if (xhr == null && window.createRequest) {
158
+ try {
159
+ xmlhttp = window.createRequest();
160
+ }
161
+ catch (e) {}
162
+ }
163
+ return xhr;
164
+ }
165
+
166
+ //wfu_filedetails_showhide: function to show or hide file messages
167
+ function wfu_filedetails_showhide(sid, fileid, show) {
168
+ var item1 = document.getElementById('wfu_messageblock_arrow_' + sid + '_' + fileid);
169
+ var item2 = document.getElementById('wfu_messageblock_arrow_' + sid + '_up_' + fileid);
170
+ var item3 = document.getElementById('wfu_messageblock_arrow_' + sid + '_down_' + fileid);
171
+ var item4 = document.getElementById('wfu_messageblock_subheader_' + sid + '_' + fileid);
172
+ var item5 = document.getElementById('wfu_messageblock_header_' + sid + '_state_' + fileid);
173
+ if (show) {
174
+ item2.style.display = "";
175
+ item3.style.display = "none";
176
+ item4.style.display = "";
177
+ item5.value = "";
178
+ }
179
+ else {
180
+ item2.style.display = "none";
181
+ item3.style.display = "";
182
+ item4.style.display = "none";
183
+ item5.value = "none";
184
+ }
185
+ }
186
+
187
+ //wfu_get_file_ids: function to get an array with ids of files already uploaded
188
+ function wfu_get_file_ids(sid) {
189
+ var message_table = document.getElementById('wfu_messageblock_' + sid);
190
+ var next_block = document.getElementById('wfu_messageblock_subheader_' + sid).nextSibling;
191
+ var prefix = 'wfu_messageblock_' + sid + '_';
192
+ var file_ids = [];
193
+ while (next_block != null) {
194
+ if (next_block.nodeType === 1 && next_block.id.substr(0, prefix.length) == prefix)
195
+ file_ids.push(next_block.id.substr(next_block.id.lastIndexOf("_") + 1));
196
+ next_block = next_block.nextSibling;
197
+ }
198
+ return file_ids;
199
+ }
200
+
201
+ //wfu_filedetails_toggle: function to toggle file messages visibility
202
+ function wfu_filedetails_toggle(sid, fileid) {
203
+ var item1 = document.getElementById('wfu_messageblock_arrow_' + sid + '_' + fileid);
204
+ var item2 = document.getElementById('wfu_messageblock_arrow_' + sid + '_up_' + fileid);
205
+ wfu_filedetails_showhide(sid, fileid, item2.style.display == "none");
206
+ }
207
+
208
+ //wfu_headerdetails_showhide: function to show or hide header messages and upload results for each uploaded file
209
+ function wfu_headerdetails_showhide(sid, show) {
210
+ var item1 = document.getElementById('wfu_messageblock_arrow_' + sid);
211
+ var item2 = document.getElementById('wfu_messageblock_arrow_' + sid + '_up');
212
+ var item3 = document.getElementById('wfu_messageblock_arrow_' + sid + '_down');
213
+ var item4 = document.getElementById('wfu_messageblock_subheader_' + sid);
214
+ var item5 = document.getElementById('wfu_messageblock_subheader_' + sid + '_message');
215
+ var item6 = document.getElementById('wfu_messageblock_subheader_' + sid + '_adminmessage');
216
+ var item7 = document.getElementById('wfu_messageblock_header_' + sid + '_state');
217
+ var file_ids = wfu_get_file_ids(sid);
218
+ if (show) {
219
+ item2.style.display = "";
220
+ item3.style.display = "none";
221
+ if ( item5.style.display != "none" || item6.style.display != "none" ) item4.style.display = "";
222
+ item7.value = "";
223
+ for (var i = 0; i < file_ids.length; i++) {
224
+ document.getElementById('wfu_messageblock_' + sid + '_' + file_ids[i]).style.display = "";
225
+ document.getElementById('wfu_messageblock_subheader_' + sid + '_' + file_ids[i]).style.display = document.getElementById('wfu_messageblock_header_' + sid + '_state_' + file_ids[i]).value;
226
+ }
227
+ }
228
+ else {
229
+ item2.style.display = "none";
230
+ item3.style.display = "";
231
+ item4.style.display = "none";
232
+ item7.value = "none";
233
+ for (var i = 0; i < file_ids.length; i++) {
234
+ document.getElementById('wfu_messageblock_' + sid + '_' + file_ids[i]).style.display = "none";
235
+ document.getElementById('wfu_messageblock_subheader_' + sid + '_' + file_ids[i]).style.display = "none";
236
+ }
237
+ }
238
+ }
239
+
240
+ //wfu_headerdetails_toggle: function to toggle header messages and file results visibility
241
+ function wfu_headerdetails_toggle(sid) {
242
+ var item1 = document.getElementById('wfu_messageblock_arrow_' + sid);
243
+ var item2 = document.getElementById('wfu_messageblock_arrow_' + sid + '_up');
244
+ wfu_headerdetails_showhide(sid, item2.style.display == "none");
245
+ }
246
+
247
+
248
+ //wfu_selectbutton_changed: function that executes when files have been selected
249
+ function wfu_selectbutton_changed(sid, usefilearray) {
250
+ //if browser cannot handle HTML5 AJAX requests then deactivate use of array to store uploaded files
251
+ if (!wfu_BrowserCaps.supportsAJAX || !wfu_BrowserCaps.supportsHTML5) usefilearray = 0;
252
+
253
+ var inputfile = document.getElementById("upfile_" + sid);
254
+ var farr = inputfile.files;
255
+ //fix in case files attribute is not supported
256
+ if (!farr) { if (inputfile.value) farr = [{name:inputfile.value}]; else farr = []; }
257
+ //update textbox with filename of the file to be uploaded
258
+ var ftext = document.getElementById("fileName_" + sid);
259
+ if (ftext) ftext.value = inputfile.value.replace(/c:\\fakepath\\/i, "");
260
+ //if use of array is possible to store filelist, then create it and append selected files
261
+ if (usefilearray == 1) {
262
+ if (typeof inputfile.filearray == "undefined") {
263
+ inputfile.filearray = Array();
264
+ }
265
+ for (var i = 0; i < farr.length; i++) {
266
+ inputfile.filearray.push(farr[i]);
267
+ }
268
+ }
269
+ }
270
+
271
+ //wfu_selectbutton_clicked: function that executes when select button is clicked
272
+ function wfu_selectbutton_clicked(sid) {
273
+ var message_container = document.getElementById("wordpress_file_upload_message_" + sid);
274
+ if (message_container) message_container.style.display = "none";
275
+ wfu_reset_message(sid);
276
+ document.getElementById("upfile_" + sid).value = "";
277
+ var ftext = document.getElementById("fileName_" + sid);
278
+ if (ftext) {
279
+ ftext.value = "";
280
+ ftext.className = "file_input_textbox";
281
+ }
282
+ }
283
+
284
+ //wfu_RunWPFileBaseHttpRequest: function to update WP-FileBase plugin
285
+ function wfu_RunWPFileBaseHttpRequest(filebaseurl) {
286
+ var xmlhttp = wfu_GetHttpRequestObject();
287
+ if (xmlhttp == null) {
288
+ //alternative way of sending GET request using IFRAME, in case AJAX is disabled
289
+ var i = document.createElement("iframe");
290
+ i.style.display = "none";
291
+ i.src = filebaseurl;
292
+ document.body.appendChild(i);
293
+ return;
294
+ }
295
+
296
+ xmlhttp.open("GET", filebaseurl, true);
297
+ xmlhttp.onreadystatechange=function() {
298
+ if (xmlhttp.readyState==4) {
299
+ }
300
+ }
301
+ xmlhttp.send(null);
302
+ }
303
+
304
+ //wfu_Redirect: function to redirect to another url
305
+ function wfu_Redirect(link) {
306
+ window.location = link;
307
+ }
308
+
309
+ //wfu_loadStrat: function to start upload of file
310
+ function wfu_loadStart(evt) {
311
+ }
312
+
313
+ //wfu_uploadProgress: function to update progress bar
314
+ function wfu_uploadProgress(evt) {
315
+ var sid = this.xhr.shortcode_id;
316
+ var percentComplete = 0;
317
+ var simplebar = document.getElementById('progressbar_' + sid + '_animation');
318
+ if (evt.lengthComputable) {
319
+ if (this.xhr.size != evt.total && evt.total > 0) this.xhr.size = evt.total;
320
+ if (simplebar) {
321
+ var total = 0;
322
+ var totalloaded = 0;
323
+ for (var i = 0; i < GlobalData[sid].xhrs.length; i++) {
324
+ total += GlobalData[sid].xhrs[i].size;
325
+ totalloaded += GlobalData[sid].xhrs[i].sizeloaded;
326
+ }
327
+ percentComplete = Math.round((totalloaded + evt.loaded - this.xhr.sizeloaded) * 100 / total);
328
+ simplebar.style.width = percentComplete.toString() + '%';
329
+ }
330
+ this.xhr.sizeloaded = evt.loaded;
331
+ }
332
+ else {
333
+ if (simplebar) simplebar.style.width = '0%';
334
+ }
335
+ }
336
+
337
+ /* wfu_notify_WPFilebase: function to notify WPFilebase plugin about file changes */
338
+ function wfu_notify_WPFilebase(url) {
339
+ wfu_RunWPFileBaseHttpRequest(url + "/wp-admin/tools.php?page=wpfilebase&action=sync&hash_sync=1");
340
+ //addition to support newer versions of WP-Filebase
341
+ wfu_RunWPFileBaseHttpRequest(url + "/wp-admin/admin.php?page=wpfilebase_manage&action=sync&hash_sync=1");
342
+ }
343
+
344
+ /* wfu_send_email_notification: function to send notification message as ajax request */
345
+ function wfu_send_email_notification(sid, unique_id, params_index, session_token, notify_only_filename_list, notify_target_path_list, notify_attachment_list, debugmode, is_admin) {
346
+ var xhr = wfu_GetHttpRequestObject();
347
+ if (xhr == null) {
348
+ // error sending email
349
+ return;
350
+ }
351
+
352
+ var url = GlobalData.consts.ajax_url;
353
+ var userdata_count = wfu_get_userdata_count(sid);
354
+ params = new Array(7 + userdata_count);
355
+ params[0] = new Array(2);
356
+ params[0][0] = 'action';
357
+ params[0][1] = 'wfu_ajax_action_send_email_notification';
358
+ params[1] = new Array(2);
359
+ params[1][0] = 'params_index';
360
+ params[1][1] = params_index;
361
+ params[2] = new Array(2);
362
+ params[2][0] = 'session_token';
363
+ params[2][1] = session_token;
364
+ params[3] = new Array(2);
365
+ params[3][0] = 'only_filename_list';
366
+ params[3][1] = notify_only_filename_list;
367
+ params[4] = new Array(2);
368
+ params[4][0] = 'target_path_list';
369
+ params[4][1] = notify_target_path_list;
370
+ params[5] = new Array(2);
371
+ params[5][0] = 'attachment_list';
372
+ params[5][1] = notify_attachment_list;
373
+ params[6] = new Array(2);
374
+ params[6][0] = 'unique_id';
375
+ params[6][1] = unique_id;
376
+ for (var i = 0; i < userdata_count; i++) {
377
+ params[7 + i] = new Array(2);
378
+ params[7 + i][0] = 'userdata_' + i;
379
+ params[7 + i][1] = document.getElementById('hiddeninput_' + sid + '_userdata_' + i).value;
380
+ }
381
+
382
+ var parameters = '';
383
+ for (var i = 0; i < params.length; i++) {
384
+ parameters += (i > 0 ? "&" : "") + params[i][0] + "=" + encodeURI(params[i][1]);
385
+ }
386
+
387
+ var d = new Date();
388
+ xhr.shortcode_id = sid;
389
+ xhr.requesttype = "email";
390
+ xhr.file_id = 0;
391
+ xhr.unique_id = unique_id;
392
+ xhr.debugmode = debugmode;
393
+ xhr.is_admin = is_admin;
394
+ xhr.params_index = params_index;
395
+ xhr.session_token = session_token;
396
+ xhr.finish_time = d.getTime() + parseInt(GlobalData.consts.max_time_limit) * 1000;
397
+ xhr.fail_colors = GlobalData.consts.fail_colors;
398
+ xhr.error_message_header = "";
399
+ xhr.error_message_failed = GlobalData.consts.message_failed;
400
+ xhr.error_message_cancelled = GlobalData.consts.message_cancelled;
401
+ xhr.error_adminmessage_unknown = "";
402
+
403
+ xhr.open("POST", url, true);
404
+ xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
405
+ xhr.setRequestHeader("Content-length", parameters.length);
406
+ xhr.setRequestHeader("Connection", "close");
407
+ xhr.addEventListener("load", wfu_uploadComplete, false);
408
+ xhr.addEventListener("error", wfu_uploadFailed, false);
409
+ xhr.addEventListener("abort", wfu_uploadCanceled, false);
410
+
411
+ xhr.send(parameters);
412
+ }
413
+
414
+ //wfu_format_debug_data: function to format and prepare debug data for output
415
+ function wfu_format_debug_data(data, title) {
416
+ output = '<label class="file_messageblock_subheader_debugmessage_label">';
417
+ output += 'Debug Data' + title;
418
+ output += '</label>';
419
+ output += '<div class="file_messageblock_subheader_debugmessage_container">';
420
+ output += data;
421
+ output += '</div>';
422
+ return output;
423
+ }
424
+
425
+ //wfu_uploadComplete: function that is called after successfull file upload
426
+ function wfu_uploadComplete(evt) {
427
+ var sid = this.shortcode_id;
428
+ var i = this.file_id;
429
+ var last = false;
430
+ var upload_params = "";
431
+ var safe_params = "";
432
+ var debug_data = "";
433
+ var result_data = evt.target.responseText;
434
+ if (evt.target.responseText != -1) {
435
+ var txt = evt.target.responseText;
436
+ var success_txt = "wfu_fileupload_success:";
437
+ var pos = txt.indexOf(success_txt);
438
+ if ( pos > -1 ) {
439
+ if (this.debugmode == "true") debug_data = txt.substr(0, pos);
440
+ result_data = txt.substr(pos + success_txt.length);
441
+ pos = result_data.indexOf(":");
442
+ safe_params = result_data.substr(0, pos);
443
+ upload_params = result_data.substr(pos + 1);
444
+ }
445
+ if (debug_data != "") {
446
+ var title = "";
447
+ if (this.requesttype == "fileupload") title = ' - File: ' + this.file_id;
448
+ else if (this.requesttype == "email") title = ' - Email Notification';
449
+ debug_data = wfu_format_debug_data(debug_data, title);
450
+ }
451
+ }
452
+
453
+ if (upload_params == "" || safe_params == "") {
454
+ var error_colors = this.fail_colors.split(",");
455
+ var Params = wfu_Initialize_Params();
456
+ Params.general.shortcode_id = sid;
457
+ Params.general.unique_id = this.unique_id;
458
+ Params.general.state = 7;
459
+ Params.general.files_count = (this.requesttype == "fileupload") ? 1 : 0;
460
+ Params.general.upload_finish_time = this.finish_time;
461
+ Params.general.fail_message = GlobalData.consts.message_unknown;
462
+ Params.general.fail_admin_message = wfu_join_strings("<br />", this.error_adminmessage_unknown, this.requesttype + ":" + result_data);
463
+ if (Params.general.files_count > 0) {
464
+ Params[0] = {};
465
+ Params[0]['color'] = error_colors[0];
466
+ Params[0]['bgcolor'] = error_colors[1];
467
+ Params[0]['borcolor'] = error_colors[2];
468
+ Params[0]['message_type'] = "error";
469
+ Params[0]['header'] = this.error_message_header;
470
+ Params[0]['message'] = GlobalData.consts.message_timelimit;
471
+ Params[0]['admin_messages'] = this.is_admin == "true" ? GlobalData.consts.message_admin_timelimit : "";
472
+ }
473
+ else Params.general.admin_messages.other = this.is_admin == "true" ? GlobalData.consts.message_admin_timelimit : "";
474
+ //check if we have a failed upload probably due to exceeded upload time limit
475
+ if (Params.general.upload_finish_time > 0) {
476
+ var d = new Date();
477
+ if (d.getTime() < Params.general.upload_finish_time) {
478
+ if (Params.general.files_count > 0) {
479
+ Params[0]['message'] = Params.general.fail_message;
480
+ Params[0]['admin_messages'] = this.is_admin == "true" ? Params.general.fail_admin_message : "";
481
+ }
482
+ else Params.general.admin_messages.other = this.is_admin == "true" ? Params.general.fail_admin_message : "";
483
+ }
484
+ }
485
+ // note that upload_params is passed as object, so no need to pass a safe_output string
486
+ last = wfu_ProcessUploadComplete(sid, this.file_id, Params, this.unique_id, this.params_index, this.session_token, "", [this.debugmode, debug_data, this.is_admin]);
487
+ }
488
+ else {
489
+ last = wfu_ProcessUploadComplete(sid, this.file_id, upload_params, this.unique_id, this.params_index, this.session_token, safe_params, [this.debugmode, debug_data, this.is_admin]);
490
+ }
491
+ if (last) {
492
+ wfu_unlock_upload(evt.target.shortcode_id);
493
+ wfu_hide_simple_progressbar(sid);
494
+ wfu_clear(evt.target.shortcode_id);
495
+ }
496
+ }
497
+
498
+ //wfu_ProcessUploadComplete: function to perform actions after successfull upload
499
+ function wfu_ProcessUploadComplete(sid, file_id, upload_params, unique_id, params_index, session_token, safe_output, debug_data) {
500
+ //initial checks to process or not the data
501
+ if (!sid || sid < 0) return;
502
+ if (upload_params == null || upload_params == "") return;
503
+ if (unique_id == "") return;
504
+ if (unique_id != "no-ajax" && !GlobalData[sid]) return;
505
+
506
+ var do_redirect = false;
507
+
508
+ if (typeof upload_params === "string") {
509
+ upload_params = wfu_plugin_decode_string(upload_params.replace(/^\s+|\s+$/g,""));
510
+ var Params = null;
511
+ try { Params = JSON.parse(upload_params); }
512
+ catch(e) {}
513
+ if (Params == null) {
514
+ // JSON parse error that does not allow to read the parameters of the upload. The safe output string will be used in place.
515
+ var safe_parts = safe_output.split(";");
516
+ Params = wfu_Initialize_Params();
517
+ Params.general.shortcode_id = sid;
518
+ Params.general.unique_id = unique_id;
519
+ Params.general.state = safe_parts[0];
520
+ // upload state cannot be 4, because we have json warnings
521
+ if (Params.general.state == 4) Params.general.state++;
522
+ var default_colors = safe_parts[1].split(",");
523
+ var filedata = "";
524
+ var error_jsonparse_filemessage = GlobalData.consts.jsonparse_filemessage;
525
+ var error_jsonparse_message = GlobalData.consts.jsonparse_message;
526
+ var error_jsonparse_adminmessage = GlobalData.consts.jsonparse_adminmessage;
527
+ Params.general.files_count = parseInt(safe_parts[2]);
528
+ for (var i = 0; i < Params.general.files_count; i++) {
529
+ Params[i] = {};
530
+ Params[i]['color'] = default_colors[0];
531
+ Params[i]['bgcolor'] = default_colors[1];
532
+ Params[i]['borcolor'] = default_colors[2];
533
+ filedata = safe_parts[i + 3].split(",");
534
+ Params[i]['message_type'] = wfu_plugin_decode_string(filedata[0]);
535
+ Params[i]['header'] = wfu_plugin_decode_string(filedata[1]);
536
+ if (Params[i]['message_type'] == "success") {
537
+ Params[i]['header'] += error_jsonparse_filemessage;
538
+ Params[i]['message_type'] = "warning";
539
+ }
540
+ Params[i]['message'] = wfu_join_strings("<br />", error_jsonparse_message, wfu_plugin_decode_string(filedata[2]));
541
+ Params[i]['admin_messages'] = wfu_join_strings("<br />", error_jsonparse_adminmessage, wfu_plugin_decode_string(filedata[3]));
542
+ }
543
+ }
544
+ }
545
+ // include case for results returned straight as object in case of error or wait state
546
+ else if (typeof upload_params === "object") var Params = upload_params;
547
+ else return;
548
+
549
+ var message_table = document.getElementById('wfu_messageblock_' + sid);
550
+
551
+ // initialize UploadStates object, if not already initialized and if message box is activated
552
+ var UploadStates_Ok = true;
553
+ if (!UploadStates[sid] && message_table) {
554
+ var upload_states = document.getElementById('wfu_messageblock_header_' + sid + '_states').value;
555
+ upload_states = wfu_plugin_decode_string(upload_states.replace(/^\s+|\s+$/g,""));
556
+ UploadStates[sid] = null;
557
+ try { UploadStates[sid] = JSON.parse(upload_states); }
558
+ catch(e) {}
559
+ if (UploadStates[sid] == null) {
560
+ // JSON parse error that does not allow to show and style accordingly the header message. A generic JSON parse error message will be shown
561
+ UploadStates_Ok = false;
562
+ }
563
+ }
564
+
565
+ // pass upload parameters to GlobalData object, which is used to configure the message contents
566
+ if (!GlobalData[sid]) GlobalData[sid] = Object();
567
+ var G = GlobalData[sid];
568
+ // in case of no-ajax method, simply pass upload parameters to GlobalData object
569
+ if (unique_id == "no-ajax") {
570
+ G.last = false;
571
+ G.unique_id = "";
572
+ G.files_count = Params.general.files_count;
573
+ if (Params.general.state == 0) Params.general.files_count = 0;
574
+ G.files_processed = Params.general.files_count;
575
+ if (UploadStates_Ok) G.upload_state = Params.general.state;
576
+ // if UploadStates could not be parsed, then set header state to JSON error (state 10)
577
+ else G.upload_state = 10;
578
+ G.message = Params.general.message;
579
+ G.update_wpfilebase = Params.general.update_wpfilebase;
580
+ G.redirect_link = Params.general.redirect_link;
581
+ G.notify_only_filename_list = ""; //in the case of no-ajax method, email notification has already been executed by php, so it is suppressed here
582
+ G.notify_target_path_list = "";
583
+ G.notify_attachment_list = "";
584
+ G.admin_messages = {};
585
+ G.admin_messages.wpfilebase = Params.general.admin_messages.wpfilebase;
586
+ G.admin_messages.notify = Params.general.admin_messages.notify;
587
+ G.admin_messages.redirect = Params.general.admin_messages.redirect;
588
+ G.admin_messages.debug = debug_data[1];
589
+ G.admin_messages.other = Params.general.admin_messages.other;
590
+ G.errors = {};
591
+ G.errors.wpfilebase = Params.general.errors.wpfilebase;
592
+ G.errors.notify = Params.general.errors.notify;
593
+ G.errors.redirect = Params.general.errors.redirect;
594
+ G.current_size = 0;
595
+ G.total_size = 0;
596
+ }
597
+ else {
598
+ if (G.unique_id == "" || G.unique_id != unique_id || G.unique_id != Params.general.unique_id) return;
599
+ if (G.last) return;
600
+ var file_status = "";
601
+ for (var i = 0; i < Params.general.files_count; i++) {
602
+ // define new upload state based on the status of current file
603
+ if (Params[i].message_type == "error" && G.files_processed == 0) file_status = "error1";
604
+ else if (Params[i].message_type == "error" && G.files_processed > 0) file_status = "error2";
605
+ else file_status = Params[i].message_type;
606
+ G.upload_state = GlobalData.filestatematch[file_status][G.upload_state];
607
+ }
608
+ // if UploadStates could not be parsed, then set header state to JSON error (state 10)
609
+ if (!UploadStates_Ok) G.upload_state = 10;
610
+ G.files_processed += Params.general.files_count;
611
+ G.message = wfu_join_strings("<br />", G.message, Params.general.message);
612
+ if (G.update_wpfilebase == "") G.update_wpfilebase = Params.general.update_wpfilebase;
613
+ if (G.redirect_link == "") G.redirect_link = Params.general.redirect_link;
614
+ G.notify_only_filename_list = wfu_join_strings(", ", G.notify_only_filename_list, Params.general.notify_only_filename_list);
615
+ G.notify_target_path_list = wfu_join_strings(", ", G.notify_target_path_list, Params.general.notify_target_path_list);
616
+ G.notify_attachment_list = wfu_join_strings(",", G.notify_attachment_list, Params.general.notify_attachment_list);
617
+ G.admin_messages.debug = wfu_join_strings("<br />", G.admin_messages.debug, debug_data[1]);
618
+ G.admin_messages.other = wfu_join_strings("<br />", G.admin_messages.other, Params.general.admin_messages.other);
619
+ if (G.admin_messages.wpfilebase == "") G.admin_messages.wpfilebase = Params.general.admin_messages.wpfilebase;
620
+ if (G.admin_messages.notify == "") G.admin_messages.notify = Params.general.admin_messages.notify;
621
+ if (G.admin_messages.redirect == "") G.admin_messages.redirect = Params.general.admin_messages.redirect;
622
+ if (G.errors.wpfilebase == "") G.errors.wpfilebase = Params.general.errors.wpfilebase;
623
+ if (G.errors.notify == "") G.errors.notify = Params.general.errors.notify;
624
+ if (G.errors.redirect == "") G.errors.redirect = Params.general.errors.redirect;
625
+ }
626
+ // adjust upload parameters if this is the last combined call to this function
627
+ if (G.files_processed == G.files_count) {
628
+ G.last = true;
629
+
630
+ // prepare and execute actions related to WPFilebase, email notifications and redirection if this is the last call
631
+ if (G.update_wpfilebase != "") {
632
+ G.admin_messages.wpfilebase = "";
633
+ wfu_notify_WPFilebase(G.update_wpfilebase);
634
+ }
635
+ if (G.notify_only_filename_list != "") {
636
+ G.admin_messages.notify = "";
637
+ wfu_send_email_notification(sid, unique_id, params_index, session_token, G.notify_only_filename_list, G.notify_target_path_list, G.notify_attachment_list, debug_data[0], debug_data[2]);
638
+ // in email notification we declare that this is not the last call, because we wait for a last answer from email sending result
639
+ G.last = false;
640
+ G.notify_only_filename_list = ""; //reset this variable so that repetitive email messages are not sent
641
+ }
642
+ if (G.errors.redirect != "") G.redirect_link = "";
643
+ if (G.redirect_link != "") {
644
+ // if redirection is executed, then set upload state to redirecting...
645
+ G.upload_state = 11;
646
+ do_redirect = true;
647
+ // wfu_Redirect(G.redirect_link);
648
+ }
649
+ }
650
+
651
+ // last adjustment of header messages due to json parse error of UploadState or debug messages
652
+ var nonadmin_message = G.message;
653
+ var admin_message = wfu_join_strings("<br />",
654
+ G.admin_messages.other,
655
+ G.admin_messages.wpfilebase,
656
+ G.admin_messages.notify,
657
+ G.admin_messages.redirect,
658
+ G.admin_messages.debug);
659
+ if (!UploadStates_Ok) {
660
+ var error_jsonparse_headermessage = GlobalData.consts.jsonparse_headermessage;
661
+ var error_jsonparse_headeradminmessage = GlobalData.consts.jsonparse_headeradminmessage;
662
+ nonadmin_message = wfu_join_strings("<br />", error_jsonparse_headermessage, nonadmin_message);
663
+ admin_message = wfu_join_strings("<br />", error_jsonparse_headeradminmessage, admin_message);
664
+ }
665
+
666
+ if (G.last) {
667
+ // update upload state
668
+ if (G.files_count == 0) G.upload_state = 8;
669
+ else if (G.upload_state < 4) G.upload_state += 4;
670
+ // final adjust of upload state because admin messages may have been modified
671
+ var admin_messages_exist = (G.admin_messages.wpfilebase != "" || G.admin_messages.notify != "" || G.admin_messages.redirect != "" || G.admin_messages.other != "");
672
+ if (G.upload_state == 4 && admin_message != "") G.upload_state ++;
673
+ else if (G.upload_state == 5 && !admin_message == "" && nonadmin_message == "") G.upload_state --;
674
+ }
675
+
676
+ // if (typeof console != "undefined") {
677
+ // console.log(Params);
678
+ // var GG = G;
679
+ // console.log(GG);
680
+ // }
681
+
682
+ // section to update message box, executed only if message box is activated
683
+ if (message_table) {
684
+ var subheader_state = document.getElementById('wfu_messageblock_header_' + sid + '_state');
685
+ var single_file_shown = (G.files_count == 1 && nonadmin_message == "" && admin_message == "" && G.last && !do_redirect);
686
+ // adjust header if must be shown
687
+ if (single_file_shown) {
688
+ document.getElementById('wfu_messageblock_header_' + sid).style.display = "none";
689
+ }
690
+ else {
691
+ document.getElementById('wfu_messageblock_header_' + sid).style.display = "";
692
+ var header_container = document.getElementById('wfu_messageblock_header_' + sid + '_container');
693
+ if (UploadStates_Ok) {
694
+ var suffix = "";
695
+ if (G.files_count == 1 && (G.upload_state == 5 || G.upload_state == 7)) suffix = "_singlefile";
696
+ header_container.innerHTML = UploadStates[sid]["State" + G.upload_state + suffix];
697
+ }
698
+ else {
699
+ header_container.innerHTML = "";
700
+ var safe_container = document.getElementById('wfu_messageblock_header_' + sid + '_safecontainer');
701
+ header_container.innerHTML = safe_container.innerHTML.replace(/_safe/g, "");
702
+ }
703
+
704
+ // adjust subheader message
705
+ var subheader_show = false;
706
+ if (nonadmin_message != "") {
707
+ document.getElementById('wfu_messageblock_subheader_' + sid + '_message').style.display = "";
708
+ document.getElementById('wfu_messageblock_subheader_' + sid + '_messagelabel').innerHTML = nonadmin_message;
709
+ subheader_show = true;
710
+ }
711
+ else
712
+ document.getElementById('wfu_messageblock_subheader_' + sid + '_message').style.display = "none";
713
+
714
+ // adjust subheader admin message
715
+ if (admin_message != "") {
716
+ document.getElementById('wfu_messageblock_subheader_' + sid + '_adminmessage').style.display = "";
717
+ document.getElementById('wfu_messageblock_subheader_' + sid + '_adminmessagelabel').innerHTML = admin_message;
718
+ subheader_show = true;
719
+ }
720
+ else
721
+ document.getElementById('wfu_messageblock_subheader_' + sid + '_adminmessage').style.display = "none";
722
+
723
+ // adjust subheader
724
+ if (subheader_show)
725
+ document.getElementById('wfu_messageblock_subheader_' + sid).style.display = subheader_state.value;
726
+ else
727
+ document.getElementById('wfu_messageblock_subheader_' + sid).style.display = "none";
728
+
729
+ // adjust header arrow
730
+ if (subheader_show || G.files_processed > 0) {
731
+ header_container.colSpan = 2;
732
+ document.getElementById('wfu_messageblock_arrow_' + sid).style.display = "";
733
+ }
734
+ else {
735
+ document.getElementById('wfu_messageblock_arrow_' + sid).style.display = "none";
736
+ header_container.colSpan = 3;
737
+ }
738
+ }
739
+ var next_block = document.getElementById('wfu_messageblock_subheader_' + sid);
740
+ var next_block_id = 0;
741
+
742
+ // insert file blocks
743
+ var file_block = null;
744
+ var file_template_container = document.getElementById('wfu_messageblock_' + sid + '_filetemplate');
745
+ var file_contents = "";
746
+ var door = document.getElementById('wfu_messageblock_' + sid + '_door');
747
+ var ii = 0;
748
+ var headerspan = 1;
749
+ var subheaderspan = 2;
750
+ var file_template = wfu_plugin_decode_string(file_template_container.value.replace(/^\s+|\s+$/g,""));
751
+ for (var i = 0; i < Params.general.files_count; i++) {
752
+ ii = i + file_id;
753
+ // replace template variables with file data
754
+ file_contents = file_template.replace(/\[file_id\]/g, ii);
755
+ file_contents = file_contents.replace(/\[filenumber_display\]/g, "");
756
+ file_contents = file_contents.replace(/\[fileheader_color\]/g, Params[i].color);
757
+ file_contents = file_contents.replace(/\[fileheader_bgcolor\]/g, Params[i].bgcolor);
758
+ file_contents = file_contents.replace(/\[fileheader_borcolor\]/g, Params[i].borcolor);
759
+ file_contents = file_contents.replace(/\[fileheader_message\]/g, Params[i].header);
760
+ file_contents = file_contents.replace(/\[filesubheadermessage_display\]/g, "style=\"display:none;\"");
761
+ file_contents = file_contents.replace(/\[filesubheader_message\]/g, Params[i].message);
762
+ file_contents = file_contents.replace(/\[filesubheaderadminmessage_display\]/g, "style=\"display:none;\"");
763
+ file_contents = file_contents.replace(/\[filesubheader_adminmessage\]/g, Params[i].admin_messages);
764
+ // put file contents to temp div element to convert them to HTML elements
765
+ file_contents = "<table><tbody>" + file_contents + "</tbody></table>"; //IE6 fix: door is a div element so that innerHTML is writable
766
+ door.innerHTML = file_contents;
767
+ // post process created file block to adjust visibility of its contents
768
+ headerspan = 1;
769
+ subheaderspan = 2;
770
+ subheader_show = false;
771
+ file_block = document.getElementById('wfu_messageblock_' + sid + '_' + ii);
772
+ if (G.files_count == 1) {
773
+ document.getElementById('wfu_messageblock_' + sid + '_filenumber_' + ii).style.display = "none";
774
+ document.getElementById('wfu_messageblock_subheader_' + sid + '_fileempty_' + ii).style.display = "none";
775
+ if (single_file_shown) file_block.style.display = "";
776
+ else file_block.style.display = subheader_state.value;
777
+ headerspan ++;
778
+ subheaderspan ++;
779
+ }
780
+ else file_block.style.display = subheader_state.value;
781
+ if (Params[i].message != "") {
782
+ document.getElementById('wfu_messageblock_subheader_' + sid + '_message_' + ii).style.display = "";
783
+ subheader_show = true;
784
+ }
785
+ if (Params[i].admin_messages != "") {
786
+ document.getElementById('wfu_messageblock_subheader_' + sid + '_adminmessage_' + ii).style.display = "";
787
+ subheader_show = true;
788
+ }
789
+ if (!subheader_show) {
790
+ document.getElementById('wfu_messageblock_arrow_' + sid + '_' + ii).style.display = "none";
791
+ headerspan ++;
792
+ }
793
+ document.getElementById('wfu_messageblock_header_' + sid + '_container_' + ii).colSpan = headerspan;
794
+ document.getElementById('wfu_messageblock_subheader_' + sid + '_container_' + ii).colSpan = subheaderspan;
795
+ // move file block inside message block
796
+ while (next_block_id < ii) {
797
+ next_block = next_block.nextSibling;
798
+ if (next_block == null) break;
799
+ if (next_block.nodeType === 1) next_block_id = next_block.id.substr(next_block.id.lastIndexOf("_") + 1);
800
+ }
801
+ message_table.tBodies[0].insertBefore(file_block, next_block);
802
+ next_block = file_block.nextSibling;
803
+ file_block = document.getElementById('wfu_messageblock_subheader_' + sid + '_' + ii);
804
+ message_table.tBodies[0].insertBefore(file_block, next_block);
805
+ next_block = file_block;
806
+ next_block_id = ii;
807
+ }
808
+ if (single_file_shown) document.getElementById('wfu_messageblock_' + sid + '_1').style.display = "";
809
+ message_table.style.display = "";
810
+ document.getElementById('wordpress_file_upload_message_' + sid).style.display = "";
811
+ }
812
+ if (do_redirect) wfu_Redirect(G.redirect_link);
813
+
814
+ return G.last;
815
+ }
816
+
817
+ //wfu_uploadFailed: function that is called if uploading fails
818
+ function wfu_uploadFailed(evt) {
819
+ // alert(this.error_message_failed);
820
+ }
821
+
822
+ //wfu_uploadCanceled: function that is called if uploading is cancelled
823
+ function wfu_uploadCanceled(evt) {
824
+ // alert(this.error_message_cancelled);
825
+ }
826
+
827
+ //wfu_Initialize_Params: function that creates an object with default parameters used for generation of message box
828
+ function wfu_Initialize_Params() {
829
+ var params = {};
830
+ params.version = "full";
831
+ params.general = {};
832
+ params.general.shortcode_id = 0;
833
+ params.general.unique_id = "";
834
+ params.general.state = 0;
835
+ params.general.files_count = 0;
836
+ params.general.update_wpfilebase = "";
837
+ params.general.redirect_link = "";
838
+ params.general.upload_finish_time = 0;
839
+ params.general.message = "";
840
+ params.general.message_type = "";
841
+ params.general.admin_messages = {};
842
+ params.general.admin_messages.wpfilebase = "";
843
+ params.general.admin_messages.notify = "";
844
+ params.general.admin_messages.redirect = "";
845
+ params.general.admin_messages.other = "";
846
+ params.general.errors = {};
847
+ params.general.errors.wpfilebase = "";
848
+ params.general.errors.notify = "";
849
+ params.general.errors.redirect = "";
850
+ params.general.color = "";
851
+ params.general.bgcolor = "";
852
+ params.general.borcolor = "";
853
+ params.general.notify_only_filename_list = "";
854
+ params.general.notify_target_path_list = "";
855
+ params.general.notify_attachment_list = "";
856
+ params.general.fail_message = "";
857
+ params.general.fail_admin_message = "";
858
+
859
+ return params;
860
+ }
861
+
862
+ //wfu_redirect_to_classic: function that switches to classic functionality (HTML upload form) if HTML5 is not supported
863
+ function wfu_redirect_to_classic(sid, session_token, flag, adminerrorcode) {
864
+
865
+ //check if file has been selected or not
866
+ if (wfu_filesselected(sid) == 0) return;
867
+
868
+ // check if there are empty user data fields that are required
869
+ if (!wfu_check_required_userdata(sid)) return;
870
+
871
+ wfu_redirect_to_classic_cont(sid, session_token, flag, adminerrorcode, [""]);
872
+ }
873
+
874
+ //wfu_redirect_to_classic_cont: function thatinforms the page to process the file after reloading, informs the page if this is a redirection from HTML5 to classic functionality and submits the file
875
+ function wfu_redirect_to_classic_cont(sid, session_token, flag, adminerrorcode, other_params) {
876
+ var process_function = function(responseText) {
877
+ if (responseText.indexOf("wfu_response_success:") > -1) {
878
+ // show message in wait for upload state
879
+ var Params = wfu_Initialize_Params();
880
+ Params.general.shortcode_id = sid;
881
+ Params.general.unique_id = "";
882
+ Params.general.files_count = wfu_filesselected(sid);
883
+ wfu_ProcessUploadComplete(sid, 0, Params, "no-ajax", "", session_token, "", ["false", "", "false"]);
884
+
885
+ if (flag == 1) {
886
+ var suffice = "";
887
+ document.getElementById('upfile_' + sid).name = 'uploadedfile_' + sid + '_redirected' + suffice;
888
+ }
889
+ if (adminerrorcode > 0) document.getElementById('adminerrorcodes_' + sid).value = adminerrorcode;
890
+ else document.getElementById('adminerrorcodes_' + sid).value = "";
891
+ document.getElementById('upfile_' + sid).disabled = false;
892
+ document.getElementById('uploadform_' + sid).submit();
893
+ }
894
+ }
895
+
896
+ var pass_params = "";
897
+ var d = new Date();
898
+ var url = GlobalData.consts.response_url + "?shortcode_id=" + sid + "&start_time=" + d.getTime() + "&session_token=" + session_token + pass_params;
899
+
900
+ // disable controls
901
+ wfu_lock_upload(sid);
902
+
903
+ //dispatch of GET request using AJAX asynchronous call
904
+ var xmlhttp = wfu_GetHttpRequestObject();
905
+ if (xmlhttp == null) {
906
+ //alternative way of sending GET request using IFRAME, in case AJAX is disabled
907
+ var i = document.createElement("iframe");
908
+ if (i) {
909
+ i.style.display = "none";
910
+ i.src = url;
911
+ document.body.appendChild(i);
912
+ i.onload = function() {
913
+ process_function(i.contentDocument.body.innerHTML);
914
+ }
915
+ return;
916
+ }
917
+ else {
918
+ return;
919
+ }
920
+ }
921
+
922
+ xmlhttp.open("GET", url, true);
923
+ xmlhttp.onreadystatechange=function() {
924
+ if (xmlhttp.readyState==4) {
925
+ if ( xmlhttp.status == 200 ) {
926
+ process_function(xmlhttp.responseText);
927
+ }
928
+ }
929
+ }
930
+ xmlhttp.send(null);
931
+ }
932
+
933
+
934
+ function wfu_filesselected(sid) {
935
+ var inputfile = document.getElementById("upfile_" + sid);
936
+ var ftext = document.getElementById("fileName_" + sid);
937
+ var farr = inputfile.files;
938
+ //fix in case files attribute is not supported
939
+ if (!farr) { if (inputfile.value) farr = [{name:inputfile.value}]; else farr = []; }
940
+ if (typeof inputfile.filearray != "undefined") farr = inputfile.filearray;
941
+
942
+ if (farr.length == 0) {
943
+ if (ftext) {
944
+ ftext.value = GlobalData.consts.nofilemessage;
945
+ ftext.className = "file_input_textbox_nofile";
946
+ }
947
+ }
948
+ return farr.length;
949
+ }
950
+
951
+ //wfu_check_required_userdata: check if there are required user fields that are empty
952
+ function wfu_check_required_userdata(sid) {
953
+ var userdata_count = wfu_get_userdata_count(sid);
954
+ var req_empty = false;
955
+ for (var i = 0; i < userdata_count; i++) {
956
+ var msg_hid = document.getElementById('hiddeninput_' + sid + '_userdata_' + i);
957
+ var msg = document.getElementById('userdata_' + sid + '_message_' + i);
958
+ var req_class = "file_userdata_message_required";
959
+ if (msg.className.substr(0, req_class.length) == req_class && msg_hid.value == "") {
960
+ msg.className = req_class + "_empty";
961
+ msg.value = GlobalData.consts.userdata_empty;
962
+ req_empty = true;
963
+ }
964
+ }
965
+ return !req_empty;
966
+ }
967
+
968
+ //wfu_HTML5UploadFile: function that is called if the plugin is not using classic functionality
969
+ function wfu_HTML5UploadFile(sid, JSONtext, session_token) {
970
+ //redirect to classic if AJAX is not supported
971
+ if (!wfu_BrowserCaps.supportsAJAX) {
972
+ wfu_redirect_to_classic(sid, session_token, 1, 1);
973
+ return;
974
+ }
975
+ //redirect to classic if HTML5 is not supported
976
+ if (!wfu_BrowserCaps.supportsHTML5) {
977
+ wfu_redirect_to_classic(sid, session_token, 1, 2);
978
+ return;
979
+ }
980
+ //get plugin params and redirect to classic if JSON decoding fails
981
+ JSONtext = wfu_plugin_decode_string(JSONtext.replace(/^\s+|\s+$/g,""));
982
+ var JSONobj = null;
983
+ try {
984
+ JSONobj = JSON.parse(JSONtext);
985
+ }
986
+ catch(e) {}
987
+ if (JSONobj == null) {
988
+ wfu_redirect_to_classic(sid, session_token, 1, 3);
989
+ return;
990
+ }
991
+ var xhr = wfu_GetHttpRequestObject();
992
+ if (xhr == null) return;
993
+
994
+ //check if file has been selected or not
995
+ var numfiles = wfu_filesselected(sid);
996
+ if (numfiles == 0) return;
997
+
998
+
999
+ // check if there are empty user data fields that are required
1000
+ if (!wfu_check_required_userdata(sid)) return;
1001
+
1002
+ wfu_HTML5UploadFile_cont(sid, JSONobj, session_token, [""]);
1003
+ }
1004
+
1005
+ function wfu_HTML5UploadFile_cont(sid, JSONobj, session_token, other_params) {
1006
+ function sendfile(ind, file) {
1007
+ // initialise AJAX and FormData objects
1008
+ var xhr = wfu_GetHttpRequestObject();
1009
+ if (xhr == null) return;
1010
+ var fd = null;
1011
+ try {
1012
+ var fd = new FormData();
1013
+ }
1014
+ catch(e) {}
1015
+ if (fd == null) return;
1016
+
1017
+ // define POST parameters
1018
+ fd.append("uploadedfile_" + sid + suffice, file);
1019
+ fd.append("action", "wfu_ajax_action");
1020
+ fd.append("params_index", JSONobj.params_index);
1021
+ fd.append("subdir_sel_index", subdir_sel_index);
1022
+ fd.append("session_token", session_token);
1023
+ fd.append("unique_id", rand_str);
1024
+ var userdata_count = wfu_get_userdata_count(sid);
1025
+ for (var ii = 0; ii < userdata_count; ii++)
1026
+ fd.append("hiddeninput_" + sid + "_userdata_" + ii, document.getElementById('hiddeninput_' + sid + '_userdata_' + ii).value);
1027
+
1028
+ // define variables
1029
+ GlobalData[sid].xhrs.push(xhr);
1030
+ var d = new Date();
1031
+ xhr.shortcode_id = sid;
1032
+ xhr.requesttype = "fileupload";
1033
+ xhr.file_id = ind + 1;
1034
+ xhr.size = file.size;
1035
+ xhr.sizeloaded = 0;
1036
+ xhr.unique_id = rand_str;
1037
+ xhr.params_index = JSONobj.params_index;
1038
+ xhr.session_token = session_token;
1039
+ xhr.debugmode = JSONobj.debugmode;
1040
+ xhr.is_admin = JSONobj.is_admin;
1041
+ xhr.finish_time = d.getTime() + parseInt(GlobalData.consts.max_time_limit) * 1000;
1042
+ xhr.fail_colors = JSONobj.fail_colors;
1043
+ xhr.error_message_header = GlobalData.consts.message_header.replace(/%username%/g, "no data");
1044
+ xhr.error_message_header = xhr.error_message_header.replace(/%useremail%/g, "no data");
1045
+ xhr.error_message_header = xhr.error_message_header.replace(/%filename%/g, file.name);
1046
+ xhr.error_message_header = xhr.error_message_header.replace(/%filepath%/g, file.name);
1047
+ xhr.error_message_failed = GlobalData.consts.message_failed;
1048
+ xhr.error_message_cancelled = GlobalData.consts.message_cancelled;
1049
+ xhr.error_adminmessage_unknown = GlobalData.consts.adminmessage_unknown.replace(/%username%/g, "no data");
1050
+ xhr.error_adminmessage_unknown = xhr.error_adminmessage_unknown.replace(/%useremail%/g, "no data");
1051
+ xhr.error_adminmessage_unknown = xhr.error_adminmessage_unknown.replace(/%filename%/g, file.name);
1052
+ xhr.error_adminmessage_unknown = xhr.error_adminmessage_unknown.replace(/%filepath%/g, file.name);
1053
+
1054
+ xhr.upload.xhr = xhr;
1055
+
1056
+ // event listeners
1057
+ xhr.upload.addEventListener("loadstart", wfu_loadStart, false);
1058
+ xhr.upload.addEventListener("progress", wfu_uploadProgress, false);
1059
+ xhr.addEventListener("load", wfu_uploadComplete, false);
1060
+ xhr.addEventListener("error", wfu_uploadFailed, false);
1061
+ xhr.addEventListener("abort", wfu_uploadCanceled, false);
1062
+
1063
+ xhr.open("POST", GlobalData.consts.ajax_url);
1064
+ xhr.send(fd);
1065
+ inc ++;
1066
+ }
1067
+ // get index of subdirectory if subdirectory dropdown list is activated
1068
+ var subdir_sel_index = -1;
1069
+ if (document.getElementById('selectsubdir_' + sid) != null)
1070
+ subdir_sel_index = document.getElementById('selectsubdir_' + sid).selectedIndex;
1071
+
1072
+ // get file list
1073
+ var inputfile = document.getElementById("upfile_" + sid);
1074
+ var farr = inputfile.files;
1075
+ //fix in case files attribute is not supported
1076
+ if (!farr) { if (inputfile.value) farr = [{name:inputfile.value}]; else farr = []; }
1077
+ if (typeof inputfile.filearray != "undefined") farr = inputfile.filearray;
1078
+ var suffice = "";
1079
+ /* initialize global object to hold dynamic upload status during upload */
1080
+ var rand_str = wfu_randomString(10);
1081
+ GlobalData[sid] = {};
1082
+ GlobalData[sid].unique_id = rand_str;
1083
+ GlobalData[sid].last = false;
1084
+ GlobalData[sid].files_count = farr.length;
1085
+ GlobalData[sid].files_processed = 0;
1086
+ GlobalData[sid].upload_state = 0;
1087
+ GlobalData[sid].message = "";
1088
+ GlobalData[sid].update_wpfilebase = "";
1089
+ GlobalData[sid].redirect_link = "";
1090
+ GlobalData[sid].notify_only_filename_list = "";
1091
+ GlobalData[sid].notify_target_path_list = "";
1092
+ GlobalData[sid].notify_attachment_list = "";
1093
+ GlobalData[sid].admin_messages = {};
1094
+ GlobalData[sid].admin_messages.wpfilebase = "";
1095
+ GlobalData[sid].admin_messages.notify = "";
1096
+ GlobalData[sid].admin_messages.redirect = "";
1097
+ GlobalData[sid].admin_messages.debug = "";
1098
+ GlobalData[sid].admin_messages.other = "";
1099
+ GlobalData[sid].errors = {};
1100
+ GlobalData[sid].errors.wpfilebase = "";
1101
+ GlobalData[sid].errors.notify = "";
1102
+ GlobalData[sid].errors.redirect = "";
1103
+ GlobalData[sid].xhrs = Array();
1104
+
1105
+ wfu_show_simple_progressbar(JSONobj.shortcode_id, "progressive");
1106
+
1107
+ // show message in wait for upload state
1108
+ var Params = wfu_Initialize_Params();
1109
+ Params.general.shortcode_id = sid;
1110
+ Params.general.unique_id = rand_str;
1111
+ wfu_ProcessUploadComplete(sid, 0, Params, rand_str, JSONobj.params_index, session_token, "", ["false", "", "false"]);
1112
+
1113
+ var inc = 0;
1114
+ for (var i = 0; i < farr.length; i++) {
1115
+ sendfile(i, farr[i]);
1116
+ }
1117
+ }
1118
+
1119
+ //wfu_get_userdata_count: get number of userdata fields
1120
+ function wfu_get_userdata_count(sid) {
1121
+ var fields_count = 0;
1122
+ while (document.getElementById('userdata_' + sid + '_' + fields_count)) fields_count ++;
1123
+ return fields_count;
1124
+ }
1125
+
1126
+ function wfu_lock_upload(sid) {
1127
+ var textbox = document.getElementById('fileName_' + sid);
1128
+ if (textbox) textbox.disabled = true;
1129
+ document.getElementById('input_' + sid).disabled = true;
1130
+ document.getElementById('upfile_' + sid).disabled = true;
1131
+ var subdir = document.getElementById('selectsubdir_' + sid);
1132
+ if (subdir) subdir.disabled = true;
1133
+ var upload = document.getElementById('upload_' + sid);
1134
+ if (upload) upload.disabled = true;
1135
+ var userdata_count = wfu_get_userdata_count(sid);
1136
+ for (var i = 0; i < userdata_count; i++)
1137
+ document.getElementById('userdata_' + sid + '_message_' + i).disabled = true;
1138
+ }
1139
+
1140
+ function wfu_unlock_upload(sid) {
1141
+ var textbox = document.getElementById('fileName_' + sid);
1142
+ if (textbox) textbox.disabled = false;
1143
+ document.getElementById('input_' + sid).disabled = false;
1144
+ document.getElementById('upfile_' + sid).disabled = false;
1145
+ var subdir = document.getElementById('selectsubdir_' + sid);
1146
+ if (subdir) subdir.disabled = false;
1147
+ var upload = document.getElementById('upload_' + sid);
1148
+ if (upload) upload.disabled = false;
1149
+ var userdata_count = wfu_get_userdata_count(sid);
1150
+ for (var i = 0; i < userdata_count; i++)
1151
+ document.getElementById('userdata_' + sid + '_message_' + i).disabled = false;
1152
+ }
1153
+
1154
+ function wfu_clear(sid) {
1155
+ var textbox = document.getElementById('fileName_' + sid);
1156
+ if (textbox) {
1157
+ textbox.value = '';
1158
+ textbox.className = 'file_input_textbox';
1159
+ }
1160
+ var subdir = document.getElementById('selectsubdir_' + sid);
1161
+ if (subdir) subdir.selectedIndex = 0;
1162
+ var userdata_count = wfu_get_userdata_count(sid);
1163
+ for (var i = 0; i < userdata_count; i++) {
1164
+ document.getElementById('userdata_' + sid + '_message_' + i).value = "";
1165
+ document.getElementById('hiddeninput_' + sid + '_userdata_' + i).value = "";
1166
+ }
1167
+ }
1168
+
1169
+ function wfu_reset_message(sid) {
1170
+ var message_table = document.getElementById('wfu_messageblock_' + sid);
1171
+ if (message_table) {
1172
+ // reset header
1173
+ document.getElementById('wfu_messageblock_header_' + sid).style.display = "";
1174
+ var header_container = document.getElementById('wfu_messageblock_header_' + sid + '_container');
1175
+ if (UploadStates[sid]) header_container.innerHTML = UploadStates[sid]["State0"];
1176
+ document.getElementById('wfu_messageblock_header_' + sid + '_state').value = "none";
1177
+ document.getElementById('wfu_messageblock_arrow_' + sid).style.display = "none";
1178
+ header_container.colSpan = 3;
1179
+ // reset subheader
1180
+ document.getElementById('wfu_messageblock_subheader_' + sid + '_messagelabel').innerHTML = "";
1181
+ document.getElementById('wfu_messageblock_subheader_' + sid + '_adminmessagelabel').innerHTML = "";
1182
+ document.getElementById('wfu_messageblock_subheader_' + sid).style.display = "none";
1183
+ document.getElementById('wfu_messageblock_subheader_' + sid + '_message').style.display = "none";
1184
+ document.getElementById('wfu_messageblock_subheader_' + sid + '_adminmessage').style.display = "none";
1185
+ // reset files
1186
+ var file_array = wfu_get_file_ids(sid);
1187
+ for (var i = 1; i <= file_array.length; i++) {
1188
+ message_table.tBodies[0].removeChild(document.getElementById('wfu_messageblock_' + sid + '_' + i));
1189
+ message_table.tBodies[0].removeChild(document.getElementById('wfu_messageblock_subheader_' + sid + '_' + i));
1190
+ }
1191
+ }
1192
+ }
1193
+
1194
+
1195
+ function wfu_show_simple_progressbar(sid, effect) {
1196
+ var bar = document.getElementById('progressbar_' + sid + '_animation');
1197
+ var barsafe = document.getElementById('progressbar_' + sid + '_imagesafe');
1198
+ if (bar) {
1199
+ if (effect == "progressive") {
1200
+ bar.style.width = "0%";
1201
+ bar.className = "file_progress_progressive";
1202
+ barsafe.style.display = "none";
1203
+ bar.style.display = "block";
1204
+ }
1205
+ else if (wfu_BrowserCaps.supportsAnimation) {
1206
+ bar.style.width = "25%";
1207
+ bar.className = "file_progress_shuffle";
1208
+ barsafe.style.display = "none";
1209
+ bar.style.display = "block";
1210
+ }
1211
+ else {
1212
+ bar.style.width = "0%";
1213
+ bar.className = "file_progress_noanimation";
1214
+ bar.style.display = "none";
1215
+ barsafe.style.display = "block";
1216
+ }
1217
+ document.getElementById('wordpress_file_upload_progressbar_' + sid).style.display = "block";
1218
+ }
1219
+ }
1220
+
1221
+ function wfu_hide_simple_progressbar(sid) {
1222
+ var bar = document.getElementById('progressbar_' + sid + '_animation');
1223
+ var barsafe = document.getElementById('progressbar_' + sid + '_imagesafe');
1224
+ if (bar) {
1225
+ document.getElementById('wordpress_file_upload_progressbar_' + sid).style.display = "none";
1226
+ bar.style.width = "0%";
1227
+ bar.className = "file_progress_noanimation";
1228
+ barsafe.style.display = "none";
1229
+ bar.style.display = "block";
1230
+ }
1231
+ }
1232
+
1233
+
languages/wordpress-file-upload.pot CHANGED
@@ -2,16 +2,18 @@ msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Wordpress File Upload\n"
4
  "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2014-01-10 00:16+0200\n"
6
- "PO-Revision-Date: 2014-01-10 00:16+0200\n"
7
  "Last-Translator: nickboss <info@iptanus.com>\n"
8
  "Language-Team: Iptanus Team <info@iptanus.com>\n"
9
- "Language: \n"
10
  "MIME-Version: 1.0\n"
11
  "Content-Type: text/plain; charset=UTF-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
13
  "X-Poedit-KeywordsList: __;gettext;gettext_noop\n"
14
  "X-Poedit-Basepath: ../\n"
 
 
15
  "X-Poedit-SearchPath-0: .\n"
16
 
17
  #: lib/wfu_constants.php:7
@@ -31,7 +33,9 @@ msgid "File Upload Notification"
31
  msgstr ""
32
 
33
  #: lib/wfu_constants.php:25
34
- msgid "Dear Recipient,%n%%n% This is an automatic delivery message to notify you that a new file has been uploaded.%n%%n%Best Regards"
 
 
35
  msgstr ""
36
 
37
  #: lib/wfu_constants.php:31
@@ -56,314 +60,362 @@ msgstr ""
56
  msgid "Your message"
57
  msgstr ""
58
 
59
- #: lib/wfu_constants.php:54
60
- msgid "Error. Could not resolve ftp target filedir. Check the domain in 'ftpinfo' attribute."
61
- msgstr ""
62
-
63
  #: lib/wfu_constants.php:55
64
- msgid "Error. Invalid ftp information. Check 'ftpinfo' attribute."
 
 
65
  msgstr ""
66
 
67
  #: lib/wfu_constants.php:56
68
- msgid "Error. Could not extract ftp information from 'ftpinfo' attribute. Check its syntax."
69
  msgstr ""
70
 
71
  #: lib/wfu_constants.php:57
72
- msgid "Error. Could not resolve ftp target filename. Check the domain in 'ftpinfo' attribute."
 
 
73
  msgstr ""
74
 
75
  #: lib/wfu_constants.php:58
76
  msgid ""
77
- "Error. The upload size limit of PHP directive upload_max_filesize is preventing the upload of big files.\n"
78
- "PHP directive upload_max_filesize limit is: "
79
  msgstr ""
80
 
81
  #: lib/wfu_constants.php:59
82
  msgid ""
83
- "The upload time limit of PHP directive max_input_time is preventing the upload of big files.\n"
84
- "PHP directive max_input_time limit is: "
 
85
  msgstr ""
86
 
87
  #: lib/wfu_constants.php:60
88
  msgid ""
89
- "Error. Permission denied to write to target folder.\n"
90
- "Check and correct read/write permissions of target folder."
 
91
  msgstr ""
92
 
93
  #: lib/wfu_constants.php:61
94
- msgid "Targer folder doesn't exist."
 
 
95
  msgstr ""
96
 
97
  #: lib/wfu_constants.php:62
98
- msgid "Upload failed! Missing a temporary folder."
99
  msgstr ""
100
 
101
  #: lib/wfu_constants.php:63
102
- msgid "Upload failed! Permission denied to write to target folder."
103
  msgstr ""
104
 
105
  #: lib/wfu_constants.php:64
106
- msgid "File not allowed."
107
  msgstr ""
108
 
109
  #: lib/wfu_constants.php:65
110
- msgid "The uploaded file exceeds the file size limit."
111
  msgstr ""
112
 
113
  #: lib/wfu_constants.php:66
114
- msgid "Upload failed! The uploaded file exceeds the file size limit of the server. Please contact the administrator."
115
  msgstr ""
116
 
117
  #: lib/wfu_constants.php:67
118
- msgid "Upload failed! The duration of the upload exceeded the time limit of the server. Please contact the administrator."
 
 
119
  msgstr ""
120
 
121
  #: lib/wfu_constants.php:68
122
- msgid "Upload failed! The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form."
 
 
123
  msgstr ""
124
 
125
  #: lib/wfu_constants.php:69
126
- msgid "Upload failed! The uploaded file was only partially uploaded."
 
 
127
  msgstr ""
128
 
129
  #: lib/wfu_constants.php:70
130
- msgid "Upload failed! No file was uploaded."
131
  msgstr ""
132
 
133
  #: lib/wfu_constants.php:71
134
- msgid "Upload failed! Failed to write file to disk."
135
  msgstr ""
136
 
137
  #: lib/wfu_constants.php:72
138
- msgid "Upload failed! Error occured while moving temporary file. Please contact administrator."
139
  msgstr ""
140
 
141
  #: lib/wfu_constants.php:73
142
- msgid "Upload failed! A PHP extension stopped the file upload. PHP does not provide a way to ascertain which extension caused the file upload to stop; examining the list of loaded extensions with phpinfo() may help."
 
 
143
  msgstr ""
144
 
145
  #: lib/wfu_constants.php:74
146
- msgid "Upload failed! Error occured while attemting to upload the file."
 
 
 
147
  msgstr ""
148
 
149
  #: lib/wfu_constants.php:75
150
- msgid "Upload failed!"
151
  msgstr ""
152
 
153
  #: lib/wfu_constants.php:76
154
- msgid "No file!"
155
  msgstr ""
156
 
157
  #: lib/wfu_constants.php:77
158
- msgid "Upload failed! The upload has been canceled by the user or the browser dropped the connection."
159
  msgstr ""
160
 
161
  #: lib/wfu_constants.php:78
162
- msgid "Upload failed! Unknown error."
 
 
163
  msgstr ""
164
 
165
  #: lib/wfu_constants.php:79
166
- msgid "Please contact the administrator."
167
  msgstr ""
168
 
169
  #: lib/wfu_constants.php:80
170
- msgid "No result from remote server!"
171
  msgstr ""
172
 
173
  #: lib/wfu_constants.php:81
174
- msgid " but with warnings"
175
  msgstr ""
176
 
177
  #: lib/wfu_constants.php:82
178
- #: lib/wfu_constants.php:84
179
- msgid "Warning: JSON parse error."
180
  msgstr ""
181
 
182
- #: lib/wfu_constants.php:83
183
- msgid "Upload parameters of this file, passed as JSON string to the handler, could not be parsed."
184
  msgstr ""
185
 
186
- #: lib/wfu_constants.php:85
187
- msgid "UploadStates, passed as JSON string to the handler, could not be parsed."
 
 
188
  msgstr ""
189
 
190
  #: lib/wfu_constants.php:86
191
- msgid "Redirection to classic form functionality occurred due to unknown error."
 
192
  msgstr ""
193
 
194
  #: lib/wfu_constants.php:87
195
- msgid "Redirection to classic form functionality occurred because AJAX is not supported."
 
196
  msgstr ""
197
 
198
  #: lib/wfu_constants.php:88
199
- msgid "Redirection to classic form functionality occurred because HTML5 is not supported."
 
 
200
  msgstr ""
201
 
202
  #: lib/wfu_constants.php:89
203
- msgid "Redirection to classic form functionality occurred due to JSON parse error."
 
 
204
  msgstr ""
205
 
206
  #: lib/wfu_constants.php:90
207
- msgid "cannot be empty!"
 
208
  msgstr ""
209
 
210
- #: lib/wfu_constants.php:93
211
- msgid "Upload skipped! File already exists."
212
  msgstr ""
213
 
214
  #: lib/wfu_constants.php:94
215
- msgid "No files have been selected!"
216
  msgstr ""
217
 
218
  #: lib/wfu_constants.php:95
219
- msgid "WPFilebase Plugin not updated because there were no files uploaded."
220
  msgstr ""
221
 
222
  #: lib/wfu_constants.php:96
223
- msgid "Notification email was not sent because there were no files uploaded."
224
  msgstr ""
225
 
226
  #: lib/wfu_constants.php:97
227
- msgid "Notification email was not sent because no recipients were defined. Please check notifyrecipients attribute in the shortcode."
228
  msgstr ""
229
 
230
  #: lib/wfu_constants.php:98
231
- msgid "Notification email was not sent due to an error. Please check notifyrecipients, notifysubject and notifymessage attributes for errors."
 
 
232
  msgstr ""
233
 
234
  #: lib/wfu_constants.php:99
235
- msgid "Redirection not executed because redirection link is empty. Please check redirectlink attribute."
 
 
236
  msgstr ""
237
 
238
  #: lib/wfu_constants.php:100
239
- msgid "Redirection not executed because not all files were successfully uploaded."
 
 
240
  msgstr ""
241
 
242
- #: lib/wfu_constants.php:103
243
- msgid "Test Mode"
 
244
  msgstr ""
245
 
246
  #: lib/wfu_constants.php:104
247
- msgid "Upload path: %filepath%"
248
  msgstr ""
249
 
250
  #: lib/wfu_constants.php:105
251
- msgid "Failed upload path: %filepath%"
252
  msgstr ""
253
 
254
- #: lib/wfu_constants.php:108
255
- msgid "This is a test message"
256
  msgstr ""
257
 
258
  #: lib/wfu_constants.php:109
259
- msgid "This is a test administrator message"
260
  msgstr ""
261
 
262
  #: lib/wfu_constants.php:110
263
- msgid "File testfile 1 under test"
264
  msgstr ""
265
 
266
  #: lib/wfu_constants.php:111
267
- msgid "File testfile 1 message"
268
  msgstr ""
269
 
270
  #: lib/wfu_constants.php:112
271
- msgid "File testfile 1 administrator message"
272
  msgstr ""
273
 
274
  #: lib/wfu_constants.php:113
275
- msgid "File testfile 2 under test"
276
  msgstr ""
277
 
278
  #: lib/wfu_constants.php:114
279
- msgid "File testfile 2 message"
280
  msgstr ""
281
 
282
  #: lib/wfu_constants.php:115
283
- msgid "File testfile 2 administrator message"
284
  msgstr ""
285
 
286
- #: lib/wfu_constants.php:118
287
- msgid "Insert variable %username% inside text. It will be replaced by the username of the current user."
288
  msgstr ""
289
 
290
  #: lib/wfu_constants.php:119
291
- msgid "Insert variable %useremail% inside text. It will be replaced by the email of the current user."
 
 
292
  msgstr ""
293
 
294
  #: lib/wfu_constants.php:120
295
- msgid "Insert variable %filename% inside text. It will be replaced by the filename of the uploaded file."
 
 
296
  msgstr ""
297
 
298
  #: lib/wfu_constants.php:121
299
- msgid "Insert variable %filepath% inside text. It will be replaced by the full filepath of the uploaded file."
 
 
300
  msgstr ""
301
 
302
  #: lib/wfu_constants.php:122
303
- msgid "Insert variable %blogid% inside text. It will be replaced by the blog id of the website."
 
 
304
  msgstr ""
305
 
306
  #: lib/wfu_constants.php:123
307
- msgid "Insert variable %userdataXXX% inside text. Select the user field from the drop-down list. It will be replaced by the value that the user entered in this field."
 
 
308
  msgstr ""
309
 
310
  #: lib/wfu_constants.php:124
 
 
 
 
 
 
 
311
  msgid "Insert variable %n% inside text to denote a line change."
312
  msgstr ""
313
 
314
- #: lib/wfu_constants.php:127
315
  msgid "Upload in progress"
316
  msgstr ""
317
 
318
- #: lib/wfu_constants.php:128
319
  msgid "Upload in progress with warnings!"
320
  msgstr ""
321
 
322
- #: lib/wfu_constants.php:129
323
  msgid "Upload in progress but some files already failed!"
324
  msgstr ""
325
 
326
- #: lib/wfu_constants.php:130
327
  msgid "Upload in progress but no files uploaded so far!"
328
  msgstr ""
329
 
330
- #: lib/wfu_constants.php:131
331
  msgid "All files uploaded successfully"
332
  msgstr ""
333
 
334
- #: lib/wfu_constants.php:132
335
  msgid "All files uploaded successfully but there are warnings!"
336
  msgstr ""
337
 
338
- #: lib/wfu_constants.php:133
339
  msgid "File uploaded successfully but there are warnings!"
340
  msgstr ""
341
 
342
- #: lib/wfu_constants.php:134
343
  msgid "Some files failed to upload!"
344
  msgstr ""
345
 
346
- #: lib/wfu_constants.php:135
347
  msgid "All files failed to upload"
348
  msgstr ""
349
 
350
- #: lib/wfu_constants.php:136
351
  msgid "File failed to upload"
352
  msgstr ""
353
 
354
- #: lib/wfu_constants.php:137
355
  msgid "There are no files to upload!"
356
  msgstr ""
357
 
358
- #: lib/wfu_constants.php:138
359
  msgid "Test upload message"
360
  msgstr ""
361
 
362
- #: lib/wfu_constants.php:139
363
  msgid "JSON parse warning!"
364
  msgstr ""
365
 
366
- #: lib/wfu_constants.php:140
367
  msgid "please wait while redirecting..."
368
  msgstr ""
369
-
2
  msgstr ""
3
  "Project-Id-Version: Wordpress File Upload\n"
4
  "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2014-01-26 12:49+0200\n"
6
+ "PO-Revision-Date: 2014-01-26 12:49+0200\n"
7
  "Last-Translator: nickboss <info@iptanus.com>\n"
8
  "Language-Team: Iptanus Team <info@iptanus.com>\n"
9
+ "Language: en\n"
10
  "MIME-Version: 1.0\n"
11
  "Content-Type: text/plain; charset=UTF-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
13
  "X-Poedit-KeywordsList: __;gettext;gettext_noop\n"
14
  "X-Poedit-Basepath: ../\n"
15
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
16
+ "X-Generator: Poedit 1.6.3\n"
17
  "X-Poedit-SearchPath-0: .\n"
18
 
19
  #: lib/wfu_constants.php:7
33
  msgstr ""
34
 
35
  #: lib/wfu_constants.php:25
36
+ msgid ""
37
+ "Dear Recipient,%n%%n% This is an automatic delivery message to notify you "
38
+ "that a new file has been uploaded.%n%%n%Best Regards"
39
  msgstr ""
40
 
41
  #: lib/wfu_constants.php:31
60
  msgid "Your message"
61
  msgstr ""
62
 
 
 
 
 
63
  #: lib/wfu_constants.php:55
64
+ msgid ""
65
+ "Error. Could not resolve ftp target filedir. Check the domain in 'ftpinfo' "
66
+ "attribute."
67
  msgstr ""
68
 
69
  #: lib/wfu_constants.php:56
70
+ msgid "Error. Invalid ftp information. Check 'ftpinfo' attribute."
71
  msgstr ""
72
 
73
  #: lib/wfu_constants.php:57
74
+ msgid ""
75
+ "Error. Could not extract ftp information from 'ftpinfo' attribute. Check its "
76
+ "syntax."
77
  msgstr ""
78
 
79
  #: lib/wfu_constants.php:58
80
  msgid ""
81
+ "Error. Could not resolve ftp target filename. Check the domain in 'ftpinfo' "
82
+ "attribute."
83
  msgstr ""
84
 
85
  #: lib/wfu_constants.php:59
86
  msgid ""
87
+ "Error. The upload size limit of PHP directive upload_max_filesize is "
88
+ "preventing the upload of big files.\n"
89
+ "PHP directive upload_max_filesize limit is: "
90
  msgstr ""
91
 
92
  #: lib/wfu_constants.php:60
93
  msgid ""
94
+ "The upload time limit of PHP directive max_input_time is preventing the "
95
+ "upload of big files.\n"
96
+ "PHP directive max_input_time limit is: "
97
  msgstr ""
98
 
99
  #: lib/wfu_constants.php:61
100
+ msgid ""
101
+ "Error. Permission denied to write to target folder.\n"
102
+ "Check and correct read/write permissions of target folder."
103
  msgstr ""
104
 
105
  #: lib/wfu_constants.php:62
106
+ msgid "Targer folder doesn't exist."
107
  msgstr ""
108
 
109
  #: lib/wfu_constants.php:63
110
+ msgid "Upload failed! Missing a temporary folder."
111
  msgstr ""
112
 
113
  #: lib/wfu_constants.php:64
114
+ msgid "Upload failed! Permission denied to write to target folder."
115
  msgstr ""
116
 
117
  #: lib/wfu_constants.php:65
118
+ msgid "File not allowed."
119
  msgstr ""
120
 
121
  #: lib/wfu_constants.php:66
122
+ msgid "The uploaded file exceeds the file size limit."
123
  msgstr ""
124
 
125
  #: lib/wfu_constants.php:67
126
+ msgid ""
127
+ "Upload failed! The uploaded file exceeds the file size limit of the server. "
128
+ "Please contact the administrator."
129
  msgstr ""
130
 
131
  #: lib/wfu_constants.php:68
132
+ msgid ""
133
+ "Upload failed! The duration of the upload exceeded the time limit of the "
134
+ "server. Please contact the administrator."
135
  msgstr ""
136
 
137
  #: lib/wfu_constants.php:69
138
+ msgid ""
139
+ "Upload failed! The uploaded file exceeds the MAX_FILE_SIZE directive that "
140
+ "was specified in the HTML form."
141
  msgstr ""
142
 
143
  #: lib/wfu_constants.php:70
144
+ msgid "Upload failed! The uploaded file was only partially uploaded."
145
  msgstr ""
146
 
147
  #: lib/wfu_constants.php:71
148
+ msgid "Upload failed! No file was uploaded."
149
  msgstr ""
150
 
151
  #: lib/wfu_constants.php:72
152
+ msgid "Upload failed! Failed to write file to disk."
153
  msgstr ""
154
 
155
  #: lib/wfu_constants.php:73
156
+ msgid ""
157
+ "Upload failed! Error occured while moving temporary file. Please contact "
158
+ "administrator."
159
  msgstr ""
160
 
161
  #: lib/wfu_constants.php:74
162
+ msgid ""
163
+ "Upload failed! A PHP extension stopped the file upload. PHP does not provide "
164
+ "a way to ascertain which extension caused the file upload to stop; examining "
165
+ "the list of loaded extensions with phpinfo() may help."
166
  msgstr ""
167
 
168
  #: lib/wfu_constants.php:75
169
+ msgid "Upload failed! Error occured while attemting to upload the file."
170
  msgstr ""
171
 
172
  #: lib/wfu_constants.php:76
173
+ msgid "Upload failed!"
174
  msgstr ""
175
 
176
  #: lib/wfu_constants.php:77
177
+ msgid "No file!"
178
  msgstr ""
179
 
180
  #: lib/wfu_constants.php:78
181
+ msgid ""
182
+ "Upload failed! The upload has been canceled by the user or the browser "
183
+ "dropped the connection."
184
  msgstr ""
185
 
186
  #: lib/wfu_constants.php:79
187
+ msgid "Upload failed! Unknown error."
188
  msgstr ""
189
 
190
  #: lib/wfu_constants.php:80
191
+ msgid "Please contact the administrator."
192
  msgstr ""
193
 
194
  #: lib/wfu_constants.php:81
195
+ msgid "No result from remote server!"
196
  msgstr ""
197
 
198
  #: lib/wfu_constants.php:82
199
+ msgid " but with warnings"
 
200
  msgstr ""
201
 
202
+ #: lib/wfu_constants.php:83 lib/wfu_constants.php:85
203
+ msgid "Warning: JSON parse error."
204
  msgstr ""
205
 
206
+ #: lib/wfu_constants.php:84
207
+ msgid ""
208
+ "Upload parameters of this file, passed as JSON string to the handler, could "
209
+ "not be parsed."
210
  msgstr ""
211
 
212
  #: lib/wfu_constants.php:86
213
+ msgid ""
214
+ "UploadStates, passed as JSON string to the handler, could not be parsed."
215
  msgstr ""
216
 
217
  #: lib/wfu_constants.php:87
218
+ msgid ""
219
+ "Redirection to classic form functionality occurred due to unknown error."
220
  msgstr ""
221
 
222
  #: lib/wfu_constants.php:88
223
+ msgid ""
224
+ "Redirection to classic form functionality occurred because AJAX is not "
225
+ "supported."
226
  msgstr ""
227
 
228
  #: lib/wfu_constants.php:89
229
+ msgid ""
230
+ "Redirection to classic form functionality occurred because HTML5 is not "
231
+ "supported."
232
  msgstr ""
233
 
234
  #: lib/wfu_constants.php:90
235
+ msgid ""
236
+ "Redirection to classic form functionality occurred due to JSON parse error."
237
  msgstr ""
238
 
239
+ #: lib/wfu_constants.php:91
240
+ msgid "cannot be empty!"
241
  msgstr ""
242
 
243
  #: lib/wfu_constants.php:94
244
+ msgid "Upload skipped! File already exists."
245
  msgstr ""
246
 
247
  #: lib/wfu_constants.php:95
248
+ msgid "No files have been selected!"
249
  msgstr ""
250
 
251
  #: lib/wfu_constants.php:96
252
+ msgid "WPFilebase Plugin not updated because there were no files uploaded."
253
  msgstr ""
254
 
255
  #: lib/wfu_constants.php:97
256
+ msgid "Notification email was not sent because there were no files uploaded."
257
  msgstr ""
258
 
259
  #: lib/wfu_constants.php:98
260
+ msgid ""
261
+ "Notification email was not sent because no recipients were defined. Please "
262
+ "check notifyrecipients attribute in the shortcode."
263
  msgstr ""
264
 
265
  #: lib/wfu_constants.php:99
266
+ msgid ""
267
+ "Notification email was not sent due to an error. Please check "
268
+ "notifyrecipients, notifysubject and notifymessage attributes for errors."
269
  msgstr ""
270
 
271
  #: lib/wfu_constants.php:100
272
+ msgid ""
273
+ "Redirection not executed because redirection link is empty. Please check "
274
+ "redirectlink attribute."
275
  msgstr ""
276
 
277
+ #: lib/wfu_constants.php:101
278
+ msgid ""
279
+ "Redirection not executed because not all files were successfully uploaded."
280
  msgstr ""
281
 
282
  #: lib/wfu_constants.php:104
283
+ msgid "Test Mode"
284
  msgstr ""
285
 
286
  #: lib/wfu_constants.php:105
287
+ msgid "Upload path: %filepath%"
288
  msgstr ""
289
 
290
+ #: lib/wfu_constants.php:106
291
+ msgid "Failed upload path: %filepath%"
292
  msgstr ""
293
 
294
  #: lib/wfu_constants.php:109
295
+ msgid "This is a test message"
296
  msgstr ""
297
 
298
  #: lib/wfu_constants.php:110
299
+ msgid "This is a test administrator message"
300
  msgstr ""
301
 
302
  #: lib/wfu_constants.php:111
303
+ msgid "File testfile 1 under test"
304
  msgstr ""
305
 
306
  #: lib/wfu_constants.php:112
307
+ msgid "File testfile 1 message"
308
  msgstr ""
309
 
310
  #: lib/wfu_constants.php:113
311
+ msgid "File testfile 1 administrator message"
312
  msgstr ""
313
 
314
  #: lib/wfu_constants.php:114
315
+ msgid "File testfile 2 under test"
316
  msgstr ""
317
 
318
  #: lib/wfu_constants.php:115
319
+ msgid "File testfile 2 message"
320
  msgstr ""
321
 
322
+ #: lib/wfu_constants.php:116
323
+ msgid "File testfile 2 administrator message"
324
  msgstr ""
325
 
326
  #: lib/wfu_constants.php:119
327
+ msgid ""
328
+ "Insert variable %username% inside text. It will be replaced by the username "
329
+ "of the current user."
330
  msgstr ""
331
 
332
  #: lib/wfu_constants.php:120
333
+ msgid ""
334
+ "Insert variable %useremail% inside text. It will be replaced by the email of "
335
+ "the current user."
336
  msgstr ""
337
 
338
  #: lib/wfu_constants.php:121
339
+ msgid ""
340
+ "Insert variable %filename% inside text. It will be replaced by the filename "
341
+ "of the uploaded file."
342
  msgstr ""
343
 
344
  #: lib/wfu_constants.php:122
345
+ msgid ""
346
+ "Insert variable %filepath% inside text. It will be replaced by the full "
347
+ "filepath of the uploaded file."
348
  msgstr ""
349
 
350
  #: lib/wfu_constants.php:123
351
+ msgid ""
352
+ "Insert variable %blogid% inside text. It will be replaced by the blog id of "
353
+ "the website."
354
  msgstr ""
355
 
356
  #: lib/wfu_constants.php:124
357
+ msgid ""
358
+ "Insert variable %userdataXXX% inside text. Select the user field from the "
359
+ "drop-down list. It will be replaced by the value that the user entered in "
360
+ "this field."
361
+ msgstr ""
362
+
363
+ #: lib/wfu_constants.php:125
364
  msgid "Insert variable %n% inside text to denote a line change."
365
  msgstr ""
366
 
367
+ #: lib/wfu_constants.php:128
368
  msgid "Upload in progress"
369
  msgstr ""
370
 
371
+ #: lib/wfu_constants.php:129
372
  msgid "Upload in progress with warnings!"
373
  msgstr ""
374
 
375
+ #: lib/wfu_constants.php:130
376
  msgid "Upload in progress but some files already failed!"
377
  msgstr ""
378
 
379
+ #: lib/wfu_constants.php:131
380
  msgid "Upload in progress but no files uploaded so far!"
381
  msgstr ""
382
 
383
+ #: lib/wfu_constants.php:132
384
  msgid "All files uploaded successfully"
385
  msgstr ""
386
 
387
+ #: lib/wfu_constants.php:133
388
  msgid "All files uploaded successfully but there are warnings!"
389
  msgstr ""
390
 
391
+ #: lib/wfu_constants.php:134
392
  msgid "File uploaded successfully but there are warnings!"
393
  msgstr ""
394
 
395
+ #: lib/wfu_constants.php:135
396
  msgid "Some files failed to upload!"
397
  msgstr ""
398
 
399
+ #: lib/wfu_constants.php:136
400
  msgid "All files failed to upload"
401
  msgstr ""
402
 
403
+ #: lib/wfu_constants.php:137
404
  msgid "File failed to upload"
405
  msgstr ""
406
 
407
+ #: lib/wfu_constants.php:138
408
  msgid "There are no files to upload!"
409
  msgstr ""
410
 
411
+ #: lib/wfu_constants.php:139
412
  msgid "Test upload message"
413
  msgstr ""
414
 
415
+ #: lib/wfu_constants.php:140
416
  msgid "JSON parse warning!"
417
  msgstr ""
418
 
419
+ #: lib/wfu_constants.php:141
420
  msgid "please wait while redirecting..."
421
  msgstr ""
 
lib/wfu_admin.php CHANGED
@@ -1,383 +1,761 @@
1
- <?php
2
-
3
- function wordpress_file_upload_add_admin_pages() {
4
- add_options_page('Wordpress File Upload', 'Wordpress File Upload', 10, 'wordpress_file_upload', 'wordpress_file_upload_manage_dashboard');
5
- }
6
-
7
- // This is the callback function that generates dashboard page content
8
- function wordpress_file_upload_manage_dashboard() {
9
- global $wpdb;
10
- $_POST = stripslashes_deep($_POST);
11
- $_GET = stripslashes_deep($_GET);
12
- $action = (!empty($_POST['action']) ? $_POST['action'] : (!empty($_GET['action']) ? $_GET['action'] : ''));
13
-
14
- if ( $action == 'edit_settings' ) {
15
- wfu_update_settings();
16
- $echo_str = wfu_manage_settings();
17
- }
18
- elseif ( $action == 'shortcode_composer' ) {
19
- $echo_str = wfu_shortcode_composer();
20
- }
21
- else {
22
- $echo_str = wfu_manage_settings();
23
- }
24
-
25
- echo $echo_str;
26
- }
27
-
28
- function wfu_manage_settings() {
29
- return wfu_shortcode_composer();
30
-
31
- global $wpdb;
32
- // $plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
33
-
34
- $echo_str = '<div class="wfu_wrap">';
35
- $echo_str .= "\n\t".'<h2>Wordpress File Upload Control Panel</h2>';
36
- $echo_str .= "\n\t".'<div style="margin-top:10px;">';
37
- $echo_str .= "\n\t\t".'<a href="/wp-admin/options-general.php?page=wordpress_file_upload&amp;action=shortcode_composer" class="button" title="Shortcode composer">Shortcode Composer</a>';
38
- $echo_str .= "\n\t\t".'<h3 style="margin-bottom: 10px; margin-top: 40px;">Settings</h3>';
39
- $echo_str .= "\n\t\t".'<form enctype="multipart/form-data" name="editsettings" id="editsettings" method="post" action="/wp-admin/options-general.php?page=event_register&amp;action=edit_settings" class="validate">';
40
- $echo_str .= "\n\t\t\t".'<input type="hidden" name="action" value="edit_settings">';
41
- $echo_str .= "\n\t\t\t".'<table class="form-table">';
42
- $echo_str .= "\n\t\t\t\t".'<tbody>';
43
- $echo_str .= "\n\t\t\t\t\t".'<tr class="form-field">';
44
- $echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
45
- $echo_str .= "\n\t\t\t\t\t\t\t".'<label for="wfu_testprop">Test Property</label>';
46
- $echo_str .= "\n\t\t\t\t\t\t".'</th>';
47
- $echo_str .= "\n\t\t\t\t\t\t".'<td>';
48
- $echo_str .= "\n\t\t\t\t\t\t\t".'<input name="wfu_testprop" id="wfu_testprop" type="text" value="Test Property" />';
49
- $echo_str .= "\n\t\t\t\t\t\t\t".'<p style="cursor: text; font-size:9px; padding: 0px; margin: 0px; width: 95%; color: #AAAAAA;">Current value: <strong>Test Property</strong></p>';
50
- $echo_str .= "\n\t\t\t\t\t\t".'</td>';
51
- $echo_str .= "\n\t\t\t\t\t".'</tr>';
52
- $echo_str .= "\n\t\t\t\t".'</tbody>';
53
- $echo_str .= "\n\t\t\t".'</table>';
54
- $echo_str .= "\n\t\t\t".'<p class="submit">';
55
- $echo_str .= "\n\t\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Update" disabled="disabled" />';
56
- $echo_str .= "\n\t\t\t".'</p>';
57
- $echo_str .= "\n\t\t".'</form>';
58
- $echo_str .= "\n\t".'</div>';
59
- $echo_str .= "\n".'</div>';
60
-
61
- echo $echo_str;
62
- }
63
-
64
- function wfu_shortcode_composer() {
65
- global $wpdb;
66
- global $wp_roles;
67
-
68
- $components = wfu_component_definitions();
69
-
70
- $cats = wfu_category_definitions();
71
- $defs = wfu_attribute_definitions();
72
-
73
- $plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
74
- $shortcode_attrs = wfu_shortcode_string_to_array($plugin_options['shortcode']);
75
- foreach ( $defs as $key => $def ) {
76
- $defs[$key]['default'] = $def['value'];
77
- if ( array_key_exists($def['attribute'], $shortcode_attrs) ) {
78
- $defs[$key]['value'] = $shortcode_attrs[$def['attribute']];
79
- }
80
- }
81
-
82
- // index $components
83
- $components_indexed = array();
84
- foreach ( $components as $component ) $components_indexed[$component['id']] = $component;
85
- // index dependiencies
86
- $governors = array();
87
-
88
- $echo_str = '<div id="wfu_wrapper" class="wfu_wrap">';
89
- $echo_str .= "\n\t".'<h2>Wordpress File Upload Shortcode Composer</h2>';
90
- // $echo_str .= "\n\t\t".'<a href="/wp-admin/options-general.php?page=wordpress_file_upload&amp;action=manage_settings" class="button" title="Go back">Go Back</a>';
91
- $echo_str .= "\n\t".'<div style="margin-top:10px;">';
92
- $echo_str .= "\n\t\t".'<div class="wfu_shortcode_container">';
93
- $echo_str .= "\n\t\t\t".'<span><strong>Generated Shortcode</strong></span>';
94
- $echo_str .= "\n\t\t\t".'<span id="wfu_save_label" class="wfu_save_label">saved</span>';
95
- $echo_str .= "\n\t\t\t".'<textarea id="wfu_shortcode" class="wfu_shortcode" rows="5">[wordpress_file_upload]</textarea>';
96
- $echo_str .= "\n\t\t\t".'<div id="wfu_attribute_defaults" style="display:none;">';
97
- foreach ( $defs as $def )
98
- $echo_str .= "\n\t\t\t\t".'<input id="wfu_attribute_default_'.$def['attribute'].'" type="hidden" value="'.$def['default'].'" />';
99
- $echo_str .= "\n\t\t\t".'</div>';
100
- $echo_str .= "\n\t\t\t".'<div id="wfu_attribute_values" style="display:none;">';
101
- foreach ( $defs as $def )
102
- $echo_str .= "\n\t\t\t\t".'<input id="wfu_attribute_value_'.$def['attribute'].'" type="hidden" value="'.$def['value'].'" />';
103
- $echo_str .= "\n\t\t\t".'</div>';
104
- $echo_str .= "\n\t\t".'</div>';
105
- $echo_str .= "\n\t".'</div>';
106
- $echo_str .= "\n\t".'<h3 id="wfu_tab_container" class="nav-tab-wrapper">';
107
- $is_first = true;
108
- foreach ( $cats as $key => $cat ) {
109
- $echo_str .= "\n\t\t".'<a id="wfu_tab_'.$key.'" class="nav-tab'.( $is_first ? ' nav-tab-active' : '' ).'" href="javascript: wfu_admin_activate_tab(\''.$key.'\');">'.$cat.'</a>';
110
- $is_first = false;
111
- }
112
- $echo_str .= "\n\t".'</h3>';
113
-
114
- $prevcat = "";
115
- $prevsubcat = "";
116
- $is_first = true;
117
- $block_open = false;
118
- $subblock_open = false;
119
- foreach ( $defs as $def ) {
120
- $attr = $def['attribute'];
121
- $subblock_active = false;
122
- //detect if the dependencies of this attribute will be disabled or not
123
- if ( ( $def['type'] == "onoff" && $def['value'] == "true" ) ||
124
- ( $def['type'] == "radio" && in_array("*".$def['value'], $def['listitems']) ) )
125
- $subblock_active = true;
126
- // assign dependencies if exist
127
- if ( $def['dependencies'] != null )
128
- foreach ( $def['dependencies'] as $dependency ) {
129
- if ( substr($dependency, 0, 1) == "!" ) //invert state for this dependency if an exclamation mark is defined
130
- $governors[substr($dependency, 1)] = array( 'attribute' => $attr, 'active' => !$subblock_active, 'inv' => '_inv' );
131
- else
132
- $governors[$dependency] = array( 'attribute' => $attr, 'active' => $subblock_active, 'inv' => '' );
133
- }
134
- //check if this attribute depends on other
135
- if ( $governors[$attr] != "" ) $governor = $governors[$attr];
136
- else $governor = array( 'attribute' => "independent", 'active' => true, 'inv' => '' );
137
-
138
- //close previous blocks
139
- if ( $def['parent'] == "" ) {
140
- if ( $subblock_open ) {
141
- $echo_str .= "\n\t\t\t\t\t\t\t".'</tbody>';
142
- $echo_str .= "\n\t\t\t\t\t\t".'</table>';
143
- $subblock_open = false;
144
- }
145
- if ( $block_open ) {
146
- $echo_str .= "\n\t\t\t\t\t".'</div></td>';
147
- $echo_str .= "\n\t\t\t\t".'</tr>';
148
- $block_open = false;
149
- }
150
- }
151
- //check if new category must be generated
152
- if ( $def['category'] != $prevcat ) {
153
- if ( $prevcat != "" ) {
154
- $echo_str .= "\n\t\t\t".'</tbody>';
155
- $echo_str .= "\n\t\t".'</table>';
156
- $echo_str .= "\n\t".'</div>';
157
- }
158
- $prevcat = $def['category'];
159
- $prevsubcat = "";
160
- $echo_str .= "\n\t".'<div id="wfu_container_'.$prevcat.'" class="wfu_container"'.( $is_first ? '' : ' style="display:none;"' ).'">';
161
- $echo_str .= "\n\t\t".'<table class="form-table wfu_main_table">';
162
- $echo_str .= "\n\t\t\t".'<thead><tr><th></th><td></td><td></td></tr></thead>';
163
- $echo_str .= "\n\t\t\t".'<tbody>';
164
- $is_first = false;
165
- }
166
- //check if new sub-category must be generated
167
- if ( $def['subcategory'] != $prevsubcat ) {
168
- $prevsubcat = $def['subcategory'];
169
- $echo_str .= "\n\t\t\t\t".'<tr class="form-field wfu_subcategory">';
170
- $echo_str .= "\n\t\t\t\t\t".'<th scope="row" colspan="3">';
171
- $echo_str .= "\n\t\t\t\t\t\t".'<h3 style="margin-bottom: 10px; margin-top: 10px;">'.$prevsubcat.'</h3>';
172
- $echo_str .= "\n\t\t\t\t\t".'</th>';
173
- $echo_str .= "\n\t\t\t\t".'</tr>';
174
- }
175
- //draw attribute element
176
- if ( $def['parent'] == "" ) {
177
- $dlp = "\n\t\t\t\t";
178
- }
179
- else {
180
- if ( !$subblock_open ) {
181
- $echo_str .= "\n\t\t\t\t\t\t".'<div class="wfu_shadow wfu_shadow_'.$def['parent'].$governor['inv'].'" style="display:'.( $governor['active'] ? 'none' : 'block' ).';"></div>';
182
- $echo_str .= "\n\t\t\t\t\t\t".'<table class="form-table wfu_inner_table" style="margin:0;">';
183
- $echo_str .= "\n\t\t\t\t\t\t\t".'<tbody>';
184
- }
185
- $dlp = "\n\t\t\t\t\t\t\t\t";
186
- }
187
- $echo_str .= $dlp.'<tr class="form-field">';
188
- $echo_str .= $dlp."\t".'<th scope="row"><div class="wfu_td_div">';
189
- if ( $def['parent'] == "" ) $echo_str .= $dlp."\t\t".'<div class="wfu_shadow wfu_shadow_'.$governor['attribute'].$governor['inv'].'" style="display:'.( $governor['active'] ? 'none' : 'block' ).';"></div>';
190
- $echo_str .= $dlp."\t\t".'<label for="wfu_attribute_'.$attr.'">'.$def['name'].'</label>';
191
- $echo_str .= $dlp."\t\t".'<div class="wfu_help_container" title="'.$def['help'].'"><img src="'.WFU_IMAGE_ADMIN_HELP.'" ></div>';
192
- $echo_str .= $dlp."\t".'</div></th>';
193
- $echo_str .= $dlp."\t".'<td style="vertical-align:top;"><div class="wfu_td_div">';
194
- if ( $def['parent'] == "" ) $echo_str .= $dlp."\t\t".'<div class="wfu_shadow wfu_shadow_'.$governor['attribute'].$governor['inv'].'" style="display:'.( $governor['active'] ? 'none' : 'block' ).';"></div>';
195
- if ( $def['type'] == "onoff" ) {
196
- $echo_str .= $dlp."\t\t".'<div id="wfu_attribute_'.$attr.'" class="wfu_onoff_container_'.( $def['value'] == "true" ? "on" : "off" ).'" onclick="wfu_admin_onoff_clicked(\''.$attr.'\');">';
197
- $echo_str .= $dlp."\t\t\t".'<div class="wfu_onoff_slider"></div>';
198
- $echo_str .= $dlp."\t\t\t".'<span class="wfu_onoff_text">ON</span>';
199
- $echo_str .= $dlp."\t\t\t".'<span class="wfu_onoff_text">OFF</span>';
200
- $echo_str .= $dlp."\t\t".'</div>';
201
- }
202
- elseif ( $def['type'] == "text" ) {
203
- $echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" value="'.$def['value'].'" />';
204
- if ( $def['variables'] != null ) $echo_str .= wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
205
- }
206
- elseif ( $def['type'] == "placements" ) {
207
- $components_used = array();
208
- foreach ( $components as $component ) $components_used[$component['id']] = false;
209
- $centered_content = '<div style="display:table; width:100%; height:100%;"><div style="display:table-cell; text-align:center; vertical-align:middle;">XXX</div></div>';
210
- $echo_str .= $dlp."\t\t".'<div class="wfu_placements_wrapper">';
211
- $echo_str .= $dlp."\t\t\t".'<div id="wfu_placements_container" class="wfu_placements_container">';
212
- $itemplaces = explode("/", $def['value']);
213
- foreach ( $itemplaces as $section ) {
214
- $echo_str .= $dlp."\t\t\t\t".'<div class="wfu_component_separator_hor"></div>';
215
- $echo_str .= $dlp."\t\t\t\t".'<div class="wfu_component_separator_ver"></div>';
216
- $items_in_section = explode("+", trim($section));
217
- $section_array = array( );
218
- foreach ( $items_in_section as $item_in_section ) {
219
- if ( key_exists($item_in_section, $components_indexed) ) {
220
- $components_used[$item_in_section] = true;
221
- $echo_str .= $dlp."\t\t\t\t".'<div id="wfu_component_box_'.$item_in_section.'" class="wfu_component_box" draggable="true">'.str_replace("XXX", $components_indexed[$item_in_section]['name'], $centered_content).'</div>';
222
- $echo_str .= $dlp."\t\t\t\t".'<div class="wfu_component_separator_ver"></div>';
223
- }
224
- }
225
- }
226
- $echo_str .= $dlp."\t\t\t\t".'<div class="wfu_component_separator_hor"></div>';
227
- $echo_str .= $dlp."\t\t\t\t".'<div id="wfu_component_bar_hor" class="wfu_component_bar_hor"></div>';
228
- $echo_str .= $dlp."\t\t\t\t".'<div id="wfu_component_bar_ver" class="wfu_component_bar_ver"></div>';
229
- $echo_str .= $dlp."\t\t\t".'</div>';
230
- $echo_str .= $dlp."\t\t\t".'<div id="wfu_componentlist_container" class="wfu_componentlist_container">';
231
- $echo_str .= $dlp."\t\t\t\t".'<div id="wfu_componentlist_dragdrop" class="wfu_componentlist_dragdrop" style="display:none;"></div>';
232
- $ii = 1;
233
- foreach ( $components as $component ) {
234
- $echo_str .= $dlp."\t\t\t\t".'<div id="wfu_component_box_container_'.$component['id'].'" class="wfu_component_box_container">';
235
- $echo_str .= $dlp."\t\t\t\t\t".'<div class="wfu_component_box_base">'.str_replace("XXX", $component['name'], $centered_content).'</div>';
236
- if ( !$components_used[$component['id']] )
237
- $echo_str .= $dlp."\t\t\t\t\t".'<div id="wfu_component_box_'.$component['id'].'" class="wfu_component_box wfu_inbase" draggable="true">'.str_replace("XXX", $component['name'], $centered_content).'</div>';
238
- $echo_str .= $dlp."\t\t\t\t".'</div>'.( ($ii++) % 3 == 0 ? '<br />' : '' );
239
- }
240
- $echo_str .= $dlp."\t\t\t".'</div>';
241
- $echo_str .= $dlp."\t\t".'</div>';
242
- }
243
- elseif ( $def['type'] == "ltext" ) {
244
- $echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" class="wfu_long_text" value="'.$def['value'].'" />';
245
- if ( $def['variables'] != null ) $echo_str .= wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
246
- }
247
- elseif ( $def['type'] == "integer" ) {
248
- $echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="number" name="wfu_text_elements" class="wfu_short_text" min="1" value="'.$def['value'].'" />';
249
- }
250
- elseif ( $def['type'] == "float" ) {
251
- $echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="number" name="wfu_text_elements" class="wfu_short_text" step="any" min="0" value="'.$def['value'].'" />';
252
- }
253
- elseif ( $def['type'] == "radio" ) {
254
- $echo_str .= $dlp."\t\t";
255
- $ii = 0;
256
- foreach ( $def['listitems'] as $item )
257
- $echo_str .= '<input name="wfu_radioattribute_'.$attr.'" type="radio" value="'.$item.'" '.( $item == $def['value'] || $item == "*".$def['value'] ? 'checked="checked" ' : '' ).'style="width:auto; margin:0px 2px 0px '.( ($ii++) == 0 ? '0px' : '8px' ).';" onchange="wfu_admin_radio_clicked(\''.$attr.'\');" />'.( $item[0] == "*" ? substr($item, 1) : $item );
258
- // $echo_str .= '<input type="button" class="button" value="empty" style="width:auto; margin:-2px 0px 0px 8px;" />';
259
- }
260
- elseif ( $def['type'] == "ptext" ) {
261
- $parts = explode("/", $def['value']);
262
- $singular = $parts[0];
263
- if ( count($parts) < 2 ) $plural = $singular;
264
- else $plural = $parts[1];
265
- $echo_str .= $dlp."\t\t".'<span class="wfu_ptext_span">Singular</span><input id="wfu_attribute_s_'.$attr.'" type="text" name="wfu_ptext_elements" value="'.$singular.'" />';
266
- if ( $def['variables'] != null ) if ( count($def['variables']) > 0 ) $echo_str .= $dlp."\t\t".'<br /><span class="wfu_ptext_span">&nbsp;</span>';
267
- if ( $def['variables'] != null ) $echo_str .= wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_s_'.$attr);
268
- $echo_str .= $dlp."\t\t".'<br /><span class="wfu_ptext_span">Plural</span><input id="wfu_attribute_p_'.$attr.'" type="text" name="wfu_ptext_elements" value="'.$plural.'" />';
269
- if ( $def['variables'] != null ) if ( count($def['variables']) > 0 ) $echo_str .= $dlp."\t\t".'<br /><span class="wfu_ptext_span">&nbsp;</span>';
270
- if ( $def['variables'] != null ) $echo_str .= wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_p_'.$attr);
271
- }
272
- elseif ( $def['type'] == "mtext" ) {
273
- $val = str_replace("%n%", "\n", $def['value']);
274
- $echo_str .= $dlp."\t\t".'<textarea id="wfu_attribute_'.$attr.'" name="wfu_text_elements" rows="5">'.$val.'</textarea>';
275
- if ( $def['variables'] != null ) $echo_str .= wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
276
- }
277
- elseif ( $def['type'] == "rolelist" ) {
278
- $roles = $wp_roles->get_names();
279
- $def['value'] = strtolower($def['value']);
280
- if ( $def['value'] == "all" ) $selected = array("administrator");
281
- else $selected = explode(",", $def['value']);
282
- foreach ( $selected as $key => $item ) $selected[$key] = trim($item);
283
- $echo_str .= $dlp."\t\t".'<select id="wfu_attribute_'.$attr.'" multiple="multiple" size="'.count($roles).'" onchange="wfu_update_rolelist_value(\''.$attr.'\');"'.( strtolower($def['value']) == "all" ? ' disabled="disabled"' : '' ).'>';
284
- foreach ( $roles as $roleid => $rolename )
285
- $echo_str .= $dlp."\t\t\t".'<option value="'.$roleid.'"'.( in_array($roleid, $selected) ? ' selected="selected"' : '' ).'>'.$rolename.'</option>';
286
- $echo_str .= $dlp."\t\t".'</select>';
287
- $echo_str .= $dlp."\t\t".'<div class="wfu_rolelist_checkall"><input id="wfu_attribute_'.$attr.'_all" type="checkbox" onchange="wfu_update_rolelist_value(\''.$attr.'\');"'.( strtolower($def['value']) == "all" ? ' checked="checked"' : '' ).' /> Select all (including guests)</div>';
288
- }
289
- elseif ( $def['type'] == "dimensions" ) {
290
- $vals_arr = explode(",", $def['value']);
291
- $vals = array();
292
- foreach ( $vals_arr as $val_raw ) {
293
- list($val_id, $val) = explode(":", $val_raw);
294
- $vals[trim($val_id)] = trim($val);
295
- }
296
- $dims = array();
297
- foreach ( $components as $comp ) {
298
- if ( $comp['dimensions'] == null ) $dims[$comp['id']] = $comp['name'];
299
- else foreach ( $comp['dimensions'] as $dimraw ) {
300
- list($dim_id, $dim_name) = explode("/", $dimraw);
301
- $dims[$dim_id] = $dim_name;
302
- }
303
- }
304
- foreach ( $dims as $dim_id => $dim_name ) {
305
- $echo_str .= $dlp."\t\t".'<span style="display:inline-block; width:130px;">'.$dim_name.'</span><input id="wfu_attribute_'.$attr.'_'.$dim_id.'" type="text" name="wfu_dimension_elements_'.$attr.'" class="wfu_short_text" value="'.$vals[$dim_id].'" /><br />';
306
- }
307
- }
308
- elseif ( $def['type'] == "userfields" ) {
309
- $fields_arr = explode("/", $def['value']);
310
- $fields = array();
311
- foreach ( $fields_arr as $field_raw ) {
312
- $is_req = ( substr($field_raw, 0, 1) == "*" );
313
- if ( $is_req ) $field_raw = substr($field_raw, 1);
314
- if ( $field_raw != "" ) array_push($fields, array( "name" => $field_raw, "required" => $is_req ));
315
- }
316
- if ( count($fields) == 0 ) array_push($fields, array( "name" => "", "required" => false ));
317
- $echo_str .= $dlp."\t\t".'<div class="wfu_userdata_container">';
318
- foreach ( $fields as $field ) {
319
- $echo_str .= $dlp."\t\t\t".'<div class="wfu_userdata_line">';
320
- $echo_str .= $dlp."\t\t\t\t".'<input type="text" name="wfu_userfield_elements" value="'.$field['name'].'" />';
321
- $echo_str .= $dlp."\t\t\t\t".'<div class="wfu_userdata_action" onclick="wfu_userdata_add_field(this);"><img src="'.WFU_IMAGE_ADMIN_USERDATA_ADD.'" ></div>';
322
- $echo_str .= $dlp."\t\t\t\t".'<div class="wfu_userdata_action wfu_userdata_action_disabled" onclick="wfu_userdata_remove_field(this);"><img src="'.WFU_IMAGE_ADMIN_USERDATA_REMOVE.'" ></div>';
323
- $echo_str .= $dlp."\t\t\t\t".'<input type="checkbox"'.( $field['required'] ? 'checked="checked"' : '' ).' onchange="wfu_update_userfield_value({target:this});" />';
324
- $echo_str .= $dlp."\t\t\t\t".'<span>Required</span>';
325
- $echo_str .= $dlp."\t\t\t".'</div>';
326
- }
327
- $echo_str .= $dlp."\t\t".'</div>';
328
- }
329
- elseif ( $def['type'] == "color" ) {
330
- $echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" class="wfu_color_field" value="'.$def['value'].'" />';
331
- }
332
- elseif ( $def['type'] == "color-triplet" ) {
333
- $triplet = explode(",", $def['value']);
334
- foreach ( $triplet as $key => $item ) $triplet[$key] = trim($item);
335
- $echo_str .= $dlp."\t\t".'<div class="wfu_color_container"><label style="display:inline-block; width:120px; margin-top:-16px;">Text Color</label><input id="wfu_attribute_'.$attr.'_color" type="text" class="wfu_color_field" name="wfu_triplecolor_elements" value="'.$triplet[0].'" /></div>';
336
- $echo_str .= $dlp."\t\t".'<div class="wfu_color_container"><label style="display:inline-block; width:120px; margin-top:-16px;">Background Color</label><input id="wfu_attribute_'.$attr.'_bgcolor" type="text" class="wfu_color_field" name="wfu_triplecolor_elements" value="'.$triplet[1].'" /></div>';
337
- $echo_str .= $dlp."\t\t".'<div class="wfu_color_container"><label style="display:inline-block; width:120px; margin-top:-16px;">Border Color</label><input id="wfu_attribute_'.$attr.'_borcolor" type="text" class="wfu_color_field" name="wfu_triplecolor_elements" value="'.$triplet[2].'" /></div>';
338
- }
339
- else {
340
- $echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" value="'.$def['value'].'" />';
341
- if ( $def['variables'] != null ) $echo_str .= wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
342
- }
343
- $echo_str .= $dlp."\t".'</div></td>';
344
- if ( $def['parent'] == "" ) {
345
- $echo_str .= $dlp."\t".'<td style="position:relative; vertical-align:top; padding:0;"><div class="wfu_td_div">';
346
- $block_open = false;
347
- }
348
- else {
349
- $echo_str .= $dlp.'</tr>';
350
- $subblock_open = true;
351
- }
352
- }
353
- if ( $subblock_open ) {
354
- $echo_str .= "\n\t\t\t\t\t\t".'</div>';
355
- }
356
- if ( $block_open ) {
357
- $echo_str .= "\n\t\t\t\t\t".'</div></td>';
358
- $echo_str .= "\n\t\t\t\t".'</tr>';
359
- }
360
- $echo_str .= "\n\t\t\t".'</tbody>';
361
- $echo_str .= "\n\t\t".'</table>';
362
- $handler = 'function() { wfu_Attach_Admin_Events(); }';
363
- $echo_str .= "\n\t".'<script type="text/javascript">if(window.addEventListener) { window.addEventListener("load", '.$handler.', false); } else if(window.attachEvent) { window.attachEvent("onload", '.$handler.'); } else { window["onload"] = '.$handler.'; }</script>';
364
- $echo_str .= "\n".'</div>';
365
- // $echo_str .= "\n\t".'<div style="margin-top:10px;">';
366
- // $echo_str .= "\n\t\t".'<label>Final shortcode text</label>';
367
- // $echo_str .= "\n\t".'</div>';
368
-
369
- echo $echo_str;
370
- }
371
-
372
- function wfu_insert_variables($variables, $class) {
373
- $ret = "";
374
- foreach ( $variables as $variable )
375
- if ( $variable == "%userdataXXX%" ) $ret .= $dlp."\t\t".'<select class="'.$class.'" name="wfu_userfield_select" title="'.constant("WFU_VARIABLE_TITLE_".strtoupper(str_replace("%", "", $variable))).'" onchange="wfu_insert_userfield_variable(this);"><option style="display:none;">%userdataXXX%</option></select>';
376
- elseif ( $variable != "%n%" ) $ret .= $dlp."\t\t".'<span class="'.$class.'" title="'.constant("WFU_VARIABLE_TITLE_".strtoupper(str_replace("%", "", $variable))).'" ondblclick="wfu_insert_variable(this);">'.$variable.'</span>';
377
- return $ret;
378
- }
379
-
380
- function wfu_update_settings() {
381
- }
382
-
383
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function wordpress_file_upload_add_admin_pages() {
4
+ add_options_page('Wordpress File Upload', 'Wordpress File Upload', 10, 'wordpress_file_upload', 'wordpress_file_upload_manage_dashboard');
5
+ }
6
+
7
+ // This is the callback function that generates dashboard page content
8
+ function wordpress_file_upload_manage_dashboard() {
9
+ global $wpdb;
10
+ $_POST = stripslashes_deep($_POST);
11
+ $_GET = stripslashes_deep($_GET);
12
+ $action = (!empty($_POST['action']) ? $_POST['action'] : (!empty($_GET['action']) ? $_GET['action'] : ''));
13
+ $dir = (!empty($_POST['dir']) ? $_POST['dir'] : (!empty($_GET['dir']) ? $_GET['dir'] : ''));
14
+ $file = (!empty($_POST['file']) ? $_POST['file'] : (!empty($_GET['file']) ? $_GET['file'] : ''));
15
+
16
+ if ( $action == 'edit_settings' ) {
17
+ wfu_update_settings();
18
+ $echo_str = wfu_manage_settings();
19
+ }
20
+ elseif ( $action == 'shortcode_composer' ) {
21
+ $echo_str = wfu_shortcode_composer();
22
+ }
23
+ elseif ( $action == 'file_browser' ) {
24
+ $echo_str = wfu_browse_files($dir);
25
+ }
26
+ elseif ( $action == 'rename_file' && $file != "" ) {
27
+ $echo_str = wfu_rename_file_prompt($file, 'file', false);
28
+ }
29
+ elseif ( $action == 'rename_dir' && $file != "" ) {
30
+ $echo_str = wfu_rename_file_prompt($file, 'dir', false);
31
+ }
32
+ elseif ( $action == 'renamefile' && $file != "" ) {
33
+ if ( wfu_rename_file($file, 'file') ) $echo_str = wfu_browse_files($dir);
34
+ else $echo_str = wfu_rename_file_prompt($file, 'file', true);
35
+ }
36
+ elseif ( $action == 'renamedir' && $file != "" ) {
37
+ if ( wfu_rename_file($file, 'dir') ) $echo_str = wfu_browse_files($dir);
38
+ else $echo_str = wfu_rename_file_prompt($file, 'dir', true);
39
+ }
40
+ elseif ( $action == 'delete_file' && $file != "" ) {
41
+ $echo_str = wfu_delete_file_prompt($file, 'file');
42
+ }
43
+ elseif ( $action == 'delete_dir' && $file != "" ) {
44
+ $echo_str = wfu_delete_file_prompt($file, 'dir');
45
+ }
46
+ elseif ( $action == 'deletefile' && $file != "" ) {
47
+ wfu_delete_file($file, 'file');
48
+ $echo_str = wfu_browse_files($dir);
49
+ }
50
+ elseif ( $action == 'deletedir' && $file != "" ) {
51
+ wfu_delete_file($file, 'dir');
52
+ $echo_str = wfu_browse_files($dir);
53
+ }
54
+ elseif ( $action == 'create_dir' ) {
55
+ $echo_str = wfu_create_dir_prompt($dir, false);
56
+ }
57
+ elseif ( $action == 'createdir' ) {
58
+ if ( wfu_create_dir($dir) ) $echo_str = wfu_browse_files($dir);
59
+ else $echo_str = wfu_create_dir_prompt($dir, true);
60
+ }
61
+ else {
62
+ $echo_str = wfu_manage_settings();
63
+ }
64
+
65
+ echo $echo_str;
66
+ }
67
+
68
+ function wfu_manage_settings() {
69
+ if ( !current_user_can( 'manage_options' ) ) return wfu_shortcode_composer();
70
+
71
+ global $wpdb;
72
+ $plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
73
+
74
+ $echo_str = '<div class="wfu_wrap">';
75
+ $echo_str .= "\n\t".'<h2>Wordpress File Upload Control Panel</h2>';
76
+ $echo_str .= "\n\t".'<div style="margin-top:10px;">';
77
+ if ( current_user_can( 'manage_options' ) ) $echo_str .= "\n\t\t".'<a href="/wp-admin/options-general.php?page=wordpress_file_upload&amp;action=file_browser" class="button" title="File browser">File Browser</a>';
78
+ $echo_str .= "\n\t\t".'<a href="/wp-admin/options-general.php?page=wordpress_file_upload&amp;action=shortcode_composer" class="button" title="Shortcode composer">Shortcode Composer</a>';
79
+ $echo_str .= "\n\t\t".'<h3 style="margin-bottom: 10px; margin-top: 40px;">Settings</h3>';
80
+ $echo_str .= "\n\t\t".'<form enctype="multipart/form-data" name="editsettings" id="editsettings" method="post" action="/wp-admin/options-general.php?page=wordpress_file_upload&amp;action=edit_settings" class="validate">';
81
+ $echo_str .= "\n\t\t\t".'<input type="hidden" name="action" value="edit_settings">';
82
+ $echo_str .= "\n\t\t\t".'<table class="form-table">';
83
+ $echo_str .= "\n\t\t\t\t".'<tbody>';
84
+ $echo_str .= "\n\t\t\t\t\t".'<tr class="form-field">';
85
+ $echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
86
+ $echo_str .= "\n\t\t\t\t\t\t\t".'<label for="wfu_basedir">Base Directory</label>';
87
+ $echo_str .= "\n\t\t\t\t\t\t".'</th>';
88
+ $echo_str .= "\n\t\t\t\t\t\t".'<td>';
89
+ $echo_str .= "\n\t\t\t\t\t\t\t".'<input name="wfu_basedir" id="wfu_basedir" type="text" value="'.$plugin_options['basedir'].'" />';
90
+ $echo_str .= "\n\t\t\t\t\t\t\t".'<p style="cursor: text; font-size:9px; padding: 0px; margin: 0px; width: 95%; color: #AAAAAA;">Current value: <strong>'.$plugin_options['basedir'].'</strong></p>';
91
+ $echo_str .= "\n\t\t\t\t\t\t".'</td>';
92
+ $echo_str .= "\n\t\t\t\t\t".'</tr>';
93
+ $echo_str .= "\n\t\t\t\t".'</tbody>';
94
+ $echo_str .= "\n\t\t\t".'</table>';
95
+ $echo_str .= "\n\t\t\t".'<p class="submit">';
96
+ $echo_str .= "\n\t\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Update" />';
97
+ $echo_str .= "\n\t\t\t".'</p>';
98
+ $echo_str .= "\n\t\t".'</form>';
99
+ $echo_str .= "\n\t".'</div>';
100
+ $echo_str .= "\n".'</div>';
101
+
102
+ echo $echo_str;
103
+ }
104
+
105
+ function wfu_shortcode_composer() {
106
+ global $wpdb;
107
+ global $wp_roles;
108
+
109
+ $components = wfu_component_definitions();
110
+
111
+ $cats = wfu_category_definitions();
112
+ $defs = wfu_attribute_definitions();
113
+
114
+ $plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
115
+ $shortcode_attrs = wfu_shortcode_string_to_array($plugin_options['shortcode']);
116
+ foreach ( $defs as $key => $def ) {
117
+ $defs[$key]['default'] = $def['value'];
118
+ if ( array_key_exists($def['attribute'], $shortcode_attrs) ) {
119
+ $defs[$key]['value'] = $shortcode_attrs[$def['attribute']];
120
+ }
121
+ }
122
+
123
+ // index $components
124
+ $components_indexed = array();
125
+ foreach ( $components as $component ) $components_indexed[$component['id']] = $component;
126
+ // index dependiencies
127
+ $governors = array();
128
+
129
+ $echo_str = '<div id="wfu_wrapper" class="wrap">';
130
+ if ( current_user_can( 'manage_options' ) ) $echo_str .= "\n\t".'<a href="/wp-admin/options-general.php?page=wordpress_file_upload&amp;action=manage_settings" class="button" title="go back">Go to Settings</a>';
131
+ $echo_str .= "\n\t".'<h2>Wordpress File Upload Shortcode Composer</h2>';
132
+ $echo_str .= "\n\t".'<div style="margin-top:10px;">';
133
+ $echo_str .= "\n\t\t".'<div class="wfu_shortcode_container">';
134
+ $echo_str .= "\n\t\t\t".'<span><strong>Generated Shortcode</strong></span>';
135
+ $echo_str .= "\n\t\t\t".'<span id="wfu_save_label" class="wfu_save_label">saved</span>';
136
+ $echo_str .= "\n\t\t\t".'<textarea id="wfu_shortcode" class="wfu_shortcode" rows="5">[wordpress_file_upload]</textarea>';
137
+ $echo_str .= "\n\t\t\t".'<div id="wfu_attribute_defaults" style="display:none;">';
138
+ foreach ( $defs as $def )
139
+ $echo_str .= "\n\t\t\t\t".'<input id="wfu_attribute_default_'.$def['attribute'].'" type="hidden" value="'.$def['default'].'" />';
140
+ $echo_str .= "\n\t\t\t".'</div>';
141
+ $echo_str .= "\n\t\t\t".'<div id="wfu_attribute_values" style="display:none;">';
142
+ foreach ( $defs as $def )
143
+ $echo_str .= "\n\t\t\t\t".'<input id="wfu_attribute_value_'.$def['attribute'].'" type="hidden" value="'.$def['value'].'" />';
144
+ $echo_str .= "\n\t\t\t".'</div>';
145
+ $echo_str .= "\n\t\t".'</div>';
146
+ $echo_str .= "\n\t".'</div>';
147
+ $echo_str .= "\n\t".'<h3 id="wfu_tab_container" class="nav-tab-wrapper">';
148
+ $is_first = true;
149
+ foreach ( $cats as $key => $cat ) {
150
+ $echo_str .= "\n\t\t".'<a id="wfu_tab_'.$key.'" class="nav-tab'.( $is_first ? ' nav-tab-active' : '' ).'" href="javascript: wfu_admin_activate_tab(\''.$key.'\');">'.$cat.'</a>';
151
+ $is_first = false;
152
+ }
153
+ $echo_str .= "\n\t".'</h3>';
154
+
155
+ $prevcat = "";
156
+ $prevsubcat = "";
157
+ $is_first = true;
158
+ $block_open = false;
159
+ $subblock_open = false;
160
+ foreach ( $defs as $def ) {
161
+ $attr = $def['attribute'];
162
+ $subblock_active = false;
163
+ //detect if the dependencies of this attribute will be disabled or not
164
+ if ( ( $def['type'] == "onoff" && $def['value'] == "true" ) ||
165
+ ( $def['type'] == "radio" && in_array("*".$def['value'], $def['listitems']) ) )
166
+ $subblock_active = true;
167
+ // assign dependencies if exist
168
+ if ( $def['dependencies'] != null )
169
+ foreach ( $def['dependencies'] as $dependency ) {
170
+ if ( substr($dependency, 0, 1) == "!" ) //invert state for this dependency if an exclamation mark is defined
171
+ $governors[substr($dependency, 1)] = array( 'attribute' => $attr, 'active' => !$subblock_active, 'inv' => '_inv' );
172
+ else
173
+ $governors[$dependency] = array( 'attribute' => $attr, 'active' => $subblock_active, 'inv' => '' );
174
+ }
175
+ //check if this attribute depends on other
176
+ if ( $governors[$attr] != "" ) $governor = $governors[$attr];
177
+ else $governor = array( 'attribute' => "independent", 'active' => true, 'inv' => '' );
178
+
179
+ //close previous blocks
180
+ if ( $def['parent'] == "" ) {
181
+ if ( $subblock_open ) {
182
+ $echo_str .= "\n\t\t\t\t\t\t\t".'</tbody>';
183
+ $echo_str .= "\n\t\t\t\t\t\t".'</table>';
184
+ $subblock_open = false;
185
+ }
186
+ if ( $block_open ) {
187
+ $echo_str .= "\n\t\t\t\t\t".'</div></td>';
188
+ $echo_str .= "\n\t\t\t\t".'</tr>';
189
+ $block_open = false;
190
+ }
191
+ }
192
+ //check if new category must be generated
193
+ if ( $def['category'] != $prevcat ) {
194
+ if ( $prevcat != "" ) {
195
+ $echo_str .= "\n\t\t\t".'</tbody>';
196
+ $echo_str .= "\n\t\t".'</table>';
197
+ $echo_str .= "\n\t".'</div>';
198
+ }
199
+ $prevcat = $def['category'];
200
+ $prevsubcat = "";
201
+ $echo_str .= "\n\t".'<div id="wfu_container_'.$prevcat.'" class="wfu_container"'.( $is_first ? '' : ' style="display:none;"' ).'">';
202
+ $echo_str .= "\n\t\t".'<table class="form-table wfu_main_table">';
203
+ $echo_str .= "\n\t\t\t".'<thead><tr><th></th><td></td><td></td></tr></thead>';
204
+ $echo_str .= "\n\t\t\t".'<tbody>';
205
+ $is_first = false;
206
+ }
207
+ //check if new sub-category must be generated
208
+ if ( $def['subcategory'] != $prevsubcat ) {
209
+ $prevsubcat = $def['subcategory'];
210
+ $echo_str .= "\n\t\t\t\t".'<tr class="form-field wfu_subcategory">';
211
+ $echo_str .= "\n\t\t\t\t\t".'<th scope="row" colspan="3">';
212
+ $echo_str .= "\n\t\t\t\t\t\t".'<h3 style="margin-bottom: 10px; margin-top: 10px;">'.$prevsubcat.'</h3>';
213
+ $echo_str .= "\n\t\t\t\t\t".'</th>';
214
+ $echo_str .= "\n\t\t\t\t".'</tr>';
215
+ }
216
+ //draw attribute element
217
+ if ( $def['parent'] == "" ) {
218
+ $dlp = "\n\t\t\t\t";
219
+ }
220
+ else {
221
+ if ( !$subblock_open ) {
222
+ $echo_str .= "\n\t\t\t\t\t\t".'<div class="wfu_shadow wfu_shadow_'.$def['parent'].$governor['inv'].'" style="display:'.( $governor['active'] ? 'none' : 'block' ).';"></div>';
223
+ $echo_str .= "\n\t\t\t\t\t\t".'<table class="form-table wfu_inner_table" style="margin:0;">';
224
+ $echo_str .= "\n\t\t\t\t\t\t\t".'<tbody>';
225
+ }
226
+ $dlp = "\n\t\t\t\t\t\t\t\t";
227
+ }
228
+ $echo_str .= $dlp.'<tr class="form-field">';
229
+ $echo_str .= $dlp."\t".'<th scope="row"><div class="wfu_td_div">';
230
+ if ( $def['parent'] == "" ) $echo_str .= $dlp."\t\t".'<div class="wfu_shadow wfu_shadow_'.$governor['attribute'].$governor['inv'].'" style="display:'.( $governor['active'] ? 'none' : 'block' ).';"></div>';
231
+ $echo_str .= $dlp."\t\t".'<label for="wfu_attribute_'.$attr.'">'.$def['name'].'</label>';
232
+ $echo_str .= $dlp."\t\t".'<div class="wfu_help_container" title="'.$def['help'].'"><img src="'.WFU_IMAGE_ADMIN_HELP.'" ></div>';
233
+ $echo_str .= $dlp."\t".'</div></th>';
234
+ $echo_str .= $dlp."\t".'<td style="vertical-align:top;"><div class="wfu_td_div">';
235
+ if ( $def['parent'] == "" ) $echo_str .= $dlp."\t\t".'<div class="wfu_shadow wfu_shadow_'.$governor['attribute'].$governor['inv'].'" style="display:'.( $governor['active'] ? 'none' : 'block' ).';"></div>';
236
+ if ( $def['type'] == "onoff" ) {
237
+ $echo_str .= $dlp."\t\t".'<div id="wfu_attribute_'.$attr.'" class="wfu_onoff_container_'.( $def['value'] == "true" ? "on" : "off" ).'" onclick="wfu_admin_onoff_clicked(\''.$attr.'\');">';
238
+ $echo_str .= $dlp."\t\t\t".'<div class="wfu_onoff_slider"></div>';
239
+ $echo_str .= $dlp."\t\t\t".'<span class="wfu_onoff_text">ON</span>';
240
+ $echo_str .= $dlp."\t\t\t".'<span class="wfu_onoff_text">OFF</span>';
241
+ $echo_str .= $dlp."\t\t".'</div>';
242
+ }
243
+ elseif ( $def['type'] == "text" ) {
244
+ $echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" value="'.$def['value'].'" />';
245
+ if ( $def['variables'] != null ) $echo_str .= wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
246
+ }
247
+ elseif ( $def['type'] == "placements" ) {
248
+ $components_used = array();
249
+ foreach ( $components as $component ) $components_used[$component['id']] = false;
250
+ $centered_content = '<div style="display:table; width:100%; height:100%;"><div style="display:table-cell; text-align:center; vertical-align:middle;">XXX</div></div>';
251
+ $echo_str .= $dlp."\t\t".'<div class="wfu_placements_wrapper">';
252
+ $echo_str .= $dlp."\t\t\t".'<div id="wfu_placements_container" class="wfu_placements_container">';
253
+ $itemplaces = explode("/", $def['value']);
254
+ foreach ( $itemplaces as $section ) {
255
+ $echo_str .= $dlp."\t\t\t\t".'<div class="wfu_component_separator_hor"></div>';
256
+ $echo_str .= $dlp."\t\t\t\t".'<div class="wfu_component_separator_ver"></div>';
257
+ $items_in_section = explode("+", trim($section));
258
+ $section_array = array( );
259
+ foreach ( $items_in_section as $item_in_section ) {
260
+ if ( key_exists($item_in_section, $components_indexed) ) {
261
+ $components_used[$item_in_section] = true;
262
+ $echo_str .= $dlp."\t\t\t\t".'<div id="wfu_component_box_'.$item_in_section.'" class="wfu_component_box" draggable="true">'.str_replace("XXX", $components_indexed[$item_in_section]['name'], $centered_content).'</div>';
263
+ $echo_str .= $dlp."\t\t\t\t".'<div class="wfu_component_separator_ver"></div>';
264
+ }
265
+ }
266
+ }
267
+ $echo_str .= $dlp."\t\t\t\t".'<div class="wfu_component_separator_hor"></div>';
268
+ $echo_str .= $dlp."\t\t\t\t".'<div id="wfu_component_bar_hor" class="wfu_component_bar_hor"></div>';
269
+ $echo_str .= $dlp."\t\t\t\t".'<div id="wfu_component_bar_ver" class="wfu_component_bar_ver"></div>';
270
+ $echo_str .= $dlp."\t\t\t".'</div>';
271
+ $echo_str .= $dlp."\t\t\t".'<div id="wfu_componentlist_container" class="wfu_componentlist_container">';
272
+ $echo_str .= $dlp."\t\t\t\t".'<div id="wfu_componentlist_dragdrop" class="wfu_componentlist_dragdrop" style="display:none;"></div>';
273
+ $ii = 1;
274
+ foreach ( $components as $component ) {
275
+ $echo_str .= $dlp."\t\t\t\t".'<div id="wfu_component_box_container_'.$component['id'].'" class="wfu_component_box_container">';
276
+ $echo_str .= $dlp."\t\t\t\t\t".'<div class="wfu_component_box_base">'.str_replace("XXX", $component['name'], $centered_content).'</div>';
277
+ if ( !$components_used[$component['id']] )
278
+ $echo_str .= $dlp."\t\t\t\t\t".'<div id="wfu_component_box_'.$component['id'].'" class="wfu_component_box wfu_inbase" draggable="true">'.str_replace("XXX", $component['name'], $centered_content).'</div>';
279
+ $echo_str .= $dlp."\t\t\t\t".'</div>'.( ($ii++) % 3 == 0 ? '<br />' : '' );
280
+ }
281
+ $echo_str .= $dlp."\t\t\t".'</div>';
282
+ $echo_str .= $dlp."\t\t".'</div>';
283
+ }
284
+ elseif ( $def['type'] == "ltext" ) {
285
+ $echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" class="wfu_long_text" value="'.$def['value'].'" />';
286
+ if ( $def['variables'] != null ) $echo_str .= wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
287
+ }
288
+ elseif ( $def['type'] == "integer" ) {
289
+ $echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="number" name="wfu_text_elements" class="wfu_short_text" min="1" value="'.$def['value'].'" />';
290
+ }
291
+ elseif ( $def['type'] == "float" ) {
292
+ $echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="number" name="wfu_text_elements" class="wfu_short_text" step="any" min="0" value="'.$def['value'].'" />';
293
+ }
294
+ elseif ( $def['type'] == "radio" ) {
295
+ $echo_str .= $dlp."\t\t";
296
+ $ii = 0;
297
+ foreach ( $def['listitems'] as $item )
298
+ $echo_str .= '<input name="wfu_radioattribute_'.$attr.'" type="radio" value="'.$item.'" '.( $item == $def['value'] || $item == "*".$def['value'] ? 'checked="checked" ' : '' ).'style="width:auto; margin:0px 2px 0px '.( ($ii++) == 0 ? '0px' : '8px' ).';" onchange="wfu_admin_radio_clicked(\''.$attr.'\');" />'.( $item[0] == "*" ? substr($item, 1) : $item );
299
+ // $echo_str .= '<input type="button" class="button" value="empty" style="width:auto; margin:-2px 0px 0px 8px;" />';
300
+ }
301
+ elseif ( $def['type'] == "ptext" ) {
302
+ $parts = explode("/", $def['value']);
303
+ $singular = $parts[0];
304
+ if ( count($parts) < 2 ) $plural = $singular;
305
+ else $plural = $parts[1];
306
+ $echo_str .= $dlp."\t\t".'<span class="wfu_ptext_span">Singular</span><input id="wfu_attribute_s_'.$attr.'" type="text" name="wfu_ptext_elements" value="'.$singular.'" />';
307
+ if ( $def['variables'] != null ) if ( count($def['variables']) > 0 ) $echo_str .= $dlp."\t\t".'<br /><span class="wfu_ptext_span">&nbsp;</span>';
308
+ if ( $def['variables'] != null ) $echo_str .= wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_s_'.$attr);
309
+ $echo_str .= $dlp."\t\t".'<br /><span class="wfu_ptext_span">Plural</span><input id="wfu_attribute_p_'.$attr.'" type="text" name="wfu_ptext_elements" value="'.$plural.'" />';
310
+ if ( $def['variables'] != null ) if ( count($def['variables']) > 0 ) $echo_str .= $dlp."\t\t".'<br /><span class="wfu_ptext_span">&nbsp;</span>';
311
+ if ( $def['variables'] != null ) $echo_str .= wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_p_'.$attr);
312
+ }
313
+ elseif ( $def['type'] == "mtext" ) {
314
+ $val = str_replace("%n%", "\n", $def['value']);
315
+ $echo_str .= $dlp."\t\t".'<textarea id="wfu_attribute_'.$attr.'" name="wfu_text_elements" rows="5">'.$val.'</textarea>';
316
+ if ( $def['variables'] != null ) $echo_str .= wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
317
+ }
318
+ elseif ( $def['type'] == "rolelist" ) {
319
+ $roles = $wp_roles->get_names();
320
+ $def['value'] = strtolower($def['value']);
321
+ if ( $def['value'] == "all" ) $selected = array("administrator");
322
+ else $selected = explode(",", $def['value']);
323
+ foreach ( $selected as $key => $item ) $selected[$key] = trim($item);
324
+ $echo_str .= $dlp."\t\t".'<select id="wfu_attribute_'.$attr.'" multiple="multiple" size="'.count($roles).'" onchange="wfu_update_rolelist_value(\''.$attr.'\');"'.( strtolower($def['value']) == "all" ? ' disabled="disabled"' : '' ).'>';
325
+ foreach ( $roles as $roleid => $rolename )
326
+ $echo_str .= $dlp."\t\t\t".'<option value="'.$roleid.'"'.( in_array($roleid, $selected) ? ' selected="selected"' : '' ).'>'.$rolename.'</option>';
327
+ $echo_str .= $dlp."\t\t".'</select>';
328
+ $echo_str .= $dlp."\t\t".'<div class="wfu_rolelist_checkall"><input id="wfu_attribute_'.$attr.'_all" type="checkbox" onchange="wfu_update_rolelist_value(\''.$attr.'\');"'.( strtolower($def['value']) == "all" ? ' checked="checked"' : '' ).' /> Select all (including guests)</div>';
329
+ }
330
+ elseif ( $def['type'] == "dimensions" ) {
331
+ $vals_arr = explode(",", $def['value']);
332
+ $vals = array();
333
+ foreach ( $vals_arr as $val_raw ) {
334
+ list($val_id, $val) = explode(":", $val_raw);
335
+ $vals[trim($val_id)] = trim($val);
336
+ }
337
+ $dims = array();
338
+ foreach ( $components as $comp ) {
339
+ if ( $comp['dimensions'] == null ) $dims[$comp['id']] = $comp['name'];
340
+ else foreach ( $comp['dimensions'] as $dimraw ) {
341
+ list($dim_id, $dim_name) = explode("/", $dimraw);
342
+ $dims[$dim_id] = $dim_name;
343
+ }
344
+ }
345
+ foreach ( $dims as $dim_id => $dim_name ) {
346
+ $echo_str .= $dlp."\t\t".'<span style="display:inline-block; width:130px;">'.$dim_name.'</span><input id="wfu_attribute_'.$attr.'_'.$dim_id.'" type="text" name="wfu_dimension_elements_'.$attr.'" class="wfu_short_text" value="'.$vals[$dim_id].'" /><br />';
347
+ }
348
+ }
349
+ elseif ( $def['type'] == "userfields" ) {
350
+ $fields_arr = explode("/", $def['value']);
351
+ $fields = array();
352
+ foreach ( $fields_arr as $field_raw ) {
353
+ $is_req = ( substr($field_raw, 0, 1) == "*" );
354
+ if ( $is_req ) $field_raw = substr($field_raw, 1);
355
+ if ( $field_raw != "" ) array_push($fields, array( "name" => $field_raw, "required" => $is_req ));
356
+ }
357
+ if ( count($fields) == 0 ) array_push($fields, array( "name" => "", "required" => false ));
358
+ $echo_str .= $dlp."\t\t".'<div class="wfu_userdata_container">';
359
+ foreach ( $fields as $field ) {
360
+ $echo_str .= $dlp."\t\t\t".'<div class="wfu_userdata_line">';
361
+ $echo_str .= $dlp."\t\t\t\t".'<input type="text" name="wfu_userfield_elements" value="'.$field['name'].'" />';
362
+ $echo_str .= $dlp."\t\t\t\t".'<div class="wfu_userdata_action" onclick="wfu_userdata_add_field(this);"><img src="'.WFU_IMAGE_ADMIN_USERDATA_ADD.'" ></div>';
363
+ $echo_str .= $dlp."\t\t\t\t".'<div class="wfu_userdata_action wfu_userdata_action_disabled" onclick="wfu_userdata_remove_field(this);"><img src="'.WFU_IMAGE_ADMIN_USERDATA_REMOVE.'" ></div>';
364
+ $echo_str .= $dlp."\t\t\t\t".'<input type="checkbox"'.( $field['required'] ? 'checked="checked"' : '' ).' onchange="wfu_update_userfield_value({target:this});" />';
365
+ $echo_str .= $dlp."\t\t\t\t".'<span>Required</span>';
366
+ $echo_str .= $dlp."\t\t\t".'</div>';
367
+ }
368
+ $echo_str .= $dlp."\t\t".'</div>';
369
+ }
370
+ elseif ( $def['type'] == "color" ) {
371
+ $echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" class="wfu_color_field" value="'.$def['value'].'" />';
372
+ }
373
+ elseif ( $def['type'] == "color-triplet" ) {
374
+ $triplet = explode(",", $def['value']);
375
+ foreach ( $triplet as $key => $item ) $triplet[$key] = trim($item);
376
+ $echo_str .= $dlp."\t\t".'<div class="wfu_color_container"><label style="display:inline-block; width:120px; margin-top:-16px;">Text Color</label><input id="wfu_attribute_'.$attr.'_color" type="text" class="wfu_color_field" name="wfu_triplecolor_elements" value="'.$triplet[0].'" /></div>';
377
+ $echo_str .= $dlp."\t\t".'<div class="wfu_color_container"><label style="display:inline-block; width:120px; margin-top:-16px;">Background Color</label><input id="wfu_attribute_'.$attr.'_bgcolor" type="text" class="wfu_color_field" name="wfu_triplecolor_elements" value="'.$triplet[1].'" /></div>';
378
+ $echo_str .= $dlp."\t\t".'<div class="wfu_color_container"><label style="display:inline-block; width:120px; margin-top:-16px;">Border Color</label><input id="wfu_attribute_'.$attr.'_borcolor" type="text" class="wfu_color_field" name="wfu_triplecolor_elements" value="'.$triplet[2].'" /></div>';
379
+ }
380
+ else {
381
+ $echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" value="'.$def['value'].'" />';
382
+ if ( $def['variables'] != null ) $echo_str .= wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
383
+ }
384
+ $echo_str .= $dlp."\t".'</div></td>';
385
+ if ( $def['parent'] == "" ) {
386
+ $echo_str .= $dlp."\t".'<td style="position:relative; vertical-align:top; padding:0;"><div class="wfu_td_div">';
387
+ $block_open = false;
388
+ }
389
+ else {
390
+ $echo_str .= $dlp.'</tr>';
391
+ $subblock_open = true;
392
+ }
393
+ }
394
+ if ( $subblock_open ) {
395
+ $echo_str .= "\n\t\t\t\t\t\t".'</div>';
396
+ }
397
+ if ( $block_open ) {
398
+ $echo_str .= "\n\t\t\t\t\t".'</div></td>';
399
+ $echo_str .= "\n\t\t\t\t".'</tr>';
400
+ }
401
+ $echo_str .= "\n\t\t\t".'</tbody>';
402
+ $echo_str .= "\n\t\t".'</table>';
403
+ $handler = 'function() { wfu_Attach_Admin_Events(); }';
404
+ $echo_str .= "\n\t".'<script type="text/javascript">if(window.addEventListener) { window.addEventListener("load", '.$handler.', false); } else if(window.attachEvent) { window.attachEvent("onload", '.$handler.'); } else { window["onload"] = '.$handler.'; }</script>';
405
+ $echo_str .= "\n".'</div>';
406
+ // $echo_str .= "\n\t".'<div style="margin-top:10px;">';
407
+ // $echo_str .= "\n\t\t".'<label>Final shortcode text</label>';
408
+ // $echo_str .= "\n\t".'</div>';
409
+
410
+ echo $echo_str;
411
+ }
412
+
413
+ function wfu_insert_variables($variables, $class) {
414
+ $ret = "";
415
+ foreach ( $variables as $variable )
416
+ if ( $variable == "%userdataXXX%" ) $ret .= $dlp."\t\t".'<select class="'.$class.'" name="wfu_userfield_select" title="'.constant("WFU_VARIABLE_TITLE_".strtoupper(str_replace("%", "", $variable))).'" onchange="wfu_insert_userfield_variable(this);"><option style="display:none;">%userdataXXX%</option></select>';
417
+ elseif ( $variable != "%n%" ) $ret .= $dlp."\t\t".'<span class="'.$class.'" title="'.constant("WFU_VARIABLE_TITLE_".strtoupper(str_replace("%", "", $variable))).'" ondblclick="wfu_insert_variable(this);">'.$variable.'</span>';
418
+ return $ret;
419
+ }
420
+
421
+ function wfu_update_settings() {
422
+ if ( !current_user_can( 'manage_options' ) ) return;
423
+ $plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
424
+ $new_plugin_options = array();
425
+
426
+ // $enabled = ( isset($_POST['wfu_enabled']) ? ( $_POST['wfu_enabled'] == "on" ? 1 : 0 ) : 0 );
427
+ if ( isset($_POST['wfu_basedir']) && isset($_POST['submit']) ) {
428
+ if ( $_POST['submit'] == "Update" ) {
429
+ $new_plugin_options['version'] = '1.0';
430
+ $new_plugin_options['shortcode'] = $plugin_options['shortcode'];
431
+ $new_plugin_options['basedir'] = $_POST['wfu_basedir'];
432
+ $encoded_options = wfu_encode_plugin_options($new_plugin_options);
433
+ update_option( "wordpress_file_upload_options", $encoded_options );
434
+ }
435
+ }
436
+
437
+ return true;
438
+ }
439
+
440
+ function wfu_browse_files($basedir) {
441
+ if ( !current_user_can( 'manage_options' ) ) return;
442
+ //first decode basedir
443
+ $basedir = wfu_plugin_decode_string($basedir);
444
+ //then extract sort info from basedir
445
+ $ret = wfu_extract_sortdata_from_path($basedir);
446
+ $basedir = $ret['path'];
447
+ $sort = $ret['sort'];
448
+ if ( $sort == "" ) $sort = 'name';
449
+ if ( substr($sort, 0, 1) == '-' ) $order = SORT_DESC;
450
+ else $order = SORT_ASC;
451
+
452
+ //adjust basedir to have a standard format
453
+ if ( $basedir != "" ) {
454
+ if ( substr($basedir, -1) != '/' ) $basedir .= '/';
455
+ if ( !file_exists($basedir) ) $basedir = "";
456
+ }
457
+ //set basedit to default value if empty
458
+ if ( $basedir == "" ) {
459
+ $plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
460
+ $basedir = $plugin_options['basedir'];
461
+ $temp_params = array( 'uploadpath' => $basedir, 'accessmethod' => 'normal', 'ftpinfo' => '', 'useftpdomain' => 'false' );
462
+ $basedir = wfu_upload_plugin_full_path($temp_params);
463
+ }
464
+ //find relative dir
465
+ $reldir = str_replace(ABSPATH, "root/", $basedir);
466
+ //save dir route to an array
467
+ $parts = explode('/', $reldir);
468
+ $route = array();
469
+ $prev = "";
470
+ foreach ( $parts as $part ) {
471
+ $part = trim($part);
472
+ if ( $part != "" ) {
473
+ if ( $part == 'root' && $prev == "" ) $prev = ABSPATH;
474
+ else $prev .= $part.'/';
475
+ array_push($route, array( 'item' => $part, 'path' => $prev ));
476
+ }
477
+ }
478
+ //calculate upper directory
479
+ $updir = substr($basedir, 0, -1);
480
+ $delim_pos = strrpos($updir, '/');
481
+ if ( $delim_pos !== false ) $updir = substr($updir, 0, $delim_pos + 1);
482
+
483
+ $echo_str = "\n".'<div class="wrap">';
484
+ $echo_str .= "\n\t".'<div style="margin-top:20px;">';
485
+ $echo_str .= "\n\t\t".'<a href="/wp-admin/options-general.php?page=wordpress_file_upload&amp;action=manage_settings" class="button" title="go back">Go to Settings</a>';
486
+ $echo_str .= "\n\t".'</div>';
487
+ $echo_str .= "\n\t".'<h2 style="margin-bottom: 10px;">File Browser</h2>';
488
+ $echo_str .= "\n\t".'<div>';
489
+ $echo_str .= "\n\t\t".'<span><strong>Location:</strong> </span>';
490
+ foreach ( $route as $item ) {
491
+ $echo_str .= '<a href="/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.wfu_plugin_encode_string($item['path']).'">'.$item['item'].'</a>';
492
+ $echo_str .= '<span>/</span>';
493
+ }
494
+ $echo_str .= "\n\t".'</div>';
495
+ $echo_str .= "\n\t".'<a href="/wp-admin/options-general.php?page=wordpress_file_upload&amp;action=create_dir&dir='.wfu_plugin_encode_string($basedir.'[['.$sort.']]').'" class="button" title="create folder" style="margin-top:6px">Create folder</a>';
496
+ $echo_str .= "\n\t".'<div style="margin-top:10px;">';
497
+ $echo_str .= "\n\t\t".'<table class="widefat">';
498
+ $echo_str .= "\n\t\t\t".'<thead>';
499
+ $echo_str .= "\n\t\t\t\t".'<tr>';
500
+ $echo_str .= "\n\t\t\t\t\t".'<th scope="col">';
501
+ $enc_dir = wfu_plugin_encode_string($basedir.'[['.( substr($sort, -4) == 'name' ? ( $order == SORT_ASC ? '-name' : 'name' ) : 'name' ).']]');
502
+ $echo_str .= "\n\t\t\t\t\t\t".'<a href="/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$enc_dir.'">Name'.( substr($sort, -4) == 'name' ? ( $order == SORT_ASC ? ' &uarr;' : ' &darr;' ) : '' ).'</a>';
503
+ $echo_str .= "\n\t\t\t\t\t".'</th>';
504
+ $echo_str .= "\n\t\t\t\t\t".'<th scope="col">';
505
+ $enc_dir = wfu_plugin_encode_string($basedir.'[['.( substr($sort, -4) == 'size' ? ( $order == SORT_ASC ? '-size' : 'size' ) : 'size' ).']]');
506
+ $echo_str .= "\n\t\t\t\t\t\t".'<a href="/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$enc_dir.'">Size'.( substr($sort, -4) == 'size' ? ( $order == SORT_ASC ? ' &uarr;' : ' &darr;' ) : '' ).'</a>';
507
+ $echo_str .= "\n\t\t\t\t\t".'</th>';
508
+ $echo_str .= "\n\t\t\t\t\t".'<th scope="col">';
509
+ $enc_dir = wfu_plugin_encode_string($basedir.'[['.( substr($sort, -4) == 'date' ? ( $order == SORT_ASC ? '-date' : 'date' ) : 'date' ).']]');
510
+ $echo_str .= "\n\t\t\t\t\t\t".'<a href="/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$enc_dir.'">Date'.( substr($sort, -4) == 'date' ? ( $order == SORT_ASC ? ' &uarr;' : ' &darr;' ) : '' ).'</a>';
511
+ $echo_str .= "\n\t\t\t\t\t".'</th>';
512
+ $echo_str .= "\n\t\t\t\t".'</tr>';
513
+ $echo_str .= "\n\t\t\t".'</thead>';
514
+ $echo_str .= "\n\t\t\t".'<tbody>';
515
+
516
+ $dirlist = array();
517
+ $filelist = array();
518
+ if ( $handle = opendir($basedir) ) {
519
+ $blacklist = array('.', '..');
520
+ while ( false !== ($file = readdir($handle)) )
521
+ if ( !in_array($file, $blacklist) ) {
522
+ $filepath = $basedir.$file;
523
+ $stat = stat($filepath);
524
+ if ( is_dir($filepath) ) {
525
+ array_push($dirlist, array( 'name' => $file, 'fullpath' => $filepath, 'mdate' => $stat['mtime'] ));
526
+ }
527
+ else {
528
+ array_push($filelist, array( 'name' => $file, 'fullpath' => $filepath, 'size' => $stat['size'], 'mdate' => $stat['mtime'] ));
529
+ }
530
+ }
531
+ closedir($handle);
532
+ }
533
+ $dirsort = ( substr($sort, -4) == 'date' ? 'mdate' : substr($sort, -4) );
534
+ $filesort = $dirsort;
535
+ $dirorder = $order;
536
+ if ( $dirsort == 'size' ) { $dirsort = 'name'; $dirorder = SORT_ASC; }
537
+ $dirlist = wfu_array_sort($dirlist, $dirsort, $dirorder);
538
+ $filelist = wfu_array_sort($filelist, $filesort, $order);
539
+
540
+ if ( $reldir != "root/" ) {
541
+ $enc_dir = wfu_plugin_encode_string($updir);
542
+ $echo_str .= "\n\t\t\t\t".'<tr onmouseover="for (i in document.getElementsByName(\'wfu_dir_actions\')){document.getElementsByName(\'wfu_dir_actions\').item(i).style.visibility=\'hidden\';}" onmouseout="for (i in document.getElementsByName(\'wfu_dir_actions\')){document.getElementsByName(\'wfu_dir_actions\').item(i).style.visibility=\'hidden\';}">';
543
+ $echo_str .= "\n\t\t\t\t\t".'<td style="padding: 5px 5px 5px 10px;">';
544
+ $echo_str .= "\n\t\t\t\t\t\t".'<a class="row-title" href="/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$enc_dir.'" title="go up">..</a>';
545
+ $echo_str .= "\n\t\t\t\t\t".'</td>';
546
+ $echo_str .= "\n\t\t\t\t\t".'<td style="padding: 5px 5px 5px 10px;"> </td>';
547
+ $echo_str .= "\n\t\t\t\t\t".'<td style="padding: 5px 5px 5px 10px;"> </td>';
548
+ $echo_str .= "\n\t\t\t\t".'</tr>';
549
+ }
550
+ $ii = 1;
551
+ foreach ( $dirlist as $dir ) {
552
+ $enc_dir = wfu_plugin_encode_string($dir['fullpath'].'[['.$sort.']]');
553
+ $echo_str .= "\n\t\t\t\t".'<tr onmouseover="for (i in document.getElementsByName(\'wfu_dir_actions\')){document.getElementsByName(\'wfu_dir_actions\').item(i).style.visibility=\'hidden\';} document.getElementById(\'wfu_dir_actions_'.$ii.'\').style.visibility=\'visible\'" onmouseout="for (i in document.getElementsByName(\'wfu_dir_actions\')){document.getElementsByName(\'wfu_dir_actions\').item(i).style.visibility=\'hidden\';}">';
554
+ $echo_str .= "\n\t\t\t\t\t".'<td style="padding: 5px 5px 5px 10px;">';
555
+ $echo_str .= "\n\t\t\t\t\t\t".'<a class="row-title" href="/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$enc_dir.'" title="'.$dir['name'].'">'.$dir['name'].'</a>';
556
+ $echo_str .= "\n\t\t\t\t\t\t".'<div id="wfu_dir_actions_'.$ii.'" name="wfu_dir_actions" style="visibility:hidden;">';
557
+ $echo_str .= "\n\t\t\t\t\t\t\t".'<span>';
558
+ $echo_str .= "\n\t\t\t\t\t\t\t\t".'<a href="/wp-admin/options-general.php?page=wordpress_file_upload&action=rename_dir&file='.$enc_dir.'" title="Rename this folder">Rename</a>';
559
+ $echo_str .= "\n\t\t\t\t\t\t\t\t".' | ';
560
+ $echo_str .= "\n\t\t\t\t\t\t\t".'</span>';
561
+ $echo_str .= "\n\t\t\t\t\t\t\t".'<span>';
562
+ $echo_str .= "\n\t\t\t\t\t\t\t\t".'<a href="/wp-admin/options-general.php?page=wordpress_file_upload&action=delete_dir&file='.$enc_dir.'" title="Delete this folder">Delete</a>';
563
+ $echo_str .= "\n\t\t\t\t\t\t\t".'</span>';
564
+ $echo_str .= "\n\t\t\t\t\t\t".'</div>';
565
+ $echo_str .= "\n\t\t\t\t\t".'</td>';
566
+ $echo_str .= "\n\t\t\t\t\t".'<td style="padding: 5px 5px 5px 10px;"> </td>';
567
+ $echo_str .= "\n\t\t\t\t\t".'<td style="padding: 5px 5px 5px 10px;">'.date("d/m/Y H:i:s", $dir['mdate']).'</td>';
568
+ $echo_str .= "\n\t\t\t\t".'</tr>';
569
+ $ii ++;
570
+ }
571
+ foreach ( $filelist as $file ) {
572
+ $enc_file = wfu_plugin_encode_string($file['fullpath'].'[['.$sort.']]');
573
+ $echo_str .= "\n\t\t\t\t".'<tr onmouseover="for (i in document.getElementsByName(\'wfu_file_actions\')){document.getElementsByName(\'wfu_file_actions\').item(i).style.visibility=\'hidden\';} document.getElementById(\'wfu_file_actions_'.$ii.'\').style.visibility=\'visible\'" onmouseout="for (i in document.getElementsByName(\'wfu_file_actions\')){document.getElementsByName(\'wfu_file_actions\').item(i).style.visibility=\'hidden\';}">';
574
+ $echo_str .= "\n\t\t\t\t\t".'<td style="padding: 5px 5px 5px 10px;">';
575
+ $echo_str .= "\n\t\t\t\t\t\t".'<span>'.$file['name'].'</span>';
576
+ $echo_str .= "\n\t\t\t\t\t\t".'<div id="wfu_file_actions_'.$ii.'" name="wfu_file_actions" style="visibility:hidden;">';
577
+ $echo_str .= "\n\t\t\t\t\t\t\t".'<span>';
578
+ $echo_str .= "\n\t\t\t\t\t\t\t\t".'<a href="/wp-admin/options-general.php?page=wordpress_file_upload&action=rename_file&file='.$enc_file.'" title="Rename this file">Rename</a>';
579
+ $echo_str .= "\n\t\t\t\t\t\t\t\t".' | ';
580
+ $echo_str .= "\n\t\t\t\t\t\t\t".'</span>';
581
+ $echo_str .= "\n\t\t\t\t\t\t\t".'<span>';
582
+ $echo_str .= "\n\t\t\t\t\t\t\t\t".'<a href="/wp-admin/options-general.php?page=wordpress_file_upload&action=delete_file&file='.$enc_file.'" title="Delete this file">Delete</a>';
583
+ $echo_str .= "\n\t\t\t\t\t\t\t".'</span>';
584
+ $echo_str .= "\n\t\t\t\t\t\t".'</div>';
585
+ $echo_str .= "\n\t\t\t\t\t".'</td>';
586
+ $echo_str .= "\n\t\t\t\t\t".'<td style="padding: 5px 5px 5px 10px;">'.$file['size'].'</td>';
587
+ $echo_str .= "\n\t\t\t\t\t".'<td style="padding: 5px 5px 5px 10px;">'.date("d/m/Y H:i:s", $file['mdate']).'</td>';
588
+ $echo_str .= "\n\t\t\t\t".'</tr>';
589
+ $ii ++;
590
+ }
591
+ $echo_str .= "\n\t\t\t".'</tbody>';
592
+ $echo_str .= "\n\t\t".'</table>';
593
+ $echo_str .= "\n\t".'</div>';
594
+ $echo_str .= "\n".'</div>';
595
+
596
+ return $echo_str;
597
+ }
598
+
599
+ function wfu_rename_file_prompt($file, $type, $error) {
600
+ if ( !current_user_can( 'manage_options' ) ) return;
601
+ $dec_file = wfu_plugin_decode_string($file);
602
+ //first extract sort info from dec_file
603
+ $ret = wfu_extract_sortdata_from_path($dec_file);
604
+ $dec_file = $ret['path'];
605
+ if ( $type == 'dir' && substr($dec_file, -1) == '/' ) $dec_file = substr($dec_file, 0, -1);
606
+ $parts = pathinfo($dec_file);
607
+ $newname = $parts['basename'];
608
+ $enc_dir = wfu_plugin_encode_string($parts['dirname'].'[['.$ret['sort'].']]');
609
+
610
+ $echo_str = "\n".'<div class="wrap">';
611
+ if ( $error ) {
612
+ $newname = $_SESSION['wfu_rename_file']['newname'];
613
+ $echo_str .= "\n\t".'<div class="error">';
614
+ $echo_str .= "\n\t\t".'<p>'.$_SESSION['wfu_rename_file_error'].'</p>';
615
+ $echo_str .= "\n\t".'</div>';
616
+ }
617
+ $echo_str .= "\n\t".'<div style="margin-top:20px;">';
618
+ $echo_str .= "\n\t\t".'<a href="/wp-admin/options-general.php?page=wordpress_file_upload&amp;action=file_browser&dir='.$enc_dir.'" class="button" title="go back">Go back</a>';
619
+ $echo_str .= "\n\t".'</div>';
620
+ $echo_str .= "\n\t".'<h2 style="margin-bottom: 10px;">Rename '.( $type == 'dir' ? 'Folder' : 'File' ).'</h2>';
621
+ $echo_str .= "\n\t".'<form enctype="multipart/form-data" name="renamefile" id="renamefile" method="post" action="/wp-admin/options-general.php?page=wordpress_file_upload" class="validate">';
622
+ $echo_str .= "\n\t\t".'<input type="hidden" name="action" value="rename'.( $type == 'dir' ? 'dir' : 'file' ).'">';
623
+ $echo_str .= "\n\t\t".'<input type="hidden" name="dir" value="'.$enc_dir.'">';
624
+ $echo_str .= "\n\t\t".'<input type="hidden" name="file" value="'.$file.'">';
625
+ if ( $type == 'dir' ) $echo_str .= "\n\t\t".'<label>Enter new name for folder <strong>'.$dec_file.'</strong></label><br/>';
626
+ else $echo_str .= "\n\t\t".'<label>Enter new filename for file <strong>'.$dec_file.'</strong></label><br/>';
627
+ $echo_str .= "\n\t\t".'<input name="wfu_newname" id="wfu_newname" type="text" value="'.$newname.'" style="width:50%;" />';
628
+ $echo_str .= "\n\t\t".'<p class="submit">';
629
+ $echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Rename">';
630
+ $echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Cancel">';
631
+ $echo_str .= "\n\t\t".'</p>';
632
+ $echo_str .= "\n\t".'</form>';
633
+ $echo_str .= "\n".'</div>';
634
+ return $echo_str;
635
+ }
636
+
637
+ function wfu_rename_file($file, $type) {
638
+ if ( !current_user_can( 'manage_options' ) ) return;
639
+ $dec_file = wfu_plugin_decode_string($file);
640
+ $dec_file = wfu_flatten_path($dec_file);
641
+ if ( $type == 'dir' && substr($dec_file, -1) == '/' ) $dec_file = substr($dec_file, 0, -1);
642
+ if ( !file_exists($dec_file) ) return wfu_browse_files();
643
+ $parts = pathinfo($dec_file);
644
+ $error = "";
645
+ if ( isset($_POST['wfu_newname']) && isset($_POST['submit']) ) {
646
+ if ( $_POST['submit'] == "Rename" && $_POST['wfu_newname'] != $parts['basename'] ) {
647
+ $new_file = $parts['dirname'].'/'.$_POST['wfu_newname'];
648
+ if ( $_POST['wfu_newname'] == "" ) $error = 'Error: New '.( $type == 'dir' ? 'folder ' : 'file' ).'name cannot be empty!';
649
+ elseif ( preg_match("/[^A-Za-z0-9.#\-$]/", $_POST['wfu_newname']) ) $error = 'Error: name contains invalid characters! Please correct.';
650
+ elseif ( file_exists($new_file) ) $error = 'Error: The '.( $type == 'dir' ? 'folder' : 'file' ).' <strong>'.$_POST['wfu_newname'].'</strong> already exists! Please choose another one.';
651
+ elseif ( rename($dec_file, $new_file) == false ) $error = 'Error: Rename of '.( $type == 'dir' ? 'folder' : 'file' ).' <strong>'.$parts['basename'].'</strong> failed!';
652
+ }
653
+ }
654
+ if ( $error != "" ) {
655
+ $_SESSION['wfu_rename_file_error'] = $error;
656
+ $_SESSION['wfu_rename_file']['newname'] = $_POST['wfu_newname'];
657
+ }
658
+ return ( $error == "" );
659
+ }
660
+
661
+ function wfu_delete_file_prompt($file, $type) {
662
+ if ( !current_user_can( 'manage_options' ) ) return;
663
+ $dec_file = wfu_plugin_decode_string($file);
664
+ //first extract sort info from dec_file
665
+ $ret = wfu_extract_sortdata_from_path($dec_file);
666
+ $dec_file = $ret['path'];
667
+ if ( $type == 'dir' && substr($dec_file, -1) == '/' ) $dec_file = substr($dec_file, 0, -1);
668
+ $parts = pathinfo($dec_file);
669
+ $enc_dir = wfu_plugin_encode_string($parts['dirname'].'[['.$ret['sort'].']]');
670
+
671
+ $echo_str = "\n".'<div class="wrap">';
672
+ $echo_str .= "\n\t".'<div style="margin-top:20px;">';
673
+ $echo_str .= "\n\t\t".'<a href="/wp-admin/options-general.php?page=wordpress_file_upload&amp;action=file_browser&dir='.$enc_dir.'" class="button" title="go back">Go back</a>';
674
+ $echo_str .= "\n\t".'</div>';
675
+ $echo_str .= "\n\t".'<h2 style="margin-bottom: 10px;">Delete '.( $type == 'dir' ? 'Folder' : 'File' ).'</h2>';
676
+ $echo_str .= "\n\t".'<form enctype="multipart/form-data" name="deletefile" id="deletefile" method="post" action="/wp-admin/options-general.php?page=wordpress_file_upload" class="validate">';
677
+ $echo_str .= "\n\t\t".'<input type="hidden" name="action" value="delete'.( $type == 'dir' ? 'dir' : 'file' ).'">';
678
+ $echo_str .= "\n\t\t".'<input type="hidden" name="dir" value="'.$enc_dir.'">';
679
+ $echo_str .= "\n\t\t".'<input type="hidden" name="file" value="'.$file.'">';
680
+ $echo_str .= "\n\t\t".'<label>Are you sure that you want to delete '.( $type == 'dir' ? 'folder' : 'file' ).' <strong>'.$parts['basename'].'</strong>?</label><br/>';
681
+ $echo_str .= "\n\t\t".'<p class="submit">';
682
+ $echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Delete">';
683
+ $echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Cancel">';
684
+ $echo_str .= "\n\t\t".'</p>';
685
+ $echo_str .= "\n\t".'</form>';
686
+ $echo_str .= "\n".'</div>';
687
+ return $echo_str;
688
+ }
689
+
690
+ function wfu_delete_file($file, $type) {
691
+ if ( !current_user_can( 'manage_options' ) ) return;
692
+ $dec_file = wfu_plugin_decode_string($file);
693
+ $dec_file = wfu_flatten_path($dec_file);
694
+ if ( $type == 'dir' && substr($dec_file, -1) == '/' ) $dec_file = substr($dec_file, 0, -1);
695
+ if ( isset($_POST['submit']) ) {
696
+ if ( $_POST['submit'] == "Delete" ) {
697
+ if ( $type == 'dir' && $dec_file != "" ) wfu_delTree($dec_file);
698
+ else unlink($dec_file);
699
+ }
700
+ }
701
+ return true;
702
+ }
703
+
704
+ function wfu_create_dir_prompt($dir, $error) {
705
+ if ( !current_user_can( 'manage_options' ) ) return;
706
+ $dec_dir = wfu_plugin_decode_string($dir);
707
+ //first extract sort info from dec_dir
708
+ $ret = wfu_extract_sortdata_from_path($dec_dir);
709
+ $dec_dir = $ret['path'];
710
+ if ( substr($dec_dir, -1) != '/' ) $dec_dir .= '/';
711
+ $newname = '';
712
+
713
+ $echo_str = "\n".'<div class="wrap">';
714
+ if ( $error ) {
715
+ $newname = $_SESSION['wfu_create_dir']['newname'];
716
+ $echo_str .= "\n\t".'<div class="error">';
717
+ $echo_str .= "\n\t\t".'<p>'.$_SESSION['wfu_create_dir_error'].'</p>';
718
+ $echo_str .= "\n\t".'</div>';
719
+ }
720
+ $echo_str .= "\n\t".'<div style="margin-top:20px;">';
721
+ $echo_str .= "\n\t\t".'<a href="/wp-admin/options-general.php?page=wordpress_file_upload&amp;action=file_browser&dir='.$dir.'" class="button" title="go back">Go back</a>';
722
+ $echo_str .= "\n\t".'</div>';
723
+ $echo_str .= "\n\t".'<h2 style="margin-bottom: 10px;">Create Folder</h2>';
724
+ $echo_str .= "\n\t".'<form enctype="multipart/form-data" name="createdir" id="createdir" method="post" action="/wp-admin/options-general.php?page=wordpress_file_upload" class="validate">';
725
+ $echo_str .= "\n\t\t".'<input type="hidden" name="action" value="createdir">';
726
+ $echo_str .= "\n\t\t".'<input type="hidden" name="dir" value="'.$dir.'">';
727
+ $echo_str .= "\n\t\t".'<label>Enter the name of the new folder inside <strong>'.$dec_dir.'</strong></label><br/>';
728
+ $echo_str .= "\n\t\t".'<input name="wfu_newname" id="wfu_newname" type="text" value="'.$newname.'" style="width:50%;" />';
729
+ $echo_str .= "\n\t\t".'<p class="submit">';
730
+ $echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Create">';
731
+ $echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Cancel">';
732
+ $echo_str .= "\n\t\t".'</p>';
733
+ $echo_str .= "\n\t".'</form>';
734
+ $echo_str .= "\n".'</div>';
735
+ return $echo_str;
736
+ }
737
+
738
+ function wfu_create_dir($dir) {
739
+ if ( !current_user_can( 'manage_options' ) ) return;
740
+ $dec_dir = wfu_plugin_decode_string($dir);
741
+ $dec_dir = wfu_flatten_path($dec_dir);
742
+ if ( substr($dec_dir, -1) != '/' ) $dec_dir .= '/';
743
+ if ( !file_exists($dec_dir) ) return wfu_browse_files();
744
+ $error = "";
745
+ if ( isset($_POST['wfu_newname']) && isset($_POST['submit']) ) {
746
+ if ( $_POST['submit'] == "Create" ) {
747
+ $new_dir = $dec_dir.$_POST['wfu_newname'];
748
+ if ( $_POST['wfu_newname'] == "" ) $error = 'Error: New folder name cannot be empty!';
749
+ elseif ( preg_match("/[^A-Za-z0-9.#\-$]/", $_POST['wfu_newname']) ) $error = 'Error: name contains invalid characters! Please correct.';
750
+ elseif ( file_exists($new_dir) ) $error = 'Error: The folder <strong>'.$_POST['wfu_newname'].'</strong> already exists! Please choose another one.';
751
+ elseif ( mkdir($new_dir) == false ) $error = 'Error: Creation of folder <strong>'.$_POST['wfu_newname'].'</strong> failed!';
752
+ }
753
+ }
754
+ if ( $error != "" ) {
755
+ $_SESSION['wfu_create_dir_error'] = $error;
756
+ $_SESSION['wfu_create_dir']['newname'] = $_POST['wfu_newname'];
757
+ }
758
+ return ( $error == "" );
759
+ }
760
+
761
+ ?>
lib/wfu_ajaxactions.php CHANGED
@@ -1,110 +1,112 @@
1
- <?php
2
-
3
-
4
- function wfu_ajax_action_send_email_notification() {
5
- $user = wp_get_current_user();
6
- if ( 0 == $user->ID ) $is_admin = false;
7
- else $is_admin = current_user_can('manage_options');
8
-
9
- $arr = wfu_get_params_fields_from_index($_POST['params_index']);
10
- //check referer using server sessions to avoid CSRF attacks
11
- if ( $_SESSION["wfu_token_".$arr['shortcode_id']] != $_POST['session_token'] ) die();
12
- if ( $user->user_login != $arr['user_login'] ) die();
13
-
14
- $params_str = get_option('wfu_params_'.$arr['unique_id']);
15
- $params = wfu_decode_array_from_string($params_str);
16
-
17
- /* initialize return array */
18
- $params_output_array["version"] = "full";
19
- $params_output_array["general"]['shortcode_id'] = $params["uploadid"];
20
- $params_output_array["general"]['unique_id'] = ( isset($_POST['unique_id']) ? $_POST['unique_id'] : "" );
21
- $params_output_array["general"]['state'] = 0;
22
- $params_output_array["general"]['files_count'] = 0;
23
- $params_output_array["general"]['update_wpfilebase'] = "";
24
- $params_output_array["general"]['redirect_link'] = "";
25
- $params_output_array["general"]['upload_finish_time'] = "";
26
- $params_output_array["general"]['message'] = "";
27
- $params_output_array["general"]['message_type'] = "";
28
- $params_output_array["general"]['admin_messages']['wpfilebase'] = "";
29
- $params_output_array["general"]['admin_messages']['notify'] = "";
30
- $params_output_array["general"]['admin_messages']['redirect'] = "";
31
- $params_output_array["general"]['admin_messages']['other'] = "";
32
- $params_output_array["general"]['errors']['wpfilebase'] = "";
33
- $params_output_array["general"]['errors']['notify'] = "";
34
- $params_output_array["general"]['errors']['redirect'] = "";
35
- $params_output_array["general"]['color'] = "black";
36
- $params_output_array["general"]['bgcolor'] = "#F5F5F5";
37
- $params_output_array["general"]['borcolor'] = "#D3D3D3";
38
- $params_output_array["general"]['notify_only_filename_list'] = "";
39
- $params_output_array["general"]['notify_target_path_list'] = "";
40
- $params_output_array["general"]['notify_attachment_list'] = "";
41
- $params_output_array["general"]['fail_message'] = WFU_ERROR_UNKNOWN;
42
-
43
- // prepare user data
44
- $userdata_fields = $params["userdata_fields"];
45
- foreach ( $userdata_fields as $userdata_key => $userdata_field )
46
- $userdata_fields[$userdata_key]["value"] = ( isset($_POST['userdata_'.$userdata_key]) ? $_POST['userdata_'.$userdata_key] : "" );
47
-
48
- $send_error = wfu_send_notification_email($user, $_POST['only_filename_list'], $_POST['target_path_list'], $_POST['attachment_list'], $userdata_fields, $params);
49
-
50
- /* suppress any errors if user is not admin */
51
- if ( !$is_admin ) $send_error = "";
52
-
53
- if ( $send_error != "" ) {
54
- $params_output_array["general"]['admin_messages']['notify'] = $send_error;
55
- $params_output_array["general"]['errors']['notify'] = "error";
56
- }
57
-
58
- /* construct safe output */
59
- $sout = "0;".WFU_DEFAULTMESSAGECOLORS.";0";
60
-
61
- die("wfu_fileupload_success:".$sout.":".wfu_encode_array_to_string($params_output_array));
62
- }
63
-
64
- function wfu_ajax_action_callback() {
65
- $user = wp_get_current_user();
66
- $arr = wfu_get_params_fields_from_index($_POST['params_index']);
67
- //check referer using server sessions to avoid CSRF attacks
68
- if ( $_SESSION["wfu_token_".$arr['shortcode_id']] != $_POST['session_token'] ) {
69
- echo "Session failed!<br/><br/>Session Data:<br/>";
70
- print_r($_SESSION);
71
- echo "<br/><br/>Post Data:<br/>";
72
- print_r($_POST);
73
- die();
74
- }
75
-
76
- if ( $user->user_login != $arr['user_login'] ) {
77
- echo "User failed!<br/><br/>User Data:<br/>";
78
- print_r($user);
79
- echo "<br/><br/>Post Data:<br/>";
80
- print_r($_POST);
81
- echo "<br/><br/>Params Data:<br/>";
82
- print_r($arr);
83
- die();
84
- }
85
-
86
- $params_str = get_option('wfu_params_'.$arr['unique_id']);
87
- $params = wfu_decode_array_from_string($params_str);
88
-
89
- $params['subdir_selection_index'] = $_POST['subdir_sel_index'];
90
- $_SESSION['wfu_check_refresh_'.$params["uploadid"]] = 'do not process';
91
-
92
- $wfu_process_file_array = wfu_process_files($params, 'ajax');
93
- // extract safe_output from wfu_process_file_array and pass it as separate part of the response text
94
- $safe_output = $wfu_process_file_array["general"]['safe_output'];
95
- unset($wfu_process_file_array["general"]['safe_output']);
96
- die("wfu_fileupload_success:".$safe_output.":".wfu_encode_array_to_string($wfu_process_file_array));
97
- }
98
-
99
- function wfu_ajax_action_save_shortcode() {
100
- if ( !isset($_POST['shortcode']) ) die();
101
-
102
- $plugin_options['version'] = '1.0';
103
- $plugin_options['shortcode'] = wfu_plugin_decode_string($_POST['shortcode']);
104
- $encoded_options = wfu_encode_plugin_options($plugin_options);
105
- update_option( "wordpress_file_upload_options", $encoded_options );
106
-
107
- die("save_shortcode_success");
108
- }
109
-
110
- ?>
 
 
1
+ <?php
2
+
3
+
4
+ function wfu_ajax_action_send_email_notification() {
5
+ $user = wp_get_current_user();
6
+ if ( 0 == $user->ID ) $is_admin = false;
7
+ else $is_admin = current_user_can('manage_options');
8
+
9
+ $arr = wfu_get_params_fields_from_index($_POST['params_index']);
10
+ //check referer using server sessions to avoid CSRF attacks
11
+ if ( $_SESSION["wfu_token_".$arr['shortcode_id']] != $_POST['session_token'] ) die();
12
+ if ( $user->user_login != $arr['user_login'] ) die();
13
+
14
+ $params_str = get_option('wfu_params_'.$arr['unique_id']);
15
+ $params = wfu_decode_array_from_string($params_str);
16
+
17
+ /* initialize return array */
18
+ $params_output_array["version"] = "full";
19
+ $params_output_array["general"]['shortcode_id'] = $params["uploadid"];
20
+ $params_output_array["general"]['unique_id'] = ( isset($_POST['unique_id']) ? $_POST['unique_id'] : "" );
21
+ $params_output_array["general"]['state'] = 0;
22
+ $params_output_array["general"]['files_count'] = 0;
23
+ $params_output_array["general"]['update_wpfilebase'] = "";
24
+ $params_output_array["general"]['redirect_link'] = "";
25
+ $params_output_array["general"]['upload_finish_time'] = "";
26
+ $params_output_array["general"]['message'] = "";
27
+ $params_output_array["general"]['message_type'] = "";
28
+ $params_output_array["general"]['admin_messages']['wpfilebase'] = "";
29
+ $params_output_array["general"]['admin_messages']['notify'] = "";
30
+ $params_output_array["general"]['admin_messages']['redirect'] = "";
31
+ $params_output_array["general"]['admin_messages']['other'] = "";
32
+ $params_output_array["general"]['errors']['wpfilebase'] = "";
33
+ $params_output_array["general"]['errors']['notify'] = "";
34
+ $params_output_array["general"]['errors']['redirect'] = "";
35
+ $params_output_array["general"]['color'] = "black";
36
+ $params_output_array["general"]['bgcolor'] = "#F5F5F5";
37
+ $params_output_array["general"]['borcolor'] = "#D3D3D3";
38
+ $params_output_array["general"]['notify_only_filename_list'] = "";
39
+ $params_output_array["general"]['notify_target_path_list'] = "";
40
+ $params_output_array["general"]['notify_attachment_list'] = "";
41
+ $params_output_array["general"]['fail_message'] = WFU_ERROR_UNKNOWN;
42
+
43
+ // prepare user data
44
+ $userdata_fields = $params["userdata_fields"];
45
+ foreach ( $userdata_fields as $userdata_key => $userdata_field )
46
+ $userdata_fields[$userdata_key]["value"] = ( isset($_POST['userdata_'.$userdata_key]) ? $_POST['userdata_'.$userdata_key] : "" );
47
+
48
+ $send_error = wfu_send_notification_email($user, $_POST['only_filename_list'], $_POST['target_path_list'], $_POST['attachment_list'], $userdata_fields, $params);
49
+
50
+ /* suppress any errors if user is not admin */
51
+ if ( !$is_admin ) $send_error = "";
52
+
53
+ if ( $send_error != "" ) {
54
+ $params_output_array["general"]['admin_messages']['notify'] = $send_error;
55
+ $params_output_array["general"]['errors']['notify'] = "error";
56
+ }
57
+
58
+ /* construct safe output */
59
+ $sout = "0;".WFU_DEFAULTMESSAGECOLORS.";0";
60
+
61
+ die("wfu_fileupload_success:".$sout.":".wfu_encode_array_to_string($params_output_array));
62
+ }
63
+
64
+ function wfu_ajax_action_callback() {
65
+ $user = wp_get_current_user();
66
+ $arr = wfu_get_params_fields_from_index($_POST['params_index']);
67
+ //check referer using server sessions to avoid CSRF attacks
68
+ if ( $_SESSION["wfu_token_".$arr['shortcode_id']] != $_POST['session_token'] ) {
69
+ echo "Session failed!<br/><br/>Session Data:<br/>";
70
+ print_r($_SESSION);
71
+ echo "<br/><br/>Post Data:<br/>";
72
+ print_r($_POST);
73
+ die();
74
+ }
75
+
76
+ if ( $user->user_login != $arr['user_login'] ) {
77
+ echo "User failed!<br/><br/>User Data:<br/>";
78
+ print_r($user);
79
+ echo "<br/><br/>Post Data:<br/>";
80
+ print_r($_POST);
81
+ echo "<br/><br/>Params Data:<br/>";
82
+ print_r($arr);
83
+ die();
84
+ }
85
+
86
+ $params_str = get_option('wfu_params_'.$arr['unique_id']);
87
+ $params = wfu_decode_array_from_string($params_str);
88
+
89
+ $params['subdir_selection_index'] = $_POST['subdir_sel_index'];
90
+ $_SESSION['wfu_check_refresh_'.$params["uploadid"]] = 'do not process';
91
+
92
+ $wfu_process_file_array = wfu_process_files($params, 'ajax');
93
+ // extract safe_output from wfu_process_file_array and pass it as separate part of the response text
94
+ $safe_output = $wfu_process_file_array["general"]['safe_output'];
95
+ unset($wfu_process_file_array["general"]['safe_output']);
96
+ die("wfu_fileupload_success:".$safe_output.":".wfu_encode_array_to_string($wfu_process_file_array));
97
+ }
98
+
99
+ function wfu_ajax_action_save_shortcode() {
100
+ if ( !isset($_POST['shortcode']) ) die();
101
+ $plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
102
+
103
+ $new_plugin_options['version'] = '1.0';
104
+ $new_plugin_options['shortcode'] = wfu_plugin_decode_string($_POST['shortcode']);
105
+ $new_plugin_options['basedir'] = $plugin_options['basedir'];
106
+ $encoded_options = wfu_encode_plugin_options($new_plugin_options);
107
+ update_option( "wordpress_file_upload_options", $encoded_options );
108
+
109
+ die("save_shortcode_success");
110
+ }
111
+
112
+ ?>
lib/wfu_attributes.php CHANGED
@@ -1,738 +1,752 @@
1
- <?php
2
-
3
- function wfu_component_definitions() {
4
- $components = array(
5
- array(
6
- "id" => "title",
7
- "name" => "Title",
8
- "mode" => "free",
9
- "dimensions" => null,
10
- "help" => "A title text for the plugin"
11
- ),
12
- array(
13
- "id" => "filename",
14
- "name" => "Filename",
15
- "mode" => "free",
16
- "dimensions" => null,
17
- "help" => "It shows the name of the selected file (useful only for single file uploads)."
18
- ),
19
- array(
20
- "id" => "selectbutton",
21
- "name" => "Select Button",
22
- "mode" => "free",
23
- "dimensions" => null,
24
- "help" => "Represents the button to select the files for upload."
25
- ),
26
- array(
27
- "id" => "uploadbutton",
28
- "name" => "Upload Button",
29
- "mode" => "free",
30
- "dimensions" => null,
31
- "help" => "Represents the button to execute the upload after some files have been selected."
32
- ),
33
- array(
34
- "id" => "subfolders",
35
- "name" => "Subfolders",
36
- "mode" => "free",
37
- "dimensions" => array("subfolders_label/Subfolders Label", "subfolders_select/Subfolders List"),
38
- "help" => "Allows the user to select the upload folder from a dropdown list."
39
- ),
40
- array(
41
- "id" => "progressbar",
42
- "name" => "Progressbar",
43
- "mode" => "free",
44
- "dimensions" => null,
45
- "help" => "Displays a simple progress bar, showing total progress of upload."
46
- ),
47
- array(
48
- "id" => "userdata",
49
- "name" => "User Fields",
50
- "mode" => "free",
51
- "dimensions" => null,
52
- "help" => "Displays additional fields that the user must fill-in together with the uploaded files."
53
- ),
54
- array(
55
- "id" => "message",
56
- "name" => "Message",
57
- "mode" => "free",
58
- "dimensions" => null,
59
- "help" => "Displays a message block with information about the upload, together with any warnings or errors."
60
- )
61
- );
62
-
63
- wfu_array_remove_nulls($components);
64
-
65
- return $components;
66
- }
67
-
68
- function wfu_category_definitions() {
69
- $cats = array(
70
- "general" => "General",
71
- "placements" => "Placements",
72
- "general" => "General",
73
- "labels" => "Labels",
74
- "notifications" => "Notifications",
75
- "colors" => "Colors",
76
- "dimensions" => "Dimensions",
77
- "general" => "General",
78
- "userdata" => "Additional Fields",
79
- "interoperability" => "Interoperability"
80
- );
81
-
82
- return $cats;
83
- }
84
-
85
- function wfu_attribute_definitions() {
86
- $defs = array(
87
- array(
88
- "name" => "Plugin ID",
89
- "attribute" => "uploadid",
90
- "type" => "integer",
91
- "listitems" => null,
92
- "value" => WFU_UPLOADID,
93
- "mode" => "free",
94
- "category" => "general",
95
- "subcategory" => "Basic Functionalities",
96
- "parent" => "",
97
- "dependencies" => null,
98
- "variables" => null,
99
- "help" => "The unique id of each shortcode. When you have many shortcodes of this plugin in the same page, then you must use different id for each one."
100
- ),
101
- array(
102
- "name" => "Single Button Operation",
103
- "attribute" => "singlebutton",
104
- "type" => "onoff",
105
- "listitems" => null,
106
- "value" => WFU_SINGLEBUTTON,
107
- "mode" => "free",
108
- "category" => "general",
109
- "subcategory" => "Basic Functionalities",
110
- "parent" => "",
111
- "dependencies" => array("!uploadbutton"),
112
- "variables" => null,
113
- "help" => "When it is activated, no Upload button will be shown, but upload will start automatically as soon as files are selected."
114
- ),
115
- array(
116
- "name" => "Upload Path",
117
- "attribute" => "uploadpath",
118
- "type" => "ltext",
119
- "listitems" => null,
120
- "value" => WFU_UPLOADPATH,
121
- "mode" => "free",
122
- "category" => "general",
123
- "subcategory" => "Basic Functionalities",
124
- "parent" => "",
125
- "dependencies" => null,
126
- "variables" => array("%username%", "%blogid%"),
127
- "help" => "This is the folder where the files will be uploaded. The path is relative to wp-contents folder of your Wordpress website. The path can be dynamic by including variables such as %username% or %blogid%. Please check Documentation on how to use variables inside uploadpath."
128
- ),
129
- array(
130
- "name" => "Upload Roles",
131
- "attribute" => "uploadrole",
132
- "type" => "rolelist",
133
- "listitems" => null,
134
- "value" => WFU_UPLOADROLE,
135
- "mode" => "free",
136
- "category" => "general",
137
- "subcategory" => "Filters",
138
- "parent" => "",
139
- "dependencies" => null,
140
- "variables" => null,
141
- "help" => "Defines the categories (roles) of users allowed to upload files. Multiple selections can be made. If 'all' is selected, then all users, even guests (non logged users) can upload files. Please use carefully."
142
- ),
143
- array(
144
- "name" => "Allowed File Extensions",
145
- "attribute" => "uploadpatterns",
146
- "type" => "text",
147
- "listitems" => null,
148
- "value" => WFU_UPLOADPATTERNS,
149
- "mode" => "free",
150
- "category" => "general",
151
- "subcategory" => "Filters",
152
- "parent" => "",
153
- "dependencies" => null,
154
- "variables" => null,
155
- "help" => "Defines the allowed file extensions. Multiple extentions can be defined, separated with comma (,)."
156
- ),
157
- array(
158
- "name" => "Allowed File Size",
159
- "attribute" => "maxsize",
160
- "type" => "float",
161
- "listitems" => null,
162
- "value" => WFU_MAXSIZE,
163
- "mode" => "free",
164
- "category" => "general",
165
- "subcategory" => "Filters",
166
- "parent" => "",
167
- "dependencies" => null,
168
- "variables" => null,
169
- "help" => "Defines the allowed file size in MBytes. Files larger than maxsize will not be uploaded. Floating point numbers can be used (e.g. '2.5')."
170
- ),
171
- array(
172
- "name" => "Create Upload Path",
173
- "attribute" => "createpath",
174
- "type" => "onoff",
175
- "listitems" => null,
176
- "value" => WFU_CREATEPATH,
177
- "mode" => "free",
178
- "category" => "general",
179
- "subcategory" => "Upload Path and Files",
180
- "parent" => "",
181
- "dependencies" => null,
182
- "variables" => null,
183
- "help" => "If activated then the plugin will attempt to create the upload path, if it does not exist."
184
- ),
185
- array(
186
- "name" => "Folder Access Method",
187
- "attribute" => "accessmethod",
188
- "type" => "radio",
189
- "listitems" => array("normal", "*ftp"),
190
- "value" => WFU_ACCESSMETHOD,
191
- "mode" => "free",
192
- "category" => "general",
193
- "subcategory" => "Upload Path and Files",
194
- "parent" => "",
195
- "dependencies" => array("ftpinfo", "userftpdomain"),
196
- "variables" => null,
197
- "help" => "Some times files cannot be uploaded to the upload folder because of read/write permissions. A workaround is to use ftp to transfer the files, however ftp credentials must be declared, so use carefully and only if necessary."
198
- ),
199
- array(
200
- "name" => "FTP Access Credentials",
201
- "attribute" => "ftpinfo",
202
- "type" => "ltext",
203
- "listitems" => null,
204
- "value" => WFU_FTPINFO,
205
- "mode" => "free",
206
- "category" => "general",
207
- "subcategory" => "Upload Path and Files",
208
- "parent" => "accessmethod",
209
- "dependencies" => null,
210
- "variables" => null,
211
- "help" => "If FTP access method is selected, then FTP credentials must be declared here, in the form username:password@ftpdomain."
212
- ),
213
- array(
214
- "name" => "Use FTP Domain",
215
- "attribute" => "useftpdomain",
216
- "type" => "onoff",
217
- "listitems" => null,
218
- "value" => WFU_USEFTPDOMAIN,
219
- "mode" => "free",
220
- "category" => "general",
221
- "subcategory" => "Upload Path and Files",
222
- "parent" => "accessmethod",
223
- "dependencies" => null,
224
- "variables" => null,
225
- "help" => "If FTP access method is selected, then sometimes the FTP domain is different than the domain of your Wordpress installation. In this case, enable this attribute if upload of files is not successful."
226
- ),
227
- array(
228
- "name" => "Show Upload Folder Path",
229
- "attribute" => "showtargetfolder",
230
- "type" => "onoff",
231
- "listitems" => null,
232
- "value" => WFU_SHOWTARGETFOLDER,
233
- "mode" => "free",
234
- "category" => "general",
235
- "subcategory" => "Upload Path and Files",
236
- "parent" => "",
237
- "dependencies" => array("targetfolderlabel"),
238
- "variables" => null,
239
- "help" => "It defines if a label with the upload directory will be shown."
240
- ),
241
- array(
242
- "name" => "Select Subfolder",
243
- "attribute" => "askforsubfolders",
244
- "type" => "onoff",
245
- "listitems" => null,
246
- "value" => WFU_ASKFORSUBFOLDERS,
247
- "mode" => "free",
248
- "category" => "general",
249
- "subcategory" => "Upload Path and Files",
250
- "parent" => "",
251
- "dependencies" => array("subfoldertree"),
252
- "variables" => null,
253
- "help" => "If enabled then user can select the upload folder from a drop down list. The list is defined in subfoldertree attribute. The folder paths are relative to the path defined in uploadpath."
254
- ),
255
- array(
256
- "name" => "List of Subfolders",
257
- "attribute" => "subfoldertree",
258
- "type" => "text",
259
- "listitems" => null,
260
- "value" => WFU_SUBFOLDERTREE,
261
- "mode" => "free",
262
- "category" => "general",
263
- "subcategory" => "Upload Path and Files",
264
- "parent" => "askforsubfolders",
265
- "dependencies" => null,
266
- "variables" => null,
267
- "help" => "The list of folders a user can select. Please see documentation on how to create the list of folders."
268
- ),
269
- array(
270
- "name" => "File Duplicates Policy",
271
- "attribute" => "dublicatespolicy",
272
- "type" => "radio",
273
- "listitems" => array("overwrite", "reject", "*maintain both"),
274
- "value" => WFU_DUBLICATESPOLICY,
275
- "mode" => "free",
276
- "category" => "general",
277
- "subcategory" => "Upload Path and Files",
278
- "parent" => "",
279
- "dependencies" => array("uniquepattern"),
280
- "variables" => null,
281
- "help" => "It determines what happens when an uploaded file has the same name with an existing file. The uploaded file can overwrite the existing one, be rejected or both can be kept by renaming the uploaded file according to a rule defined in uniquepattern attribute."
282
- ),
283
- array(
284
- "name" => "File Rename Rule",
285
- "attribute" => "uniquepattern",
286
- "type" => "radio",
287
- "listitems" => array("index", "datetimestamp"),
288
- "value" => WFU_UNIQUEPATTERN,
289
- "mode" => "free",
290
- "category" => "general",
291
- "subcategory" => "Upload Path and Files",
292
- "parent" => "dublicatespolicy",
293
- "dependencies" => null,
294
- "variables" => null,
295
- "help" => "If dublicatespolicy is set to 'maintain both', then this rule defines how the uploaded file will be renamed, in order not to match an existing file. An incremental index number or a datetime stamp can be included in the uploaded file name to make it unique."
296
- ),
297
- array(
298
- "name" => "Redirect after Upload",
299
- "attribute" => "redirect",
300
- "type" => "onoff",
301
- "listitems" => null,
302
- "value" => WFU_REDIRECT,
303
- "mode" => "free",
304
- "category" => "general",
305
- "subcategory" => "Redirection",
306
- "parent" => "",
307
- "dependencies" => array("redirectlink"),
308
- "variables" => null,
309
- "help" => "If enabled, the user will be redirected to a url defined in redirectlink attribute upon successful upload of all the files."
310
- ),
311
- array(
312
- "name" => "Redirection URL",
313
- "attribute" => "redirectlink",
314
- "type" => "ltext",
315
- "listitems" => null,
316
- "value" => WFU_REDIRECTLINK,
317
- "mode" => "free",
318
- "category" => "general",
319
- "subcategory" => "Redirection",
320
- "parent" => "redirect",
321
- "dependencies" => null,
322
- "variables" => array("%filename%"),
323
- "help" => "This is the redirect URL. The URL can be dynamic by using variables. Please see Documentation on how to use variables inside attributes."
324
- ),
325
- array(
326
- "name" => "Show Detailed Admin Messages",
327
- "attribute" => "adminmessages",
328
- "type" => "onoff",
329
- "listitems" => null,
330
- "value" => WFU_ADMINMESSAGES,
331
- "mode" => "free",
332
- "category" => "general",
333
- "subcategory" => "Other Administrator Options",
334
- "parent" => "",
335
- "dependencies" => null,
336
- "variables" => null,
337
- "help" => "If enabled then more detailed messages about upload operations will be shown to administrators for debugging or error detection."
338
- ),
339
- array(
340
- "name" => "Disable AJAX",
341
- "attribute" => "forceclassic",
342
- "type" => "onoff",
343
- "listitems" => null,
344
- "value" => WFU_FORCECLASSIC,
345
- "mode" => "free",
346
- "category" => "general",
347
- "subcategory" => "Other Administrator Options",
348
- "parent" => "",
349
- "dependencies" => null,
350
- "variables" => null,
351
- "help" => "If AJAX is disabled, then upload of files will be performed using HTML forms, meaning that page will refresh to complete the upload. Use it in case that AJAX is causing problems with your page (although the plugin has an auto-detection feature for checking if user's browser supports AJAX or not)."
352
- ),
353
- array(
354
- "name" => "Test Mode",
355
- "attribute" => "testmode",
356
- "type" => "onoff",
357
- "listitems" => null,
358
- "value" => WFU_TESTMODE,
359
- "mode" => "free",
360
- "category" => "general",
361
- "subcategory" => "Other Administrator Options",
362
- "parent" => "",
363
- "dependencies" => null,
364
- "variables" => null,
365
- "help" => "If enabled then the plugin will be shown in test mode, meaning that all selected features will be shown but no upload will be possible. Use it to review how the plugin looks like and style it according to your needs."
366
- ),
367
- array(
368
- "name" => "Debug Mode",
369
- "attribute" => "debugmode",
370
- "type" => "onoff",
371
- "listitems" => null,
372
- "value" => WFU_DEBUGMODE,
373
- "mode" => "free",
374
- "category" => "general",
375
- "subcategory" => "Other Administrator Options",
376
- "parent" => "",
377
- "dependencies" => null,
378
- "variables" => null,
379
- "help" => "If enabled then the plugin will show to administrators any internal PHP warnings and errors generated during the upload process inside the message box."
380
- ),
381
- array(
382
- "name" => "Plugin Component Positions",
383
- "attribute" => "placements",
384
- "type" => "placements",
385
- "listitems" => null,
386
- "value" => WFU_PLACEMENTS,
387
- "mode" => "free",
388
- "category" => "placements",
389
- "subcategory" => "Plugin Component Positions",
390
- "parent" => "",
391
- "dependencies" => null,
392
- "variables" => null,
393
- "help" => "It defines the positions of the selected plugin components. Drag the components from the right pane and drop them to the left one to define your own component positions."
394
- ),
395
- array(
396
- "name" => "Plugin Title",
397
- "attribute" => "uploadtitle",
398
- "type" => "text",
399
- "listitems" => null,
400
- "value" => WFU_UPLOADTITLE,
401
- "mode" => "free",
402
- "category" => "labels",
403
- "subcategory" => "Title",
404
- "parent" => "",
405
- "dependencies" => null,
406
- "variables" => null,
407
- "help" => "A text representing the title of the plugin."
408
- ),
409
- array(
410
- "name" => "Select Button Caption",
411
- "attribute" => "selectbutton",
412
- "type" => "text",
413
- "listitems" => null,
414
- "value" => WFU_SELECTBUTTON,
415
- "mode" => "free",
416
- "category" => "labels",
417
- "subcategory" => "Buttons",
418
- "parent" => "",
419
- "dependencies" => null,
420
- "variables" => null,
421
- "help" => "The caption of the button that selects the files for upload."
422
- ),
423
- array(
424
- "name" => "Upload Button Caption",
425
- "attribute" => "uploadbutton",
426
- "type" => "text",
427
- "listitems" => null,
428
- "value" => WFU_UPLOADBUTTON,
429
- "mode" => "free",
430
- "category" => "labels",
431
- "subcategory" => "Buttons",
432
- "parent" => "",
433
- "dependencies" => null,
434
- "variables" => null,
435
- "help" => "The caption of the button that starts the upload."
436
- ),
437
- array(
438
- "name" => "Upload Folder Label",
439
- "attribute" => "targetfolderlabel",
440
- "type" => "text",
441
- "listitems" => null,
442
- "value" => WFU_TARGETFOLDERLABEL,
443
- "mode" => "free",
444
- "category" => "labels",
445
- "subcategory" => "Upload Folder",
446
- "parent" => "",
447
- "dependencies" => null,
448
- "variables" => null,
449
- "help" => "This is the label before the upload folder path, if the path is selected to be shown using the showtargetfolder attribute."
450
- ),
451
- array(
452
- "name" => "Success Upload Message",
453
- "attribute" => "successmessage",
454
- "type" => "ltext",
455
- "listitems" => null,
456
- "value" => WFU_SUCCESSMESSAGE,
457
- "mode" => "free",
458
- "category" => "labels",
459
- "subcategory" => "Upload Messages",
460
- "parent" => "",
461
- "dependencies" => null,
462
- "variables" => array("%filename%", "%filepath%"),
463
- "help" => "This is the message that will be shown for every file that has been uploaded successfully."
464
- ),
465
- array(
466
- "name" => "Warning Upload Message",
467
- "attribute" => "warningmessage",
468
- "type" => "ltext",
469
- "listitems" => null,
470
- "value" => WFU_WARNINGMESSAGE,
471
- "mode" => "free",
472
- "category" => "labels",
473
- "subcategory" => "Upload Messages",
474
- "parent" => "",
475
- "dependencies" => null,
476
- "variables" => array("%filename%", "%filepath%"),
477
- "help" => "This is the message that will be shown for every file that has been uploaded with warnings."
478
- ),
479
- array(
480
- "name" => "Error Upload Message",
481
- "attribute" => "errormessage",
482
- "type" => "ltext",
483
- "listitems" => null,
484
- "value" => WFU_ERRORMESSAGE,
485
- "mode" => "free",
486
- "category" => "labels",
487
- "subcategory" => "Upload Messages",
488
- "parent" => "",
489
- "dependencies" => null,
490
- "variables" => array("%filename%", "%filepath%"),
491
- "help" => "This is the message that will be shown for every file that has failed to upload."
492
- ),
493
- array(
494
- "name" => "Wait Upload Message",
495
- "attribute" => "waitmessage",
496
- "type" => "ltext",
497
- "listitems" => null,
498
- "value" => WFU_WAITMESSAGE,
499
- "mode" => "free",
500
- "category" => "labels",
501
- "subcategory" => "Upload Messages",
502
- "parent" => "",
503
- "dependencies" => null,
504
- "variables" => array("%filename%", "%filepath%"),
505
- "help" => "This is the message that will be shown while file is uploading."
506
- ),
507
- array(
508
- "name" => "Notify by Email",
509
- "attribute" => "notify",
510
- "type" => "onoff",
511
- "listitems" => null,
512
- "value" => WFU_NOTIFY,
513
- "mode" => "free",
514
- "category" => "notifications",
515
- "subcategory" => "Email Notifications",
516
- "parent" => "",
517
- "dependencies" => array("notifyrecipients", "notifysubject", "notifymessage", "notifyheaders", "attachfile"),
518
- "variables" => null,
519
- "help" => "If activated then email will be sent to inform about successful file uploads."
520
- ),
521
- array(
522
- "name" => "Email Recipients",
523
- "attribute" => "notifyrecipients",
524
- "type" => "mtext",
525
- "listitems" => null,
526
- "value" => WFU_NOTIFYRECIPIENTS,
527
- "mode" => "free",
528
- "category" => "notifications",
529
- "subcategory" => "Email Notifications",
530
- "parent" => "notify",
531
- "dependencies" => null,
532
- "variables" => array("%useremail%", "%n%"),
533
- "help" => "Defines the recipients of the email notification. Can be dynamic by using variables. Please check Documentation on how to use variables in atributes."
534
- ),
535
- array(
536
- "name" => "Email Headers",
537
- "attribute" => "notifyheaders",
538
- "type" => "mtext",
539
- "listitems" => null,
540
- "value" => WFU_NOTIFYHEADERS,
541
- "mode" => "free",
542
- "category" => "notifications",
543
- "subcategory" => "Email Notifications",
544
- "parent" => "notify",
545
- "dependencies" => null,
546
- "variables" => array("%n%"),
547
- "help" => "Defines additional email headers, in case you want to sent an HTML message, or use Bcc list, or use a different From address and name or other more advanced email options."
548
- ),
549
- array(
550
- "name" => "Email Subject",
551
- "attribute" => "notifysubject",
552
- "type" => "ltext",
553
- "listitems" => null,
554
- "value" => WFU_NOTIFYSUBJECT,
555
- "mode" => "free",
556
- "category" => "notifications",
557
- "subcategory" => "Email Notifications",
558
- "parent" => "notify",
559
- "dependencies" => null,
560
- "variables" => array("%username%", "%useremail%", "%filename%", "%filepath%", "%userdataXXX%"),
561
- "help" => "Defines the email subject. Can be dynamic by using variables. Please check Documentation on how to use variables in atributes."
562
- ),
563
- array(
564
- "name" => "Email Body",
565
- "attribute" => "notifymessage",
566
- "type" => "mtext",
567
- "listitems" => null,
568
- "value" => WFU_NOTIFYMESSAGE,
569
- "mode" => "free",
570
- "category" => "notifications",
571
- "subcategory" => "Email Notifications",
572
- "parent" => "notify",
573
- "dependencies" => null,
574
- "variables" => array("%username%", "%useremail%", "%filename%", "%filepath%", "%userdataXXX%", "%n%"),
575
- "help" => "Defines the email body. Can be dynamic by using variables. Please check Documentation on how to use variables in atributes."
576
- ),
577
- array(
578
- "name" => "Attach Uploaded Files",
579
- "attribute" => "attachfile",
580
- "type" => "onoff",
581
- "listitems" => null,
582
- "value" => WFU_ATTACHFILE,
583
- "mode" => "free",
584
- "category" => "notifications",
585
- "subcategory" => "Email Notifications",
586
- "parent" => "notify",
587
- "dependencies" => null,
588
- "variables" => null,
589
- "help" => "If activated, then uploaded files will be included in the notification email as attachments. Please use carefully."
590
- ),
591
- array(
592
- "name" => "Success Upload Message Color",
593
- "attribute" => "successmessagecolor",
594
- "type" => "color",
595
- "listitems" => null,
596
- "value" => WFU_SUCCESSMESSAGECOLOR,
597
- "mode" => "free",
598
- "category" => "colors",
599
- "subcategory" => "Upload Message Colors",
600
- "parent" => "",
601
- "dependencies" => null,
602
- "variables" => null,
603
- "help" => "It defines the color of the success message. This attribute has been replaced by successmessagecolors, however it is kept here for backward compatibility."
604
- ),
605
- array(
606
- "name" => "Success Message Colors",
607
- "attribute" => "successmessagecolors",
608
- "type" => "color-triplet",
609
- "listitems" => null,
610
- "value" => WFU_SUCCESSMESSAGECOLORS,
611
- "mode" => "free",
612
- "category" => "colors",
613
- "subcategory" => "Upload Message Colors",
614
- "parent" => "",
615
- "dependencies" => null,
616
- "variables" => null,
617
- "help" => "It defines the text, background and border color of the success message."
618
- ),
619
- array(
620
- "name" => "Warning Message Colors",
621
- "attribute" => "warningmessagecolors",
622
- "type" => "color-triplet",
623
- "listitems" => null,
624
- "value" => WFU_WARNINGMESSAGECOLORS,
625
- "mode" => "free",
626
- "category" => "colors",
627
- "subcategory" => "Upload Message Colors",
628
- "parent" => "",
629
- "dependencies" => null,
630
- "variables" => null,
631
- "help" => "It defines the text, background and border color of the warning message."
632
- ),
633
- array(
634
- "name" => "Fail Message Colors",
635
- "attribute" => "failmessagecolors",
636
- "type" => "color-triplet",
637
- "listitems" => null,
638
- "value" => WFU_FAILMESSAGECOLORS,
639
- "mode" => "free",
640
- "category" => "colors",
641
- "subcategory" => "Upload Message Colors",
642
- "parent" => "",
643
- "dependencies" => null,
644
- "variables" => null,
645
- "help" => "It defines the text, background and border color of the fail (error) message."
646
- ),
647
- array(
648
- "name" => "Wait Message Colors",
649
- "attribute" => "waitmessagecolors",
650
- "type" => "color-triplet",
651
- "listitems" => null,
652
- "value" => WFU_WAITMESSAGECOLORS,
653
- "mode" => "free",
654
- "category" => "colors",
655
- "subcategory" => "Upload Message Colors",
656
- "parent" => "",
657
- "dependencies" => null,
658
- "variables" => null,
659
- "help" => "It defines the text, background and border color of the wait message."
660
- ),
661
- array(
662
- "name" => "Plugin Component Widths",
663
- "attribute" => "widths",
664
- "type" => "dimensions",
665
- "listitems" => null,
666
- "value" => WFU_WIDTHS,
667
- "mode" => "free",
668
- "category" => "dimensions",
669
- "subcategory" => "Plugin Component Widths",
670
- "parent" => "",
671
- "dependencies" => null,
672
- "variables" => null,
673
- "help" => "It defines the widths of the selected plugin components."
674
- ),
675
- array(
676
- "name" => "Plugin Component Heights",
677
- "attribute" => "heights",
678
- "type" => "dimensions",
679
- "listitems" => null,
680
- "value" => WFU_HEIGHTS,
681
- "mode" => "free",
682
- "category" => "dimensions",
683
- "subcategory" => "Plugin Component Heights",
684
- "parent" => "",
685
- "dependencies" => null,
686
- "variables" => null,
687
- "help" => "It defines the heights of the selected plugin components."
688
- ),
689
- array(
690
- "name" => "Include Additional Data Fields",
691
- "attribute" => "userdata",
692
- "type" => "onoff",
693
- "listitems" => null,
694
- "value" => WFU_USERDATA,
695
- "mode" => "free",
696
- "category" => "userdata",
697
- "subcategory" => "Additional Data Fields",
698
- "parent" => "",
699
- "dependencies" => array("userdatalabel"),
700
- "variables" => null,
701
- "help" => "If enabled, then user can send additional information together with uploaded files (e.g. name, email etc), defined in userdatalabel attribute."
702
- ),
703
- array(
704
- "name" => "Additional Data Fields",
705
- "attribute" => "userdatalabel",
706
- "type" => "userfields",
707
- "listitems" => null,
708
- "value" => WFU_USERDATALABEL,
709
- "mode" => "free",
710
- "category" => "userdata",
711
- "subcategory" => "Additional Data Fields",
712
- "parent" => "userdata",
713
- "dependencies" => null,
714
- "variables" => null,
715
- "help" => "It defines the labels of the additional data fields and whether they are required or not."
716
- ),
717
- array(
718
- "name" => "WP Filebase Plugin Connection",
719
- "attribute" => "filebaselink",
720
- "type" => "onoff",
721
- "listitems" => null,
722
- "value" => WFU_FILEBASELINK,
723
- "mode" => "free",
724
- "category" => "interoperability",
725
- "subcategory" => "Connection With Other Plugins",
726
- "parent" => "",
727
- "dependencies" => null,
728
- "variables" => null,
729
- "help" => "If enabled then the WP Filebase Plugin will be informed about new file uploads."
730
- )
731
- );
732
-
733
- wfu_array_remove_nulls($defs);
734
-
735
- return $defs;
736
- }
737
-
738
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function wfu_component_definitions() {
4
+ $components = array(
5
+ array(
6
+ "id" => "title",
7
+ "name" => "Title",
8
+ "mode" => "free",
9
+ "dimensions" => null,
10
+ "help" => "A title text for the plugin"
11
+ ),
12
+ array(
13
+ "id" => "filename",
14
+ "name" => "Filename",
15
+ "mode" => "free",
16
+ "dimensions" => null,
17
+ "help" => "It shows the name of the selected file (useful only for single file uploads)."
18
+ ),
19
+ array(
20
+ "id" => "selectbutton",
21
+ "name" => "Select Button",
22
+ "mode" => "free",
23
+ "dimensions" => null,
24
+ "help" => "Represents the button to select the files for upload."
25
+ ),
26
+ array(
27
+ "id" => "uploadbutton",
28
+ "name" => "Upload Button",
29
+ "mode" => "free",
30
+ "dimensions" => null,
31
+ "help" => "Represents the button to execute the upload after some files have been selected."
32
+ ),
33
+ array(
34
+ "id" => "subfolders",
35
+ "name" => "Subfolders",
36
+ "mode" => "free",
37
+ "dimensions" => array("subfolders_label/Subfolders Label", "subfolders_select/Subfolders List"),
38
+ "help" => "Allows the user to select the upload folder from a dropdown list."
39
+ ),
40
+ array(
41
+ "id" => "progressbar",
42
+ "name" => "Progressbar",
43
+ "mode" => "free",
44
+ "dimensions" => null,
45
+ "help" => "Displays a simple progress bar, showing total progress of upload."
46
+ ),
47
+ array(
48
+ "id" => "userdata",
49
+ "name" => "User Fields",
50
+ "mode" => "free",
51
+ "dimensions" => null,
52
+ "help" => "Displays additional fields that the user must fill-in together with the uploaded files."
53
+ ),
54
+ array(
55
+ "id" => "message",
56
+ "name" => "Message",
57
+ "mode" => "free",
58
+ "dimensions" => null,
59
+ "help" => "Displays a message block with information about the upload, together with any warnings or errors."
60
+ )
61
+ );
62
+
63
+ wfu_array_remove_nulls($components);
64
+
65
+ return $components;
66
+ }
67
+
68
+ function wfu_category_definitions() {
69
+ $cats = array(
70
+ "general" => "General",
71
+ "placements" => "Placements",
72
+ "general" => "General",
73
+ "labels" => "Labels",
74
+ "notifications" => "Notifications",
75
+ "colors" => "Colors",
76
+ "dimensions" => "Dimensions",
77
+ "general" => "General",
78
+ "userdata" => "Additional Fields",
79
+ "interoperability" => "Interoperability"
80
+ );
81
+
82
+ return $cats;
83
+ }
84
+
85
+ function wfu_attribute_definitions() {
86
+ $defs = array(
87
+ array(
88
+ "name" => "Plugin ID",
89
+ "attribute" => "uploadid",
90
+ "type" => "integer",
91
+ "listitems" => null,
92
+ "value" => WFU_UPLOADID,
93
+ "mode" => "free",
94
+ "category" => "general",
95
+ "subcategory" => "Basic Functionalities",
96
+ "parent" => "",
97
+ "dependencies" => null,
98
+ "variables" => null,
99
+ "help" => "The unique id of each shortcode. When you have many shortcodes of this plugin in the same page, then you must use different id for each one."
100
+ ),
101
+ array(
102
+ "name" => "Single Button Operation",
103
+ "attribute" => "singlebutton",
104
+ "type" => "onoff",
105
+ "listitems" => null,
106
+ "value" => WFU_SINGLEBUTTON,
107
+ "mode" => "free",
108
+ "category" => "general",
109
+ "subcategory" => "Basic Functionalities",
110
+ "parent" => "",
111
+ "dependencies" => array("!uploadbutton"),
112
+ "variables" => null,
113
+ "help" => "When it is activated, no Upload button will be shown, but upload will start automatically as soon as files are selected."
114
+ ),
115
+ array(
116
+ "name" => "Upload Path",
117
+ "attribute" => "uploadpath",
118
+ "type" => "ltext",
119
+ "listitems" => null,
120
+ "value" => WFU_UPLOADPATH,
121
+ "mode" => "free",
122
+ "category" => "general",
123
+ "subcategory" => "Basic Functionalities",
124
+ "parent" => "",
125
+ "dependencies" => null,
126
+ "variables" => array("%username%", "%blogid%"),
127
+ "help" => "This is the folder where the files will be uploaded. The path is relative to wp-contents folder of your Wordpress website. The path can be dynamic by including variables such as %username% or %blogid%. Please check Documentation on how to use variables inside uploadpath."
128
+ ),
129
+ array(
130
+ "name" => "Upload Roles",
131
+ "attribute" => "uploadrole",
132
+ "type" => "rolelist",
133
+ "listitems" => null,
134
+ "value" => WFU_UPLOADROLE,
135
+ "mode" => "free",
136
+ "category" => "general",
137
+ "subcategory" => "Filters",
138
+ "parent" => "",
139
+ "dependencies" => null,
140
+ "variables" => null,
141
+ "help" => "Defines the categories (roles) of users allowed to upload files. Multiple selections can be made. If 'all' is selected, then all users, even guests (non logged users) can upload files. Please use carefully."
142
+ ),
143
+ array(
144
+ "name" => "Allowed File Extensions",
145
+ "attribute" => "uploadpatterns",
146
+ "type" => "text",
147
+ "listitems" => null,
148
+ "value" => WFU_UPLOADPATTERNS,
149
+ "mode" => "free",
150
+ "category" => "general",
151
+ "subcategory" => "Filters",
152
+ "parent" => "",
153
+ "dependencies" => null,
154
+ "variables" => null,
155
+ "help" => "Defines the allowed file extensions. Multiple extentions can be defined, separated with comma (,)."
156
+ ),
157
+ array(
158
+ "name" => "Allowed File Size",
159
+ "attribute" => "maxsize",
160
+ "type" => "float",
161
+ "listitems" => null,
162
+ "value" => WFU_MAXSIZE,
163
+ "mode" => "free",
164
+ "category" => "general",
165
+ "subcategory" => "Filters",
166
+ "parent" => "",
167
+ "dependencies" => null,
168
+ "variables" => null,
169
+ "help" => "Defines the allowed file size in MBytes. Files larger than maxsize will not be uploaded. Floating point numbers can be used (e.g. '2.5')."
170
+ ),
171
+ array(
172
+ "name" => "Create Upload Path",
173
+ "attribute" => "createpath",
174
+ "type" => "onoff",
175
+ "listitems" => null,
176
+ "value" => WFU_CREATEPATH,
177
+ "mode" => "free",
178
+ "category" => "general",
179
+ "subcategory" => "Upload Path and Files",
180
+ "parent" => "",
181
+ "dependencies" => null,
182
+ "variables" => null,
183
+ "help" => "If activated then the plugin will attempt to create the upload path, if it does not exist."
184
+ ),
185
+ array(
186
+ "name" => "Folder Access Method",
187
+ "attribute" => "accessmethod",
188
+ "type" => "radio",
189
+ "listitems" => array("normal", "*ftp"),
190
+ "value" => WFU_ACCESSMETHOD,
191
+ "mode" => "free",
192
+ "category" => "general",
193
+ "subcategory" => "Upload Path and Files",
194
+ "parent" => "",
195
+ "dependencies" => array("ftpinfo", "userftpdomain"),
196
+ "variables" => null,
197
+ "help" => "Some times files cannot be uploaded to the upload folder because of read/write permissions. A workaround is to use ftp to transfer the files, however ftp credentials must be declared, so use carefully and only if necessary."
198
+ ),
199
+ array(
200
+ "name" => "FTP Access Credentials",
201
+ "attribute" => "ftpinfo",
202
+ "type" => "ltext",
203
+ "listitems" => null,
204
+ "value" => WFU_FTPINFO,
205
+ "mode" => "free",
206
+ "category" => "general",
207
+ "subcategory" => "Upload Path and Files",
208
+ "parent" => "accessmethod",
209
+ "dependencies" => null,
210
+ "variables" => null,
211
+ "help" => "If FTP access method is selected, then FTP credentials must be declared here, in the form username:password@ftpdomain."
212
+ ),
213
+ array(
214
+ "name" => "Use FTP Domain",
215
+ "attribute" => "useftpdomain",
216
+ "type" => "onoff",
217
+ "listitems" => null,
218
+ "value" => WFU_USEFTPDOMAIN,
219
+ "mode" => "free",
220
+ "category" => "general",
221
+ "subcategory" => "Upload Path and Files",
222
+ "parent" => "accessmethod",
223
+ "dependencies" => null,
224
+ "variables" => null,
225
+ "help" => "If FTP access method is selected, then sometimes the FTP domain is different than the domain of your Wordpress installation. In this case, enable this attribute if upload of files is not successful."
226
+ ),
227
+ array(
228
+ "name" => "Show Upload Folder Path",
229
+ "attribute" => "showtargetfolder",
230
+ "type" => "onoff",
231
+ "listitems" => null,
232
+ "value" => WFU_SHOWTARGETFOLDER,
233
+ "mode" => "free",
234
+ "category" => "general",
235
+ "subcategory" => "Upload Path and Files",
236
+ "parent" => "",
237
+ "dependencies" => array("targetfolderlabel"),
238
+ "variables" => null,
239
+ "help" => "It defines if a label with the upload directory will be shown."
240
+ ),
241
+ array(
242
+ "name" => "Select Subfolder",
243
+ "attribute" => "askforsubfolders",
244
+ "type" => "onoff",
245
+ "listitems" => null,
246
+ "value" => WFU_ASKFORSUBFOLDERS,
247
+ "mode" => "free",
248
+ "category" => "general",
249
+ "subcategory" => "Upload Path and Files",
250
+ "parent" => "",
251
+ "dependencies" => array("subfoldertree"),
252
+ "variables" => null,
253
+ "help" => "If enabled then user can select the upload folder from a drop down list. The list is defined in subfoldertree attribute. The folder paths are relative to the path defined in uploadpath."
254
+ ),
255
+ array(
256
+ "name" => "List of Subfolders",
257
+ "attribute" => "subfoldertree",
258
+ "type" => "text",
259
+ "listitems" => null,
260
+ "value" => WFU_SUBFOLDERTREE,
261
+ "mode" => "free",
262
+ "category" => "general",
263
+ "subcategory" => "Upload Path and Files",
264
+ "parent" => "askforsubfolders",
265
+ "dependencies" => null,
266
+ "variables" => null,
267
+ "help" => "The list of folders a user can select. Please see documentation on how to create the list of folders."
268
+ ),
269
+ array(
270
+ "name" => "File Duplicates Policy",
271
+ "attribute" => "dublicatespolicy",
272
+ "type" => "radio",
273
+ "listitems" => array("overwrite", "reject", "*maintain both"),
274
+ "value" => WFU_DUBLICATESPOLICY,
275
+ "mode" => "free",
276
+ "category" => "general",
277
+ "subcategory" => "Upload Path and Files",
278
+ "parent" => "",
279
+ "dependencies" => array("uniquepattern"),
280
+ "variables" => null,
281
+ "help" => "It determines what happens when an uploaded file has the same name with an existing file. The uploaded file can overwrite the existing one, be rejected or both can be kept by renaming the uploaded file according to a rule defined in uniquepattern attribute."
282
+ ),
283
+ array(
284
+ "name" => "File Rename Rule",
285
+ "attribute" => "uniquepattern",
286
+ "type" => "radio",
287
+ "listitems" => array("index", "datetimestamp"),
288
+ "value" => WFU_UNIQUEPATTERN,
289
+ "mode" => "free",
290
+ "category" => "general",
291
+ "subcategory" => "Upload Path and Files",
292
+ "parent" => "dublicatespolicy",
293
+ "dependencies" => null,
294
+ "variables" => null,
295
+ "help" => "If dublicatespolicy is set to 'maintain both', then this rule defines how the uploaded file will be renamed, in order not to match an existing file. An incremental index number or a datetime stamp can be included in the uploaded file name to make it unique."
296
+ ),
297
+ array(
298
+ "name" => "Redirect after Upload",
299
+ "attribute" => "redirect",
300
+ "type" => "onoff",
301
+ "listitems" => null,
302
+ "value" => WFU_REDIRECT,
303
+ "mode" => "free",
304
+ "category" => "general",
305
+ "subcategory" => "Redirection",
306
+ "parent" => "",
307
+ "dependencies" => array("redirectlink"),
308
+ "variables" => null,
309
+ "help" => "If enabled, the user will be redirected to a url defined in redirectlink attribute upon successful upload of all the files."
310
+ ),
311
+ array(
312
+ "name" => "Redirection URL",
313
+ "attribute" => "redirectlink",
314
+ "type" => "ltext",
315
+ "listitems" => null,
316
+ "value" => WFU_REDIRECTLINK,
317
+ "mode" => "free",
318
+ "category" => "general",
319
+ "subcategory" => "Redirection",
320
+ "parent" => "redirect",
321
+ "dependencies" => null,
322
+ "variables" => array("%filename%"),
323
+ "help" => "This is the redirect URL. The URL can be dynamic by using variables. Please see Documentation on how to use variables inside attributes."
324
+ ),
325
+ array(
326
+ "name" => "Show Detailed Admin Messages",
327
+ "attribute" => "adminmessages",
328
+ "type" => "onoff",
329
+ "listitems" => null,
330
+ "value" => WFU_ADMINMESSAGES,
331
+ "mode" => "free",
332
+ "category" => "general",
333
+ "subcategory" => "Other Administrator Options",
334
+ "parent" => "",
335
+ "dependencies" => null,
336
+ "variables" => null,
337
+ "help" => "If enabled then more detailed messages about upload operations will be shown to administrators for debugging or error detection."
338
+ ),
339
+ array(
340
+ "name" => "Disable AJAX",
341
+ "attribute" => "forceclassic",
342
+ "type" => "onoff",
343
+ "listitems" => null,
344
+ "value" => WFU_FORCECLASSIC,
345
+ "mode" => "free",
346
+ "category" => "general",
347
+ "subcategory" => "Other Administrator Options",
348
+ "parent" => "",
349
+ "dependencies" => null,
350
+ "variables" => null,
351
+ "help" => "If AJAX is disabled, then upload of files will be performed using HTML forms, meaning that page will refresh to complete the upload. Use it in case that AJAX is causing problems with your page (although the plugin has an auto-detection feature for checking if user's browser supports AJAX or not)."
352
+ ),
353
+ array(
354
+ "name" => "Test Mode",
355
+ "attribute" => "testmode",
356
+ "type" => "onoff",
357
+ "listitems" => null,
358
+ "value" => WFU_TESTMODE,
359
+ "mode" => "free",
360
+ "category" => "general",
361
+ "subcategory" => "Other Administrator Options",
362
+ "parent" => "",
363
+ "dependencies" => null,
364
+ "variables" => null,
365
+ "help" => "If enabled then the plugin will be shown in test mode, meaning that all selected features will be shown but no upload will be possible. Use it to review how the plugin looks like and style it according to your needs."
366
+ ),
367
+ array(
368
+ "name" => "Debug Mode",
369
+ "attribute" => "debugmode",
370
+ "type" => "onoff",
371
+ "listitems" => null,
372
+ "value" => WFU_DEBUGMODE,
373
+ "mode" => "free",
374
+ "category" => "general",
375
+ "subcategory" => "Other Administrator Options",
376
+ "parent" => "",
377
+ "dependencies" => null,
378
+ "variables" => null,
379
+ "help" => "If enabled then the plugin will show to administrators any internal PHP warnings and errors generated during the upload process inside the message box."
380
+ ),
381
+ array(
382
+ "name" => "Plugin Component Positions",
383
+ "attribute" => "placements",
384
+ "type" => "placements",
385
+ "listitems" => null,
386
+ "value" => WFU_PLACEMENTS,
387
+ "mode" => "free",
388
+ "category" => "placements",
389
+ "subcategory" => "Plugin Component Positions",
390
+ "parent" => "",
391
+ "dependencies" => null,
392
+ "variables" => null,
393
+ "help" => "It defines the positions of the selected plugin components. Drag the components from the right pane and drop them to the left one to define your own component positions."
394
+ ),
395
+ array(
396
+ "name" => "Plugin Title",
397
+ "attribute" => "uploadtitle",
398
+ "type" => "text",
399
+ "listitems" => null,
400
+ "value" => WFU_UPLOADTITLE,
401
+ "mode" => "free",
402
+ "category" => "labels",
403
+ "subcategory" => "Title",
404
+ "parent" => "",
405
+ "dependencies" => null,
406
+ "variables" => null,
407
+ "help" => "A text representing the title of the plugin."
408
+ ),
409
+ array(
410
+ "name" => "Select Button Caption",
411
+ "attribute" => "selectbutton",
412
+ "type" => "text",
413
+ "listitems" => null,
414
+ "value" => WFU_SELECTBUTTON,
415
+ "mode" => "free",
416
+ "category" => "labels",
417
+ "subcategory" => "Buttons",
418
+ "parent" => "",
419
+ "dependencies" => null,
420
+ "variables" => null,
421
+ "help" => "The caption of the button that selects the files for upload."
422
+ ),
423
+ array(
424
+ "name" => "Upload Button Caption",
425
+ "attribute" => "uploadbutton",
426
+ "type" => "text",
427
+ "listitems" => null,
428
+ "value" => WFU_UPLOADBUTTON,
429
+ "mode" => "free",
430
+ "category" => "labels",
431
+ "subcategory" => "Buttons",
432
+ "parent" => "",
433
+ "dependencies" => null,
434
+ "variables" => null,
435
+ "help" => "The caption of the button that starts the upload."
436
+ ),
437
+ array(
438
+ "name" => "Upload Folder Label",
439
+ "attribute" => "targetfolderlabel",
440
+ "type" => "text",
441
+ "listitems" => null,
442
+ "value" => WFU_TARGETFOLDERLABEL,
443
+ "mode" => "free",
444
+ "category" => "labels",
445
+ "subcategory" => "Upload Folder",
446
+ "parent" => "",
447
+ "dependencies" => null,
448
+ "variables" => null,
449
+ "help" => "This is the label before the upload folder path, if the path is selected to be shown using the showtargetfolder attribute."
450
+ ),
451
+ array(
452
+ "name" => "Success Upload Message",
453
+ "attribute" => "successmessage",
454
+ "type" => "ltext",
455
+ "listitems" => null,
456
+ "value" => WFU_SUCCESSMESSAGE,
457
+ "mode" => "free",
458
+ "category" => "labels",
459
+ "subcategory" => "Upload Messages",
460
+ "parent" => "",
461
+ "dependencies" => null,
462
+ "variables" => array("%filename%", "%filepath%"),
463
+ "help" => "This is the message that will be shown for every file that has been uploaded successfully."
464
+ ),
465
+ array(
466
+ "name" => "Warning Upload Message",
467
+ "attribute" => "warningmessage",
468
+ "type" => "ltext",
469
+ "listitems" => null,
470
+ "value" => WFU_WARNINGMESSAGE,
471
+ "mode" => "free",
472
+ "category" => "labels",
473
+ "subcategory" => "Upload Messages",
474
+ "parent" => "",
475
+ "dependencies" => null,
476
+ "variables" => array("%filename%", "%filepath%"),
477
+ "help" => "This is the message that will be shown for every file that has been uploaded with warnings."
478
+ ),
479
+ array(
480
+ "name" => "Error Upload Message",
481
+ "attribute" => "errormessage",
482
+ "type" => "ltext",
483
+ "listitems" => null,
484
+ "value" => WFU_ERRORMESSAGE,
485
+ "mode" => "free",
486
+ "category" => "labels",
487
+ "subcategory" => "Upload Messages",
488
+ "parent" => "",
489
+ "dependencies" => null,
490
+ "variables" => array("%filename%", "%filepath%"),
491
+ "help" => "This is the message that will be shown for every file that has failed to upload."
492
+ ),
493
+ array(
494
+ "name" => "Wait Upload Message",
495
+ "attribute" => "waitmessage",
496
+ "type" => "ltext",
497
+ "listitems" => null,
498
+ "value" => WFU_WAITMESSAGE,
499
+ "mode" => "free",
500
+ "category" => "labels",
501
+ "subcategory" => "Upload Messages",
502
+ "parent" => "",
503
+ "dependencies" => null,
504
+ "variables" => array("%filename%", "%filepath%"),
505
+ "help" => "This is the message that will be shown while file is uploading."
506
+ ),
507
+ array(
508
+ "name" => "Notify by Email",
509
+ "attribute" => "notify",
510
+ "type" => "onoff",
511
+ "listitems" => null,
512
+ "value" => WFU_NOTIFY,
513
+ "mode" => "free",
514
+ "category" => "notifications",
515
+ "subcategory" => "Email Notifications",
516
+ "parent" => "",
517
+ "dependencies" => array("notifyrecipients", "notifysubject", "notifymessage", "notifyheaders", "attachfile"),
518
+ "variables" => null,
519
+ "help" => "If activated then email will be sent to inform about successful file uploads."
520
+ ),
521
+ array(
522
+ "name" => "Email Recipients",
523
+ "attribute" => "notifyrecipients",
524
+ "type" => "mtext",
525
+ "listitems" => null,
526
+ "value" => WFU_NOTIFYRECIPIENTS,
527
+ "mode" => "free",
528
+ "category" => "notifications",
529
+ "subcategory" => "Email Notifications",
530
+ "parent" => "notify",
531
+ "dependencies" => null,
532
+ "variables" => array("%useremail%", "%n%"),
533
+ "help" => "Defines the recipients of the email notification. Can be dynamic by using variables. Please check Documentation on how to use variables in atributes."
534
+ ),
535
+ array(
536
+ "name" => "Email Headers",
537
+ "attribute" => "notifyheaders",
538
+ "type" => "mtext",
539
+ "listitems" => null,
540
+ "value" => WFU_NOTIFYHEADERS,
541
+ "mode" => "free",
542
+ "category" => "notifications",
543
+ "subcategory" => "Email Notifications",
544
+ "parent" => "notify",
545
+ "dependencies" => null,
546
+ "variables" => array("%n%"),
547
+ "help" => "Defines additional email headers, in case you want to sent an HTML message, or use Bcc list, or use a different From address and name or other more advanced email options."
548
+ ),
549
+ array(
550
+ "name" => "Email Subject",
551
+ "attribute" => "notifysubject",
552
+ "type" => "ltext",
553
+ "listitems" => null,
554
+ "value" => WFU_NOTIFYSUBJECT,
555
+ "mode" => "free",
556
+ "category" => "notifications",
557
+ "subcategory" => "Email Notifications",
558
+ "parent" => "notify",
559
+ "dependencies" => null,
560
+ "variables" => array("%username%", "%useremail%", "%filename%", "%filepath%", "%userdataXXX%"),
561
+ "help" => "Defines the email subject. Can be dynamic by using variables. Please check Documentation on how to use variables in atributes."
562
+ ),
563
+ array(
564
+ "name" => "Email Body",
565
+ "attribute" => "notifymessage",
566
+ "type" => "mtext",
567
+ "listitems" => null,
568
+ "value" => WFU_NOTIFYMESSAGE,
569
+ "mode" => "free",
570
+ "category" => "notifications",
571
+ "subcategory" => "Email Notifications",
572
+ "parent" => "notify",
573
+ "dependencies" => null,
574
+ "variables" => array("%username%", "%useremail%", "%filename%", "%filepath%", "%userdataXXX%", "%n%"),
575
+ "help" => "Defines the email body. Can be dynamic by using variables. Please check Documentation on how to use variables in atributes."
576
+ ),
577
+ array(
578
+ "name" => "Attach Uploaded Files",
579
+ "attribute" => "attachfile",
580
+ "type" => "onoff",
581
+ "listitems" => null,
582
+ "value" => WFU_ATTACHFILE,
583
+ "mode" => "free",
584
+ "category" => "notifications",
585
+ "subcategory" => "Email Notifications",
586
+ "parent" => "notify",
587
+ "dependencies" => null,
588
+ "variables" => null,
589
+ "help" => "If activated, then uploaded files will be included in the notification email as attachments. Please use carefully."
590
+ ),
591
+ array(
592
+ "name" => "Success Upload Message Color",
593
+ "attribute" => "successmessagecolor",
594
+ "type" => "color",
595
+ "listitems" => null,
596
+ "value" => WFU_SUCCESSMESSAGECOLOR,
597
+ "mode" => "free",
598
+ "category" => "colors",
599
+ "subcategory" => "Upload Message Colors",
600
+ "parent" => "",
601
+ "dependencies" => null,
602
+ "variables" => null,
603
+ "help" => "It defines the color of the success message. This attribute has been replaced by successmessagecolors, however it is kept here for backward compatibility."
604
+ ),
605
+ array(
606
+ "name" => "Success Message Colors",
607
+ "attribute" => "successmessagecolors",
608
+ "type" => "color-triplet",
609
+ "listitems" => null,
610
+ "value" => WFU_SUCCESSMESSAGECOLORS,
611
+ "mode" => "free",
612
+ "category" => "colors",
613
+ "subcategory" => "Upload Message Colors",
614
+ "parent" => "",
615
+ "dependencies" => null,
616
+ "variables" => null,
617
+ "help" => "It defines the text, background and border color of the success message."
618
+ ),
619
+ array(
620
+ "name" => "Warning Message Colors",
621
+ "attribute" => "warningmessagecolors",
622
+ "type" => "color-triplet",
623
+ "listitems" => null,
624
+ "value" => WFU_WARNINGMESSAGECOLORS,
625
+ "mode" => "free",
626
+ "category" => "colors",
627
+ "subcategory" => "Upload Message Colors",
628
+ "parent" => "",
629
+ "dependencies" => null,
630
+ "variables" => null,
631
+ "help" => "It defines the text, background and border color of the warning message."
632
+ ),
633
+ array(
634
+ "name" => "Fail Message Colors",
635
+ "attribute" => "failmessagecolors",
636
+ "type" => "color-triplet",
637
+ "listitems" => null,
638
+ "value" => WFU_FAILMESSAGECOLORS,
639
+ "mode" => "free",
640
+ "category" => "colors",
641
+ "subcategory" => "Upload Message Colors",
642
+ "parent" => "",
643
+ "dependencies" => null,
644
+ "variables" => null,
645
+ "help" => "It defines the text, background and border color of the fail (error) message."
646
+ ),
647
+ array(
648
+ "name" => "Wait Message Colors",
649
+ "attribute" => "waitmessagecolors",
650
+ "type" => "color-triplet",
651
+ "listitems" => null,
652
+ "value" => WFU_WAITMESSAGECOLORS,
653
+ "mode" => "free",
654
+ "category" => "colors",
655
+ "subcategory" => "Upload Message Colors",
656
+ "parent" => "",
657
+ "dependencies" => null,
658
+ "variables" => null,
659
+ "help" => "It defines the text, background and border color of the wait message."
660
+ ),
661
+ array(
662
+ "name" => "Plugin Component Widths",
663
+ "attribute" => "widths",
664
+ "type" => "dimensions",
665
+ "listitems" => null,
666
+ "value" => WFU_WIDTHS,
667
+ "mode" => "free",
668
+ "category" => "dimensions",
669
+ "subcategory" => "Plugin Component Widths",
670
+ "parent" => "",
671
+ "dependencies" => null,
672
+ "variables" => null,
673
+ "help" => "It defines the widths of the selected plugin components."
674
+ ),
675
+ array(
676
+ "name" => "Plugin Component Heights",
677
+ "attribute" => "heights",
678
+ "type" => "dimensions",
679
+ "listitems" => null,
680
+ "value" => WFU_HEIGHTS,
681
+ "mode" => "free",
682
+ "category" => "dimensions",
683
+ "subcategory" => "Plugin Component Heights",
684
+ "parent" => "",
685
+ "dependencies" => null,
686
+ "variables" => null,
687
+ "help" => "It defines the heights of the selected plugin components."
688
+ ),
689
+ array(
690
+ "name" => "Include Additional Data Fields",
691
+ "attribute" => "userdata",
692
+ "type" => "onoff",
693
+ "listitems" => null,
694
+ "value" => WFU_USERDATA,
695
+ "mode" => "free",
696
+ "category" => "userdata",
697
+ "subcategory" => "Additional Data Fields",
698
+ "parent" => "",
699
+ "dependencies" => array("userdatalabel"),
700
+ "variables" => null,
701
+ "help" => "If enabled, then user can send additional information together with uploaded files (e.g. name, email etc), defined in userdatalabel attribute."
702
+ ),
703
+ array(
704
+ "name" => "Additional Data Fields",
705
+ "attribute" => "userdatalabel",
706
+ "type" => "userfields",
707
+ "listitems" => null,
708
+ "value" => WFU_USERDATALABEL,
709
+ "mode" => "free",
710
+ "category" => "userdata",
711
+ "subcategory" => "Additional Data Fields",
712
+ "parent" => "userdata",
713
+ "dependencies" => null,
714
+ "variables" => null,
715
+ "help" => "It defines the labels of the additional data fields and whether they are required or not."
716
+ ),
717
+ array(
718
+ "name" => "WP Filebase Plugin Connection",
719
+ "attribute" => "filebaselink",
720
+ "type" => "onoff",
721
+ "listitems" => null,
722
+ "value" => WFU_FILEBASELINK,
723
+ "mode" => "free",
724
+ "category" => "interoperability",
725
+ "subcategory" => "Connection With Other Plugins",
726
+ "parent" => "",
727
+ "dependencies" => null,
728
+ "variables" => null,
729
+ "help" => "If enabled then the WP Filebase Plugin will be informed about new file uploads."
730
+ ),
731
+ array(
732
+ "name" => "Add Uploaded Files To Media",
733
+ "attribute" => "medialink",
734
+ "type" => "onoff",
735
+ "listitems" => null,
736
+ "value" => WFU_MEDIALINK,
737
+ "mode" => "free",
738
+ "category" => "interoperability",
739
+ "subcategory" => "Connection With Other Plugins or Functions",
740
+ "parent" => "",
741
+ "dependencies" => null,
742
+ "variables" => null,
743
+ "help" => "If enabled then the WP Filebase Plugin will be informed about new file uploads."
744
+ )
745
+ );
746
+
747
+ wfu_array_remove_nulls($defs);
748
+
749
+ return $defs;
750
+ }
751
+
752
+ ?>
lib/wfu_blocks.php CHANGED
@@ -1,241 +1,241 @@
1
- <?php
2
-
3
- /* Prepare information about directory or selection of target subdirectory */
4
- function wfu_prepare_subfolders_block($params, $widths, $heights) {
5
- $sid = $params["uploadid"];
6
- $selectsubdir = 'selectsubdir_'.$sid;
7
- $hiddeninput = 'hiddeninput_'.$sid;
8
- $subfolders_item = null;
9
- $styles1 = "";
10
- if ( $widths["subfolders_label"] != "" ) $styles1 .= 'width: '.$widths["subfolders_label"].'; ';
11
- if ( $heights["subfolders_label"] != "" ) $styles1 .= 'height: '.$heights["subfolders_label"].'; ';
12
- if ( $styles1 != "" ) $styles1 = ' style="'.$styles1.'"';
13
- $styles2 = "border: 1px solid; border-color: #BBBBBB;";
14
- if ( $widths["subfolders_select"] != "" ) $styles2 .= 'width: '.$widths["subfolders_select"].'; ';
15
- if ( $heights["subfolders_select"] != "" ) $styles2 .= 'height: '.$heights["subfolders_select"].'; ';
16
- $styles2 = ' style="'.$styles2.'"';
17
- $subfolder_paths = array ( );
18
- if ( $params["testmode"] == "true" ) {
19
- $subfolders_item["title"] = 'wordpress_file_upload_subfolders_'.$sid;
20
- $subfolders_item["hidden"] = false;
21
- $subfolders_item["line1"] = '<span class="file_item_clean"'.$styles1.'>'.$params["targetfolderlabel"].' </span>';
22
- $subfolders_item["line2"] = '<select class="file_item_clean"'.$styles2.' id="'.$selectsubdir.'" onchange="javascript: document.getElementById(\''.$hiddeninput.'\').value = document.getElementById(\''.$selectsubdir.'\').selectedIndex;">';
23
-
24
- $subfolders_item["line3"] = "\t".'<option>'.WFU_NOTIFY_TESTMODE.'</option>';
25
- $subfolders_lastline = 4;
26
- $subfolders_item["line".$subfolders_lastline] = '</select>';
27
- }
28
- elseif ( $params["askforsubfolders"] == "true" ) {
29
- $subfolders = explode(",", $params["subfoldertree"]);
30
- if ( count($subfolders) == 0 ) { $subfolders = array ( wfu_upload_plugin_directory($params["uploadpath"]) ); }
31
- if ( count($subfolders) == 1 && trim($subfolders[0]) == "" ) { $subfolders = array ( wfu_upload_plugin_directory($params["uploadpath"]) ); }
32
- $subfolders_item["title"] = 'wordpress_file_upload_subfolders_'.$sid;
33
- $subfolders_item["hidden"] = false;
34
- $subfolders_item["line1"] = '<span class="file_item_clean"'.$styles1.'>'.$params["targetfolderlabel"].' </span>';
35
- $subfolders_item["line2"] = '<select class="file_item_clean"'.$styles2.' id="'.$selectsubdir.'" onchange="javascript: document.getElementById(\''.$hiddeninput.'\').value = document.getElementById(\''.$selectsubdir.'\').selectedIndex;">';
36
- $subfolders_lastline = 3;
37
- $dir_levels = array ( wfu_upload_plugin_directory($params["uploadpath"]) );
38
- $prev_level = 0;
39
- foreach ($subfolders as $subfolder) {
40
- $subfolder = trim($subfolder);
41
- $star_count = 0;
42
- $start_spaces = "";
43
- while ( $star_count < strlen($subfolder) ) {
44
- if ( substr($subfolder, $star_count, 1) == "*" ) {
45
- $star_count ++;
46
- $start_spaces .= "&nbsp;&nbsp;&nbsp;";
47
- }
48
- else break;
49
- }
50
- if ( $star_count - $prev_level <= 1 ) {
51
- $subfolder = substr($subfolder, $star_count, strlen($subfolder) - $star_count);
52
- $subfolder_items = explode('/', $subfolder);
53
- if ( $subfolder_items[1] != "" ) {
54
- $subfolder_dir = $subfolder_items[0];
55
- $subfolder_label = $subfolder_items[1];
56
- }
57
- else {
58
- $subfolder_dir = $subfolder;
59
- $subfolder_label = $subfolder;
60
- }
61
- if ( count($dir_levels) > $star_count ) $dir_levels[$star_count] = $subfolder_dir;
62
- else array_push($dir_levels, $subfolder_dir);
63
- $subfolder_path = "";
64
- for ( $i_count = 1; $i_count <= $star_count; $i_count++) {
65
- $subfolder_path .= $dir_levels[$i_count].'/';
66
- }
67
- array_push($subfolder_paths, $subfolder_path);
68
- $subfolders_item["line".$subfolders_lastline] = "\t".'<option>'.$start_spaces.$subfolder_label.'</option>';
69
- $subfolders_lastline ++;
70
- $prev_level = $star_count;
71
- }
72
- }
73
- $subfolders_item["line".$subfolders_lastline] = '</select>';
74
- }
75
- else if ( $params["showtargetfolder"] == "true" ) {
76
- $upload_directory = wfu_upload_plugin_directory($params["uploadpath"]);
77
- $subfolders_item["title"] = 'wordpress_file_upload_subfolders_'.$sid;
78
- $subfolders_item["hidden"] = false;
79
- $subfolders_item["line1"] = '<span'.$styles1.'>'.$params["targetfolderlabel"].': <strong>'.$upload_directory.'</strong></span>';
80
- }
81
-
82
- $subfolders['item'] = $subfolders_item;
83
- $subfolders['paths'] = $subfolder_paths;
84
-
85
- return $subfolders;
86
- }
87
-
88
- /* Prepare the title */
89
- function wfu_prepare_title_block($params, $widths, $heights) {
90
- $sid = $params["uploadid"];
91
- $title_item = null;
92
- if ( $params["uploadtitle"] ) {
93
- $title_item["title"] = 'wordpress_file_upload_title_'.$sid;
94
- $title_item["hidden"] = false;
95
- $styles = "";
96
- if ( $widths["title"] != "" ) $styles .= 'width: '.$widths["title"].'; ';
97
- if ( $heights["title"] != "" ) $styles .= 'height: '.$heights["title"].'; ';
98
- if ( $styles != "" ) $styles = ' style="'.$styles.'"';
99
- $title_item["line1"] = '<span class="file_title_clean"'.$styles.'>'.$params["uploadtitle"].'</span>';
100
- }
101
-
102
- return $title_item;
103
- }
104
-
105
- /* Prepare the text box showing filename */
106
- function wfu_prepare_textbox_block($params, $widths, $heights) {
107
- $sid = $params["uploadid"];
108
- $textfile = 'fileName_'.$sid;
109
- $textbox_item["title"] = 'wordpress_file_upload_textbox_'.$sid;
110
- $textbox_item["hidden"] = false;
111
- $styles = "";
112
- if ( $widths["filename"] != "" ) $styles .= 'width: '.$widths["filename"].'; ';
113
- if ( $heights["filename"] != "" ) $styles .= 'height: '.$heights["filename"].'; ';
114
- if ( $styles != "" ) $styles = ' style="'.$styles.'"';
115
- $textbox_item["line1"] = '<input type="text" id="'.$textfile.'" class="file_input_textbox"'.$styles.' readonly="readonly"/>';
116
-
117
- return $textbox_item;
118
- }
119
-
120
- /* Prepare the upload form (required) */
121
- function wfu_prepare_uploadform_block($params, $widths, $heights, $clickaction, $additional_params) {
122
- $sid = $params["uploadid"];
123
- $uploadform = 'uploadform_'.$sid;
124
- $uploadedfile = 'uploadedfile_'.$sid;
125
- $upfile = 'upfile_'.$sid;
126
- $input = 'input_'.$sid;
127
- $label = $params["selectbutton"];
128
- $usefilearray = 0;
129
-
130
- $uploadform_item["title"] = 'wordpress_file_upload_form_'.$sid;
131
- // selectbutton block is mandatory because it contains the upload form element, so in case it is not included in the placements
132
- // attribute then we set its visibility to hidden
133
- $uploadform_item["hidden"] = ( strpos($params["placements"], "selectbutton") === false );
134
- $styles_form = "";
135
- $styles = "";
136
- if ( $widths["selectbutton"] != "" ) $styles .= 'width: '.$widths["selectbutton"].'; ';
137
- if ( $heights["selectbutton"] != "" ) $styles .= 'height: '.$heights["selectbutton"].'; ';
138
- if ( $styles != "" ) $styles_form = ' style="'.$styles.'"';
139
- $i = 1;
140
- $uploadform_item["line".$i++] = '<form class="file_input_uploadform" id="'.$uploadform.'" name="'.$uploadform.'" method="post" enctype="multipart/form-data"'.$styles_form.'>';
141
- if ( $params["testmode"] == "true" ) $styles .= 'z-index: 500;';
142
- if ( $styles != "" ) $styles = ' style="'.$styles.'"';
143
- if ( $params["testmode"] == "true" ) $uploadform_item["line".$i++] = "\t".'<input align="center" type="button" id="'.$input.'" value="'.$label.'" class="file_input_button"'.$styles.' onmouseout="javascript: document.getElementById(\''.$input.'\').className = \'file_input_button\'" onmouseover="javascript: document.getElementById(\''.$input.'\').className = \'file_input_button_hover\'" onclick="alert(\''.WFU_NOTIFY_TESTMODE.'\');" />';
144
- else $uploadform_item["line".$i++] = "\t".'<input align="center" type="button" id="'.$input.'" value="'.$label.'" class="file_input_button"'.$styles.'/>';
145
- if ( $params["singlebutton"] == "true" )
146
- $uploadform_item["line".$i++] = "\t".'<input type="file" class="file_input_hidden" name="'.$uploadedfile.'" id="'.$upfile.'" tabindex="1" onchange="wfu_selectbutton_changed('.$sid.', '.$usefilearray.'); if (this.value != \'\') {'.$clickaction.'}" onmouseout="javascript: document.getElementById(\''.$input.'\').className = \'file_input_button\'" onmouseover="javascript: document.getElementById(\''.$input.'\').className = \'file_input_button_hover\'" onclick="wfu_selectbutton_clicked('.$sid.');"'.' />';
147
- else
148
- $uploadform_item["line".$i++] = "\t".'<input type="file" class="file_input_hidden" name="'.$uploadedfile.'" id="'.$upfile.'" tabindex="1" onchange="wfu_selectbutton_changed('.$sid.', '.$usefilearray.');" onmouseout="javascript: document.getElementById(\''.$input.'\').className = \'file_input_button\'" onmouseover="javascript: document.getElementById(\''.$input.'\').className = \'file_input_button_hover\'" onclick="wfu_selectbutton_clicked('.$sid.');"'.' />';
149
- $uploadform_item["line".$i++] = "\t".'<input type="hidden" id="hiddeninput_'.$sid.'" name="hiddeninput_'.$sid.'" value="" />';
150
- $uploadform_item["line".$i++] = "\t".'<input type="hidden" id="adminerrorcodes_'.$sid.'" name="adminerrorcodes_'.$sid.'" value="" />';
151
- foreach ($params["userdata_fields"] as $userdata_key => $userdata_field)
152
- $uploadform_item["line".$i++] = "\t".'<input type="hidden" id="hiddeninput_'.$sid.'_userdata_'.$userdata_key.'" name="hiddeninput_'.$sid.'_userdata_'.$userdata_key.'" value="" />';
153
- $uploadform_item["line".$i++] = '</form>';
154
-
155
- return $uploadform_item;
156
- }
157
-
158
- /* Prepare the submit button */
159
- function wfu_prepare_submit_block($params, $widths, $heights, $clickaction) {
160
- $sid = $params["uploadid"];
161
- $upload = 'upload_'.$sid;
162
- $default = $params["uploadbutton"];
163
-
164
- $submit_item["title"] = 'wordpress_file_upload_submit_'.$sid;
165
- $submit_item["hidden"] = false;
166
- $styles = "";
167
- if ( $widths["uploadbutton"] != "" ) $styles .= 'width: '.$widths["uploadbutton"].'; ';
168
- if ( $heights["uploadbutton"] != "" ) $styles .= 'height: '.$heights["uploadbutton"].'; ';
169
- if ( $styles != "" ) $styles = ' style="'.$styles.'"';
170
- if ( $params["testmode"] == "true" ) $submit_item["line1"] = '<input align="center" type="button" id="'.$upload.'" name="'.$upload.'" value="'.$default.'" class="file_input_submit" onclick="alert(\''.WFU_NOTIFY_TESTMODE.'\');"'.$styles.' />';
171
- else $submit_item["line1"] = '<input align="center" type="button" id="'.$upload.'" name="'.$upload.'" value="'.$default.'" class="file_input_submit" onclick="'.$clickaction.'"'.$styles.' />';
172
- $submit_item["line2"] = '<input type="hidden" id="'.$upload.'_default" value="'.$default.'" />';
173
-
174
- return $submit_item;
175
- }
176
-
177
-
178
- /* Prepare the progress bar */
179
- function wfu_prepare_progressbar_block($params, $widths, $heights) {
180
- $sid = $params["uploadid"];
181
- $progress_bar = 'progressbar_'.$sid;
182
-
183
- $progressbar_item["title"] = 'wordpress_file_upload_progressbar_'.$sid;
184
- $progressbar_item["hidden"] = ( $params["testmode"] != "true" );
185
- $styles = "";
186
- if ( $widths["progressbar"] != "" ) $styles .= 'width: '.$widths["progressbar"].'; ';
187
- if ( $heights["progressbar"] != "" ) $styles .= 'height: '.$heights["progressbar"].'; ';
188
- if ( $styles != "" ) $styles = ' style="'.$styles.'"';
189
- $progressbar_item["line1"] = '<div id="'.$progress_bar.'" class="file_progress_bar"'.$styles.'>';
190
- $progressbar_item["line2"] = "\t".'<div id="'.$progress_bar.'_inner" class="file_progress_inner">';
191
- $progressbar_item["line3"] = "\t\t".'<span id="'.$progress_bar.'_animation" class="file_progress_noanimation">&nbsp;</span>';
192
- $progressbar_item["line4"] = "\t\t".'<img id="'.$progress_bar.'_imagesafe" class="file_progress_imagesafe" src="'.WFU_IMAGE_SIMPLE_PROGBAR.'" style="display:none;" />';
193
- $progressbar_item["line5"] = "\t".'</div>';
194
- $progressbar_item["line6"] = '</div>';
195
-
196
- return $progressbar_item;
197
- }
198
-
199
- /* Prepare the message block */
200
- function wfu_prepare_message_block($params, $widths, $heights) {
201
- $sid = $params["uploadid"];
202
- $styles = "";
203
- if ( $widths["message"] != "" ) $styles .= 'width: '.$widths["message"].'; ';
204
- if ( $heights["message"] != "" ) $styles .= 'height: '.$heights["message"].'; ';
205
- if ( $styles != "" ) $styles = ' style="'.$styles.'"';
206
- $message_block = wfu_prepare_message_block_skeleton($sid, $styles, ( $params["testmode"] == "true" ));
207
- $message_item = $message_block["msgblock"];
208
- $message_item["title"] = 'wordpress_file_upload_message_'.$sid;
209
- $message_item["hidden"] = ( $params["testmode"] != "true" );
210
-
211
- return $message_item;
212
- }
213
-
214
- /* Prepare the user data block */
215
- function wfu_prepare_userdata_block($params, $widths, $heights) {
216
- $sid = $params["uploadid"];
217
- $userdata = 'userdata_'.$sid;
218
- $hiddeninput = 'hiddeninput_'.$sid;
219
-
220
- $userdata_item["title"] = 'wordpress_file_upload_userdata_'.$sid;
221
- $userdata_item["hidden"] = false;
222
- $styles = "";
223
- if ( $widths["userdata"] != "" ) $styles .= 'width: '.$widths["userdata"].'; ';
224
- if ( $heights["userdata"] != "" ) $styles .= 'height: '.$heights["userdata"].'; ';
225
- if ( $styles != "" ) $styles = ' style="'.$styles.'"';
226
- $i = 1;
227
- foreach ($params["userdata_fields"] as $userdata_key => $userdata_field) {
228
- $userdata_item["line".$i++] = '<div id="'.$userdata.'_'.$userdata_key.'" class="file_userdata_container"'.$styles.'>';
229
- $userdata_item["line".$i++] = "\t".'<label id="'.$userdata.'_label_'.$userdata_key.'" for="'.$userdata.'_message_'.$userdata_key.'" class="file_userdata_label">'.$userdata_field["label"].'</label>';
230
- $userdata_item_class = ( $userdata_field["required"] == "true" ? "file_userdata_message_required" : "file_userdata_message" );
231
- if ( $params["testmode"] == "true" )
232
- $userdata_item["line".$i++] = "\t".'<input type="text" id="'.$userdata.'_message_'.$userdata_key.'" class="'.$userdata_item_class.'" value="Test message" readonly="readonly" />';
233
- else
234
- $userdata_item["line".$i++] = "\t".'<input type="text" id="'.$userdata.'_message_'.$userdata_key.'" class="'.$userdata_item_class.'" value="" onchange="javascript: document.getElementById(\''.$hiddeninput.'_userdata_'.$userdata_key.'\').value = this.value;" onfocus="javascript: if (this.className == \'file_userdata_message_required_empty\') {this.value = \'\'; this.className = \'file_userdata_message_required\';}" />';
235
- $userdata_item["line".$i++] = '</div>';
236
- }
237
-
238
- return $userdata_item;
239
- }
240
-
241
- ?>
1
+ <?php
2
+
3
+ /* Prepare information about directory or selection of target subdirectory */
4
+ function wfu_prepare_subfolders_block($params, $widths, $heights) {
5
+ $sid = $params["uploadid"];
6
+ $selectsubdir = 'selectsubdir_'.$sid;
7
+ $hiddeninput = 'hiddeninput_'.$sid;
8
+ $subfolders_item = null;
9
+ $styles1 = "";
10
+ if ( $widths["subfolders_label"] != "" ) $styles1 .= 'width: '.$widths["subfolders_label"].'; ';
11
+ if ( $heights["subfolders_label"] != "" ) $styles1 .= 'height: '.$heights["subfolders_label"].'; ';
12
+ if ( $styles1 != "" ) $styles1 = ' style="'.$styles1.'"';
13
+ $styles2 = "border: 1px solid; border-color: #BBBBBB;";
14
+ if ( $widths["subfolders_select"] != "" ) $styles2 .= 'width: '.$widths["subfolders_select"].'; ';
15
+ if ( $heights["subfolders_select"] != "" ) $styles2 .= 'height: '.$heights["subfolders_select"].'; ';
16
+ $styles2 = ' style="'.$styles2.'"';
17
+ $subfolder_paths = array ( );
18
+ if ( $params["testmode"] == "true" ) {
19
+ $subfolders_item["title"] = 'wordpress_file_upload_subfolders_'.$sid;
20
+ $subfolders_item["hidden"] = false;
21
+ $subfolders_item["line1"] = '<span class="file_item_clean"'.$styles1.'>'.$params["targetfolderlabel"].' </span>';
22
+ $subfolders_item["line2"] = '<select class="file_item_clean"'.$styles2.' id="'.$selectsubdir.'" onchange="javascript: document.getElementById(\''.$hiddeninput.'\').value = document.getElementById(\''.$selectsubdir.'\').selectedIndex;">';
23
+
24
+ $subfolders_item["line3"] = "\t".'<option>'.WFU_NOTIFY_TESTMODE.'</option>';
25
+ $subfolders_lastline = 4;
26
+ $subfolders_item["line".$subfolders_lastline] = '</select>';
27
+ }
28
+ elseif ( $params["askforsubfolders"] == "true" ) {
29
+ $subfolders = explode(",", $params["subfoldertree"]);
30
+ if ( count($subfolders) == 0 ) { $subfolders = array ( wfu_upload_plugin_directory($params["uploadpath"]) ); }
31
+ if ( count($subfolders) == 1 && trim($subfolders[0]) == "" ) { $subfolders = array ( wfu_upload_plugin_directory($params["uploadpath"]) ); }
32
+ $subfolders_item["title"] = 'wordpress_file_upload_subfolders_'.$sid;
33
+ $subfolders_item["hidden"] = false;
34
+ $subfolders_item["line1"] = '<span class="file_item_clean"'.$styles1.'>'.$params["targetfolderlabel"].' </span>';
35
+ $subfolders_item["line2"] = '<select class="file_item_clean"'.$styles2.' id="'.$selectsubdir.'" onchange="javascript: document.getElementById(\''.$hiddeninput.'\').value = document.getElementById(\''.$selectsubdir.'\').selectedIndex;">';
36
+ $subfolders_lastline = 3;
37
+ $dir_levels = array ( wfu_upload_plugin_directory($params["uploadpath"]) );
38
+ $prev_level = 0;
39
+ foreach ($subfolders as $subfolder) {
40
+ $subfolder = trim($subfolder);
41
+ $star_count = 0;
42
+ $start_spaces = "";
43
+ while ( $star_count < strlen($subfolder) ) {
44
+ if ( substr($subfolder, $star_count, 1) == "*" ) {
45
+ $star_count ++;
46
+ $start_spaces .= "&nbsp;&nbsp;&nbsp;";
47
+ }
48
+ else break;
49
+ }
50
+ if ( $star_count - $prev_level <= 1 ) {
51
+ $subfolder = substr($subfolder, $star_count, strlen($subfolder) - $star_count);
52
+ $subfolder_items = explode('/', $subfolder);
53
+ if ( $subfolder_items[1] != "" ) {
54
+ $subfolder_dir = $subfolder_items[0];
55
+ $subfolder_label = $subfolder_items[1];
56
+ }
57
+ else {
58
+ $subfolder_dir = $subfolder;
59
+ $subfolder_label = $subfolder;
60
+ }
61
+ if ( count($dir_levels) > $star_count ) $dir_levels[$star_count] = $subfolder_dir;
62
+ else array_push($dir_levels, $subfolder_dir);
63
+ $subfolder_path = "";
64
+ for ( $i_count = 1; $i_count <= $star_count; $i_count++) {
65
+ $subfolder_path .= $dir_levels[$i_count].'/';
66
+ }
67
+ array_push($subfolder_paths, $subfolder_path);
68
+ $subfolders_item["line".$subfolders_lastline] = "\t".'<option>'.$start_spaces.$subfolder_label.'</option>';
69
+ $subfolders_lastline ++;
70
+ $prev_level = $star_count;
71
+ }
72
+ }
73
+ $subfolders_item["line".$subfolders_lastline] = '</select>';
74
+ }
75
+ else if ( $params["showtargetfolder"] == "true" ) {
76
+ $upload_directory = wfu_upload_plugin_directory($params["uploadpath"]);
77
+ $subfolders_item["title"] = 'wordpress_file_upload_subfolders_'.$sid;
78
+ $subfolders_item["hidden"] = false;
79
+ $subfolders_item["line1"] = '<span'.$styles1.'>'.$params["targetfolderlabel"].': <strong>'.$upload_directory.'</strong></span>';
80
+ }
81
+
82
+ $subfolders['item'] = $subfolders_item;
83
+ $subfolders['paths'] = $subfolder_paths;
84
+
85
+ return $subfolders;
86
+ }
87
+
88
+ /* Prepare the title */
89
+ function wfu_prepare_title_block($params, $widths, $heights) {
90
+ $sid = $params["uploadid"];
91
+ $title_item = null;
92
+ if ( $params["uploadtitle"] ) {
93
+ $title_item["title"] = 'wordpress_file_upload_title_'.$sid;
94
+ $title_item["hidden"] = false;
95
+ $styles = "";
96
+ if ( $widths["title"] != "" ) $styles .= 'width: '.$widths["title"].'; ';
97
+ if ( $heights["title"] != "" ) $styles .= 'height: '.$heights["title"].'; ';
98
+ if ( $styles != "" ) $styles = ' style="'.$styles.'"';
99
+ $title_item["line1"] = '<span class="file_title_clean"'.$styles.'>'.$params["uploadtitle"].'</span>';
100
+ }
101
+
102
+ return $title_item;
103
+ }
104
+
105
+ /* Prepare the text box showing filename */
106
+ function wfu_prepare_textbox_block($params, $widths, $heights) {
107
+ $sid = $params["uploadid"];
108
+ $textfile = 'fileName_'.$sid;
109
+ $textbox_item["title"] = 'wordpress_file_upload_textbox_'.$sid;
110
+ $textbox_item["hidden"] = false;
111
+ $styles = "";
112
+ if ( $widths["filename"] != "" ) $styles .= 'width: '.$widths["filename"].'; ';
113
+ if ( $heights["filename"] != "" ) $styles .= 'height: '.$heights["filename"].'; ';
114
+ if ( $styles != "" ) $styles = ' style="'.$styles.'"';
115
+ $textbox_item["line1"] = '<input type="text" id="'.$textfile.'" class="file_input_textbox"'.$styles.' readonly="readonly"/>';
116
+
117
+ return $textbox_item;
118
+ }
119
+
120
+ /* Prepare the upload form (required) */
121
+ function wfu_prepare_uploadform_block($params, $widths, $heights, $clickaction, $additional_params) {
122
+ $sid = $params["uploadid"];
123
+ $uploadform = 'uploadform_'.$sid;
124
+ $uploadedfile = 'uploadedfile_'.$sid;
125
+ $upfile = 'upfile_'.$sid;
126
+ $input = 'input_'.$sid;
127
+ $label = $params["selectbutton"];
128
+ $usefilearray = 0;
129
+
130
+ $uploadform_item["title"] = 'wordpress_file_upload_form_'.$sid;
131
+ // selectbutton block is mandatory because it contains the upload form element, so in case it is not included in the placements
132
+ // attribute then we set its visibility to hidden
133
+ $uploadform_item["hidden"] = ( strpos($params["placements"], "selectbutton") === false );
134
+ $styles_form = "";
135
+ $styles = "";
136
+ if ( $widths["selectbutton"] != "" ) $styles .= 'width: '.$widths["selectbutton"].'; ';
137
+ if ( $heights["selectbutton"] != "" ) $styles .= 'height: '.$heights["selectbutton"].'; ';
138
+ if ( $styles != "" ) $styles_form = ' style="'.$styles.'"';
139
+ $i = 1;
140
+ $uploadform_item["line".$i++] = '<form class="file_input_uploadform" id="'.$uploadform.'" name="'.$uploadform.'" method="post" enctype="multipart/form-data"'.$styles_form.'>';
141
+ if ( $params["testmode"] == "true" ) $styles .= 'z-index: 500;';
142
+ if ( $styles != "" ) $styles = ' style="'.$styles.'"';
143
+ if ( $params["testmode"] == "true" ) $uploadform_item["line".$i++] = "\t".'<input align="center" type="button" id="'.$input.'" value="'.$label.'" class="file_input_button"'.$styles.' onmouseout="javascript: document.getElementById(\''.$input.'\').className = \'file_input_button\'" onmouseover="javascript: document.getElementById(\''.$input.'\').className = \'file_input_button_hover\'" onclick="alert(\''.WFU_NOTIFY_TESTMODE.'\');" />';
144
+ else $uploadform_item["line".$i++] = "\t".'<input align="center" type="button" id="'.$input.'" value="'.$label.'" class="file_input_button"'.$styles.'/>';
145
+ if ( $params["singlebutton"] == "true" )
146
+ $uploadform_item["line".$i++] = "\t".'<input type="file" class="file_input_hidden" name="'.$uploadedfile.'" id="'.$upfile.'" tabindex="1" onchange="wfu_selectbutton_changed('.$sid.', '.$usefilearray.'); if (this.value != \'\') {'.$clickaction.'}" onmouseout="javascript: document.getElementById(\''.$input.'\').className = \'file_input_button\'" onmouseover="javascript: document.getElementById(\''.$input.'\').className = \'file_input_button_hover\'" onclick="wfu_selectbutton_clicked('.$sid.');"'.' />';
147
+ else
148
+ $uploadform_item["line".$i++] = "\t".'<input type="file" class="file_input_hidden" name="'.$uploadedfile.'" id="'.$upfile.'" tabindex="1" onchange="wfu_selectbutton_changed('.$sid.', '.$usefilearray.');" onmouseout="javascript: document.getElementById(\''.$input.'\').className = \'file_input_button\'" onmouseover="javascript: document.getElementById(\''.$input.'\').className = \'file_input_button_hover\'" onclick="wfu_selectbutton_clicked('.$sid.');"'.' />';
149
+ $uploadform_item["line".$i++] = "\t".'<input type="hidden" id="hiddeninput_'.$sid.'" name="hiddeninput_'.$sid.'" value="" />';
150
+ $uploadform_item["line".$i++] = "\t".'<input type="hidden" id="adminerrorcodes_'.$sid.'" name="adminerrorcodes_'.$sid.'" value="" />';
151
+ foreach ($params["userdata_fields"] as $userdata_key => $userdata_field)
152
+ $uploadform_item["line".$i++] = "\t".'<input type="hidden" id="hiddeninput_'.$sid.'_userdata_'.$userdata_key.'" name="hiddeninput_'.$sid.'_userdata_'.$userdata_key.'" value="" />';
153
+ $uploadform_item["line".$i++] = '</form>';
154
+
155
+ return $uploadform_item;
156
+ }
157
+
158
+ /* Prepare the submit button */
159
+ function wfu_prepare_submit_block($params, $widths, $heights, $clickaction) {
160
+ $sid = $params["uploadid"];
161
+ $upload = 'upload_'.$sid;
162
+ $default = $params["uploadbutton"];
163
+
164
+ $submit_item["title"] = 'wordpress_file_upload_submit_'.$sid;
165
+ $submit_item["hidden"] = false;
166
+ $styles = "";
167
+ if ( $widths["uploadbutton"] != "" ) $styles .= 'width: '.$widths["uploadbutton"].'; ';
168
+ if ( $heights["uploadbutton"] != "" ) $styles .= 'height: '.$heights["uploadbutton"].'; ';
169
+ if ( $styles != "" ) $styles = ' style="'.$styles.'"';
170
+ if ( $params["testmode"] == "true" ) $submit_item["line1"] = '<input align="center" type="button" id="'.$upload.'" name="'.$upload.'" value="'.$default.'" class="file_input_submit" onclick="alert(\''.WFU_NOTIFY_TESTMODE.'\');"'.$styles.' />';
171
+ else $submit_item["line1"] = '<input align="center" type="button" id="'.$upload.'" name="'.$upload.'" value="'.$default.'" class="file_input_submit" onclick="'.$clickaction.'"'.$styles.' />';
172
+ $submit_item["line2"] = '<input type="hidden" id="'.$upload.'_default" value="'.$default.'" />';
173
+
174
+ return $submit_item;
175
+ }
176
+
177
+
178
+ /* Prepare the progress bar */
179
+ function wfu_prepare_progressbar_block($params, $widths, $heights) {
180
+ $sid = $params["uploadid"];
181
+ $progress_bar = 'progressbar_'.$sid;
182
+
183
+ $progressbar_item["title"] = 'wordpress_file_upload_progressbar_'.$sid;
184
+ $progressbar_item["hidden"] = ( $params["testmode"] != "true" );
185
+ $styles = "";
186
+ if ( $widths["progressbar"] != "" ) $styles .= 'width: '.$widths["progressbar"].'; ';
187
+ if ( $heights["progressbar"] != "" ) $styles .= 'height: '.$heights["progressbar"].'; ';
188
+ if ( $styles != "" ) $styles = ' style="'.$styles.'"';
189
+ $progressbar_item["line1"] = '<div id="'.$progress_bar.'" class="file_progress_bar"'.$styles.'>';
190
+ $progressbar_item["line2"] = "\t".'<div id="'.$progress_bar.'_inner" class="file_progress_inner">';
191
+ $progressbar_item["line3"] = "\t\t".'<span id="'.$progress_bar.'_animation" class="file_progress_noanimation">&nbsp;</span>';
192
+ $progressbar_item["line4"] = "\t\t".'<img id="'.$progress_bar.'_imagesafe" class="file_progress_imagesafe" src="'.WFU_IMAGE_SIMPLE_PROGBAR.'" style="display:none;" />';
193
+ $progressbar_item["line5"] = "\t".'</div>';
194
+ $progressbar_item["line6"] = '</div>';
195
+
196
+ return $progressbar_item;
197
+ }
198
+
199
+ /* Prepare the message block */
200
+ function wfu_prepare_message_block($params, $widths, $heights) {
201
+ $sid = $params["uploadid"];
202
+ $styles = "";
203
+ if ( $widths["message"] != "" ) $styles .= 'width: '.$widths["message"].'; ';
204
+ if ( $heights["message"] != "" ) $styles .= 'height: '.$heights["message"].'; ';
205
+ if ( $styles != "" ) $styles = ' style="'.$styles.'"';
206
+ $message_block = wfu_prepare_message_block_skeleton($sid, $styles, ( $params["testmode"] == "true" ));
207
+ $message_item = $message_block["msgblock"];
208
+ $message_item["title"] = 'wordpress_file_upload_message_'.$sid;
209
+ $message_item["hidden"] = ( $params["testmode"] != "true" );
210
+
211
+ return $message_item;
212
+ }
213
+
214
+ /* Prepare the user data block */
215
+ function wfu_prepare_userdata_block($params, $widths, $heights) {
216
+ $sid = $params["uploadid"];
217
+ $userdata = 'userdata_'.$sid;
218
+ $hiddeninput = 'hiddeninput_'.$sid;
219
+
220
+ $userdata_item["title"] = 'wordpress_file_upload_userdata_'.$sid;
221
+ $userdata_item["hidden"] = false;
222
+ $styles = "";
223
+ if ( $widths["userdata"] != "" ) $styles .= 'width: '.$widths["userdata"].'; ';
224
+ if ( $heights["userdata"] != "" ) $styles .= 'height: '.$heights["userdata"].'; ';
225
+ if ( $styles != "" ) $styles = ' style="'.$styles.'"';
226
+ $i = 1;
227
+ foreach ($params["userdata_fields"] as $userdata_key => $userdata_field) {
228
+ $userdata_item["line".$i++] = '<div id="'.$userdata.'_'.$userdata_key.'" class="file_userdata_container"'.$styles.'>';
229
+ $userdata_item["line".$i++] = "\t".'<label id="'.$userdata.'_label_'.$userdata_key.'" for="'.$userdata.'_message_'.$userdata_key.'" class="file_userdata_label">'.$userdata_field["label"].'</label>';
230
+ $userdata_item_class = ( $userdata_field["required"] == "true" ? "file_userdata_message_required" : "file_userdata_message" );
231
+ if ( $params["testmode"] == "true" )
232
+ $userdata_item["line".$i++] = "\t".'<input type="text" id="'.$userdata.'_message_'.$userdata_key.'" class="'.$userdata_item_class.'" value="Test message" readonly="readonly" />';
233
+ else
234
+ $userdata_item["line".$i++] = "\t".'<input type="text" id="'.$userdata.'_message_'.$userdata_key.'" class="'.$userdata_item_class.'" value="" onchange="javascript: document.getElementById(\''.$hiddeninput.'_userdata_'.$userdata_key.'\').value = this.value;" onfocus="javascript: if (this.className == \'file_userdata_message_required_empty\') {this.value = \'\'; this.className = \'file_userdata_message_required\';}" />';
235
+ $userdata_item["line".$i++] = '</div>';
236
+ }
237
+
238
+ return $userdata_item;
239
+ }
240
+
241
+ ?>
lib/wfu_constants.php CHANGED
@@ -1,197 +1,198 @@
1
- <?php
2
-
3
- $siteurl = site_url();
4
-
5
- //define plugin defaults
6
- DEFINE("WFU_UPLOADID", "1");
7
- DEFINE("WFU_UPLOADTITLE", __('Upload files', 'wordpress-file-upload'));
8
- DEFINE("WFU_SELECTBUTTON", __('Select File', 'wordpress-file-upload'));
9
- DEFINE("WFU_UPLOADBUTTON", __('Upload File', 'wordpress-file-upload'));
10
- DEFINE("WFU_SINGLEBUTTON", "false");
11
- DEFINE("WFU_UPLOADROLE", "administrator");
12
- DEFINE("WFU_UPLOADPATH", 'uploads');
13
- DEFINE("WFU_CREATEPATH", "false");
14
- DEFINE("WFU_UPLOADPATTERNS", "*.*");
15
- DEFINE("WFU_MAXSIZE", "50");
16
- DEFINE("WFU_ACCESSMETHOD", "normal");
17
- DEFINE("WFU_FTPINFO", "");
18
- DEFINE("WFU_USEFTPDOMAIN", "false");
19
- DEFINE("WFU_DUBLICATESPOLICY", "overwrite");
20
- DEFINE("WFU_UNIQUEPATTERN", "index");
21
- DEFINE("WFU_FILEBASELINK", "false");
22
- DEFINE("WFU_NOTIFY", "false");
23
- DEFINE("WFU_NOTIFYRECIPIENTS", "");
24
- DEFINE("WFU_NOTIFYSUBJECT", __('File Upload Notification', 'wordpress-file-upload'));
25
- DEFINE("WFU_NOTIFYMESSAGE", __("Dear Recipient,%n%%n% This is an automatic delivery message to notify you that a new file has been uploaded.%n%%n%Best Regards", 'wordpress-file-upload'));
26
- DEFINE("WFU_NOTIFYHEADERS", "");
27
- DEFINE("WFU_ATTACHFILE", "false");
28
- DEFINE("WFU_REDIRECT", "false");
29
- DEFINE("WFU_REDIRECTLINK", "");
30
- DEFINE("WFU_ADMINMESSAGES", "false");
31
- DEFINE("WFU_SUCCESSMESSAGE", __('File %filename% uploaded successfully', 'wordpress-file-upload'));
32
- DEFINE("WFU_WARNINGMESSAGE", __('File %filename% uploaded successfully but with warnings', 'wordpress-file-upload'));
33
- DEFINE("WFU_ERRORMESSAGE", __('File %filename% not uploaded', 'wordpress-file-upload'));
34
- DEFINE("WFU_WAITMESSAGE", __('File %filename% is being uploaded', 'wordpress-file-upload'));
35
- DEFINE("WFU_SUCCESSMESSAGECOLOR", "green");
36
- DEFINE("WFU_SUCCESSMESSAGECOLORS", "#006600,#EEFFEE,#006666");
37
- DEFINE("WFU_WARNINGMESSAGECOLORS", "#F88017,#FEF2E7,#633309");
38
- DEFINE("WFU_FAILMESSAGECOLORS", "#660000,#FFEEEE,#666600");
39
- DEFINE("WFU_WAITMESSAGECOLORS", "#666666,#EEEEEE,#333333");
40
- DEFINE("WFU_SHOWTARGETFOLDER", "false");
41
- DEFINE("WFU_TARGETFOLDERLABEL", "Upload Directory");
42
- DEFINE("WFU_ASKFORSUBFOLDERS", "false");
43
- DEFINE("WFU_SUBFOLDERTREE", "");
44
- DEFINE("WFU_FORCECLASSIC", "false");
45
- DEFINE("WFU_TESTMODE", "false");
46
- DEFINE("WFU_DEBUGMODE", "false");
47
- DEFINE("WFU_WIDTHS", "");
48
- DEFINE("WFU_HEIGHTS", "");
49
- DEFINE("WFU_PLACEMENTS", "title/filename+selectbutton+uploadbutton/subfolders"."/userdata"."/message");
50
- DEFINE("WFU_USERDATA", "false");
51
- DEFINE("WFU_USERDATALABEL", __('Your message', 'wordpress-file-upload'));
52
-
53
- //define plugin errors
54
- DEFINE("WFU_ERROR_ADMIN_FTPDIR_RESOLVE", __("Error. Could not resolve ftp target filedir. Check the domain in 'ftpinfo' attribute.", "wordpress-file-upload"));
55
- DEFINE("WFU_ERROR_ADMIN_FTPINFO_INVALID", __("Error. Invalid ftp information. Check 'ftpinfo' attribute.", "wordpress-file-upload"));
56
- DEFINE("WFU_ERROR_ADMIN_FTPINFO_EXTRACT", __("Error. Could not extract ftp information from 'ftpinfo' attribute. Check its syntax.", "wordpress-file-upload"));
57
- DEFINE("WFU_ERROR_ADMIN_FTPFILE_RESOLVE", __("Error. Could not resolve ftp target filename. Check the domain in 'ftpinfo' attribute.", "wordpress-file-upload"));
58
- DEFINE("WFU_ERROR_ADMIN_FILE_PHP_SIZE", __("Error. The upload size limit of PHP directive upload_max_filesize is preventing the upload of big files.\nPHP directive upload_max_filesize limit is: ".ini_get("upload_max_filesize").".\nTo increase the limit change the value of the directive from php.ini.\nIf you don't have access to php.ini, then try adding the following line to your .htaccess file:\n\nphp_value upload_max_filesize 10M\n\n(adjust the size according to your needs)\n\nThe file .htaccess is found in your website root directory (where index.php is found).\nIf your don't have this file, then create it.\nIf this does not work either, then contact your domain provider.", "wordpress-file-upload"));
59
- DEFINE("WFU_ERROR_ADMIN_FILE_PHP_TIME", __("The upload time limit of PHP directive max_input_time is preventing the upload of big files.\nPHP directive max_input_time limit is: ".ini_get("max_input_time")." seconds.\nTo increase the limit change the value of the directive from php.ini.\nIf you don't have access to php.ini, then add the following line to your .htaccess file:\n\nphp_value max_input_time 500\n\n(adjust the time according to your needs)\n\nThe file .htaccess is found in your website root directory (where index.php is found).\nIf your don't have this file, then create it.\nIf this does not work either, then contact your domain provider.", "wordpress-file-upload"));
60
- DEFINE("WFU_ERROR_ADMIN_DIR_PERMISSION", __("Error. Permission denied to write to target folder.\nCheck and correct read/write permissions of target folder.", "wordpress-file-upload"));
61
- DEFINE("WFU_ERROR_DIR_EXIST", __("Targer folder doesn't exist.", "wordpress-file-upload"));
62
- DEFINE("WFU_ERROR_DIR_NOTEMP", __("Upload failed! Missing a temporary folder.", "wordpress-file-upload"));
63
- DEFINE("WFU_ERROR_DIR_PERMISSION", __("Upload failed! Permission denied to write to target folder.", "wordpress-file-upload"));
64
- DEFINE("WFU_ERROR_FILE_ALLOW", __("File not allowed.", "wordpress-file-upload"));
65
- DEFINE("WFU_ERROR_FILE_PLUGIN_SIZE", __("The uploaded file exceeds the file size limit.", "wordpress-file-upload"));
66
- DEFINE("WFU_ERROR_FILE_PHP_SIZE", __("Upload failed! The uploaded file exceeds the file size limit of the server. Please contact the administrator.", "wordpress-file-upload"));
67
- DEFINE("WFU_ERROR_FILE_PHP_TIME", __("Upload failed! The duration of the upload exceeded the time limit of the server. Please contact the administrator.", "wordpress-file-upload"));
68
- DEFINE("WFU_ERROR_FILE_HTML_SIZE", __("Upload failed! The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.", "wordpress-file-upload"));
69
- DEFINE("WFU_ERROR_FILE_PARTIAL", __("Upload failed! The uploaded file was only partially uploaded.", "wordpress-file-upload"));
70
- DEFINE("WFU_ERROR_FILE_NOTHING", __("Upload failed! No file was uploaded.", "wordpress-file-upload"));
71
- DEFINE("WFU_ERROR_FILE_WRITE", __("Upload failed! Failed to write file to disk.", "wordpress-file-upload"));
72
- DEFINE("WFU_ERROR_FILE_MOVE", __("Upload failed! Error occured while moving temporary file. Please contact administrator.", "wordpress-file-upload"));
73
- DEFINE("WFU_ERROR_UPLOAD_STOPPED", __("Upload failed! A PHP extension stopped the file upload. PHP does not provide a way to ascertain which extension caused the file upload to stop; examining the list of loaded extensions with phpinfo() may help.", "wordpress-file-upload"));
74
- DEFINE("WFU_ERROR_UPLOAD_FAILED_WHILE", __("Upload failed! Error occured while attemting to upload the file.", "wordpress-file-upload"));
75
- DEFINE("WFU_ERROR_UPLOAD_FAILED", __("Upload failed!", "wordpress-file-upload"));
76
- DEFINE("WFU_ERROR_UPLOAD_NOFILESELECTED", __("No file!", "wordpress-file-upload"));
77
- DEFINE("WFU_ERROR_UPLOAD_CANCELLED", __("Upload failed! The upload has been canceled by the user or the browser dropped the connection.", "wordpress-file-upload"));
78
- DEFINE("WFU_ERROR_UNKNOWN", __("Upload failed! Unknown error.", "wordpress-file-upload"));
79
- DEFINE("WFU_ERROR_CONTACT_ADMIN", __("Please contact the administrator.", "wordpress-file-upload"));
80
- DEFINE("WFU_ERROR_REMOTESERVER_NORESULT", __("No result from remote server!", "wordpress-file-upload"));
81
- DEFINE("WFU_ERROR_JSONPARSE_FILEMESSAGE", __(" but with warnings", "wordpress-file-upload"));
82
- DEFINE("WFU_ERROR_JSONPARSE_MESSAGE", __("Warning: JSON parse error.", "wordpress-file-upload"));
83
- DEFINE("WFU_ERROR_JSONPARSE_ADMINMESSAGE", __("Upload parameters of this file, passed as JSON string to the handler, could not be parsed.", "wordpress-file-upload"));
84
- DEFINE("WFU_ERROR_JSONPARSE_HEADERMESSAGE", __("Warning: JSON parse error.", "wordpress-file-upload"));
85
- DEFINE("WFU_ERROR_JSONPARSE_HEADERADMINMESSAGE", __("UploadStates, passed as JSON string to the handler, could not be parsed.", "wordpress-file-upload"));
86
- DEFINE("WFU_ERROR_REDIRECTION_ERRORCODE0", __("Redirection to classic form functionality occurred due to unknown error.", "wordpress-file-upload"));
87
- DEFINE("WFU_ERROR_REDIRECTION_ERRORCODE1", __("Redirection to classic form functionality occurred because AJAX is not supported.", "wordpress-file-upload"));
88
- DEFINE("WFU_ERROR_REDIRECTION_ERRORCODE2", __("Redirection to classic form functionality occurred because HTML5 is not supported.", "wordpress-file-upload"));
89
- DEFINE("WFU_ERROR_REDIRECTION_ERRORCODE3", __("Redirection to classic form functionality occurred due to JSON parse error.", "wordpress-file-upload"));
90
- DEFINE("WFU_ERROR_USERDATA_EMPTY", __("cannot be empty!", "wordpress-file-upload"));
91
-
92
- //define plugin warnings
93
- DEFINE("WFU_WARNING_FILE_EXISTS", __("Upload skipped! File already exists.", "wordpress-file-upload"));
94
- DEFINE("WFU_WARNING_NOFILES_SELECTED", __("No files have been selected!", "wordpress-file-upload"));
95
- DEFINE("WFU_WARNING_WPFILEBASE_NOTUPDATED_NOFILES", __("WPFilebase Plugin not updated because there were no files uploaded.", "wordpress-file-upload"));
96
- DEFINE("WFU_WARNING_NOTIFY_NOTSENT_NOFILES", __("Notification email was not sent because there were no files uploaded.", "wordpress-file-upload"));
97
- DEFINE("WFU_WARNING_NOTIFY_NOTSENT_NORECIPIENTS", __("Notification email was not sent because no recipients were defined. Please check notifyrecipients attribute in the shortcode.", "wordpress-file-upload"));
98
- DEFINE("WFU_WARNING_NOTIFY_NOTSENT_UNKNOWNERROR", __("Notification email was not sent due to an error. Please check notifyrecipients, notifysubject and notifymessage attributes for errors.", "wordpress-file-upload"));
99
- DEFINE("WFU_WARNING_REDIRECT_NOTEXECUTED_EMPTY", __("Redirection not executed because redirection link is empty. Please check redirectlink attribute.", "wordpress-file-upload"));
100
- DEFINE("WFU_WARNING_REDIRECT_NOTEXECUTED_FILESFAILED", __("Redirection not executed because not all files were successfully uploaded.", "wordpress-file-upload"));
101
-
102
- //define plugin messages
103
- DEFINE("WFU_NOTIFY_TESTMODE", __("Test Mode", "wordpress-file-upload"));
104
- DEFINE("WFU_SUCCESSMESSAGE_DETAILS", __('Upload path: %filepath%', 'wordpress-file-upload'));
105
- DEFINE("WFU_FAILMESSAGE_DETAILS", __('Failed upload path: %filepath%', 'wordpress-file-upload'));
106
-
107
- //define plugin test messages
108
- DEFINE("WFU_TESTMESSAGE_MESSAGE", __('This is a test message', 'wordpress-file-upload'));
109
- DEFINE("WFU_TESTMESSAGE_ADMINMESSAGE", __('This is a test administrator message', 'wordpress-file-upload'));
110
- DEFINE("WFU_TESTMESSAGE_FILE1_HEADER", __('File testfile 1 under test', 'wordpress-file-upload'));
111
- DEFINE("WFU_TESTMESSAGE_FILE1_MESSAGE", __('File testfile 1 message', 'wordpress-file-upload'));
112
- DEFINE("WFU_TESTMESSAGE_FILE1_ADMINMESSAGE", __('File testfile 1 administrator message', 'wordpress-file-upload'));
113
- DEFINE("WFU_TESTMESSAGE_FILE2_HEADER", __('File testfile 2 under test', 'wordpress-file-upload'));
114
- DEFINE("WFU_TESTMESSAGE_FILE2_MESSAGE", __('File testfile 2 message', 'wordpress-file-upload'));
115
- DEFINE("WFU_TESTMESSAGE_FILE2_ADMINMESSAGE", __('File testfile 2 administrator message', 'wordpress-file-upload'));
116
-
117
- //define tool tip constants
118
- DEFINE("WFU_VARIABLE_TITLE_USERNAME", __("Insert variable %username% inside text. It will be replaced by the username of the current user.", "wordpress-file-upload"));
119
- DEFINE("WFU_VARIABLE_TITLE_USEREMAIL", __("Insert variable %useremail% inside text. It will be replaced by the email of the current user.", "wordpress-file-upload"));
120
- DEFINE("WFU_VARIABLE_TITLE_FILENAME", __("Insert variable %filename% inside text. It will be replaced by the filename of the uploaded file.", "wordpress-file-upload"));
121
- DEFINE("WFU_VARIABLE_TITLE_FILEPATH", __("Insert variable %filepath% inside text. It will be replaced by the full filepath of the uploaded file.", "wordpress-file-upload"));
122
- DEFINE("WFU_VARIABLE_TITLE_BLOGID", __("Insert variable %blogid% inside text. It will be replaced by the blog id of the website.", "wordpress-file-upload"));
123
- DEFINE("WFU_VARIABLE_TITLE_USERDATAXXX", __("Insert variable %userdataXXX% inside text. Select the user field from the drop-down list. It will be replaced by the value that the user entered in this field.", "wordpress-file-upload"));
124
- DEFINE("WFU_VARIABLE_TITLE_N", __("Insert variable %n% inside text to denote a line change.", "wordpress-file-upload"));
125
-
126
- //define plugin other constants
127
- DEFINE("WFU_UPLOAD_STATE0", __("Upload in progress", "wordpress-file-upload"));
128
- DEFINE("WFU_UPLOAD_STATE1", __("Upload in progress with warnings!", "wordpress-file-upload"));
129
- DEFINE("WFU_UPLOAD_STATE2", __("Upload in progress but some files already failed!", "wordpress-file-upload"));
130
- DEFINE("WFU_UPLOAD_STATE3", __("Upload in progress but no files uploaded so far!", "wordpress-file-upload"));
131
- DEFINE("WFU_UPLOAD_STATE4", __("All files uploaded successfully", "wordpress-file-upload"));
132
- DEFINE("WFU_UPLOAD_STATE5", __("All files uploaded successfully but there are warnings!", "wordpress-file-upload"));
133
- DEFINE("WFU_UPLOAD_STATE5_SINGLEFILE", __("File uploaded successfully but there are warnings!", "wordpress-file-upload"));
134
- DEFINE("WFU_UPLOAD_STATE6", __("Some files failed to upload!", "wordpress-file-upload"));
135
- DEFINE("WFU_UPLOAD_STATE7", __("All files failed to upload", "wordpress-file-upload"));
136
- DEFINE("WFU_UPLOAD_STATE7_SINGLEFILE", __("File failed to upload", "wordpress-file-upload"));
137
- DEFINE("WFU_UPLOAD_STATE8", __("There are no files to upload!", "wordpress-file-upload"));
138
- DEFINE("WFU_UPLOAD_STATE9", __("Test upload message", "wordpress-file-upload"));
139
- DEFINE("WFU_UPLOAD_STATE10", __("JSON parse warning!", "wordpress-file-upload"));
140
- DEFINE("WFU_UPLOAD_STATE11", __("please wait while redirecting...", "wordpress-file-upload"));
141
- DEFINE("WFU_MAX_TIME_LIMIT", ini_get("max_input_time"));
142
- DEFINE("WFU_RESPONSE_URL", $siteurl.WPFILEUPLOAD_DIR."wfu_response.php");
143
- DEFINE("WFU_AJAX_URL", $siteurl."/wp-admin/admin-ajax.php");
144
-
145
- //define colors
146
- DEFINE("WFU_TESTMESSAGECOLORS", "#666666,#EEEEEE,#333333");
147
- DEFINE("WFU_DEFAULTMESSAGECOLORS", "#666666,#EEEEEE,#333333");
148
- DEFINE("WFU_HEADERMESSAGECOLORS_STATE0", "#666666,#EEEEEE,#333333");
149
- DEFINE("WFU_HEADERMESSAGECOLORS_STATE1", "#F88017,#FEF2E7,#633309");
150
- DEFINE("WFU_HEADERMESSAGECOLORS_STATE2", "#660000,#FFEEEE,#666600");
151
- DEFINE("WFU_HEADERMESSAGECOLORS_STATE3", "#660000,#FFEEEE,#666600");
152
- DEFINE("WFU_HEADERMESSAGECOLORS_STATE4", "#006600,#EEFFEE,#006666");
153
- DEFINE("WFU_HEADERMESSAGECOLORS_STATE5", "#F88017,#FEF2E7,#633309");
154
- DEFINE("WFU_HEADERMESSAGECOLORS_STATE6", "#660000,#FFEEEE,#666600");
155
- DEFINE("WFU_HEADERMESSAGECOLORS_STATE7", "#660000,#FFEEEE,#666600");
156
- DEFINE("WFU_HEADERMESSAGECOLORS_STATE8", "#660000,#FFEEEE,#666600");
157
- DEFINE("WFU_HEADERMESSAGECOLORS_STATE9", "#666666,#EEEEEE,#333333");
158
- DEFINE("WFU_HEADERMESSAGECOLORS_STATE10", "#F88017,#FEF2E7,#633309");
159
- DEFINE("WFU_HEADERMESSAGECOLORS_STATE11", "#666666,#EEEEEE,#333333");
160
-
161
- //define images
162
- DEFINE("WFU_IMAGE_ADMIN_HELP", $siteurl.WPFILEUPLOAD_DIR.'images/help_16.png');
163
- DEFINE("WFU_IMAGE_ADMIN_USERDATA_ADD", $siteurl.WPFILEUPLOAD_DIR.'images/add_12.png');
164
- DEFINE("WFU_IMAGE_ADMIN_USERDATA_REMOVE", $siteurl.WPFILEUPLOAD_DIR.'images/remove_12.png');
165
- DEFINE("WFU_IMAGE_SIMPLE_PROGBAR", $siteurl.WPFILEUPLOAD_DIR.'images/progbar.gif');
166
-
167
- function wfu_set_javascript_constants() {
168
- $consts = array(
169
- "nofilemessage" => WFU_ERROR_UPLOAD_NOFILESELECTED,
170
- "userdata_empty" => WFU_ERROR_USERDATA_EMPTY,
171
- "remoteserver_noresult" => WFU_ERROR_REMOTESERVER_NORESULT,
172
- "message_header" => WFU_ERRORMESSAGE,
173
- "message_failed" => WFU_ERROR_UPLOAD_FAILED_WHILE,
174
- "message_cancelled" => WFU_ERROR_UPLOAD_CANCELLED,
175
- "message_unknown" => WFU_ERROR_UNKNOWN,
176
- "adminmessage_unknown" => WFU_FAILMESSAGE_DETAILS,
177
- "message_timelimit" => WFU_ERROR_FILE_PHP_TIME,
178
- "message_admin_timelimit" => WFU_ERROR_ADMIN_FILE_PHP_TIME,
179
- "jsonparse_filemessage" => WFU_ERROR_JSONPARSE_FILEMESSAGE,
180
- "jsonparse_message" => WFU_ERROR_JSONPARSE_MESSAGE,
181
- "jsonparse_adminmessage" => WFU_ERROR_JSONPARSE_ADMINMESSAGE,
182
- "jsonparse_headermessage" => WFU_ERROR_JSONPARSE_HEADERMESSAGE,
183
- "jsonparse_headeradminmessage" => WFU_ERROR_JSONPARSE_HEADERADMINMESSAGE,
184
- "default_colors" => WFU_DEFAULTMESSAGECOLORS,
185
- "fail_colors" => WFU_FAILMESSAGECOLORS,
186
- "max_time_limit" => WFU_MAX_TIME_LIMIT,
187
- "response_url" => WFU_RESPONSE_URL,
188
- "ajax_url" => WFU_AJAX_URL
189
- );
190
- $consts_txt = "";
191
- foreach ( $consts as $key => $val )
192
- $consts_txt .= ( $consts_txt == "" ? "" : ";" ).wfu_plugin_encode_string($key).":".wfu_plugin_encode_string($val);
193
-
194
- return $consts_txt;
195
- }
196
-
197
- ?>
 
1
+ <?php
2
+
3
+ $siteurl = site_url();
4
+
5
+ //define plugin defaults
6
+ DEFINE("WFU_UPLOADID", "1");
7
+ DEFINE("WFU_UPLOADTITLE", __('Upload files', 'wordpress-file-upload'));
8
+ DEFINE("WFU_SELECTBUTTON", __('Select File', 'wordpress-file-upload'));
9
+ DEFINE("WFU_UPLOADBUTTON", __('Upload File', 'wordpress-file-upload'));
10
+ DEFINE("WFU_SINGLEBUTTON", "false");
11
+ DEFINE("WFU_UPLOADROLE", "administrator");
12
+ DEFINE("WFU_UPLOADPATH", 'uploads');
13
+ DEFINE("WFU_CREATEPATH", "false");
14
+ DEFINE("WFU_UPLOADPATTERNS", "*.*");
15
+ DEFINE("WFU_MAXSIZE", "50");
16
+ DEFINE("WFU_ACCESSMETHOD", "normal");
17
+ DEFINE("WFU_FTPINFO", "");
18
+ DEFINE("WFU_USEFTPDOMAIN", "false");
19
+ DEFINE("WFU_DUBLICATESPOLICY", "overwrite");
20
+ DEFINE("WFU_UNIQUEPATTERN", "index");
21
+ DEFINE("WFU_FILEBASELINK", "false");
22
+ DEFINE("WFU_NOTIFY", "false");
23
+ DEFINE("WFU_NOTIFYRECIPIENTS", "");
24
+ DEFINE("WFU_NOTIFYSUBJECT", __('File Upload Notification', 'wordpress-file-upload'));
25
+ DEFINE("WFU_NOTIFYMESSAGE", __("Dear Recipient,%n%%n% This is an automatic delivery message to notify you that a new file has been uploaded.%n%%n%Best Regards", 'wordpress-file-upload'));
26
+ DEFINE("WFU_NOTIFYHEADERS", "");
27
+ DEFINE("WFU_ATTACHFILE", "false");
28
+ DEFINE("WFU_REDIRECT", "false");
29
+ DEFINE("WFU_REDIRECTLINK", "");
30
+ DEFINE("WFU_ADMINMESSAGES", "false");
31
+ DEFINE("WFU_SUCCESSMESSAGE", __('File %filename% uploaded successfully', 'wordpress-file-upload'));
32
+ DEFINE("WFU_WARNINGMESSAGE", __('File %filename% uploaded successfully but with warnings', 'wordpress-file-upload'));
33
+ DEFINE("WFU_ERRORMESSAGE", __('File %filename% not uploaded', 'wordpress-file-upload'));
34
+ DEFINE("WFU_WAITMESSAGE", __('File %filename% is being uploaded', 'wordpress-file-upload'));
35
+ DEFINE("WFU_SUCCESSMESSAGECOLOR", "green");
36
+ DEFINE("WFU_SUCCESSMESSAGECOLORS", "#006600,#EEFFEE,#006666");
37
+ DEFINE("WFU_WARNINGMESSAGECOLORS", "#F88017,#FEF2E7,#633309");
38
+ DEFINE("WFU_FAILMESSAGECOLORS", "#660000,#FFEEEE,#666600");
39
+ DEFINE("WFU_WAITMESSAGECOLORS", "#666666,#EEEEEE,#333333");
40
+ DEFINE("WFU_SHOWTARGETFOLDER", "false");
41
+ DEFINE("WFU_TARGETFOLDERLABEL", "Upload Directory");
42
+ DEFINE("WFU_ASKFORSUBFOLDERS", "false");
43
+ DEFINE("WFU_SUBFOLDERTREE", "");
44
+ DEFINE("WFU_FORCECLASSIC", "false");
45
+ DEFINE("WFU_TESTMODE", "false");
46
+ DEFINE("WFU_DEBUGMODE", "false");
47
+ DEFINE("WFU_WIDTHS", "");
48
+ DEFINE("WFU_HEIGHTS", "");
49
+ DEFINE("WFU_PLACEMENTS", "title/filename+selectbutton+uploadbutton/subfolders"."/userdata"."/message");
50
+ DEFINE("WFU_USERDATA", "false");
51
+ DEFINE("WFU_USERDATALABEL", __('Your message', 'wordpress-file-upload'));
52
+ DEFINE("WFU_MEDIALINK", "false");
53
+
54
+ //define plugin errors
55
+ DEFINE("WFU_ERROR_ADMIN_FTPDIR_RESOLVE", __("Error. Could not resolve ftp target filedir. Check the domain in 'ftpinfo' attribute.", "wordpress-file-upload"));
56
+ DEFINE("WFU_ERROR_ADMIN_FTPINFO_INVALID", __("Error. Invalid ftp information. Check 'ftpinfo' attribute.", "wordpress-file-upload"));
57
+ DEFINE("WFU_ERROR_ADMIN_FTPINFO_EXTRACT", __("Error. Could not extract ftp information from 'ftpinfo' attribute. Check its syntax.", "wordpress-file-upload"));
58
+ DEFINE("WFU_ERROR_ADMIN_FTPFILE_RESOLVE", __("Error. Could not resolve ftp target filename. Check the domain in 'ftpinfo' attribute.", "wordpress-file-upload"));
59
+ DEFINE("WFU_ERROR_ADMIN_FILE_PHP_SIZE", __("Error. The upload size limit of PHP directive upload_max_filesize is preventing the upload of big files.\nPHP directive upload_max_filesize limit is: ".ini_get("upload_max_filesize").".\nTo increase the limit change the value of the directive from php.ini.\nIf you don't have access to php.ini, then try adding the following line to your .htaccess file:\n\nphp_value upload_max_filesize 10M\n\n(adjust the size according to your needs)\n\nThe file .htaccess is found in your website root directory (where index.php is found).\nIf your don't have this file, then create it.\nIf this does not work either, then contact your domain provider.", "wordpress-file-upload"));
60
+ DEFINE("WFU_ERROR_ADMIN_FILE_PHP_TIME", __("The upload time limit of PHP directive max_input_time is preventing the upload of big files.\nPHP directive max_input_time limit is: ".ini_get("max_input_time")." seconds.\nTo increase the limit change the value of the directive from php.ini.\nIf you don't have access to php.ini, then add the following line to your .htaccess file:\n\nphp_value max_input_time 500\n\n(adjust the time according to your needs)\n\nThe file .htaccess is found in your website root directory (where index.php is found).\nIf your don't have this file, then create it.\nIf this does not work either, then contact your domain provider.", "wordpress-file-upload"));
61
+ DEFINE("WFU_ERROR_ADMIN_DIR_PERMISSION", __("Error. Permission denied to write to target folder.\nCheck and correct read/write permissions of target folder.", "wordpress-file-upload"));
62
+ DEFINE("WFU_ERROR_DIR_EXIST", __("Targer folder doesn't exist.", "wordpress-file-upload"));
63
+ DEFINE("WFU_ERROR_DIR_NOTEMP", __("Upload failed! Missing a temporary folder.", "wordpress-file-upload"));
64
+ DEFINE("WFU_ERROR_DIR_PERMISSION", __("Upload failed! Permission denied to write to target folder.", "wordpress-file-upload"));
65
+ DEFINE("WFU_ERROR_FILE_ALLOW", __("File not allowed.", "wordpress-file-upload"));
66
+ DEFINE("WFU_ERROR_FILE_PLUGIN_SIZE", __("The uploaded file exceeds the file size limit.", "wordpress-file-upload"));
67
+ DEFINE("WFU_ERROR_FILE_PHP_SIZE", __("Upload failed! The uploaded file exceeds the file size limit of the server. Please contact the administrator.", "wordpress-file-upload"));
68
+ DEFINE("WFU_ERROR_FILE_PHP_TIME", __("Upload failed! The duration of the upload exceeded the time limit of the server. Please contact the administrator.", "wordpress-file-upload"));
69
+ DEFINE("WFU_ERROR_FILE_HTML_SIZE", __("Upload failed! The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.", "wordpress-file-upload"));
70
+ DEFINE("WFU_ERROR_FILE_PARTIAL", __("Upload failed! The uploaded file was only partially uploaded.", "wordpress-file-upload"));
71
+ DEFINE("WFU_ERROR_FILE_NOTHING", __("Upload failed! No file was uploaded.", "wordpress-file-upload"));
72
+ DEFINE("WFU_ERROR_FILE_WRITE", __("Upload failed! Failed to write file to disk.", "wordpress-file-upload"));
73
+ DEFINE("WFU_ERROR_FILE_MOVE", __("Upload failed! Error occured while moving temporary file. Please contact administrator.", "wordpress-file-upload"));
74
+ DEFINE("WFU_ERROR_UPLOAD_STOPPED", __("Upload failed! A PHP extension stopped the file upload. PHP does not provide a way to ascertain which extension caused the file upload to stop; examining the list of loaded extensions with phpinfo() may help.", "wordpress-file-upload"));
75
+ DEFINE("WFU_ERROR_UPLOAD_FAILED_WHILE", __("Upload failed! Error occured while attemting to upload the file.", "wordpress-file-upload"));
76
+ DEFINE("WFU_ERROR_UPLOAD_FAILED", __("Upload failed!", "wordpress-file-upload"));
77
+ DEFINE("WFU_ERROR_UPLOAD_NOFILESELECTED", __("No file!", "wordpress-file-upload"));
78
+ DEFINE("WFU_ERROR_UPLOAD_CANCELLED", __("Upload failed! The upload has been canceled by the user or the browser dropped the connection.", "wordpress-file-upload"));
79
+ DEFINE("WFU_ERROR_UNKNOWN", __("Upload failed! Unknown error.", "wordpress-file-upload"));
80
+ DEFINE("WFU_ERROR_CONTACT_ADMIN", __("Please contact the administrator.", "wordpress-file-upload"));
81
+ DEFINE("WFU_ERROR_REMOTESERVER_NORESULT", __("No result from remote server!", "wordpress-file-upload"));
82
+ DEFINE("WFU_ERROR_JSONPARSE_FILEMESSAGE", __(" but with warnings", "wordpress-file-upload"));
83
+ DEFINE("WFU_ERROR_JSONPARSE_MESSAGE", __("Warning: JSON parse error.", "wordpress-file-upload"));
84
+ DEFINE("WFU_ERROR_JSONPARSE_ADMINMESSAGE", __("Upload parameters of this file, passed as JSON string to the handler, could not be parsed.", "wordpress-file-upload"));
85
+ DEFINE("WFU_ERROR_JSONPARSE_HEADERMESSAGE", __("Warning: JSON parse error.", "wordpress-file-upload"));
86
+ DEFINE("WFU_ERROR_JSONPARSE_HEADERADMINMESSAGE", __("UploadStates, passed as JSON string to the handler, could not be parsed.", "wordpress-file-upload"));
87
+ DEFINE("WFU_ERROR_REDIRECTION_ERRORCODE0", __("Redirection to classic form functionality occurred due to unknown error.", "wordpress-file-upload"));
88
+ DEFINE("WFU_ERROR_REDIRECTION_ERRORCODE1", __("Redirection to classic form functionality occurred because AJAX is not supported.", "wordpress-file-upload"));
89
+ DEFINE("WFU_ERROR_REDIRECTION_ERRORCODE2", __("Redirection to classic form functionality occurred because HTML5 is not supported.", "wordpress-file-upload"));
90
+ DEFINE("WFU_ERROR_REDIRECTION_ERRORCODE3", __("Redirection to classic form functionality occurred due to JSON parse error.", "wordpress-file-upload"));
91
+ DEFINE("WFU_ERROR_USERDATA_EMPTY", __("cannot be empty!", "wordpress-file-upload"));
92
+
93
+ //define plugin warnings
94
+ DEFINE("WFU_WARNING_FILE_EXISTS", __("Upload skipped! File already exists.", "wordpress-file-upload"));
95
+ DEFINE("WFU_WARNING_NOFILES_SELECTED", __("No files have been selected!", "wordpress-file-upload"));
96
+ DEFINE("WFU_WARNING_WPFILEBASE_NOTUPDATED_NOFILES", __("WPFilebase Plugin not updated because there were no files uploaded.", "wordpress-file-upload"));
97
+ DEFINE("WFU_WARNING_NOTIFY_NOTSENT_NOFILES", __("Notification email was not sent because there were no files uploaded.", "wordpress-file-upload"));
98
+ DEFINE("WFU_WARNING_NOTIFY_NOTSENT_NORECIPIENTS", __("Notification email was not sent because no recipients were defined. Please check notifyrecipients attribute in the shortcode.", "wordpress-file-upload"));
99
+ DEFINE("WFU_WARNING_NOTIFY_NOTSENT_UNKNOWNERROR", __("Notification email was not sent due to an error. Please check notifyrecipients, notifysubject and notifymessage attributes for errors.", "wordpress-file-upload"));
100
+ DEFINE("WFU_WARNING_REDIRECT_NOTEXECUTED_EMPTY", __("Redirection not executed because redirection link is empty. Please check redirectlink attribute.", "wordpress-file-upload"));
101
+ DEFINE("WFU_WARNING_REDIRECT_NOTEXECUTED_FILESFAILED", __("Redirection not executed because not all files were successfully uploaded.", "wordpress-file-upload"));
102
+
103
+ //define plugin messages
104
+ DEFINE("WFU_NOTIFY_TESTMODE", __("Test Mode", "wordpress-file-upload"));
105
+ DEFINE("WFU_SUCCESSMESSAGE_DETAILS", __('Upload path: %filepath%', 'wordpress-file-upload'));
106
+ DEFINE("WFU_FAILMESSAGE_DETAILS", __('Failed upload path: %filepath%', 'wordpress-file-upload'));
107
+
108
+ //define plugin test messages
109
+ DEFINE("WFU_TESTMESSAGE_MESSAGE", __('This is a test message', 'wordpress-file-upload'));
110
+ DEFINE("WFU_TESTMESSAGE_ADMINMESSAGE", __('This is a test administrator message', 'wordpress-file-upload'));
111
+ DEFINE("WFU_TESTMESSAGE_FILE1_HEADER", __('File testfile 1 under test', 'wordpress-file-upload'));
112
+ DEFINE("WFU_TESTMESSAGE_FILE1_MESSAGE", __('File testfile 1 message', 'wordpress-file-upload'));
113
+ DEFINE("WFU_TESTMESSAGE_FILE1_ADMINMESSAGE", __('File testfile 1 administrator message', 'wordpress-file-upload'));
114
+ DEFINE("WFU_TESTMESSAGE_FILE2_HEADER", __('File testfile 2 under test', 'wordpress-file-upload'));
115
+ DEFINE("WFU_TESTMESSAGE_FILE2_MESSAGE", __('File testfile 2 message', 'wordpress-file-upload'));
116
+ DEFINE("WFU_TESTMESSAGE_FILE2_ADMINMESSAGE", __('File testfile 2 administrator message', 'wordpress-file-upload'));
117
+
118
+ //define tool tip constants
119
+ DEFINE("WFU_VARIABLE_TITLE_USERNAME", __("Insert variable %username% inside text. It will be replaced by the username of the current user.", "wordpress-file-upload"));
120
+ DEFINE("WFU_VARIABLE_TITLE_USEREMAIL", __("Insert variable %useremail% inside text. It will be replaced by the email of the current user.", "wordpress-file-upload"));
121
+ DEFINE("WFU_VARIABLE_TITLE_FILENAME", __("Insert variable %filename% inside text. It will be replaced by the filename of the uploaded file.", "wordpress-file-upload"));
122
+ DEFINE("WFU_VARIABLE_TITLE_FILEPATH", __("Insert variable %filepath% inside text. It will be replaced by the full filepath of the uploaded file.", "wordpress-file-upload"));
123
+ DEFINE("WFU_VARIABLE_TITLE_BLOGID", __("Insert variable %blogid% inside text. It will be replaced by the blog id of the website.", "wordpress-file-upload"));
124
+ DEFINE("WFU_VARIABLE_TITLE_USERDATAXXX", __("Insert variable %userdataXXX% inside text. Select the user field from the drop-down list. It will be replaced by the value that the user entered in this field.", "wordpress-file-upload"));
125
+ DEFINE("WFU_VARIABLE_TITLE_N", __("Insert variable %n% inside text to denote a line change.", "wordpress-file-upload"));
126
+
127
+ //define plugin other constants
128
+ DEFINE("WFU_UPLOAD_STATE0", __("Upload in progress", "wordpress-file-upload"));
129
+ DEFINE("WFU_UPLOAD_STATE1", __("Upload in progress with warnings!", "wordpress-file-upload"));
130
+ DEFINE("WFU_UPLOAD_STATE2", __("Upload in progress but some files already failed!", "wordpress-file-upload"));
131
+ DEFINE("WFU_UPLOAD_STATE3", __("Upload in progress but no files uploaded so far!", "wordpress-file-upload"));
132
+ DEFINE("WFU_UPLOAD_STATE4", __("All files uploaded successfully", "wordpress-file-upload"));
133
+ DEFINE("WFU_UPLOAD_STATE5", __("All files uploaded successfully but there are warnings!", "wordpress-file-upload"));
134
+ DEFINE("WFU_UPLOAD_STATE5_SINGLEFILE", __("File uploaded successfully but there are warnings!", "wordpress-file-upload"));
135
+ DEFINE("WFU_UPLOAD_STATE6", __("Some files failed to upload!", "wordpress-file-upload"));
136
+ DEFINE("WFU_UPLOAD_STATE7", __("All files failed to upload", "wordpress-file-upload"));
137
+ DEFINE("WFU_UPLOAD_STATE7_SINGLEFILE", __("File failed to upload", "wordpress-file-upload"));
138
+ DEFINE("WFU_UPLOAD_STATE8", __("There are no files to upload!", "wordpress-file-upload"));
139
+ DEFINE("WFU_UPLOAD_STATE9", __("Test upload message", "wordpress-file-upload"));
140
+ DEFINE("WFU_UPLOAD_STATE10", __("JSON parse warning!", "wordpress-file-upload"));
141
+ DEFINE("WFU_UPLOAD_STATE11", __("please wait while redirecting...", "wordpress-file-upload"));
142
+ DEFINE("WFU_MAX_TIME_LIMIT", ini_get("max_input_time"));
143
+ DEFINE("WFU_RESPONSE_URL", $siteurl.WPFILEUPLOAD_DIR."wfu_response.php");
144
+ DEFINE("WFU_AJAX_URL", $siteurl."/wp-admin/admin-ajax.php");
145
+
146
+ //define colors
147
+ DEFINE("WFU_TESTMESSAGECOLORS", "#666666,#EEEEEE,#333333");
148
+ DEFINE("WFU_DEFAULTMESSAGECOLORS", "#666666,#EEEEEE,#333333");
149
+ DEFINE("WFU_HEADERMESSAGECOLORS_STATE0", "#666666,#EEEEEE,#333333");
150
+ DEFINE("WFU_HEADERMESSAGECOLORS_STATE1", "#F88017,#FEF2E7,#633309");
151
+ DEFINE("WFU_HEADERMESSAGECOLORS_STATE2", "#660000,#FFEEEE,#666600");
152
+ DEFINE("WFU_HEADERMESSAGECOLORS_STATE3", "#660000,#FFEEEE,#666600");
153
+ DEFINE("WFU_HEADERMESSAGECOLORS_STATE4", "#006600,#EEFFEE,#006666");
154
+ DEFINE("WFU_HEADERMESSAGECOLORS_STATE5", "#F88017,#FEF2E7,#633309");
155
+ DEFINE("WFU_HEADERMESSAGECOLORS_STATE6", "#660000,#FFEEEE,#666600");
156
+ DEFINE("WFU_HEADERMESSAGECOLORS_STATE7", "#660000,#FFEEEE,#666600");
157
+ DEFINE("WFU_HEADERMESSAGECOLORS_STATE8", "#660000,#FFEEEE,#666600");
158
+ DEFINE("WFU_HEADERMESSAGECOLORS_STATE9", "#666666,#EEEEEE,#333333");
159
+ DEFINE("WFU_HEADERMESSAGECOLORS_STATE10", "#F88017,#FEF2E7,#633309");
160
+ DEFINE("WFU_HEADERMESSAGECOLORS_STATE11", "#666666,#EEEEEE,#333333");
161
+
162
+ //define images
163
+ DEFINE("WFU_IMAGE_ADMIN_HELP", $siteurl.WPFILEUPLOAD_DIR.'images/help_16.png');
164
+ DEFINE("WFU_IMAGE_ADMIN_USERDATA_ADD", $siteurl.WPFILEUPLOAD_DIR.'images/add_12.png');
165
+ DEFINE("WFU_IMAGE_ADMIN_USERDATA_REMOVE", $siteurl.WPFILEUPLOAD_DIR.'images/remove_12.png');
166
+ DEFINE("WFU_IMAGE_SIMPLE_PROGBAR", $siteurl.WPFILEUPLOAD_DIR.'images/progbar.gif');
167
+
168
+ function wfu_set_javascript_constants() {
169
+ $consts = array(
170
+ "nofilemessage" => WFU_ERROR_UPLOAD_NOFILESELECTED,
171
+ "userdata_empty" => WFU_ERROR_USERDATA_EMPTY,
172
+ "remoteserver_noresult" => WFU_ERROR_REMOTESERVER_NORESULT,
173
+ "message_header" => WFU_ERRORMESSAGE,
174
+ "message_failed" => WFU_ERROR_UPLOAD_FAILED_WHILE,
175
+ "message_cancelled" => WFU_ERROR_UPLOAD_CANCELLED,
176
+ "message_unknown" => WFU_ERROR_UNKNOWN,
177
+ "adminmessage_unknown" => WFU_FAILMESSAGE_DETAILS,
178
+ "message_timelimit" => WFU_ERROR_FILE_PHP_TIME,
179
+ "message_admin_timelimit" => WFU_ERROR_ADMIN_FILE_PHP_TIME,
180
+ "jsonparse_filemessage" => WFU_ERROR_JSONPARSE_FILEMESSAGE,
181
+ "jsonparse_message" => WFU_ERROR_JSONPARSE_MESSAGE,
182
+ "jsonparse_adminmessage" => WFU_ERROR_JSONPARSE_ADMINMESSAGE,
183
+ "jsonparse_headermessage" => WFU_ERROR_JSONPARSE_HEADERMESSAGE,
184
+ "jsonparse_headeradminmessage" => WFU_ERROR_JSONPARSE_HEADERADMINMESSAGE,
185
+ "default_colors" => WFU_DEFAULTMESSAGECOLORS,
186
+ "fail_colors" => WFU_FAILMESSAGECOLORS,
187
+ "max_time_limit" => WFU_MAX_TIME_LIMIT,
188
+ "response_url" => WFU_RESPONSE_URL,
189
+ "ajax_url" => WFU_AJAX_URL
190
+ );
191
+ $consts_txt = "";
192
+ foreach ( $consts as $key => $val )
193
+ $consts_txt .= ( $consts_txt == "" ? "" : ";" ).wfu_plugin_encode_string($key).":".wfu_plugin_encode_string($val);
194
+
195
+ return $consts_txt;
196
+ }
197
+
198
+ ?>
lib/wfu_functions.php CHANGED
@@ -1,350 +1,521 @@
1
- <?php
2
-
3
- //********************* String Functions *******************************************************************************************************
4
-
5
- function wfu_upload_plugin_clean($label) {
6
- /**
7
- * Regular expressions to change some characters.
8
- */
9
-
10
- $search = array ('@[eeeeEE]@i','@[aaaAA]@i','@[iiII]@i','@[uuuUU]@i','@[ooOO]@i',
11
- '@[c]@i','@[^a-zA-Z0-9._]@');
12
- $replace = array ('e','a','i','u','o','c','-');
13
- $label = preg_replace($search, $replace, $label);
14
- $label = strtolower($label); // Convert in lower case
15
- return $label;
16
- }
17
-
18
- function wfu_upload_plugin_wildcard_to_preg($pattern) {
19
- return '/^' . str_replace(array('\*', '\?', '\[', '\]'), array('.*', '.', '[', ']+'), preg_quote($pattern)) . '$/is';
20
- }
21
-
22
- function wfu_upload_plugin_wildcard_match($pattern, $str) {
23
- $pattern = wfu_upload_plugin_wildcard_to_preg($pattern);
24
- return preg_match($pattern, $str);
25
- }
26
-
27
- function wfu_plugin_encode_string($string) {
28
- $array = unpack('C*', $string);
29
- $new_string = "";
30
- for ($i = 1; $i <= count($array); $i ++) {
31
- $new_string .= sprintf("%02X", $array[$i]);
32
- }
33
- return $new_string;
34
- }
35
-
36
- function wfu_plugin_decode_string($string) {
37
- $new_string = "";
38
- for ($i = 0; $i < strlen($string); $i += 2 ) {
39
- $new_string .= sprintf("%c", hexdec(substr($string, $i ,2)));
40
- }
41
- return $new_string;
42
- }
43
-
44
- function wfu_create_random_string($len) {
45
- $base = 'ABCDEFGHKLMNOPQRSTWXYZabcdefghjkmnpqrstwxyz123456789';
46
- $max = strlen($base) - 1;
47
- $activatecode = '';
48
- mt_srand((double)microtime()*1000000);
49
- while (strlen($activatecode) < $len)
50
- $activatecode .= $base{mt_rand(0, $max)};
51
- return $activatecode;
52
- }
53
-
54
- function wfu_join_strings($delimeter) {
55
- $arr = func_get_args();
56
- unset($arr[0]);
57
- foreach ($arr as $key => $item)
58
- if ( $item == "" ) unset($arr[$key]);
59
- return join($delimeter, $arr);
60
- }
61
-
62
- function wfu_create_string($size) {
63
- $piece = str_repeat("0", 1024);
64
- $str = "";
65
- $reps = $size / 1024;
66
- $rem = $size - 1024 * $reps;
67
- for ( $i = 0; $i < $reps; $i++ ) $str .= $piece;
68
- $str .= substr($piece, 0, $rem);
69
- return $str;
70
- }
71
-
72
- //********************* Array Functions *****************************************************************************************************
73
-
74
- function wfu_encode_array_to_string($arr) {
75
- $arr_str = json_encode($arr);
76
- $arr_str = wfu_plugin_encode_string($arr_str);
77
- return $arr_str;
78
- }
79
-
80
- function wfu_decode_array_from_string($arr_str) {
81
- $arr_str = wfu_plugin_decode_string($arr_str);
82
- $arr = json_decode($arr_str, true);
83
- return $arr;
84
- }
85
-
86
- function wfu_plugin_parse_array($source) {
87
- $keys = array_keys($source);
88
- $new_arr = array();
89
- for ($i = 0; $i < count($keys); $i ++)
90
- $new_arr[$keys[$i]] = wp_specialchars_decode($source[$keys[$i]]);
91
- return $new_arr;
92
- }
93
-
94
- function wfu_array_remove_nulls(&$arr) {
95
- foreach ( $arr as $key => $arri )
96
- if ( $arri == null )
97
- array_splice($arr, $key, 1);
98
- }
99
-
100
- function wfu_shortcode_string_to_array($shortcode) {
101
- $arr = explode(" ", $shortcode);
102
- $attrs = array();
103
- foreach ( $arr as $attr ) {
104
- if ( trim($attr) != "" ) {
105
- $attr_arr = explode("=", $attr, 2);
106
- $key = "";
107
- if ( count($attr_arr) > 0 ) $key = $attr_arr[0];
108
- $val = "";
109
- if ( count($attr_arr) > 1 ) $val = $attr_arr[1];
110
- if ( trim($key) != "" ) $attrs[trim($key)] = str_replace('"', '', $val);
111
- }
112
- }
113
- $i=0;
114
- $m=array();
115
- $mm = preg_replace_callback('/"([^"]*)"/', function ($matches) use(&$i, &$m) {array_push($m, $matches[1]); return "attr".$i++;}, $shortcode);
116
- return $attrs;
117
- }
118
-
119
- //********************* Plugin Options Functions ************************************************************************************************
120
-
121
- function wfu_encode_plugin_options($plugin_options) {
122
- $encoded_options = 'version='.$plugin_options['version'].';';
123
- $encoded_options .= 'shortcode='.wfu_plugin_encode_string($plugin_options['shortcode']);
124
- return $encoded_options;
125
- }
126
-
127
- function wfu_decode_plugin_options($encoded_options) {
128
- $decoded_array = explode(';', $encoded_options);
129
- $plugin_options = array();
130
- foreach ($decoded_array as $decoded_item) {
131
- list($item_key, $item_value) = explode("=", $decoded_item, 2);
132
- if ( $item_key == 'shortcode' )
133
- $plugin_options[$item_key] = wfu_plugin_decode_string($item_value);
134
- else
135
- $plugin_options[$item_key] = $item_value;
136
-
137
- }
138
- return $plugin_options;
139
- }
140
-
141
- //********************* Directory Functions ************************************************************************************************
142
-
143
- function wfu_upload_plugin_full_path( $params ) {
144
- $path = $params["uploadpath"];
145
- if ( $params["accessmethod"]=='ftp' && $params["ftpinfo"] != '' && $params["useftpdomain"] == "true" ) {
146
- $ftpdata_flat = str_replace(array('\:', '\@'), array('\_', '\_'), $params["ftpinfo"]);
147
- $pos1 = strpos($ftpdata_flat, ":");
148
- $pos2 = strpos($ftpdata_flat, "@");
149
- if ( $pos1 && $pos2 && $pos2 > $pos1 ) {
150
- $ftp_username = substr($params["ftpinfo"], 0, $pos1);
151
- $ftp_password = substr($params["ftpinfo"], $pos1 + 1, $pos2 - $pos1 - 1);
152
- $ftp_host = substr($params["ftpinfo"], $pos2 + 1);
153
- $ftp_username = str_replace('@', '%40', $ftp_username); //if username contains @ character then convert it to %40
154
- $ftp_password = str_replace('@', '%40', $ftp_password); //if password contains @ character then convert it to %40
155
- $start_folder = 'ftp://'.$ftp_username.':'.$ftp_password."@".$ftp_host.'/';
156
- }
157
- else $start_folder = 'ftp://'.$params["ftpinfo"].'/';
158
- }
159
- else $start_folder = WP_CONTENT_DIR.'/';
160
- if ($path) {
161
- if ( $path == ".." || substr($path, 0, 3) == "../" ) {
162
- $start_folder = ABSPATH;
163
- $path = substr($path, 2, strlen($path) - 2);
164
- }
165
- if ( substr($path, 0, 1) == "/" ) $path = substr($path, 1, strlen($path) - 1);
166
- if ( substr($path, -1, 1) == "/" ) $path = substr($path, 0, strlen($path) - 1);
167
- $full_upload_path = $start_folder;
168
- if ( $path != "" ) $full_upload_path .= $path.'/';
169
- }
170
- else {
171
- $full_upload_path = $start_folder;
172
- }
173
- return $full_upload_path;
174
- }
175
-
176
- function wfu_upload_plugin_directory( $path ) {
177
- $dirparts = explode("/", $path);
178
- return $dirparts[count($dirparts) - 1];
179
- }
180
-
181
- //********************* User Functions *********************************************************************************************************
182
-
183
- function wfu_get_user_role($user, $param_roles) {
184
- if ( !empty( $user->roles ) && is_array( $user->roles ) ) {
185
- /* Go through the array of the roles of the current user */
186
- foreach ( $user->roles as $user_role ) {
187
- $user_role = strtolower($user_role);
188
- /* If one role of the current user matches to the roles allowed to upload */
189
- if ( in_array($user_role, $param_roles) || $user_role == 'administrator' ) {
190
- /* We affect this role to current user */
191
- $result_role = $user_role;
192
- break;
193
- }
194
- else {
195
- /* We affect the 'visitor' role to current user */
196
- $result_role = 'visitor';
197
- }
198
- }
199
- }
200
- else {
201
- $result_role = 'visitor';
202
- }
203
- return $result_role;
204
- }
205
-
206
- //********************* Shortcode Options Functions ************************************************************************************************
207
-
208
- function wfu_generate_current_params_index($shortcode_id, $user_login) {
209
- global $post;
210
- $cur_index_str = '||'.$post->ID.'||'.$shortcode_id.'||'.$user_login;
211
- $cur_index_str_search = '\|\|'.$post->ID.'\|\|'.$shortcode_id.'\|\|'.$user_login;
212
- $index_str = get_option('wfu_params_index');
213
- $index = explode("&&", $index_str);
214
- foreach ($index as $key => $value) if ($value == "") unset($index[$key]);
215
- $index_match = preg_grep("/".$cur_index_str_search."$/", $index);
216
- if ( count($index_match) == 1 )
217
- foreach ( $index_match as $key => $value )
218
- if ( $value == "" ) unset($index_match[$key]);
219
- if ( count($index_match) <= 0 ) {
220
- $cur_index_rand = wfu_create_random_string(16);
221
- array_push($index, $cur_index_rand.$cur_index_str);
222
- }
223
- else {
224
- reset($index_match);
225
- $cur_index_rand = substr(current($index_match), 0, 16);
226
- if ( count($index_match) > 1 ) {
227
- $index_match_keys = array_keys($index_match);
228
- for ($i = 1; $i < count($index_match); $i++) {
229
- $ii = $index_match_keys[$i];
230
- unset($index[array_search($index_match[$ii], $index, true)]);
231
- }
232
- }
233
- }
234
- if ( count($index_match) != 1 ) {
235
- $index_str = implode("&&", $index);
236
- update_option('wfu_params_index', $index_str);
237
- }
238
- return $cur_index_rand;
239
- }
240
-
241
- function wfu_get_params_fields_from_index($params_index) {
242
- $fields = array();
243
- $index_str = get_option('wfu_params_index');
244
- $index = explode("&&", $index_str);
245
- $index_match = preg_grep("/^".$params_index."/", $index);
246
- if ( count($index_match) == 1 )
247
- foreach ( $index_match as $key => $value )
248
- if ( $value == "" ) unset($index_match[$key]);
249
- if ( count($index_match) > 0 ) {
250
- reset($index_match);
251
- list($fields['unique_id'], $fields['page_id'], $fields['shortcode_id'], $fields['user_login']) = explode("||", current($index_match));
252
- }
253
- return $fields;
254
- }
255
-
256
- function wfu_decode_dimensions($dimensions_str) {
257
- $components = wfu_component_definitions();
258
- $dimensions = array();
259
- foreach ( $components as $comp ) {
260
- if ( $comp['dimensions'] == null ) $dimensions[$comp['id']] = "";
261
- else foreach ( $comp['dimensions'] as $dimraw ) {
262
- list($dim_id, $dim_name) = explode("/", $dimraw);
263
- $dimensions[$dim_id] = "";
264
- }
265
- }
266
- $dimensions_raw = explode(",", $dimensions_str);
267
- foreach ( $dimensions_raw as $dimension_str ) {
268
- $dimension_raw = explode(":", $dimension_str);
269
- $item = strtolower(trim($dimension_raw[0]));
270
- foreach ( array_keys($dimensions) as $key ) {
271
- if ( $item == $key ) $dimensions[$key] = trim($dimension_raw[1]);
272
- }
273
- }
274
- return $dimensions;
275
- }
276
-
277
- //********************* Plugin Design Functions *********************************************************************************************************
278
-
279
- function wfu_add_div() {
280
- $items_count = func_num_args();
281
- if ( $items_count == 0 ) return "";
282
- $items_raw = func_get_args();
283
- $items = array( );
284
- foreach ( $items_raw as $item_raw ) {
285
- if ( is_array($item_raw) ) array_push($items, $item_raw);
286
- }
287
- $items_count = count($items);
288
- if ( $items_count == 0 ) return "";
289
- $div = "";
290
- $div .= "\n\t".'<div class="file_div_clean">';
291
- $div .= "\n\t\t".'<table class="file_table_clean">';
292
- $div .= "\n\t\t\t".'<tbody>';
293
- $div .= "\n\t\t\t\t".'<tr>';
294
- for ( $i = 0; $i < $items_count; $i++ ) {
295
- $div .= "\n\t\t\t\t\t".'<td class="file_td_clean"';
296
- if ( $i < $items_count - 1 ) $div .= ' style="padding: 0 4px 0 0"';
297
- $div .= '>';
298
- $div .= "\n\t\t\t\t\t\t".'<div id="'.$items[$i]["title"].'" class="file_div_clean"';
299
- if ( $items[$i]["hidden"] ) $div .= ' style="display: none"';
300
- $div .= '>';
301
- $item_lines_count = count($items[$i]) - 2;
302
- for ( $k = 1; $k <= $item_lines_count; $k++ ) {
303
- if ( $items[$i]["line".$k] != "" ) $div .= "\n\t\t\t\t\t\t\t".$items[$i]["line".$k];
304
- }
305
- $div .= "\n\t\t\t\t\t\t\t".'<div class="file_space_clean" />';
306
- $div .= "\n\t\t\t\t\t\t".'</div>';
307
- $div .= "\n\t\t\t\t\t".'</td>';
308
- }
309
- $div .= "\n\t\t\t\t".'</tr>';
310
- $div .= "\n\t\t\t".'</tbody>';
311
- $div .= "\n\t\t".'</table>';
312
- $div .= "\n\t".'</div>';
313
- return $div;
314
- }
315
-
316
- //********************* Email Functions **************************************************************************************************************
317
-
318
- function wfu_send_notification_email($user, $only_filename_list, $target_path_list, $attachment_list, $userdata_fields, $params) {
319
- if ( 0 == $user->ID ) {
320
- $user_login = "guest";
321
- $user_email = "";
322
- }
323
- else {
324
- $user_login = $user->user_login;
325
- $user_email = $user->user_email;
326
- }
327
- $notifyrecipients = trim(preg_replace('/%useremail%/', $user_email, $params["notifyrecipients"]));
328
- $search = array ('/%n%/');
329
- $replace = array ("\n");
330
- $notifyheaders = preg_replace($search, $replace, $params["notifyheaders"]);
331
- $search = array ('/%username%/', '/%useremail%/', '/%filename%/', '/%filepath%/', '/%n%/');
332
- $replace = array ($user_login, ( $user_email == "" ? "no email" : $user_email ), $only_filename_list, $target_path_list, "\n");
333
- foreach ( $userdata_fields as $userdata_key => $userdata_field ) {
334
- $ind = 1 + $userdata_key;
335
- array_push($search, '/%userdata'.$ind.'%/');
336
- array_push($replace, $userdata_field["value"]);
337
- }
338
- $notifysubject = preg_replace($search, $replace, $params["notifysubject"]);
339
- $notifymessage = preg_replace($search, $replace, $params["notifymessage"]);
340
- if ( $params["attachfile"] == "true" ) {
341
- $attachments = explode(",", $attachment_list);
342
- $notify_sent = wp_mail($notifyrecipients, $notifysubject, $notifymessage, $notifyheaders, $attachments);
343
- }
344
- else {
345
- $notify_sent = wp_mail($notifyrecipients, $notifysubject, $notifymessage, $notifyheaders);
346
- }
347
- return ( $notify_sent ? "" : WFU_WARNING_NOTIFY_NOTSENT_UNKNOWNERROR );
348
- }
349
-
350
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ //********************* String Functions *******************************************************************************************************
4
+
5
+ function wfu_upload_plugin_clean($label) {
6
+ /**
7
+ * Regular expressions to change some characters.
8
+ */
9
+
10
+ $search = array ('@[eeeeEE]@i','@[aaaAA]@i','@[iiII]@i','@[uuuUU]@i','@[ooOO]@i',
11
+ '@[c]@i','@[^a-zA-Z0-9._]@');
12
+ $replace = array ('e','a','i','u','o','c','-');
13
+ $label = preg_replace($search, $replace, $label);
14
+ $label = strtolower($label); // Convert in lower case
15
+ return $label;
16
+ }
17
+
18
+ function wfu_upload_plugin_wildcard_to_preg($pattern) {
19
+ return '/^' . str_replace(array('\*', '\?', '\[', '\]'), array('.*', '.', '[', ']+'), preg_quote($pattern)) . '$/is';
20
+ }
21
+
22
+ function wfu_upload_plugin_wildcard_match($pattern, $str) {
23
+ $pattern = wfu_upload_plugin_wildcard_to_preg($pattern);
24
+ return preg_match($pattern, $str);
25
+ }
26
+
27
+ function wfu_plugin_encode_string($string) {
28
+ $array = unpack('C*', $string);
29
+ $new_string = "";
30
+ for ($i = 1; $i <= count($array); $i ++) {
31
+ $new_string .= sprintf("%02X", $array[$i]);
32
+ }
33
+ return $new_string;
34
+ }
35
+
36
+ function wfu_plugin_decode_string($string) {
37
+ $new_string = "";
38
+ for ($i = 0; $i < strlen($string); $i += 2 ) {
39
+ $new_string .= sprintf("%c", hexdec(substr($string, $i ,2)));
40
+ }
41
+ return $new_string;
42
+ }
43
+
44
+ function wfu_create_random_string($len) {
45
+ $base = 'ABCDEFGHKLMNOPQRSTWXYZabcdefghjkmnpqrstwxyz123456789';
46
+ $max = strlen($base) - 1;
47
+ $activatecode = '';
48
+ mt_srand((double)microtime()*1000000);
49
+ while (strlen($activatecode) < $len)
50
+ $activatecode .= $base{mt_rand(0, $max)};
51
+ return $activatecode;
52
+ }
53
+
54
+ function wfu_join_strings($delimeter) {
55
+ $arr = func_get_args();
56
+ unset($arr[0]);
57
+ foreach ($arr as $key => $item)
58
+ if ( $item == "" ) unset($arr[$key]);
59
+ return join($delimeter, $arr);
60
+ }
61
+
62
+ function wfu_create_string($size) {
63
+ $piece = str_repeat("0", 1024);
64
+ $str = "";
65
+ $reps = $size / 1024;
66
+ $rem = $size - 1024 * $reps;
67
+ for ( $i = 0; $i < $reps; $i++ ) $str .= $piece;
68
+ $str .= substr($piece, 0, $rem);
69
+ return $str;
70
+ }
71
+
72
+ //********************* Array Functions *****************************************************************************************************
73
+
74
+ function wfu_encode_array_to_string($arr) {
75
+ $arr_str = json_encode($arr);
76
+ $arr_str = wfu_plugin_encode_string($arr_str);
77
+ return $arr_str;
78
+ }
79
+
80
+ function wfu_decode_array_from_string($arr_str) {
81
+ $arr_str = wfu_plugin_decode_string($arr_str);
82
+ $arr = json_decode($arr_str, true);
83
+ return $arr;
84
+ }
85
+
86
+ function wfu_plugin_parse_array($source) {
87
+ $keys = array_keys($source);
88
+ $new_arr = array();
89
+ for ($i = 0; $i < count($keys); $i ++)
90
+ $new_arr[$keys[$i]] = wp_specialchars_decode($source[$keys[$i]]);
91
+ return $new_arr;
92
+ }
93
+
94
+ function wfu_array_remove_nulls(&$arr) {
95
+ foreach ( $arr as $key => $arri )
96
+ if ( $arri == null )
97
+ array_splice($arr, $key, 1);
98
+ }
99
+
100
+ function wfu_shortcode_string_to_array($shortcode) {
101
+ function _wfu_preg_replace_callback_alt($contents, $token) {
102
+ $in_block = false;
103
+ $prev_pos = 0;
104
+ $new_contents = '';
105
+ $ret['items'] = array();
106
+ $ret['tokens'] = array();
107
+ $ii = 0;
108
+ while ( ($pos = strpos($contents, '"', $prev_pos)) !== false ) {
109
+ if ( !$in_block ) {
110
+ $new_contents .= substr($contents, $prev_pos, $pos - $prev_pos + 1);
111
+ $in_block = true;
112
+ }
113
+ else {
114
+ $ret['items'][$ii] = substr($contents, $prev_pos, $pos - $prev_pos);
115
+ $ret['tokens'][$ii] = $token.$ii;
116
+ $new_contents .= $token.$ii.'"';
117
+ $ii ++;
118
+ $in_block = false;
119
+ }
120
+ $prev_pos = $pos + 1;
121
+ }
122
+ if ( $in_block ) {
123
+ $ret['items'][$ii] = substr($contents, $prev_pos);
124
+ $ret['tokens'][$ii] = $token.$ii;
125
+ $new_contents .= $token.$ii.'"';
126
+ }
127
+ else
128
+ $new_contents .= substr($contents, $prev_pos);
129
+ $ret['contents'] = $new_contents;
130
+ return $ret;
131
+ }
132
+
133
+ $i = 0;
134
+ $m1 = array();
135
+ $m2 = array();
136
+ //for some reason preg_replace_callback does not work in all cases, so it has been replaced by a similar custom inline routine
137
+ // $mm = preg_replace_callback('/"([^"]*)"/', function ($matches) use(&$i, &$m1, &$m2) {array_push($m1, $matches[1]); array_push($m2, "attr".$i); return "attr".$i++;}, $shortcode);
138
+ $ret = _wfu_preg_replace_callback_alt($shortcode, "attr");
139
+ $mm = $ret['contents'];
140
+ $m1 = $ret['items'];
141
+ $m2 = $ret['tokens'];
142
+ $arr = explode(" ", $mm);
143
+ $attrs = array();
144
+ foreach ( $arr as $attr ) {
145
+ if ( trim($attr) != "" ) {
146
+ $attr_arr = explode("=", $attr, 2);
147
+ $key = "";
148
+ if ( count($attr_arr) > 0 ) $key = $attr_arr[0];
149
+ $val = "";
150
+ if ( count($attr_arr) > 1 ) $val = $attr_arr[1];
151
+ if ( trim($key) != "" ) $attrs[trim($key)] = str_replace('"', '', $val);
152
+ }
153
+ }
154
+ $attrs2 = str_replace($m2, $m1, $attrs);
155
+ return $attrs2;
156
+ }
157
+
158
+ function wfu_array_sort($array, $on, $order=SORT_ASC) {
159
+ $new_array = array();
160
+ $sortable_array = array();
161
+
162
+ if (count($array) > 0) {
163
+ foreach ($array as $k => $v) {
164
+ if (is_array($v)) {
165
+ foreach ($v as $k2 => $v2) {
166
+ if ($k2 == $on) {
167
+ $sortable_array[$k] = $v2;
168
+ }
169
+ }
170
+ } else {
171
+ $sortable_array[$k] = $v;
172
+ }
173
+ }
174
+
175
+ switch ($order) {
176
+ case SORT_ASC:
177
+ asort($sortable_array);
178
+ break;
179
+ case SORT_DESC:
180
+ arsort($sortable_array);
181
+ break;
182
+ }
183
+
184
+ foreach ($sortable_array as $k => $v) {
185
+ $new_array[$k] = $array[$k];
186
+ }
187
+ }
188
+
189
+ return $new_array;
190
+ }
191
+
192
+ //********************* Plugin Options Functions ************************************************************************************************
193
+
194
+ function wfu_encode_plugin_options($plugin_options) {
195
+ $encoded_options = 'version='.$plugin_options['version'].';';
196
+ $encoded_options .= 'shortcode='.wfu_plugin_encode_string($plugin_options['shortcode']).';';
197
+ $encoded_options .= 'basedir='.wfu_plugin_encode_string($plugin_options['basedir']);
198
+ return $encoded_options;
199
+ }
200
+
201
+ function wfu_decode_plugin_options($encoded_options) {
202
+ $decoded_array = explode(';', $encoded_options);
203
+ $plugin_options = array();
204
+ foreach ($decoded_array as $decoded_item) {
205
+ list($item_key, $item_value) = explode("=", $decoded_item, 2);
206
+ if ( $item_key == 'shortcode' || $item_key == 'basedir' )
207
+ $plugin_options[$item_key] = wfu_plugin_decode_string($item_value);
208
+ else
209
+ $plugin_options[$item_key] = $item_value;
210
+
211
+ }
212
+ return $plugin_options;
213
+ }
214
+
215
+ //********************* Directory Functions ************************************************************************************************
216
+
217
+ function wfu_upload_plugin_full_path( $params ) {
218
+ $path = $params["uploadpath"];
219
+ if ( $params["accessmethod"]=='ftp' && $params["ftpinfo"] != '' && $params["useftpdomain"] == "true" ) {
220
+ $ftpdata_flat = str_replace(array('\:', '\@'), array('\_', '\_'), $params["ftpinfo"]);
221
+ $pos1 = strpos($ftpdata_flat, ":");
222
+ $pos2 = strpos($ftpdata_flat, "@");
223
+ if ( $pos1 && $pos2 && $pos2 > $pos1 ) {
224
+ $ftp_username = substr($params["ftpinfo"], 0, $pos1);
225
+ $ftp_password = substr($params["ftpinfo"], $pos1 + 1, $pos2 - $pos1 - 1);
226
+ $ftp_host = substr($params["ftpinfo"], $pos2 + 1);
227
+ $ftp_username = str_replace('@', '%40', $ftp_username); //if username contains @ character then convert it to %40
228
+ $ftp_password = str_replace('@', '%40', $ftp_password); //if password contains @ character then convert it to %40
229
+ $start_folder = 'ftp://'.$ftp_username.':'.$ftp_password."@".$ftp_host.'/';
230
+ }
231
+ else $start_folder = 'ftp://'.$params["ftpinfo"].'/';
232
+ }
233
+ else $start_folder = WP_CONTENT_DIR.'/';
234
+ if ($path) {
235
+ if ( $path == ".." || substr($path, 0, 3) == "../" ) {
236
+ $start_folder = ABSPATH;
237
+ $path = substr($path, 2, strlen($path) - 2);
238
+ }
239
+ if ( substr($path, 0, 1) == "/" ) $path = substr($path, 1, strlen($path) - 1);
240
+ if ( substr($path, -1, 1) == "/" ) $path = substr($path, 0, strlen($path) - 1);
241
+ $full_upload_path = $start_folder;
242
+ if ( $path != "" ) $full_upload_path .= $path.'/';
243
+ }
244
+ else {
245
+ $full_upload_path = $start_folder;
246
+ }
247
+ return $full_upload_path;
248
+ }
249
+
250
+ function wfu_upload_plugin_directory( $path ) {
251
+ $dirparts = explode("/", $path);
252
+ return $dirparts[count($dirparts) - 1];
253
+ }
254
+
255
+ //function to extract sort information from path, which is stored as [[-sort]] inside the path
256
+ function wfu_extract_sortdata_from_path($path) {
257
+ $pos1 = strpos($path, '[[');
258
+ $pos2 = strpos($path, ']]');
259
+ $ret['path'] = $path;
260
+ $ret['sort'] = "";
261
+ if ( $pos1 !== false && $pos2 !== false )
262
+ if ( $pos2 > $pos1 ) {
263
+ $ret['sort'] = substr($path, $pos1 + 2, $pos2 - $pos1 - 2);
264
+ $ret['path'] = str_replace('[['.$ret['sort'].']]', '', $path);
265
+ }
266
+ return $ret;
267
+ }
268
+
269
+ //extract sort information from path and return the flatten path
270
+ function wfu_flatten_path($path) {
271
+ $ret = wfu_extract_sortdata_from_path($path);
272
+ return $ret['path'];
273
+ }
274
+
275
+ function wfu_delTree($dir) {
276
+ $files = array_diff(scandir($dir), array('.','..'));
277
+ foreach ($files as $file) {
278
+ is_dir("$dir/$file") ? wfu_delTree("$dir/$file") : unlink("$dir/$file");
279
+ }
280
+ return rmdir($dir);
281
+ }
282
+
283
+ //********************* User Functions *********************************************************************************************************
284
+
285
+ function wfu_get_user_role($user, $param_roles) {
286
+ if ( !empty( $user->roles ) && is_array( $user->roles ) ) {
287
+ /* Go through the array of the roles of the current user */
288
+ foreach ( $user->roles as $user_role ) {
289
+ $user_role = strtolower($user_role);
290
+ /* If one role of the current user matches to the roles allowed to upload */
291
+ if ( in_array($user_role, $param_roles) || $user_role == 'administrator' ) {
292
+ /* We affect this role to current user */
293
+ $result_role = $user_role;
294
+ break;
295
+ }
296
+ else {
297
+ /* We affect the 'visitor' role to current user */
298
+ $result_role = 'visitor';
299
+ }
300
+ }
301
+ }
302
+ else {
303
+ $result_role = 'visitor';
304
+ }
305
+ return $result_role;
306
+ }
307
+
308
+ //********************* Shortcode Options Functions ************************************************************************************************
309
+
310
+ function wfu_generate_current_params_index($shortcode_id, $user_login) {
311
+ global $post;
312
+ $cur_index_str = '||'.$post->ID.'||'.$shortcode_id.'||'.$user_login;
313
+ $cur_index_str_search = '\|\|'.$post->ID.'\|\|'.$shortcode_id.'\|\|'.$user_login;
314
+ $index_str = get_option('wfu_params_index');
315
+ $index = explode("&&", $index_str);
316
+ foreach ($index as $key => $value) if ($value == "") unset($index[$key]);
317
+ $index_match = preg_grep("/".$cur_index_str_search."$/", $index);
318
+ if ( count($index_match) == 1 )
319
+ foreach ( $index_match as $key => $value )
320
+ if ( $value == "" ) unset($index_match[$key]);
321
+ if ( count($index_match) <= 0 ) {
322
+ $cur_index_rand = wfu_create_random_string(16);
323
+ array_push($index, $cur_index_rand.$cur_index_str);
324
+ }
325
+ else {
326
+ reset($index_match);
327
+ $cur_index_rand = substr(current($index_match), 0, 16);
328
+ if ( count($index_match) > 1 ) {
329
+ $index_match_keys = array_keys($index_match);
330
+ for ($i = 1; $i < count($index_match); $i++) {
331
+ $ii = $index_match_keys[$i];
332
+ unset($index[array_search($index_match[$ii], $index, true)]);
333
+ }
334
+ }
335
+ }
336
+ if ( count($index_match) != 1 ) {
337
+ $index_str = implode("&&", $index);
338
+ update_option('wfu_params_index', $index_str);
339
+ }
340
+ return $cur_index_rand;
341
+ }
342
+
343
+ function wfu_get_params_fields_from_index($params_index) {
344
+ $fields = array();
345
+ $index_str = get_option('wfu_params_index');
346
+ $index = explode("&&", $index_str);
347
+ $index_match = preg_grep("/^".$params_index."/", $index);
348
+ if ( count($index_match) == 1 )
349
+ foreach ( $index_match as $key => $value )
350
+ if ( $value == "" ) unset($index_match[$key]);
351
+ if ( count($index_match) > 0 ) {
352
+ reset($index_match);
353
+ list($fields['unique_id'], $fields['page_id'], $fields['shortcode_id'], $fields['user_login']) = explode("||", current($index_match));
354
+ }
355
+ return $fields;
356
+ }
357
+
358
+ function wfu_decode_dimensions($dimensions_str) {
359
+ $components = wfu_component_definitions();
360
+ $dimensions = array();
361
+ foreach ( $components as $comp ) {
362
+ if ( $comp['dimensions'] == null ) $dimensions[$comp['id']] = "";
363
+ else foreach ( $comp['dimensions'] as $dimraw ) {
364
+ list($dim_id, $dim_name) = explode("/", $dimraw);
365
+ $dimensions[$dim_id] = "";
366
+ }
367
+ }
368
+ $dimensions_raw = explode(",", $dimensions_str);
369
+ foreach ( $dimensions_raw as $dimension_str ) {
370
+ $dimension_raw = explode(":", $dimension_str);
371
+ $item = strtolower(trim($dimension_raw[0]));
372
+ foreach ( array_keys($dimensions) as $key ) {
373
+ if ( $item == $key ) $dimensions[$key] = trim($dimension_raw[1]);
374
+ }
375
+ }
376
+ return $dimensions;
377
+ }
378
+
379
+ //********************* Plugin Design Functions *********************************************************************************************************
380
+
381
+ function wfu_add_div() {
382
+ $items_count = func_num_args();
383
+ if ( $items_count == 0 ) return "";
384
+ $items_raw = func_get_args();
385
+ $items = array( );
386
+ foreach ( $items_raw as $item_raw ) {
387
+ if ( is_array($item_raw) ) array_push($items, $item_raw);
388
+ }
389
+ $items_count = count($items);
390
+ if ( $items_count == 0 ) return "";
391
+ $div = "";
392
+ $div .= "\n\t".'<div class="file_div_clean">';
393
+ $div .= "\n\t\t".'<table class="file_table_clean">';
394
+ $div .= "\n\t\t\t".'<tbody>';
395
+ $div .= "\n\t\t\t\t".'<tr>';
396
+ for ( $i = 0; $i < $items_count; $i++ ) {
397
+ $div .= "\n\t\t\t\t\t".'<td class="file_td_clean"';
398
+ if ( $i < $items_count - 1 ) $div .= ' style="padding: 0 4px 0 0"';
399
+ $div .= '>';
400
+ $div .= "\n\t\t\t\t\t\t".'<div id="'.$items[$i]["title"].'" class="file_div_clean"';
401
+ if ( $items[$i]["hidden"] ) $div .= ' style="display: none"';
402
+ $div .= '>';
403
+ $item_lines_count = count($items[$i]) - 2;
404
+ for ( $k = 1; $k <= $item_lines_count; $k++ ) {
405
+ if ( $items[$i]["line".$k] != "" ) $div .= "\n\t\t\t\t\t\t\t".$items[$i]["line".$k];
406
+ }
407
+ $div .= "\n\t\t\t\t\t\t\t".'<div class="file_space_clean" />';
408
+ $div .= "\n\t\t\t\t\t\t".'</div>';
409
+ $div .= "\n\t\t\t\t\t".'</td>';
410
+ }
411
+ $div .= "\n\t\t\t\t".'</tr>';
412
+ $div .= "\n\t\t\t".'</tbody>';
413
+ $div .= "\n\t\t".'</table>';
414
+ $div .= "\n\t".'</div>';
415
+ return $div;
416
+ }
417
+
418
+ //********************* Email Functions **************************************************************************************************************
419
+
420
+ function wfu_send_notification_email($user, $only_filename_list, $target_path_list, $attachment_list, $userdata_fields, $params) {
421
+ if ( 0 == $user->ID ) {
422
+ $user_login = "guest";
423
+ $user_email = "";
424
+ }
425
+ else {
426
+ $user_login = $user->user_login;
427
+ $user_email = $user->user_email;
428
+ }
429
+ $notifyrecipients = trim(preg_replace('/%useremail%/', $user_email, $params["notifyrecipients"]));
430
+ $search = array ('/%n%/');
431
+ $replace = array ("\n");
432
+ $notifyheaders = preg_replace($search, $replace, $params["notifyheaders"]);
433
+ $search = array ('/%username%/', '/%useremail%/', '/%filename%/', '/%filepath%/', '/%n%/');
434
+ $replace = array ($user_login, ( $user_email == "" ? "no email" : $user_email ), $only_filename_list, $target_path_list, "\n");
435
+ foreach ( $userdata_fields as $userdata_key => $userdata_field ) {
436
+ $ind = 1 + $userdata_key;
437
+ array_push($search, '/%userdata'.$ind.'%/');
438
+ array_push($replace, $userdata_field["value"]);
439
+ }
440
+ $notifysubject = preg_replace($search, $replace, $params["notifysubject"]);
441
+ $notifymessage = preg_replace($search, $replace, $params["notifymessage"]);
442
+ if ( $params["attachfile"] == "true" ) {
443
+ $attachments = explode(",", $attachment_list);
444
+ $notify_sent = wp_mail($notifyrecipients, $notifysubject, $notifymessage, $notifyheaders, $attachments);
445
+ }
446
+ else {
447
+ $notify_sent = wp_mail($notifyrecipients, $notifysubject, $notifymessage, $notifyheaders);
448
+ }
449
+ return ( $notify_sent ? "" : WFU_WARNING_NOTIFY_NOTSENT_UNKNOWNERROR );
450
+ }
451
+
452
+ //********************* Media Functions **************************************************************************************************************
453
+
454
+ // function wfu_process_media_insert contribution from Aaron Olin
455
+ function wfu_process_media_insert($file_path){
456
+ $file_no_ext = preg_replace("/ /", "_", pathinfo($file_path, PATHINFO_FILENAME) );
457
+ $ext = strtolower( pathinfo($file_path, PATHINFO_EXTENSION) );
458
+
459
+ switch($ext){
460
+ case 'pdf':
461
+ $filetype = 'application/pdf';
462
+ break;
463
+ // images
464
+ case 'bmp':
465
+ $filetype = 'image/bmp';
466
+ break;
467
+ case 'gif':
468
+ $filetype = 'image/gif';
469
+ break;
470
+ case ( preg_match('~\b(jpg|jpeg)\b~i', $ext) ) ? true : false :
471
+ $filetype = 'image/jpeg';
472
+ break;
473
+ case 'png':
474
+ $filetype = 'image/png';
475
+ break;
476
+ // office apps
477
+ case ( preg_match('~\b(doc|docx)\b~i', $ext) ) ? true : false :
478
+ $filetype = 'application/msword';
479
+ break;
480
+ case ( preg_match('~\b(ppt|pptx)\b~i', $ext) ) ? true : false :
481
+ $filetype = 'application/vnd.ms-powerpoint';
482
+ break;
483
+ case ( preg_match('~\b(xls|xlsx)\b~i', $ext) ) ? true : false :
484
+ $filetype = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
485
+ break;
486
+ // compression
487
+ case 'zip':
488
+ $filetype = 'application/zip';
489
+ break;
490
+ case 'rar':
491
+ $filetype = 'application/rar';
492
+ break;
493
+
494
+ default:
495
+ $filetype = 'application/msword';
496
+ break; }
497
+
498
+ $attachment = array(
499
+ 'guid' => $guid,
500
+ 'post_mime_type' => $filetype,
501
+ 'post_title' => $file_no_ext,
502
+ 'post_content' => '',
503
+ 'post_status' => 'inherit'
504
+ );
505
+
506
+
507
+ $attach_id = wp_insert_attachment( $attachment, $file_path);
508
+
509
+ // If file is an image, process the default thumbnails for previews
510
+ $image_types = array('gif','png','bmp','jpeg','jpg');
511
+ if ( in_array($ext, $image_types) ) {
512
+ require_once(ABSPATH . 'wp-admin/includes/image.php');
513
+ require_once(ABSPATH . 'wp-admin/includes/media.php');
514
+ $attach_data = wp_generate_attachment_metadata( $attach_id, $file_path );
515
+ $update_attach = wp_update_attachment_metadata( $attach_id, $attach_data );
516
+ }
517
+
518
+ return $attach_id;
519
+ }
520
+
521
+ ?>
lib/wfu_io.php CHANGED
@@ -1,106 +1,106 @@
1
- <?php
2
-
3
- function wfu_create_directory($path, $method, $ftpdata) {
4
- $ret_message = "";
5
- if ( $method == "" || $method == "normal" ) {
6
- mkdir($path, 0777, true);
7
- }
8
- else if ( $method == "ftp" && $ftpdata != "" ) {
9
- $ftpdata_flat = str_replace(array('\:', '\@'), array('\_', '\_'), $ftpdata);
10
- $pos1 = strpos($ftpdata_flat, ":");
11
- $pos2 = strpos($ftpdata_flat, "@");
12
- if ( $pos1 && $pos2 && $pos2 > $pos1 ) {
13
- $ftp_username = substr($ftpdata, 0, $pos1);
14
- $ftp_password = substr($ftpdata, $pos1 + 1, $pos2 - $pos1 - 1);
15
- $ftp_host = substr($ftpdata, $pos2 + 1);
16
- $conn_id = ftp_connect($ftp_host);
17
- $login_result = ftp_login($conn_id, $ftp_username, $ftp_password);
18
- if ( $conn_id && $login_result ) {
19
- $flat_host = preg_replace("/^(.*\.)?([^.]*\..*)$/", "$2", $ftp_host);
20
- $pos1 = strpos($path, $flat_host);
21
- if ( $pos1 ) {
22
- $path = substr($path, $pos1 + strlen($flat_host));
23
- ftp_mkdir($conn_id, $path);
24
- ftp_chmod($conn_id, 511, $path);
25
- }
26
- else {
27
- $ret_message = WFU_ERROR_ADMIN_FTPDIR_RESOLVE;
28
- }
29
- }
30
- else {
31
- $ret_message = WFU_ERROR_ADMIN_FTPINFO_INVALID;
32
- }
33
- ftp_quit($conn_id);
34
- }
35
- else {
36
- $ret_message = WFU_ERROR_ADMIN_FTPINFO_EXTRACT;
37
- }
38
- }
39
- else {
40
- $ret_message = WFU_ERROR_ADMIN_FTPINFO_INVALID;
41
- }
42
- return $ret_message;
43
- }
44
-
45
-
46
- function wfu_upload_file($source, $target, $method, $ftpdata) {
47
- $ret_array = "";
48
- $ret_array["uploaded"] = false;
49
- $ret_array["admin_message"] = "";
50
- $ret_message = "";
51
- $target_perms = substr(sprintf('%o', fileperms(dirname($target))), -4);
52
- if ( $method == "" || $method == "normal" ) {
53
- $ret_array["uploaded"] = move_uploaded_file($source, $target);
54
- if ( !$ret_array["uploaded"] && !is_writable(dirname($target)) ) {
55
- $ret_message = WFU_ERROR_ADMIN_DIR_PERMISSION;
56
- }
57
- }
58
- elseif ( $method == "ftp" && $ftpdata != "" ) {
59
- $result = false;
60
- $ftpdata_flat = str_replace(array('\:', '\@'), array('\_', '\_'), $ftpdata);
61
- $pos1 = strpos($ftpdata_flat, ":");
62
- $pos2 = strpos($ftpdata_flat, "@");
63
- if ( $pos1 && $pos2 && $pos2 > $pos1 ) {
64
- $ftp_username = substr($ftpdata, 0, $pos1);
65
- $ftp_password = substr($ftpdata, $pos1 + 1, $pos2 - $pos1 - 1);
66
- $ftp_host = substr($ftpdata, $pos2 + 1);
67
- $conn_id = ftp_connect($ftp_host);
68
- $login_result = ftp_login($conn_id, $ftp_username, $ftp_password);
69
- if ( $conn_id && $login_result ) {
70
- $flat_host = preg_replace("/^(.*\.)?([^.]*\..*)$/", "$2", $ftp_host);
71
- $pos1 = strpos($target, $flat_host);
72
- if ( $pos1 ) {
73
- // $temp_fname = tempnam(dirname($target), "tmp");
74
- // move_uploaded_file($source, $temp_fname);
75
- $target = substr($target, $pos1 + strlen($flat_host));
76
- ftp_chmod($conn_id, 0755, dirname($target));
77
- $ret_array["uploaded"] = ftp_put($conn_id, $target, $source, FTP_BINARY);
78
- ftp_chmod($conn_id, 0755, $target);
79
- ftp_chmod($conn_id, $target_perms, dirname($target));
80
- unlink($source);
81
- if ( !$ret_array["uploaded"] ) {
82
- $ret_message = WFU_ERROR_ADMIN_DIR_PERMISSION;
83
- }
84
- }
85
- else {
86
- $ret_message = WFU_ERROR_ADMIN_FTPFILE_RESOLVE;
87
- }
88
- }
89
- else {
90
- $ret_message = WFU_ERROR_ADMIN_FTPINFO_INVALID;
91
- }
92
- ftp_quit($conn_id);
93
- }
94
- else {
95
- $ret_message = WFU_ERROR_ADMIN_FTPINFO_EXTRACT.$ftpdata_flat;
96
- }
97
- }
98
- else {
99
- $ret_message = WFU_ERROR_ADMIN_FTPINFO_INVALID;
100
- }
101
-
102
- $ret_array["admin_message"] = $ret_message;
103
- return $ret_array;
104
- }
105
-
106
- ?>
1
+ <?php
2
+
3
+ function wfu_create_directory($path, $method, $ftpdata) {
4
+ $ret_message = "";
5
+ if ( $method == "" || $method == "normal" ) {
6
+ mkdir($path, 0777, true);
7
+ }
8
+ else if ( $method == "ftp" && $ftpdata != "" ) {
9
+ $ftpdata_flat = str_replace(array('\:', '\@'), array('\_', '\_'), $ftpdata);
10
+ $pos1 = strpos($ftpdata_flat, ":");
11
+ $pos2 = strpos($ftpdata_flat, "@");
12
+ if ( $pos1 && $pos2 && $pos2 > $pos1 ) {
13
+ $ftp_username = substr($ftpdata, 0, $pos1);
14
+ $ftp_password = substr($ftpdata, $pos1 + 1, $pos2 - $pos1 - 1);
15
+ $ftp_host = substr($ftpdata, $pos2 + 1);
16
+ $conn_id = ftp_connect($ftp_host);
17
+ $login_result = ftp_login($conn_id, $ftp_username, $ftp_password);
18
+ if ( $conn_id && $login_result ) {
19
+ $flat_host = preg_replace("/^(.*\.)?([^.]*\..*)$/", "$2", $ftp_host);
20
+ $pos1 = strpos($path, $flat_host);
21
+ if ( $pos1 ) {
22
+ $path = substr($path, $pos1 + strlen($flat_host));
23
+ ftp_mkdir($conn_id, $path);
24
+ ftp_chmod($conn_id, 511, $path);
25
+ }
26
+ else {
27
+ $ret_message = WFU_ERROR_ADMIN_FTPDIR_RESOLVE;
28
+ }
29
+ }
30
+ else {
31
+ $ret_message = WFU_ERROR_ADMIN_FTPINFO_INVALID;
32
+ }
33
+ ftp_quit($conn_id);
34
+ }
35
+ else {
36
+ $ret_message = WFU_ERROR_ADMIN_FTPINFO_EXTRACT;
37
+ }
38
+ }
39
+ else {
40
+ $ret_message = WFU_ERROR_ADMIN_FTPINFO_INVALID;
41
+ }
42
+ return $ret_message;
43
+ }
44
+
45
+
46
+ function wfu_upload_file($source, $target, $method, $ftpdata) {
47
+ $ret_array = "";
48
+ $ret_array["uploaded"] = false;
49
+ $ret_array["admin_message"] = "";
50
+ $ret_message = "";
51
+ $target_perms = substr(sprintf('%o', fileperms(dirname($target))), -4);
52
+ if ( $method == "" || $method == "normal" ) {
53
+ $ret_array["uploaded"] = move_uploaded_file($source, $target);
54
+ if ( !$ret_array["uploaded"] && !is_writable(dirname($target)) ) {
55
+ $ret_message = WFU_ERROR_ADMIN_DIR_PERMISSION;
56
+ }
57
+ }
58
+ elseif ( $method == "ftp" && $ftpdata != "" ) {
59
+ $result = false;
60
+ $ftpdata_flat = str_replace(array('\:', '\@'), array('\_', '\_'), $ftpdata);
61
+ $pos1 = strpos($ftpdata_flat, ":");
62
+ $pos2 = strpos($ftpdata_flat, "@");
63
+ if ( $pos1 && $pos2 && $pos2 > $pos1 ) {
64
+ $ftp_username = substr($ftpdata, 0, $pos1);
65
+ $ftp_password = substr($ftpdata, $pos1 + 1, $pos2 - $pos1 - 1);
66
+ $ftp_host = substr($ftpdata, $pos2 + 1);
67
+ $conn_id = ftp_connect($ftp_host);
68
+ $login_result = ftp_login($conn_id, $ftp_username, $ftp_password);
69
+ if ( $conn_id && $login_result ) {
70
+ $flat_host = preg_replace("/^(.*\.)?([^.]*\..*)$/", "$2", $ftp_host);
71
+ $pos1 = strpos($target, $flat_host);
72
+ if ( $pos1 ) {
73
+ // $temp_fname = tempnam(dirname($target), "tmp");
74
+ // move_uploaded_file($source, $temp_fname);
75
+ $target = substr($target, $pos1 + strlen($flat_host));
76
+ ftp_chmod($conn_id, 0755, dirname($target));
77
+ $ret_array["uploaded"] = ftp_put($conn_id, $target, $source, FTP_BINARY);
78
+ ftp_chmod($conn_id, 0755, $target);
79
+ ftp_chmod($conn_id, $target_perms, dirname($target));
80
+ unlink($source);
81
+ if ( !$ret_array["uploaded"] ) {
82
+ $ret_message = WFU_ERROR_ADMIN_DIR_PERMISSION;
83
+ }
84
+ }
85
+ else {
86
+ $ret_message = WFU_ERROR_ADMIN_FTPFILE_RESOLVE;
87
+ }
88
+ }
89
+ else {
90
+ $ret_message = WFU_ERROR_ADMIN_FTPINFO_INVALID;
91
+ }
92
+ ftp_quit($conn_id);
93
+ }
94
+ else {
95
+ $ret_message = WFU_ERROR_ADMIN_FTPINFO_EXTRACT.$ftpdata_flat;
96
+ }
97
+ }
98
+ else {
99
+ $ret_message = WFU_ERROR_ADMIN_FTPINFO_INVALID;
100
+ }
101
+
102
+ $ret_array["admin_message"] = $ret_message;
103
+ return $ret_array;
104
+ }
105
+
106
+ ?>
lib/wfu_message.php CHANGED
@@ -1,211 +1,211 @@
1
- <?php
2
-
3
- function wfu_prepare_message_block_skeleton($sid, $styles, $test) {
4
- /* Prepare header styles for all upload states */
5
- $header_styles["State0"] = wfu_prepare_message_colors(WFU_HEADERMESSAGECOLORS_STATE0);
6
- $header_styles["State0"]['message'] = WFU_UPLOAD_STATE0;
7
- $header_styles["State1"] = wfu_prepare_message_colors(WFU_HEADERMESSAGECOLORS_STATE1);
8
- $header_styles["State1"]['message'] = WFU_UPLOAD_STATE1;
9
- $header_styles["State2"] = wfu_prepare_message_colors(WFU_HEADERMESSAGECOLORS_STATE2);
10
- $header_styles["State2"]['message'] = WFU_UPLOAD_STATE2;
11
- $header_styles["State3"] = wfu_prepare_message_colors(WFU_HEADERMESSAGECOLORS_STATE3);
12
- $header_styles["State3"]['message'] = WFU_UPLOAD_STATE3;
13
- $header_styles["State4"] = wfu_prepare_message_colors(WFU_HEADERMESSAGECOLORS_STATE4);
14
- $header_styles["State4"]['message'] = WFU_UPLOAD_STATE4;
15
- $header_styles["State5"] = wfu_prepare_message_colors(WFU_HEADERMESSAGECOLORS_STATE5);
16
- $header_styles["State5"]['message'] = WFU_UPLOAD_STATE5;
17
- $header_styles["State5_singlefile"] = wfu_prepare_message_colors(WFU_HEADERMESSAGECOLORS_STATE5);
18
- $header_styles["State5_singlefile"]['message'] = WFU_UPLOAD_STATE5_SINGLEFILE;
19
- $header_styles["State6"] = wfu_prepare_message_colors(WFU_HEADERMESSAGECOLORS_STATE6);
20
- $header_styles["State6"]['message'] = WFU_UPLOAD_STATE6;
21
- $header_styles["State7"] = wfu_prepare_message_colors(WFU_HEADERMESSAGECOLORS_STATE7);
22
- $header_styles["State7"]['message'] = WFU_UPLOAD_STATE7;
23
- $header_styles["State7_singlefile"] = wfu_prepare_message_colors(WFU_HEADERMESSAGECOLORS_STATE7);
24
- $header_styles["State7_singlefile"]['message'] = WFU_UPLOAD_STATE7_SINGLEFILE;
25
- $header_styles["State8"] = wfu_prepare_message_colors(WFU_HEADERMESSAGECOLORS_STATE8);
26
- $header_styles["State8"]['message'] = WFU_UPLOAD_STATE8;
27
- $header_styles["State9"] = wfu_prepare_message_colors(WFU_HEADERMESSAGECOLORS_STATE9);
28
- $header_styles["State9"]['message'] = WFU_UPLOAD_STATE9;
29
- $header_styles["State10"] = wfu_prepare_message_colors(WFU_HEADERMESSAGECOLORS_STATE10);
30
- $header_styles["State10"]['message'] = WFU_UPLOAD_STATE10;
31
- $header_styles["State11"] = wfu_prepare_message_colors(WFU_HEADERMESSAGECOLORS_STATE11);
32
- $header_styles["State11"]['message'] = WFU_UPLOAD_STATE11;
33
- $ExposedStateIndex = array("0", "1", "2", "3", "4", "5", "5_singlefile", "6", "7", "7_singlefile", "8", "11");
34
-
35
- /* set general variables */
36
- $messageblock_main = 'wfu_messageblock_'.$sid;
37
- $messageblock_header = 'wfu_messageblock_header_'.$sid;
38
- $messageblock_arrow = 'wfu_messageblock_arrow_'.$sid;
39
- $messageblock_subheader = 'wfu_messageblock_subheader_'.$sid;
40
- $dlp = "\n\t\t\t\t\t\t\t";
41
-
42
- /* Prepare header HTML template
43
- Variables:
44
- [header_safe]: suffix having the value "_safe" in case of State10 upload state, or empty otherwise,
45
- [header_color]: text color of header,
46
- [header_bgcolor]: background color of header,
47
- [header_borcolor]: border color of header,
48
- [header_message]: text shown in header */
49
- $i = 1;
50
- $messageblock_headers[$i++] = "\t\t\t".'<div id="'.$messageblock_header.'[header_safe]" class="file_messageblock_header" style="color:[header_color]; background-color:[header_bgcolor]; border:1px solid [header_borcolor];">';
51
- $messageblock_headers[$i++] = "\t\t\t\t".'<label id="'.$messageblock_header.'_label[header_safe]" class="file_messageblock_header_label">[header_message]</label>';
52
- $messageblock_headers[$i++] = "\t\t\t".'</div>';
53
-
54
- /* Prepare the file block HTML template
55
- Variables:
56
- [file_id]: replaced by the id of the file (1, 2, ...),
57
- [filenumber_display]: display:none if single file upload, otherwise empty,
58
- [fileheader_color], [fileheader_bgcolor], [fileheader_borcolor], [fileheader_message]: replaced by the returned values,
59
- [filesubheadermessage_display]: display:none if there is no message, otherwise empty,
60
- [filesubheader_message]: replaced by the returned value,
61
- [filesubheaderadminmessage_display]: display:none if there is no admin message, otherwise empty,
62
- [filesubheader_adminmessage]: replaced by the returned value */
63
- /* Prepare the files header block HTML template */
64
- $i = 1;
65
- $file_count = ( $test ? 2 : 1);
66
- for ($ii = 1; $ii <= $file_count; $ii++) {
67
- if ( $test ) {
68
- $file_props = wfu_prepare_message_colors(WFU_TESTMESSAGECOLORS);
69
- $file_id = $ii;
70
- $filenumber_display = "";
71
- $fileheader_color = $file_props['color'];
72
- $fileheader_bgcolor = $file_props['bgcolor'];
73
- $fileheader_borcolor = $file_props['borcolor'];
74
- $fileheader_message = constant('WFU_TESTMESSAGE_FILE'.$ii.'_HEADER');
75
- $filesubheadermessage_display = "";
76
- $filesubheader_message = constant('WFU_TESTMESSAGE_FILE'.$ii.'_MESSAGE');
77
- $filesubheaderadminmessage_display = "";
78
- $filesubheader_adminmessage = constant('WFU_TESTMESSAGE_FILE'.$ii.'_ADMINMESSAGE');
79
- }
80
- else {
81
- $file_id = '[file_id]';
82
- $filenumber_display = '[filenumber_display]';
83
- $fileheader_color = '[fileheader_color]';
84
- $fileheader_bgcolor = '[fileheader_bgcolor]';
85
- $fileheader_borcolor = '[fileheader_borcolor]';
86
- $fileheader_message = '[fileheader_message]';
87
- $filesubheadermessage_display = '[filesubheadermessage_display]';
88
- $filesubheader_message = '[filesubheader_message]';
89
- $filesubheaderadminmessage_display = '[filesubheaderadminmessage_display]';
90
- $filesubheader_adminmessage = '[filesubheader_adminmessage]';
91
- }
92
- $messageblock_file[$i++] = "\t".'<tr id="'.$messageblock_main.'_'.$file_id.'" class="file_messageblock_fileheader_tr" style="display:none;">';
93
- $messageblock_file[$i++] = "\t\t".'<td id="'.$messageblock_main.'_filenumber_'.$file_id.'" class="file_messageblock_filenumber_td"'.$filenumber_display.'>'.$file_id.'</td>';
94
- $messageblock_file[$i++] = "\t\t".'<td id="'.$messageblock_header.'_container_'.$file_id.'" class="file_messageblock_fileheader_td">';
95
- $messageblock_file[$i++] = "\t\t\t".'<div id="'.$messageblock_header.'_'.$file_id.'" class="file_messageblock_fileheader" style="color:'.$fileheader_color.'; background-color:'.$fileheader_bgcolor.'; border:1px solid '.$fileheader_borcolor.';">';
96
- $messageblock_file[$i++] = "\t\t\t\t".'<label id="'.$messageblock_header.'_label_'.$file_id.'" class="file_messageblock_fileheader_label">'.$fileheader_message.'</label>';
97
- /* The following hidden input holds state of arrow (open or close) */
98
- $messageblock_file[$i++] = "\t\t\t\t".'<input id="'.$messageblock_header.'_state_'.$file_id.'" type="hidden" value="none" />';
99
- $messageblock_file[$i++] = "\t\t\t".'</div>';
100
- $messageblock_file[$i++] = "\t\t".'</td>';
101
- /* Add a drop down arrow to the file header (file has always details to be shown) */
102
- $messageblock_file[$i++] = "\t\t".'<td id="'.$messageblock_arrow.'_'.$file_id.'" class="file_messageblock_filearrow_td" onclick="wfu_filedetails_toggle('.$sid.', '.$file_id.');">';
103
- $messageblock_file[$i++] = "\t\t\t".'<div id="'.$messageblock_arrow.'_up_'.$file_id.'" class="file_messageblock_file_arrow_up" style="display:none;"></div>';
104
- $messageblock_file[$i++] = "\t\t\t".'<div id="'.$messageblock_arrow.'_down_'.$file_id.'" class="file_messageblock_file_arrow_down"></div>';
105
- $messageblock_file[$i++] = "\t\t".'</td>';
106
- $messageblock_file[$i++] = "\t".'</tr>';
107
- /* Prepare the files subheader block HTML template */
108
- $messageblock_file[$i++] = "\t".'<tr id="'.$messageblock_subheader.'_'.$file_id.'" class="file_messageblock_filesubheader_tr" style="display:none;">';
109
- $messageblock_file[$i++] = "\t\t".'<td id="'.$messageblock_subheader.'_fileempty_'.$file_id.'" class="file_messageblock_filesubheaderempty_td"'.$filenumber_display.'></td>';
110
- $messageblock_file[$i++] = "\t\t".'<td colspan="2" id="'.$messageblock_subheader.'_container_'.$file_id.'" class="file_messageblock_filesubheader_td">';
111
- $messageblock_file[$i++] = "\t\t\t".'<div id="'.$messageblock_subheader.'_message_'.$file_id.'" class="file_messageblock_filesubheader_message"'.$filesubheadermessage_display.'>';
112
- $messageblock_file[$i++] = "\t\t\t\t".'<label id="'.$messageblock_subheader.'_messagelabel_'.$file_id.'" class="file_messageblock_filesubheader_messagelabel">'.$filesubheader_message.'</label>';
113
- $messageblock_file[$i++] = "\t\t\t".'</div>';
114
- $messageblock_file[$i++] = "\t\t\t".'<div id="'.$messageblock_subheader.'_adminmessage_'.$file_id.'" class="file_messageblock_filesubheader_adminmessage"'.$filesubheaderadminmessage_display.'>';
115
- $messageblock_file[$i++] = "\t\t\t\t".'<label id="'.$messageblock_subheader.'_adminmessagelabel_'.$file_id.'" class="file_messageblock_filesubheader_adminmessagelabel">'.$filesubheader_adminmessage.'</label>';
116
- $messageblock_file[$i++] = "\t\t\t".'</div>';
117
- $messageblock_file[$i++] = "\t\t".'</td>';
118
- $messageblock_file[$i++] = "\t".'</tr>';
119
- }
120
-
121
- /* Construct the main header block HTML text
122
- /* Construct the header block HTML text */
123
- $i = 1;
124
- $messageblock["msgblock"]["line".$i++] = '<table id="'.$messageblock_main.'" class="file_messageblock_table"'.$styles.'><tbody>';
125
- $messageblock["msgblock"]["line".$i++] = "\t".'<tr id="'.$messageblock_header.'" class="file_messageblock_header_tr"'.( $test ? '' : 'style="display:none;"' ).'>';
126
- $messageblock["msgblock"]["line".$i++] = "\t\t".'<td colspan="2" id="'.$messageblock_header.'_container" class="file_messageblock_header_td">';
127
- /* Inside this td element the appropriate upload state HTML block is going to be inserted using Javascript
128
- If the plugin is in test mode, then State9 HTML block is inserted now */
129
- if ( $test ) {
130
- foreach ( $messageblock_headers as $messageblock_header_part )
131
- $messageblock["msgblock"]["line".$i++] = strtr($messageblock_header_part, array(
132
- "[header_safe]" => "",
133
- "[header_color]" => $header_styles["State9"]["color"],
134
- "[header_bgcolor]" => $header_styles["State9"]["bgcolor"],
135
- "[header_borcolor]" => $header_styles["State9"]["borcolor"],
136
- "[header_message]" => $header_styles["State9"]["message"]
137
- ));
138
- }
139
- $messageblock["msgblock"]["line".$i++] = "\t\t".'</td>';
140
- /* Add a drop down arrow to the header */
141
- $messageblock["msgblock"]["line".$i++] = "\t\t".'<td id="'.$messageblock_arrow.'" class="file_messageblock_arrow_td"'.( $test ? '' : 'style="display:none;"' ).' onclick="wfu_headerdetails_toggle('.$sid.');">';
142
- $messageblock["msgblock"]["line".$i++] = "\t\t\t".'<input id="'.$messageblock_header.'_state" type="hidden" value="none" />';
143
- $messageblock["msgblock"]["line".$i++] = "\t\t\t".'<div id="'.$messageblock_arrow.'_up" class="file_messageblock_header_arrow_up" style="display:none;"></div>';
144
- $messageblock["msgblock"]["line".$i++] = "\t\t\t".'<div id="'.$messageblock_arrow.'_down" class="file_messageblock_header_arrow_down"></div>';
145
- $messageblock["msgblock"]["line".$i++] = "\t\t".'</td>';
146
- $messageblock["msgblock"]["line".$i++] = "\t".'</tr>';
147
- /* Construct the subheader block HTML text if exists */
148
- $messageblock["msgblock"]["line".$i++] = "\t".'<tr id="'.$messageblock_subheader.'" class="file_messageblock_subheader_tr" style="display:none;">';
149
- $messageblock["msgblock"]["line".$i++] = "\t\t".'<td colspan="3" id="'.$messageblock_subheader.'_td" class="file_messageblock_subheader_td">';
150
- $messageblock["msgblock"]["line".$i++] = "\t\t\t".'<div id="'.$messageblock_subheader.'_message" class="file_messageblock_subheader_message"'.( $test ? '' : 'style="display:none;"' ).'>';
151
- $messageblock["msgblock"]["line".$i++] = "\t\t\t\t".'<label id="'.$messageblock_subheader.'_messagelabel" class="file_messageblock_subheader_messagelabel">'.( $test ? WFU_TESTMESSAGE_MESSAGE : '' ).'</label>';
152
- $messageblock["msgblock"]["line".$i++] = "\t\t\t".'</div>';
153
- $messageblock["msgblock"]["line".$i++] = "\t\t\t".'<div id="'.$messageblock_subheader.'_adminmessage" class="file_messageblock_subheader_adminmessage"'.( $test ? '' : 'style="display:none;"' ).'>';
154
- $messageblock["msgblock"]["line".$i++] = "\t\t\t\t".'<label id="'.$messageblock_subheader.'_adminmessagelabel" class="file_messageblock_subheader_adminmessagelabel">'.( $test ? WFU_TESTMESSAGE_ADMINMESSAGE : '' ).'</label>';
155
- $messageblock["msgblock"]["line".$i++] = "\t\t\t".'</div>';
156
- $messageblock["msgblock"]["line".$i++] = "\t\t".'</td>';
157
- $messageblock["msgblock"]["line".$i++] = "\t".'</tr>';
158
- /* After the above tr the file blocks are appended by Javascript dynamically as additional tr elements
159
- If the plugin is in test mode, then two test file blocks are appended now */
160
- if ( $test ) {
161
- foreach ( $messageblock_file as $messageblock_file_part )
162
- $messageblock["msgblock"]["line".$i++] = $messageblock_file_part;
163
- }
164
- $messageblock["msgblock"]["line".$i++] = '</tbody></table>';
165
- /* Construct a div element that will hold the State10 header and use it in case JSON parse fails and upload results cannot be decoded */
166
- $messageblock["msgblock"]["line".$i++] = '<div id="'.$messageblock_header.'_safecontainer" style="display:none;">';
167
- foreach ( $messageblock_headers as $messageblock_header_part )
168
- $messageblock["msgblock"]["line".$i++] = strtr($messageblock_header_part, array(
169
- "[header_safe]" => "_safe",
170
- "[header_color]" => $header_styles["State10"]["color"],
171
- "[header_bgcolor]" => $header_styles["State10"]["bgcolor"],
172
- "[header_borcolor]" => $header_styles["State10"]["borcolor"],
173
- "[header_message]" => $header_styles["State10"]["message"]
174
- ));
175
- $messageblock["msgblock"]["line".$i++] = '</div>';
176
-
177
- /* Construct header HTML text for all upload states and save it to hidden input, to be used later on by Javascript to adjust the upload state dynamically */
178
- $messageblock_header_template = "";
179
- foreach ( $messageblock_headers as $messageblock_header_part )
180
- $messageblock_header_template .= $dlp.$messageblock_header_part;
181
- foreach ($ExposedStateIndex as $ii)
182
- $messageblock["header"]["State".$ii] = strtr($messageblock_header_template, array(
183
- "[header_safe]" => "",
184
- "[header_color]" => $header_styles["State".$ii]["color"],
185
- "[header_bgcolor]" => $header_styles["State".$ii]["bgcolor"],
186
- "[header_borcolor]" => $header_styles["State".$ii]["borcolor"],
187
- "[header_message]" => $header_styles["State".$ii]["message"]
188
- ));
189
- $messageblock_header_str = wfu_encode_array_to_string($messageblock["header"]);
190
- $messageblock["msgblock"]["line".$i++] = '<input id="'.$messageblock_header.'_states" type="hidden" value="'.$messageblock_header_str.'" />';
191
-
192
- /* Construct file HTML block template and save it to hidden div to be used later on by Javascript to add file results to the upload message dynamically */
193
- $messageblock_file_str = "";
194
- foreach ( $messageblock_file as $messageblock_file_part )
195
- $messageblock_file_str .= $dlp.$messageblock_file_part;
196
- $messageblock_file_str = wfu_plugin_encode_string($messageblock_file_str);
197
- $messageblock["msgblock"]["line".$i++] = '<input id="'.$messageblock_main.'_filetemplate" type="hidden" value="'.$messageblock_file_str.'" />';
198
- $messageblock["msgblock"]["line".$i++] = '<div id="'.$messageblock_main.'_door" style="display:none;"></div>';
199
-
200
- return $messageblock;
201
- }
202
-
203
- function wfu_prepare_message_colors($template) {
204
- $color_array = explode(",", $template);
205
- $colors['color'] = $color_array[0];
206
- $colors['bgcolor'] = $color_array[1];
207
- $colors['borcolor'] = $color_array[2];
208
- return $colors;
209
- }
210
-
211
- ?>
1
+ <?php
2
+
3
+ function wfu_prepare_message_block_skeleton($sid, $styles, $test) {
4
+ /* Prepare header styles for all upload states */
5
+ $header_styles["State0"] = wfu_prepare_message_colors(WFU_HEADERMESSAGECOLORS_STATE0);
6
+ $header_styles["State0"]['message'] = WFU_UPLOAD_STATE0;
7
+ $header_styles["State1"] = wfu_prepare_message_colors(WFU_HEADERMESSAGECOLORS_STATE1);
8
+ $header_styles["State1"]['message'] = WFU_UPLOAD_STATE1;
9
+ $header_styles["State2"] = wfu_prepare_message_colors(WFU_HEADERMESSAGECOLORS_STATE2);
10
+ $header_styles["State2"]['message'] = WFU_UPLOAD_STATE2;
11
+ $header_styles["State3"] = wfu_prepare_message_colors(WFU_HEADERMESSAGECOLORS_STATE3);
12
+ $header_styles["State3"]['message'] = WFU_UPLOAD_STATE3;
13
+ $header_styles["State4"] = wfu_prepare_message_colors(WFU_HEADERMESSAGECOLORS_STATE4);
14
+ $header_styles["State4"]['message'] = WFU_UPLOAD_STATE4;
15
+ $header_styles["State5"] = wfu_prepare_message_colors(WFU_HEADERMESSAGECOLORS_STATE5);
16
+ $header_styles["State5"]['message'] = WFU_UPLOAD_STATE5;
17
+ $header_styles["State5_singlefile"] = wfu_prepare_message_colors(WFU_HEADERMESSAGECOLORS_STATE5);
18
+ $header_styles["State5_singlefile"]['message'] = WFU_UPLOAD_STATE5_SINGLEFILE;
19
+ $header_styles["State6"] = wfu_prepare_message_colors(WFU_HEADERMESSAGECOLORS_STATE6);
20
+ $header_styles["State6"]['message'] = WFU_UPLOAD_STATE6;
21
+ $header_styles["State7"] = wfu_prepare_message_colors(WFU_HEADERMESSAGECOLORS_STATE7);
22
+ $header_styles["State7"]['message'] = WFU_UPLOAD_STATE7;
23
+ $header_styles["State7_singlefile"] = wfu_prepare_message_colors(WFU_HEADERMESSAGECOLORS_STATE7);
24
+ $header_styles["State7_singlefile"]['message'] = WFU_UPLOAD_STATE7_SINGLEFILE;
25
+ $header_styles["State8"] = wfu_prepare_message_colors(WFU_HEADERMESSAGECOLORS_STATE8);
26
+ $header_styles["State8"]['message'] = WFU_UPLOAD_STATE8;
27
+ $header_styles["State9"] = wfu_prepare_message_colors(WFU_HEADERMESSAGECOLORS_STATE9);
28
+ $header_styles["State9"]['message'] = WFU_UPLOAD_STATE9;
29
+ $header_styles["State10"] = wfu_prepare_message_colors(WFU_HEADERMESSAGECOLORS_STATE10);
30
+ $header_styles["State10"]['message'] = WFU_UPLOAD_STATE10;
31
+ $header_styles["State11"] = wfu_prepare_message_colors(WFU_HEADERMESSAGECOLORS_STATE11);
32
+ $header_styles["State11"]['message'] = WFU_UPLOAD_STATE11;
33
+ $ExposedStateIndex = array("0", "1", "2", "3", "4", "5", "5_singlefile", "6", "7", "7_singlefile", "8", "11");
34
+
35
+ /* set general variables */
36
+ $messageblock_main = 'wfu_messageblock_'.$sid;
37
+ $messageblock_header = 'wfu_messageblock_header_'.$sid;
38
+ $messageblock_arrow = 'wfu_messageblock_arrow_'.$sid;
39
+ $messageblock_subheader = 'wfu_messageblock_subheader_'.$sid;
40
+ $dlp = "\n\t\t\t\t\t\t\t";
41
+
42
+ /* Prepare header HTML template
43
+ Variables:
44
+ [header_safe]: suffix having the value "_safe" in case of State10 upload state, or empty otherwise,
45
+ [header_color]: text color of header,
46
+ [header_bgcolor]: background color of header,
47
+ [header_borcolor]: border color of header,
48
+ [header_message]: text shown in header */
49
+ $i = 1;
50
+ $messageblock_headers[$i++] = "\t\t\t".'<div id="'.$messageblock_header.'[header_safe]" class="file_messageblock_header" style="color:[header_color]; background-color:[header_bgcolor]; border:1px solid [header_borcolor];">';
51
+ $messageblock_headers[$i++] = "\t\t\t\t".'<label id="'.$messageblock_header.'_label[header_safe]" class="file_messageblock_header_label">[header_message]</label>';
52
+ $messageblock_headers[$i++] = "\t\t\t".'</div>';
53
+
54
+ /* Prepare the file block HTML template
55
+ Variables:
56
+ [file_id]: replaced by the id of the file (1, 2, ...),
57
+ [filenumber_display]: display:none if single file upload, otherwise empty,
58
+ [fileheader_color], [fileheader_bgcolor], [fileheader_borcolor], [fileheader_message]: replaced by the returned values,
59
+ [filesubheadermessage_display]: display:none if there is no message, otherwise empty,
60
+ [filesubheader_message]: replaced by the returned value,
61
+ [filesubheaderadminmessage_display]: display:none if there is no admin message, otherwise empty,
62
+ [filesubheader_adminmessage]: replaced by the returned value */
63
+ /* Prepare the files header block HTML template */
64
+ $i = 1;
65
+ $file_count = ( $test ? 2 : 1);
66
+ for ($ii = 1; $ii <= $file_count; $ii++) {
67
+ if ( $test ) {
68
+ $file_props = wfu_prepare_message_colors(WFU_TESTMESSAGECOLORS);
69
+ $file_id = $ii;
70
+ $filenumber_display = "";
71
+ $fileheader_color = $file_props['color'];
72
+ $fileheader_bgcolor = $file_props['bgcolor'];
73
+ $fileheader_borcolor = $file_props['borcolor'];
74
+ $fileheader_message = constant('WFU_TESTMESSAGE_FILE'.$ii.'_HEADER');
75
+ $filesubheadermessage_display = "";
76
+ $filesubheader_message = constant('WFU_TESTMESSAGE_FILE'.$ii.'_MESSAGE');
77
+ $filesubheaderadminmessage_display = "";
78
+ $filesubheader_adminmessage = constant('WFU_TESTMESSAGE_FILE'.$ii.'_ADMINMESSAGE');
79
+ }
80
+ else {
81
+ $file_id = '[file_id]';
82
+ $filenumber_display = '[filenumber_display]';
83
+ $fileheader_color = '[fileheader_color]';
84
+ $fileheader_bgcolor = '[fileheader_bgcolor]';
85
+ $fileheader_borcolor = '[fileheader_borcolor]';
86
+ $fileheader_message = '[fileheader_message]';
87
+ $filesubheadermessage_display = '[filesubheadermessage_display]';
88
+ $filesubheader_message = '[filesubheader_message]';
89
+ $filesubheaderadminmessage_display = '[filesubheaderadminmessage_display]';
90
+ $filesubheader_adminmessage = '[filesubheader_adminmessage]';
91
+ }
92
+ $messageblock_file[$i++] = "\t".'<tr id="'.$messageblock_main.'_'.$file_id.'" class="file_messageblock_fileheader_tr" style="display:none;">';
93
+ $messageblock_file[$i++] = "\t\t".'<td id="'.$messageblock_main.'_filenumber_'.$file_id.'" class="file_messageblock_filenumber_td"'.$filenumber_display.'>'.$file_id.'</td>';
94
+ $messageblock_file[$i++] = "\t\t".'<td id="'.$messageblock_header.'_container_'.$file_id.'" class="file_messageblock_fileheader_td">';
95
+ $messageblock_file[$i++] = "\t\t\t".'<div id="'.$messageblock_header.'_'.$file_id.'" class="file_messageblock_fileheader" style="color:'.$fileheader_color.'; background-color:'.$fileheader_bgcolor.'; border:1px solid '.$fileheader_borcolor.';">';
96
+ $messageblock_file[$i++] = "\t\t\t\t".'<label id="'.$messageblock_header.'_label_'.$file_id.'" class="file_messageblock_fileheader_label">'.$fileheader_message.'</label>';
97
+ /* The following hidden input holds state of arrow (open or close) */
98
+ $messageblock_file[$i++] = "\t\t\t\t".'<input id="'.$messageblock_header.'_state_'.$file_id.'" type="hidden" value="none" />';
99
+ $messageblock_file[$i++] = "\t\t\t".'</div>';
100
+ $messageblock_file[$i++] = "\t\t".'</td>';
101
+ /* Add a drop down arrow to the file header (file has always details to be shown) */
102
+ $messageblock_file[$i++] = "\t\t".'<td id="'.$messageblock_arrow.'_'.$file_id.'" class="file_messageblock_filearrow_td" onclick="wfu_filedetails_toggle('.$sid.', '.$file_id.');">';
103
+ $messageblock_file[$i++] = "\t\t\t".'<div id="'.$messageblock_arrow.'_up_'.$file_id.'" class="file_messageblock_file_arrow_up" style="display:none;"></div>';
104
+ $messageblock_file[$i++] = "\t\t\t".'<div id="'.$messageblock_arrow.'_down_'.$file_id.'" class="file_messageblock_file_arrow_down"></div>';
105
+ $messageblock_file[$i++] = "\t\t".'</td>';
106
+ $messageblock_file[$i++] = "\t".'</tr>';
107
+ /* Prepare the files subheader block HTML template */
108
+ $messageblock_file[$i++] = "\t".'<tr id="'.$messageblock_subheader.'_'.$file_id.'" class="file_messageblock_filesubheader_tr" style="display:none;">';
109
+ $messageblock_file[$i++] = "\t\t".'<td id="'.$messageblock_subheader.'_fileempty_'.$file_id.'" class="file_messageblock_filesubheaderempty_td"'.$filenumber_display.'></td>';
110
+ $messageblock_file[$i++] = "\t\t".'<td colspan="2" id="'.$messageblock_subheader.'_container_'.$file_id.'" class="file_messageblock_filesubheader_td">';
111
+ $messageblock_file[$i++] = "\t\t\t".'<div id="'.$messageblock_subheader.'_message_'.$file_id.'" class="file_messageblock_filesubheader_message"'.$filesubheadermessage_display.'>';
112
+ $messageblock_file[$i++] = "\t\t\t\t".'<label id="'.$messageblock_subheader.'_messagelabel_'.$file_id.'" class="file_messageblock_filesubheader_messagelabel">'.$filesubheader_message.'</label>';
113
+ $messageblock_file[$i++] = "\t\t\t".'</div>';
114
+ $messageblock_file[$i++] = "\t\t\t".'<div id="'.$messageblock_subheader.'_adminmessage_'.$file_id.'" class="file_messageblock_filesubheader_adminmessage"'.$filesubheaderadminmessage_display.'>';
115
+ $messageblock_file[$i++] = "\t\t\t\t".'<label id="'.$messageblock_subheader.'_adminmessagelabel_'.$file_id.'" class="file_messageblock_filesubheader_adminmessagelabel">'.$filesubheader_adminmessage.'</label>';
116
+ $messageblock_file[$i++] = "\t\t\t".'</div>';
117
+ $messageblock_file[$i++] = "\t\t".'</td>';
118
+ $messageblock_file[$i++] = "\t".'</tr>';
119
+ }
120
+
121
+ /* Construct the main header block HTML text
122
+ /* Construct the header block HTML text */
123
+ $i = 1;
124
+ $messageblock["msgblock"]["line".$i++] = '<table id="'.$messageblock_main.'" class="file_messageblock_table"'.$styles.'><tbody>';
125
+ $messageblock["msgblock"]["line".$i++] = "\t".'<tr id="'.$messageblock_header.'" class="file_messageblock_header_tr"'.( $test ? '' : 'style="display:none;"' ).'>';
126
+ $messageblock["msgblock"]["line".$i++] = "\t\t".'<td colspan="2" id="'.$messageblock_header.'_container" class="file_messageblock_header_td">';
127
+ /* Inside this td element the appropriate upload state HTML block is going to be inserted using Javascript
128
+ If the plugin is in test mode, then State9 HTML block is inserted now */
129
+ if ( $test ) {
130
+ foreach ( $messageblock_headers as $messageblock_header_part )
131
+ $messageblock["msgblock"]["line".$i++] = strtr($messageblock_header_part, array(
132
+ "[header_safe]" => "",
133
+ "[header_color]" => $header_styles["State9"]["color"],
134
+ "[header_bgcolor]" => $header_styles["State9"]["bgcolor"],
135
+ "[header_borcolor]" => $header_styles["State9"]["borcolor"],
136
+ "[header_message]" => $header_styles["State9"]["message"]
137
+ ));
138
+ }
139
+ $messageblock["msgblock"]["line".$i++] = "\t\t".'</td>';
140
+ /* Add a drop down arrow to the header */
141
+ $messageblock["msgblock"]["line".$i++] = "\t\t".'<td id="'.$messageblock_arrow.'" class="file_messageblock_arrow_td"'.( $test ? '' : 'style="display:none;"' ).' onclick="wfu_headerdetails_toggle('.$sid.');">';
142
+ $messageblock["msgblock"]["line".$i++] = "\t\t\t".'<input id="'.$messageblock_header.'_state" type="hidden" value="none" />';
143
+ $messageblock["msgblock"]["line".$i++] = "\t\t\t".'<div id="'.$messageblock_arrow.'_up" class="file_messageblock_header_arrow_up" style="display:none;"></div>';
144
+ $messageblock["msgblock"]["line".$i++] = "\t\t\t".'<div id="'.$messageblock_arrow.'_down" class="file_messageblock_header_arrow_down"></div>';
145
+ $messageblock["msgblock"]["line".$i++] = "\t\t".'</td>';
146
+ $messageblock["msgblock"]["line".$i++] = "\t".'</tr>';
147
+ /* Construct the subheader block HTML text if exists */
148
+ $messageblock["msgblock"]["line".$i++] = "\t".'<tr id="'.$messageblock_subheader.'" class="file_messageblock_subheader_tr" style="display:none;">';
149
+ $messageblock["msgblock"]["line".$i++] = "\t\t".'<td colspan="3" id="'.$messageblock_subheader.'_td" class="file_messageblock_subheader_td">';
150
+ $messageblock["msgblock"]["line".$i++] = "\t\t\t".'<div id="'.$messageblock_subheader.'_message" class="file_messageblock_subheader_message"'.( $test ? '' : 'style="display:none;"' ).'>';
151
+ $messageblock["msgblock"]["line".$i++] = "\t\t\t\t".'<label id="'.$messageblock_subheader.'_messagelabel" class="file_messageblock_subheader_messagelabel">'.( $test ? WFU_TESTMESSAGE_MESSAGE : '' ).'</label>';
152
+ $messageblock["msgblock"]["line".$i++] = "\t\t\t".'</div>';
153
+ $messageblock["msgblock"]["line".$i++] = "\t\t\t".'<div id="'.$messageblock_subheader.'_adminmessage" class="file_messageblock_subheader_adminmessage"'.( $test ? '' : 'style="display:none;"' ).'>';
154
+ $messageblock["msgblock"]["line".$i++] = "\t\t\t\t".'<label id="'.$messageblock_subheader.'_adminmessagelabel" class="file_messageblock_subheader_adminmessagelabel">'.( $test ? WFU_TESTMESSAGE_ADMINMESSAGE : '' ).'</label>';
155
+ $messageblock["msgblock"]["line".$i++] = "\t\t\t".'</div>';
156
+ $messageblock["msgblock"]["line".$i++] = "\t\t".'</td>';
157
+ $messageblock["msgblock"]["line".$i++] = "\t".'</tr>';
158
+ /* After the above tr the file blocks are appended by Javascript dynamically as additional tr elements
159
+ If the plugin is in test mode, then two test file blocks are appended now */
160
+ if ( $test ) {
161
+ foreach ( $messageblock_file as $messageblock_file_part )
162
+ $messageblock["msgblock"]["line".$i++] = $messageblock_file_part;
163
+ }
164
+ $messageblock["msgblock"]["line".$i++] = '</tbody></table>';
165
+ /* Construct a div element that will hold the State10 header and use it in case JSON parse fails and upload results cannot be decoded */
166
+ $messageblock["msgblock"]["line".$i++] = '<div id="'.$messageblock_header.'_safecontainer" style="display:none;">';
167
+ foreach ( $messageblock_headers as $messageblock_header_part )
168
+ $messageblock["msgblock"]["line".$i++] = strtr($messageblock_header_part, array(
169
+ "[header_safe]" => "_safe",
170
+ "[header_color]" => $header_styles["State10"]["color"],
171
+ "[header_bgcolor]" => $header_styles["State10"]["bgcolor"],
172
+ "[header_borcolor]" => $header_styles["State10"]["borcolor"],
173
+ "[header_message]" => $header_styles["State10"]["message"]
174
+ ));
175
+ $messageblock["msgblock"]["line".$i++] = '</div>';
176
+
177
+ /* Construct header HTML text for all upload states and save it to hidden input, to be used later on by Javascript to adjust the upload state dynamically */
178
+ $messageblock_header_template = "";
179
+ foreach ( $messageblock_headers as $messageblock_header_part )
180
+ $messageblock_header_template .= $dlp.$messageblock_header_part;
181
+ foreach ($ExposedStateIndex as $ii)
182
+ $messageblock["header"]["State".$ii] = strtr($messageblock_header_template, array(
183
+ "[header_safe]" => "",
184
+ "[header_color]" => $header_styles["State".$ii]["color"],
185
+ "[header_bgcolor]" => $header_styles["State".$ii]["bgcolor"],
186
+ "[header_borcolor]" => $header_styles["State".$ii]["borcolor"],
187
+ "[header_message]" => $header_styles["State".$ii]["message"]
188
+ ));
189
+ $messageblock_header_str = wfu_encode_array_to_string($messageblock["header"]);
190
+ $messageblock["msgblock"]["line".$i++] = '<input id="'.$messageblock_header.'_states" type="hidden" value="'.$messageblock_header_str.'" />';
191
+
192
+ /* Construct file HTML block template and save it to hidden div to be used later on by Javascript to add file results to the upload message dynamically */
193
+ $messageblock_file_str = "";
194
+ foreach ( $messageblock_file as $messageblock_file_part )
195
+ $messageblock_file_str .= $dlp.$messageblock_file_part;
196
+ $messageblock_file_str = wfu_plugin_encode_string($messageblock_file_str);
197
+ $messageblock["msgblock"]["line".$i++] = '<input id="'.$messageblock_main.'_filetemplate" type="hidden" value="'.$messageblock_file_str.'" />';
198
+ $messageblock["msgblock"]["line".$i++] = '<div id="'.$messageblock_main.'_door" style="display:none;"></div>';
199
+
200
+ return $messageblock;
201
+ }
202
+
203
+ function wfu_prepare_message_colors($template) {
204
+ $color_array = explode(",", $template);
205
+ $colors['color'] = $color_array[0];
206
+ $colors['bgcolor'] = $color_array[1];
207
+ $colors['borcolor'] = $color_array[2];
208
+ return $colors;
209
+ }
210
+
211
+ ?>
lib/wfu_processfiles.php CHANGED
@@ -1,458 +1,466 @@
1
- <?php
2
-
3
- function wfu_process_files($params, $method) {
4
- $sid = $params["uploadid"];
5
- $user = wp_get_current_user();
6
- if ( 0 == $user->ID ) {
7
- $user_login = "guest";
8
- $user_email = "";
9
- $is_admin = false;
10
- }
11
- else {
12
- $user_login = $user->user_login;
13
- $user_email = $user->user_email;
14
- $is_admin = current_user_can('manage_options');
15
- }
16
-
17
- $suppress_admin_messages = ( $params["adminmessages"] != "true" || !$is_admin );
18
- $success_count = 0;
19
- $warning_count = 0;
20
- $error_count = 0;
21
- $default_colors = wfu_prepare_message_colors(WFU_DEFAULTMESSAGECOLORS);
22
- $notify_only_filename_list = "";
23
- $notify_target_path_list = "";
24
- $notify_attachment_list = "";
25
- $uploadedfile = 'uploadedfile_'.$sid;
26
- $hiddeninput = 'hiddeninput_'.$sid;
27
- $allowed_patterns = explode(",",$params["uploadpatterns"]);
28
- $userdata_fields = $params["userdata_fields"];
29
- foreach ( $userdata_fields as $userdata_key => $userdata_field )
30
- $userdata_fields[$userdata_key]["value"] = ( isset($_POST[$hiddeninput.'_userdata_'.$userdata_key]) ? $_POST[$hiddeninput.'_userdata_'.$userdata_key] : "" );
31
- $params_output_array["version"] = "full";
32
- $params_output_array["general"]['shortcode_id'] = $sid;
33
- $params_output_array["general"]['unique_id'] = ( isset($_POST['unique_id']) ? $_POST['unique_id'] : "" );
34
- $params_output_array["general"]['state'] = 0;
35
- $params_output_array["general"]['files_count'] = 0;
36
- $params_output_array["general"]['update_wpfilebase'] = "";
37
- $params_output_array["general"]['redirect_link'] = "";
38
- $params_output_array["general"]['upload_finish_time'] = 0;
39
- $params_output_array["general"]['message'] = "";
40
- $params_output_array["general"]['message_type'] = "";
41
- $params_output_array["general"]['admin_messages']['wpfilebase'] = "";
42
- $params_output_array["general"]['admin_messages']['notify'] = "";
43
- $params_output_array["general"]['admin_messages']['redirect'] = "";
44
- $params_output_array["general"]['admin_messages']['other'] = "";
45
- $params_output_array["general"]['errors']['wpfilebase'] = "";
46
- $params_output_array["general"]['errors']['notify'] = "";
47
- $params_output_array["general"]['errors']['redirect'] = "";
48
- $params_output_array["general"]['color'] = $default_colors['color'];
49
- $params_output_array["general"]['bgcolor'] = $default_colors['bgcolor'];
50
- $params_output_array["general"]['borcolor'] = $default_colors['borcolor'];
51
- $params_output_array["general"]['notify_only_filename_list'] = "";
52
- $params_output_array["general"]['notify_target_path_list'] = "";
53
- $params_output_array["general"]['notify_attachment_list'] = "";
54
- $params_output_array["general"]['fail_message'] = "";
55
- $params_output_array["general"]['fail_admin_message'] = "";
56
- /* safe_output is a minimized version of params_output_array, that is passed as text, in case JSON parse fails
57
- its data are separated by semicolon (;) and are the following:
58
- upload state: the upload state number
59
- default colors: the default color, bgcolor and borcolor values, separated by comma(,)
60
- file_count: the number of files processed
61
- filedata: message type, header, message and admin message of each file, encoded and separated by comma (,) */
62
- $params_output_array["general"]['safe_output'] = "";
63
-
64
- /* adjust $uploadedfile variable (holding file data) if this is a redirection caused because the browser of the user could not handle AJAX upload */
65
- if ( isset($_FILES[$uploadedfile.'_redirected']) ) $uploadedfile .= '_redirected';
66
- /* notify admin if this is a redirection caused because the browser of the user could not handle AJAX upload */
67
- $params_output_array["general"]['admin_messages']['other'] = $params['adminerrors'];
68
-
69
- if ( isset($_FILES[$uploadedfile]['error']) ) {
70
- $files_count = 1;
71
- }
72
- else $files_count = 0;
73
- $params_output_array["general"]['files_count'] = $files_count;
74
-
75
- /* append subfolder name to upload path */
76
- if ( $params["askforsubfolders"] == "true" && $params['subdir_selection_index'] >= 0 ) {
77
- if ( substr($params["uploadpath"], -1, 1) == "/" ) $params["uploadpath"] .= $params['subfoldersarray'][$params['subdir_selection_index']];
78
- else $params["uploadpath"] .= '/'.$params['subfoldersarray'][$params['subdir_selection_index']];
79
- }
80
-
81
- if ( $files_count == 1 ) {
82
-
83
- foreach ( $_FILES[$uploadedfile] as $key => $prop )
84
- $fileprops[$key] = $prop;
85
-
86
- $upload_path_ok = false;
87
- $allowed_file_ok = false;
88
- $size_file_ok = false;
89
- $file_output['color'] = $default_colors['color'];
90
- $file_output['bgcolor'] = $default_colors['bgcolor'];
91
- $file_output['borcolor'] = $default_colors['borcolor'];
92
- $file_output['header'] = "";
93
- $file_output['message'] = "";
94
- $file_output['message_type'] = "";
95
- $file_output['admin_messages'] = "";
96
-
97
- /* Get uploaded file size in Mbytes */
98
- $upload_file_size = filesize($fileprops['tmp_name']) / 1024 / 1024;
99
-
100
- if ( $upload_file_size > 0 ) {
101
-
102
- /* Check if upload path exist */
103
- if ( is_dir( wfu_upload_plugin_full_path($params) ) ) {
104
- $upload_path_ok = true;
105
- }
106
- /* Attempt to create path if user has selected to do so */
107
- else if ( $params["createpath"] == "true" ) {
108
- $wfu_create_directory_ret = wfu_create_directory(wfu_upload_plugin_full_path($params), $params["accessmethod"], $params["ftpinfo"]);
109
- if ( $wfu_create_directory_ret != "" ) {
110
- $file_output['admin_messages'] = wfu_join_strings("<br />", $file_output['admin_messages'], $wfu_create_directory_ret);
111
- }
112
- if ( is_dir( wfu_upload_plugin_full_path($params) ) ) {
113
- $upload_path_ok = true;
114
- }
115
- }
116
-
117
- /* File name control */
118
- foreach ($allowed_patterns as $allowed_pattern) {
119
- if ( wfu_upload_plugin_wildcard_match( $allowed_pattern, $fileprops['name']) ) {
120
- $allowed_file_ok = true;
121
- break ;
122
- }
123
- }
124
-
125
- /* File size control */
126
- if ( $upload_file_size <= $params["maxsize"] ) {
127
- $size_file_ok = true;
128
- }
129
-
130
- if ( !$upload_path_ok or !$allowed_file_ok or !$size_file_ok ) {
131
- $file_output['message_type'] = "error";
132
- $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_ERROR_UPLOAD_FAILED);
133
-
134
- if ( !$upload_path_ok ) $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_ERROR_DIR_EXIST);
135
- if ( !$allowed_file_ok ) $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_ERROR_FILE_ALLOW);
136
- if ( !$size_file_ok ) $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_ERROR_FILE_PLUGIN_SIZE);
137
- }
138
- }
139
- else {
140
- // This block is executed when there is an error
141
- $upload_error = $fileprops['error'];
142
- if ( $upload_error == 1 ) {
143
- $message_text = WFU_ERROR_FILE_PHP_SIZE;
144
- $file_output['admin_messages'] = wfu_join_strings("<br />", $file_output['admin_messages'], WFU_ERROR_ADMIN_FILE_PHP_SIZE);
145
- }
146
- elseif ( $upload_error == 2 ) $message_text = WFU_ERROR_FILE_HTML_SIZE;
147
- elseif ( $upload_error == 3 ) $message_text = WFU_ERROR_FILE_PARTIAL;
148
- elseif ( $upload_error == 4 ) $message_text = WFU_ERROR_FILE_NOTHING;
149
- elseif ( $upload_error == 6 ) $message_text = WFU_ERROR_DIR_NOTEMP;
150
- elseif ( $upload_error == 7 ) $message_text = WFU_ERROR_FILE_WRITE;
151
- elseif ( $upload_error == 8 ) $message_text = WFU_ERROR_UPLOAD_STOPPED;
152
- else {
153
- $upload_time_limit = ini_get("max_input_time");
154
- $params_output_array["general"]['upload_finish_time'] = $params["upload_start_time"] + $upload_time_limit * 1000;
155
- $message_text = WFU_ERROR_FILE_PHP_TIME;
156
- $file_output['admin_messages'] = wfu_join_strings("<br />", $file_output['admin_messages'], WFU_ERROR_ADMIN_FILE_PHP_TIME);
157
- }
158
- $file_output['message_type'] = "error";
159
- $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], $message_text);
160
- }
161
-
162
- if ( $upload_path_ok and $allowed_file_ok and $size_file_ok ) {
163
-
164
- if ( is_uploaded_file($fileprops['tmp_name']) ) {
165
- $file_copied = false;
166
- $message_processed = false;
167
- $source_path = $fileprops['tmp_name'];
168
- $only_filename = wfu_upload_plugin_clean( $fileprops['name'] );
169
- $target_path = wfu_upload_plugin_full_path($params).$only_filename;
170
-
171
- $search = array ('/%filename%/', '/%filepath%/');
172
- $replace = array ($only_filename, $target_path);
173
- $success_message = preg_replace($search, $replace, $params["successmessage"]);
174
-
175
- if ($source_path) {
176
- $file_exists = file_exists($target_path);
177
- if ( !$file_exists || $params["dublicatespolicy"] == "" || $params["dublicatespolicy"] == "overwrite" ) {
178
- //redirect echo in internal buffer to receive and process any unwanted warning messages from wfu_upload_file
179
- ob_start();
180
- ob_clean();
181
- $wfu_upload_file_ret = wfu_upload_file($source_path, $target_path, $params["accessmethod"], $params["ftpinfo"]);
182
- $file_copied = $wfu_upload_file_ret["uploaded"];
183
- //process warning messages from wfu_upload_file
184
- $echo_message = ob_get_contents();
185
- //finish redirecting of echo to internal buffer
186
- ob_end_clean();
187
- if ( $echo_message != "" && !$file_copied ) {
188
- $file_output['message_type'] = "error";
189
- if ( stristr($echo_message, "warning") && stristr($echo_message, "permission denied") && stristr($echo_message, "unable to move") ) {
190
- $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_ERROR_DIR_PERMISSION);
191
- $file_output['admin_messages'] = wfu_join_strings("<br />", $file_output['admin_messages'], WFU_ERROR_ADMIN_DIR_PERMISSION);
192
- }
193
- else {
194
- $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_ERROR_FILE_MOVE);
195
- $file_output['admin_messages'] = wfu_join_strings("<br />", $file_output['admin_messages'], strip_tags($echo_message));
196
- }
197
- $message_processed = true;
198
- }
199
- if ( $wfu_upload_file_ret["admin_message"] != "" ) {
200
- $file_output['admin_messages'] = wfu_join_strings("<br />", $file_output['admin_messages'], $wfu_upload_file_ret["admin_message"]);
201
- }
202
- }
203
- else if ( $file_exists && $params["dublicatespolicy"] == "maintain both" ) {
204
- $full_path = wfu_upload_plugin_full_path($params);
205
- $name_part = $only_filename;
206
- $ext_part = "";
207
- $dot_pos = strrpos($name_part, ".");
208
- if ( $dot_pos ) {
209
- $ext_part = substr($name_part, $dot_pos);
210
- $name_part = substr($name_part, 0, $dot_pos);
211
- }
212
- if ( $params["uniquepattern"] != "datetimestamp" ) {
213
- $unique_ind = 1;
214
- do {
215
- $unique_ind += 1;
216
- $only_filename = $name_part . "(" . $unique_ind . ")" . $ext_part;
217
- $target_path = $full_path . $only_filename;
218
- }
219
- while ( file_exists($target_path) );
220
- }
221
- else {
222
- $current_datetime = gmdate("U") - 1;
223
- do {
224
- $current_datetime += 1;
225
- $only_filename = $name_part . "-" . gmdate("YmdHis", $current_datetime) . $ext_part;
226
- $target_path = $full_path . $only_filename;
227
- }
228
- while ( file_exists($target_path) );
229
- }
230
- //redirect echo in internal buffer to receive and process any unwanted warning messages from move_uploaded_file
231
- ob_start();
232
- ob_clean();
233
- $wfu_upload_file_ret = wfu_upload_file($source_path, $target_path, $params["accessmethod"], $params["ftpinfo"]);
234
- $file_copied = $wfu_upload_file_ret["uploaded"];
235
- //process warning messages from move_uploaded_file
236
- $echo_message = ob_get_contents();
237
- //finish redirecting of echo to internal buffer
238
- ob_end_clean();
239
- if ( $echo_message != "" && !$file_copied ) {
240
- $file_output['message_type'] = "error";
241
- if ( stristr($echo_message, "warning") && stristr($echo_message, "permission denied") && stristr($echo_message, "unable to move") ) {
242
- $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_ERROR_DIR_PERMISSION);
243
- $file_output['admin_messages'] = wfu_join_strings("<br />", $file_output['admin_messages'], WFU_ERROR_ADMIN_DIR_PERMISSION);
244
- }
245
- else {
246
- $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_ERROR_FILE_MOVE);
247
- $file_output['admin_messages'] = wfu_join_strings("<br />n", $file_output['admin_messages'], strip_tags($echo_message));
248
- }
249
- $message_processed = true;
250
- }
251
- if ( $wfu_upload_file_ret["admin_message"] != "" ) {
252
- $file_output['admin_messages'] = wfu_join_strings("<br />", $file_output['admin_messages'], $wfu_upload_file_ret["admin_message"]);
253
- }
254
- }
255
- else {
256
- $file_output['message_type'] = "error";
257
- $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_WARNING_FILE_EXISTS);
258
- $message_processed = true;
259
- $file_copied = false;
260
- }
261
- }
262
-
263
- if ( $file_copied ) {
264
- /* prepare email notification parameters if email notification is enabled */
265
- if ( $params["notify"] == "true" ) {
266
- $notify_only_filename_list .= ( $notify_only_filename_list == "" ? "" : ", " ).$only_filename;
267
- $notify_target_path_list .= ( $notify_target_path_list == "" ? "" : ", " ).$target_path;
268
- if ( $params["attachfile"] == "true" )
269
- $notify_attachment_list .= ( $notify_attachment_list == "" ? "" : "," ).$target_path;
270
- }
271
-
272
- /* prepare redirect link if redirection is enabled */
273
- if ( $params["redirect"] == "true" ) {
274
- /* Define dynamic redirect link from variables */
275
- $search = array ('/%filename%/');
276
- $replace = array ($only_filename);
277
- $params_output_array["general"]['redirect_link'] = trim(preg_replace($search, $replace, $params["redirectlink"]));
278
- }
279
-
280
- if ( !$message_processed ) {
281
- $file_output['message_type'] = "success";
282
- }
283
- }
284
- else if ( !$message_processed ) {
285
- $file_output['message_type'] = "error";
286
- $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_ERROR_UNKNOWN);
287
- }
288
-
289
- /* Delete temporary file (in tmp directory) */
290
- // unlink($source_path);
291
- }
292
- else {
293
- $file_output['message_type'] = "error";
294
- $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_ERROR_UNKNOWN);
295
- }
296
- }
297
-
298
- /* last check of output file status */
299
- if ( $file_output['message_type'] == "" ) {
300
- if ( $file_copied ) $file_output['message_type'] = "success";
301
- else {
302
- $file_output['message_type'] = "error";
303
- $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_ERROR_UNKNOWN);
304
- }
305
- }
306
-
307
- /* suppress any admin messages if user is not administrator or adminmessages is not activated */
308
- if ( $suppress_admin_messages ) $file_output['admin_messages'] = "";
309
-
310
- /* set file status to "warning" if the file has been uploaded but there are messages */
311
- if ( $file_output['message_type'] == "success" ) {
312
- if ( $file_output['message'] != "" || $file_output['admin_messages'] != "" )
313
- $file_output['message_type'] = "warning";
314
- }
315
-
316
- /* adjust message details and colors according to file result */
317
- /* FileResult: A */
318
- $search = array ('/%username%/', '/%useremail%/', '/%filename%/', '/%filepath%/');
319
- $replace = array ($user_login, ( $user_email == "" ? "no email" : $user_email ), $only_filename, $target_path);
320
- if ( $file_output['message_type'] == "success" ) {
321
- $success_count ++;
322
- $color_array = explode(",", $params['successmessagecolors']);
323
- $file_output['color'] = $color_array[0];
324
- $file_output['bgcolor'] = $color_array[1];
325
- $file_output['borcolor'] = $color_array[2];
326
- $file_output['header'] = preg_replace($search, $replace, WFU_SUCCESSMESSAGE);
327
- /* prepare details of successful file upload, visible only to administrator */
328
- $file_output['admin_messages'] = wfu_join_strings("<br />", preg_replace($search, $replace, WFU_SUCCESSMESSAGE_DETAILS), $file_output['admin_messages']);
329
- }
330
- /* FileResult: B */
331
- elseif ( $file_output['message_type'] == "warning" ) {
332
- $warning_count ++;
333
- $color_array = explode(",", $params['warningmessagecolors']);
334
- $file_output['color'] = $color_array[0];
335
- $file_output['bgcolor'] = $color_array[1];
336
- $file_output['borcolor'] = $color_array[2];
337
- $file_output['header'] = preg_replace($search, $replace, WFU_WARNINGMESSAGE);
338
- /* prepare and prepend details of successful file upload, visible only to administrator */
339
- $file_output['admin_messages'] = wfu_join_strings("<br />", preg_replace($search, $replace, WFU_SUCCESSMESSAGE_DETAILS), $file_output['admin_messages']);
340
- }
341
- /* FileResult: C */
342
- elseif ( $file_output['message_type'] == "error" ) {
343
- $error_count ++;
344
- $color_array = explode(",", $params['failmessagecolors']);
345
- $file_output['color'] = $color_array[0];
346
- $file_output['bgcolor'] = $color_array[1];
347
- $file_output['borcolor'] = $color_array[2];
348
- /* define variables that were not defined before due to error */
349
- $only_filename = wfu_upload_plugin_clean( $fileprops['name'] );
350
- $target_path = wfu_upload_plugin_full_path($params).$only_filename;
351
- $replace = array ($user_login, ( $user_email == "" ? "no email" : $user_email ), $only_filename, $target_path);
352
- $file_output['header'] = preg_replace($search, $replace, WFU_ERRORMESSAGE);
353
- /* prepare and prepend details of failed file upload, visible only to administrator */
354
- $file_output['admin_messages'] = wfu_join_strings("<br />", preg_replace($search, $replace, WFU_FAILMESSAGE_DETAILS), $file_output['admin_messages']);
355
- }
356
-
357
- /* suppress again any admin messages if user is not administrator or adminmessages is not activated */
358
- if ( $suppress_admin_messages ) $file_output['admin_messages'] = "";
359
-
360
- $params_output_array[0] = $file_output;
361
- }
362
-
363
- $somefiles_Ok = ( ( $warning_count + $success_count ) > 0 );
364
- $allfiles_Ok = ( $somefiles_Ok && ( $error_count == 0 ) );
365
-
366
- /* Prepare WPFileBase Plugin update url, if this option has been selected and only if at least one file has been successfully uploaded.
367
- Execution will happen only if accumulated $params_output_array["general"]['update_wpfilebase'] is not empty */
368
- if ( $params["filebaselink"] == "true" ) {
369
- if ( $somefiles_Ok ) {
370
- $filebaseurl = site_url();
371
- if ( substr($filebaseurl, -1, 1) == "/" ) $filebaseurl = substr($filebaseurl, 0, strlen($filebaseurl) - 1);
372
- /* if the following variable is not empty, then WPFileBase Plugin update must be executed
373
- and any admin messages must be suppressed */
374
- $params_output_array["general"]['update_wpfilebase'] = $filebaseurl;
375
- }
376
- else {
377
- $params_output_array["general"]['admin_messages']['wpfilebase'] = WFU_WARNING_WPFILEBASE_NOTUPDATED_NOFILES;
378
- $params_output_array["general"]['errors']['wpfilebase'] = "error";
379
- }
380
- }
381
-
382
- /* Prepare email notification parameters if email notification is enabled and only if at least one file has been successfully uploaded
383
- if $method = "no-ajax" then send the email to the recipients
384
- if $method = "ajax" then return the notification parameters to the handler for further processing
385
- In case of ajax, execution will happen only if accumulated notify_only_filename_list is not empty */
386
- if ( $params["notify"] == "true" ) {
387
- /* verify that there are recipients */
388
- $notifyrecipients = trim(preg_replace('/%useremail%/', $user_email, $params["notifyrecipients"]));
389
- if ( $notifyrecipients != "" ) {
390
- if ( $somefiles_Ok ) {
391
- if ( $method == 'no_ajax' ) {
392
- $send_error = wfu_send_notification_email($user, $notify_only_filename_list, $notify_target_path_list, $notify_attachment_list, $userdata_fields, $params);
393
- if ( $send_error != "" ) {
394
- $params_output_array["general"]['admin_messages']['notify'] = $send_error;
395
- $params_output_array["general"]['errors']['notify'] = "error";
396
- }
397
- }
398
- else {
399
- /* if the following variable is not empty, then email notification must be sent
400
- and any admin messages must be suppressed */
401
- $params_output_array["general"]['notify_only_filename_list'] = $notify_only_filename_list;
402
- $params_output_array["general"]['notify_target_path_list'] = $notify_target_path_list;
403
- $params_output_array["general"]['notify_attachment_list'] = $notify_attachment_list;
404
- }
405
- }
406
- else {
407
- $params_output_array["general"]['admin_messages']['notify'] = WFU_WARNING_NOTIFY_NOTSENT_NOFILES;
408
- $params_output_array["general"]['errors']['notify'] = "error";
409
- }
410
- }
411
- else {
412
- $params_output_array["general"]['admin_messages']['notify'] = WFU_WARNING_NOTIFY_NOTSENT_NORECIPIENTS;
413
- $params_output_array["general"]['errors']['notify'] = "error";
414
- }
415
- }
416
-
417
- /* Prepare redirect link if redirection is enabled and only if all files have been successfully uploaded
418
- Execution will happen only if accumulated redirect_link is not empty and accumulated redirect errors are empty */
419
- if ( $params["redirect"] == "true" ) {
420
- if ( $params_output_array["general"]['redirect_link'] == "" ) {
421
- $params_output_array["general"]['admin_messages']['redirect'] = WFU_WARNING_REDIRECT_NOTEXECUTED_EMPTY;
422
- $params_output_array["general"]['errors']['redirect'] = "error";
423
- }
424
- elseif ( !$allfiles_Ok ) {
425
- $params_output_array["general"]['admin_messages']['redirect'] = WFU_WARNING_REDIRECT_NOTEXECUTED_FILESFAILED;
426
- $params_output_array["general"]['errors']['redirect'] = "error";
427
- }
428
- }
429
-
430
- /* suppress any admin messages if user is not administrator or adminmessages is not activated */
431
- if ( $suppress_admin_messages ) {
432
- $params_output_array["general"]['admin_messages']['wpfilebase'] = "";
433
- $params_output_array["general"]['admin_messages']['notify'] = "";
434
- $params_output_array["general"]['admin_messages']['redirect'] = "";
435
- $params_output_array["general"]['admin_messages']['other'] = "";
436
- }
437
-
438
- /* Calculate upload state from file results */
439
- if ( $allfiles_Ok && ( $warning_count == 0 ) ) $params_output_array["general"]['state'] = 4;
440
- else if ( $allfiles_Ok ) $params_output_array["general"]['state'] = 5;
441
- else if ( $somefiles_Ok ) $params_output_array["general"]['state'] = 6; //only valid in no-ajax method
442
- else if ( !$somefiles_Ok && $error_count > 0 ) $params_output_array["general"]['state'] = 7;
443
- else $params_output_array["general"]['state'] = 8;
444
-
445
- /* construct safe output */
446
- $sout = $params_output_array["general"]['state'].";".WFU_DEFAULTMESSAGECOLORS.";".$files_count;
447
- for ($i = 0; $i < $files_count; $i++) {
448
- $sout .= ";".wfu_plugin_encode_string($file_output['message_type']);
449
- $sout .= ",".wfu_plugin_encode_string($file_output['header']);
450
- $sout .= ",".wfu_plugin_encode_string($file_output['message']);
451
- $sout .= ",".wfu_plugin_encode_string($file_output['admin_messages']);
452
- }
453
- $params_output_array["general"]['safe_output'] = $sout;
454
-
455
- return $params_output_array;
456
- }
457
-
458
- ?>
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function wfu_process_files($params, $method) {
4
+ $sid = $params["uploadid"];
5
+ $user = wp_get_current_user();
6
+ if ( 0 == $user->ID ) {
7
+ $user_login = "guest";
8
+ $user_email = "";
9
+ $is_admin = false;
10
+ }
11
+ else {
12
+ $user_login = $user->user_login;
13
+ $user_email = $user->user_email;
14
+ $is_admin = current_user_can('manage_options');
15
+ }
16
+
17
+ $suppress_admin_messages = ( $params["adminmessages"] != "true" || !$is_admin );
18
+ $success_count = 0;
19
+ $warning_count = 0;
20
+ $error_count = 0;
21
+ $default_colors = wfu_prepare_message_colors(WFU_DEFAULTMESSAGECOLORS);
22
+ $notify_only_filename_list = "";
23
+ $notify_target_path_list = "";
24
+ $notify_attachment_list = "";
25
+ $uploadedfile = 'uploadedfile_'.$sid;
26
+ $hiddeninput = 'hiddeninput_'.$sid;
27
+ $allowed_patterns = explode(",",$params["uploadpatterns"]);
28
+ $userdata_fields = $params["userdata_fields"];
29
+ foreach ( $userdata_fields as $userdata_key => $userdata_field )
30
+ $userdata_fields[$userdata_key]["value"] = ( isset($_POST[$hiddeninput.'_userdata_'.$userdata_key]) ? $_POST[$hiddeninput.'_userdata_'.$userdata_key] : "" );
31
+ $params_output_array["version"] = "full";
32
+ $params_output_array["general"]['shortcode_id'] = $sid;
33
+ $params_output_array["general"]['unique_id'] = ( isset($_POST['unique_id']) ? $_POST['unique_id'] : "" );
34
+ $params_output_array["general"]['state'] = 0;
35
+ $params_output_array["general"]['files_count'] = 0;
36
+ $params_output_array["general"]['update_wpfilebase'] = "";
37
+ $params_output_array["general"]['redirect_link'] = "";
38
+ $params_output_array["general"]['upload_finish_time'] = 0;
39
+ $params_output_array["general"]['message'] = "";
40
+ $params_output_array["general"]['message_type'] = "";
41
+ $params_output_array["general"]['admin_messages']['wpfilebase'] = "";
42
+ $params_output_array["general"]['admin_messages']['notify'] = "";
43
+ $params_output_array["general"]['admin_messages']['redirect'] = "";
44
+ $params_output_array["general"]['admin_messages']['other'] = "";
45
+ $params_output_array["general"]['errors']['wpfilebase'] = "";
46
+ $params_output_array["general"]['errors']['notify'] = "";
47
+ $params_output_array["general"]['errors']['redirect'] = "";
48
+ $params_output_array["general"]['color'] = $default_colors['color'];
49
+ $params_output_array["general"]['bgcolor'] = $default_colors['bgcolor'];
50
+ $params_output_array["general"]['borcolor'] = $default_colors['borcolor'];
51
+ $params_output_array["general"]['notify_only_filename_list'] = "";
52
+ $params_output_array["general"]['notify_target_path_list'] = "";
53
+ $params_output_array["general"]['notify_attachment_list'] = "";
54
+ $params_output_array["general"]['fail_message'] = "";
55
+ $params_output_array["general"]['fail_admin_message'] = "";
56
+ /* safe_output is a minimized version of params_output_array, that is passed as text, in case JSON parse fails
57
+ its data are separated by semicolon (;) and are the following:
58
+ upload state: the upload state number
59
+ default colors: the default color, bgcolor and borcolor values, separated by comma(,)
60
+ file_count: the number of files processed
61
+ filedata: message type, header, message and admin message of each file, encoded and separated by comma (,) */
62
+ $params_output_array["general"]['safe_output'] = "";
63
+
64
+ /* adjust $uploadedfile variable (holding file data) if this is a redirection caused because the browser of the user could not handle AJAX upload */
65
+ if ( isset($_FILES[$uploadedfile.'_redirected']) ) $uploadedfile .= '_redirected';
66
+ /* notify admin if this is a redirection caused because the browser of the user could not handle AJAX upload */
67
+ $params_output_array["general"]['admin_messages']['other'] = $params['adminerrors'];
68
+
69
+ if ( isset($_FILES[$uploadedfile]['error']) ) {
70
+ $files_count = 1;
71
+ }
72
+ else $files_count = 0;
73
+ $params_output_array["general"]['files_count'] = $files_count;
74
+
75
+ /* append subfolder name to upload path */
76
+ if ( $params["askforsubfolders"] == "true" && $params['subdir_selection_index'] >= 0 ) {
77
+ if ( substr($params["uploadpath"], -1, 1) == "/" ) $params["uploadpath"] .= $params['subfoldersarray'][$params['subdir_selection_index']];
78
+ else $params["uploadpath"] .= '/'.$params['subfoldersarray'][$params['subdir_selection_index']];
79
+ }
80
+
81
+ if ( $files_count == 1 ) {
82
+
83
+ foreach ( $_FILES[$uploadedfile] as $key => $prop )
84
+ $fileprops[$key] = $prop;
85
+
86
+ $upload_path_ok = false;
87
+ $allowed_file_ok = false;
88
+ $size_file_ok = false;
89
+ $file_output['color'] = $default_colors['color'];
90
+ $file_output['bgcolor'] = $default_colors['bgcolor'];
91
+ $file_output['borcolor'] = $default_colors['borcolor'];
92
+ $file_output['header'] = "";
93
+ $file_output['message'] = "";
94
+ $file_output['message_type'] = "";
95
+ $file_output['admin_messages'] = "";
96
+
97
+ /* Get uploaded file size in Mbytes */
98
+ $upload_file_size = filesize($fileprops['tmp_name']) / 1024 / 1024;
99
+
100
+ if ( $upload_file_size > 0 ) {
101
+
102
+ /* Check if upload path exist */
103
+ if ( is_dir( wfu_upload_plugin_full_path($params) ) ) {
104
+ $upload_path_ok = true;
105
+ }
106
+ /* Attempt to create path if user has selected to do so */
107
+ else if ( $params["createpath"] == "true" ) {
108
+ $wfu_create_directory_ret = wfu_create_directory(wfu_upload_plugin_full_path($params), $params["accessmethod"], $params["ftpinfo"]);
109
+ if ( $wfu_create_directory_ret != "" ) {
110
+ $file_output['admin_messages'] = wfu_join_strings("<br />", $file_output['admin_messages'], $wfu_create_directory_ret);
111
+ }
112
+ if ( is_dir( wfu_upload_plugin_full_path($params) ) ) {
113
+ $upload_path_ok = true;
114
+ }
115
+ }
116
+
117
+ /* File name control */
118
+ foreach ($allowed_patterns as $allowed_pattern) {
119
+ if ( wfu_upload_plugin_wildcard_match( $allowed_pattern, $fileprops['name']) ) {
120
+ $allowed_file_ok = true;
121
+ break ;
122
+ }
123
+ }
124
+
125
+ /* File size control */
126
+ if ( $upload_file_size <= $params["maxsize"] ) {
127
+ $size_file_ok = true;
128
+ }
129
+
130
+ if ( !$upload_path_ok or !$allowed_file_ok or !$size_file_ok ) {
131
+ $file_output['message_type'] = "error";
132
+ $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_ERROR_UPLOAD_FAILED);
133
+
134
+ if ( !$upload_path_ok ) $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_ERROR_DIR_EXIST);
135
+ if ( !$allowed_file_ok ) $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_ERROR_FILE_ALLOW);
136
+ if ( !$size_file_ok ) $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_ERROR_FILE_PLUGIN_SIZE);
137
+ }
138
+ }
139
+ else {
140
+ // This block is executed when there is an error
141
+ $upload_error = $fileprops['error'];
142
+ if ( $upload_error == 1 ) {
143
+ $message_text = WFU_ERROR_FILE_PHP_SIZE;
144
+ $file_output['admin_messages'] = wfu_join_strings("<br />", $file_output['admin_messages'], WFU_ERROR_ADMIN_FILE_PHP_SIZE);
145
+ }
146
+ elseif ( $upload_error == 2 ) $message_text = WFU_ERROR_FILE_HTML_SIZE;
147
+ elseif ( $upload_error == 3 ) $message_text = WFU_ERROR_FILE_PARTIAL;
148
+ elseif ( $upload_error == 4 ) $message_text = WFU_ERROR_FILE_NOTHING;
149
+ elseif ( $upload_error == 6 ) $message_text = WFU_ERROR_DIR_NOTEMP;
150
+ elseif ( $upload_error == 7 ) $message_text = WFU_ERROR_FILE_WRITE;
151
+ elseif ( $upload_error == 8 ) $message_text = WFU_ERROR_UPLOAD_STOPPED;
152
+ else {
153
+ $upload_time_limit = ini_get("max_input_time");
154
+ $params_output_array["general"]['upload_finish_time'] = $params["upload_start_time"] + $upload_time_limit * 1000;
155
+ $message_text = WFU_ERROR_FILE_PHP_TIME;
156
+ $file_output['admin_messages'] = wfu_join_strings("<br />", $file_output['admin_messages'], WFU_ERROR_ADMIN_FILE_PHP_TIME);
157
+ }
158
+ $file_output['message_type'] = "error";
159
+ $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], $message_text);
160
+ }
161
+
162
+ if ( $upload_path_ok and $allowed_file_ok and $size_file_ok ) {
163
+
164
+ if ( is_uploaded_file($fileprops['tmp_name']) ) {
165
+ $file_copied = false;
166
+ $message_processed = false;
167
+ $source_path = $fileprops['tmp_name'];
168
+ $only_filename = wfu_upload_plugin_clean( $fileprops['name'] );
169
+ $target_path = wfu_upload_plugin_full_path($params).$only_filename;
170
+
171
+ $search = array ('/%filename%/', '/%filepath%/');
172
+ $replace = array ($only_filename, $target_path);
173
+ $success_message = preg_replace($search, $replace, $params["successmessage"]);
174
+
175
+ if ($source_path) {
176
+ $file_exists = file_exists($target_path);
177
+ if ( !$file_exists || $params["dublicatespolicy"] == "" || $params["dublicatespolicy"] == "overwrite" ) {
178
+ //redirect echo in internal buffer to receive and process any unwanted warning messages from wfu_upload_file
179
+ ob_start();
180
+ ob_clean();
181
+ $wfu_upload_file_ret = wfu_upload_file($source_path, $target_path, $params["accessmethod"], $params["ftpinfo"]);
182
+ $file_copied = $wfu_upload_file_ret["uploaded"];
183
+ //process warning messages from wfu_upload_file
184
+ $echo_message = ob_get_contents();
185
+ //finish redirecting of echo to internal buffer
186
+ ob_end_clean();
187
+ if ( $echo_message != "" && !$file_copied ) {
188
+ $file_output['message_type'] = "error";
189
+ if ( stristr($echo_message, "warning") && stristr($echo_message, "permission denied") && stristr($echo_message, "unable to move") ) {
190
+ $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_ERROR_DIR_PERMISSION);
191
+ $file_output['admin_messages'] = wfu_join_strings("<br />", $file_output['admin_messages'], WFU_ERROR_ADMIN_DIR_PERMISSION);
192
+ }
193
+ else {
194
+ $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_ERROR_FILE_MOVE);
195
+ $file_output['admin_messages'] = wfu_join_strings("<br />", $file_output['admin_messages'], strip_tags($echo_message));
196
+ }
197
+ $message_processed = true;
198
+ }
199
+ if ( $wfu_upload_file_ret["admin_message"] != "" ) {
200
+ $file_output['admin_messages'] = wfu_join_strings("<br />", $file_output['admin_messages'], $wfu_upload_file_ret["admin_message"]);
201
+ }
202
+ }
203
+ else if ( $file_exists && $params["dublicatespolicy"] == "maintain both" ) {
204
+ $full_path = wfu_upload_plugin_full_path($params);
205
+ $name_part = $only_filename;
206
+ $ext_part = "";
207
+ $dot_pos = strrpos($name_part, ".");
208
+ if ( $dot_pos ) {
209
+ $ext_part = substr($name_part, $dot_pos);
210
+ $name_part = substr($name_part, 0, $dot_pos);
211
+ }
212
+ if ( $params["uniquepattern"] != "datetimestamp" ) {
213
+ $unique_ind = 1;
214
+ do {
215
+ $unique_ind += 1;
216
+ $only_filename = $name_part . "(" . $unique_ind . ")" . $ext_part;
217
+ $target_path = $full_path . $only_filename;
218
+ }
219
+ while ( file_exists($target_path) );
220
+ }
221
+ else {
222
+ $current_datetime = gmdate("U") - 1;
223
+ do {
224
+ $current_datetime += 1;
225
+ $only_filename = $name_part . "-" . gmdate("YmdHis", $current_datetime) . $ext_part;
226
+ $target_path = $full_path . $only_filename;
227
+ }
228
+ while ( file_exists($target_path) );
229
+ }
230
+ //redirect echo in internal buffer to receive and process any unwanted warning messages from move_uploaded_file
231
+ ob_start();
232
+ ob_clean();
233
+ $wfu_upload_file_ret = wfu_upload_file($source_path, $target_path, $params["accessmethod"], $params["ftpinfo"]);
234
+ $file_copied = $wfu_upload_file_ret["uploaded"];
235
+ //process warning messages from move_uploaded_file
236
+ $echo_message = ob_get_contents();
237
+ //finish redirecting of echo to internal buffer
238
+ ob_end_clean();
239
+ if ( $echo_message != "" && !$file_copied ) {
240
+ $file_output['message_type'] = "error";
241
+ if ( stristr($echo_message, "warning") && stristr($echo_message, "permission denied") && stristr($echo_message, "unable to move") ) {
242
+ $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_ERROR_DIR_PERMISSION);
243
+ $file_output['admin_messages'] = wfu_join_strings("<br />", $file_output['admin_messages'], WFU_ERROR_ADMIN_DIR_PERMISSION);
244
+ }
245
+ else {
246
+ $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_ERROR_FILE_MOVE);
247
+ $file_output['admin_messages'] = wfu_join_strings("<br />n", $file_output['admin_messages'], strip_tags($echo_message));
248
+ }
249
+ $message_processed = true;
250
+ }
251
+ if ( $wfu_upload_file_ret["admin_message"] != "" ) {
252
+ $file_output['admin_messages'] = wfu_join_strings("<br />", $file_output['admin_messages'], $wfu_upload_file_ret["admin_message"]);
253
+ }
254
+ }
255
+ else {
256
+ $file_output['message_type'] = "error";
257
+ $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_WARNING_FILE_EXISTS);
258
+ $message_processed = true;
259
+ $file_copied = false;
260
+ }
261
+ }
262
+
263
+ if ( $file_copied ) {
264
+ /* prepare email notification parameters if email notification is enabled */
265
+ if ( $params["notify"] == "true" ) {
266
+ $notify_only_filename_list .= ( $notify_only_filename_list == "" ? "" : ", " ).$only_filename;
267
+ $notify_target_path_list .= ( $notify_target_path_list == "" ? "" : ", " ).$target_path;
268
+ if ( $params["attachfile"] == "true" )
269
+ $notify_attachment_list .= ( $notify_attachment_list == "" ? "" : "," ).$target_path;
270
+ }
271
+
272
+ /* prepare redirect link if redirection is enabled */
273
+ if ( $params["redirect"] == "true" ) {
274
+ /* Define dynamic redirect link from variables */
275
+ $search = array ('/%filename%/');
276
+ $replace = array ($only_filename);
277
+ $params_output_array["general"]['redirect_link'] = trim(preg_replace($search, $replace, $params["redirectlink"]));
278
+ }
279
+
280
+ if ( !$message_processed ) {
281
+ $file_output['message_type'] = "success";
282
+ }
283
+ }
284
+ else if ( !$message_processed ) {
285
+ $file_output['message_type'] = "error";
286
+ $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_ERROR_UNKNOWN);
287
+ }
288
+
289
+ /* Delete temporary file (in tmp directory) */
290
+ // unlink($source_path);
291
+ }
292
+ else {
293
+ $file_output['message_type'] = "error";
294
+ $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_ERROR_UNKNOWN);
295
+ }
296
+ }
297
+
298
+ /* last check of output file status */
299
+ if ( $file_output['message_type'] == "" ) {
300
+ if ( $file_copied ) $file_output['message_type'] = "success";
301
+ else {
302
+ $file_output['message_type'] = "error";
303
+ $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_ERROR_UNKNOWN);
304
+ }
305
+ }
306
+
307
+ /* suppress any admin messages if user is not administrator or adminmessages is not activated */
308
+ if ( $suppress_admin_messages ) $file_output['admin_messages'] = "";
309
+
310
+ /* set file status to "warning" if the file has been uploaded but there are messages */
311
+ if ( $file_output['message_type'] == "success" ) {
312
+ if ( $file_output['message'] != "" || $file_output['admin_messages'] != "" )
313
+ $file_output['message_type'] = "warning";
314
+ }
315
+
316
+ /* adjust message details and colors according to file result */
317
+ /* FileResult: A */
318
+ $search = array ('/%username%/', '/%useremail%/', '/%filename%/', '/%filepath%/');
319
+ $replace = array ($user_login, ( $user_email == "" ? "no email" : $user_email ), $only_filename, $target_path);
320
+ if ( $file_output['message_type'] == "success" ) {
321
+ $success_count ++;
322
+ $color_array = explode(",", $params['successmessagecolors']);
323
+ $file_output['color'] = $color_array[0];
324
+ $file_output['bgcolor'] = $color_array[1];
325
+ $file_output['borcolor'] = $color_array[2];
326
+ $file_output['header'] = preg_replace($search, $replace, WFU_SUCCESSMESSAGE);
327
+ /* prepare details of successful file upload, visible only to administrator */
328
+ $file_output['admin_messages'] = wfu_join_strings("<br />", preg_replace($search, $replace, WFU_SUCCESSMESSAGE_DETAILS), $file_output['admin_messages']);
329
+ }
330
+ /* FileResult: B */
331
+ elseif ( $file_output['message_type'] == "warning" ) {
332
+ $warning_count ++;
333
+ $color_array = explode(",", $params['warningmessagecolors']);
334
+ $file_output['color'] = $color_array[0];
335
+ $file_output['bgcolor'] = $color_array[1];
336
+ $file_output['borcolor'] = $color_array[2];
337
+ $file_output['header'] = preg_replace($search, $replace, WFU_WARNINGMESSAGE);
338
+ /* prepare and prepend details of successful file upload, visible only to administrator */
339
+ $file_output['admin_messages'] = wfu_join_strings("<br />", preg_replace($search, $replace, WFU_SUCCESSMESSAGE_DETAILS), $file_output['admin_messages']);
340
+ }
341
+ /* FileResult: C */
342
+ elseif ( $file_output['message_type'] == "error" ) {
343
+ $error_count ++;
344
+ $color_array = explode(",", $params['failmessagecolors']);
345
+ $file_output['color'] = $color_array[0];
346
+ $file_output['bgcolor'] = $color_array[1];
347
+ $file_output['borcolor'] = $color_array[2];
348
+ /* define variables that were not defined before due to error */
349
+ $only_filename = wfu_upload_plugin_clean( $fileprops['name'] );
350
+ $target_path = wfu_upload_plugin_full_path($params).$only_filename;
351
+ $replace = array ($user_login, ( $user_email == "" ? "no email" : $user_email ), $only_filename, $target_path);
352
+ $file_output['header'] = preg_replace($search, $replace, WFU_ERRORMESSAGE);
353
+ /* prepare and prepend details of failed file upload, visible only to administrator */
354
+ $file_output['admin_messages'] = wfu_join_strings("<br />", preg_replace($search, $replace, WFU_FAILMESSAGE_DETAILS), $file_output['admin_messages']);
355
+ }
356
+
357
+ /* suppress again any admin messages if user is not administrator or adminmessages is not activated */
358
+ if ( $suppress_admin_messages ) $file_output['admin_messages'] = "";
359
+
360
+ /* set success status of the file, to be used for medialink */
361
+ $file_finished_successfully = ( $file_output['message_type'] == "success" || $file_output['message_type'] == "warning" );
362
+
363
+ $params_output_array[0] = $file_output;
364
+
365
+ /* add file to Media if this option is activated and the file has finished uploading successfully */
366
+ if ( $params["medialink"] == "true" && $file_finished_successfully ) {
367
+ wfu_process_media_insert($target_path);
368
+ }
369
+ }
370
+
371
+ $somefiles_Ok = ( ( $warning_count + $success_count ) > 0 );
372
+ $allfiles_Ok = ( $somefiles_Ok && ( $error_count == 0 ) );
373
+
374
+ /* Prepare WPFileBase Plugin update url, if this option has been selected and only if at least one file has been successfully uploaded.
375
+ Execution will happen only if accumulated $params_output_array["general"]['update_wpfilebase'] is not empty */
376
+ if ( $params["filebaselink"] == "true" ) {
377
+ if ( $somefiles_Ok ) {
378
+ $filebaseurl = site_url();
379
+ if ( substr($filebaseurl, -1, 1) == "/" ) $filebaseurl = substr($filebaseurl, 0, strlen($filebaseurl) - 1);
380
+ /* if the following variable is not empty, then WPFileBase Plugin update must be executed
381
+ and any admin messages must be suppressed */
382
+ $params_output_array["general"]['update_wpfilebase'] = $filebaseurl;
383
+ }
384
+ else {
385
+ $params_output_array["general"]['admin_messages']['wpfilebase'] = WFU_WARNING_WPFILEBASE_NOTUPDATED_NOFILES;
386
+ $params_output_array["general"]['errors']['wpfilebase'] = "error";
387
+ }
388
+ }
389
+
390
+ /* Prepare email notification parameters if email notification is enabled and only if at least one file has been successfully uploaded
391
+ if $method = "no-ajax" then send the email to the recipients
392
+ if $method = "ajax" then return the notification parameters to the handler for further processing
393
+ In case of ajax, execution will happen only if accumulated notify_only_filename_list is not empty */
394
+ if ( $params["notify"] == "true" ) {
395
+ /* verify that there are recipients */
396
+ $notifyrecipients = trim(preg_replace('/%useremail%/', $user_email, $params["notifyrecipients"]));
397
+ if ( $notifyrecipients != "" ) {
398
+ if ( $somefiles_Ok ) {
399
+ if ( $method == 'no_ajax' ) {
400
+ $send_error = wfu_send_notification_email($user, $notify_only_filename_list, $notify_target_path_list, $notify_attachment_list, $userdata_fields, $params);
401
+ if ( $send_error != "" ) {
402
+ $params_output_array["general"]['admin_messages']['notify'] = $send_error;
403
+ $params_output_array["general"]['errors']['notify'] = "error";
404
+ }
405
+ }
406
+ else {
407
+ /* if the following variable is not empty, then email notification must be sent
408
+ and any admin messages must be suppressed */
409
+ $params_output_array["general"]['notify_only_filename_list'] = $notify_only_filename_list;
410
+ $params_output_array["general"]['notify_target_path_list'] = $notify_target_path_list;
411
+ $params_output_array["general"]['notify_attachment_list'] = $notify_attachment_list;
412
+ }
413
+ }
414
+ else {
415
+ $params_output_array["general"]['admin_messages']['notify'] = WFU_WARNING_NOTIFY_NOTSENT_NOFILES;
416
+ $params_output_array["general"]['errors']['notify'] = "error";
417
+ }
418
+ }
419
+ else {
420
+ $params_output_array["general"]['admin_messages']['notify'] = WFU_WARNING_NOTIFY_NOTSENT_NORECIPIENTS;
421
+ $params_output_array["general"]['errors']['notify'] = "error";
422
+ }
423
+ }
424
+
425
+ /* Prepare redirect link if redirection is enabled and only if all files have been successfully uploaded
426
+ Execution will happen only if accumulated redirect_link is not empty and accumulated redirect errors are empty */
427
+ if ( $params["redirect"] == "true" ) {
428
+ if ( $params_output_array["general"]['redirect_link'] == "" ) {
429
+ $params_output_array["general"]['admin_messages']['redirect'] = WFU_WARNING_REDIRECT_NOTEXECUTED_EMPTY;
430
+ $params_output_array["general"]['errors']['redirect'] = "error";
431
+ }
432
+ elseif ( !$allfiles_Ok ) {
433
+ $params_output_array["general"]['admin_messages']['redirect'] = WFU_WARNING_REDIRECT_NOTEXECUTED_FILESFAILED;
434
+ $params_output_array["general"]['errors']['redirect'] = "error";
435
+ }
436
+ }
437
+
438
+ /* suppress any admin messages if user is not administrator or adminmessages is not activated */
439
+ if ( $suppress_admin_messages ) {
440
+ $params_output_array["general"]['admin_messages']['wpfilebase'] = "";
441
+ $params_output_array["general"]['admin_messages']['notify'] = "";
442
+ $params_output_array["general"]['admin_messages']['redirect'] = "";
443
+ $params_output_array["general"]['admin_messages']['other'] = "";
444
+ }
445
+
446
+ /* Calculate upload state from file results */
447
+ if ( $allfiles_Ok && ( $warning_count == 0 ) ) $params_output_array["general"]['state'] = 4;
448
+ else if ( $allfiles_Ok ) $params_output_array["general"]['state'] = 5;
449
+ else if ( $somefiles_Ok ) $params_output_array["general"]['state'] = 6; //only valid in no-ajax method
450
+ else if ( !$somefiles_Ok && $error_count > 0 ) $params_output_array["general"]['state'] = 7;
451
+ else $params_output_array["general"]['state'] = 8;
452
+
453
+ /* construct safe output */
454
+ $sout = $params_output_array["general"]['state'].";".WFU_DEFAULTMESSAGECOLORS.";".$files_count;
455
+ for ($i = 0; $i < $files_count; $i++) {
456
+ $sout .= ";".wfu_plugin_encode_string($file_output['message_type']);
457
+ $sout .= ",".wfu_plugin_encode_string($file_output['header']);
458
+ $sout .= ",".wfu_plugin_encode_string($file_output['message']);
459
+ $sout .= ",".wfu_plugin_encode_string($file_output['admin_messages']);
460
+ }
461
+ $params_output_array["general"]['safe_output'] = $sout;
462
+
463
+ return $params_output_array;
464
+ }
465
+
466
+ ?>
readme.txt CHANGED
@@ -1,502 +1,517 @@
1
- === Wordpress File Upload ===
2
- Contributors: nickboss
3
- Donate link: http://www.iptanus.com/support/wordpress-file-upload
4
- Tags: upload, upload file, upload files, multiple, multiple upload, multiple uploads, captcha, progress bar, form, ajax, directory, HTML5, filelist
5
- Requires at least: 2.9.2
6
- Tested up to: 3.8
7
- Stable tag: "trunk"
8
- License: GPLv2 or later
9
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
-
11
- Simple yet powerful plugin to allow users to upload files to your website from any page
12
-
13
- == Description ==
14
-
15
- With this plugin you or other users can upload files to your site from any page by using shortcodes.
16
-
17
- Simply put the shortcode [wordpress_file_upload] to the contents of any WordPress page and you will be able to upload files to any directory inside wp-contents of your WordPress site.
18
-
19
- Please note that this plugin is the successor of **Inline Upload** plugin.
20
-
21
- The characteristics of the plugin are:
22
-
23
- * It does not use flash and handles uploads using various technologies (HTML5, AJAX, classic HTML forms) depending on browser's capabilities, which detects automatically. As a result it can work in any browser, including mobiles phones (even old ones).
24
- * You can have more than one instances of the shortcode in the same page.
25
- * It includes an overall upload progress bar.
26
- * It supports localization.
27
- * It integrates with WP-Filebase.
28
- * It is highly customizable with many options.
29
- * It produces notification messages and e-mails.
30
- * You can create additional fields that the user must fill in along with the uploaded file.
31
- * It supports redirection to another url after successful upload.
32
- * You can create you shortcode very easily by using the included Shortcode Composer in the plugin's settings inside Dashboard.
33
-
34
- Please note that old desktop browsers or mobile browsers may not support all of the above functionalities. In order to get full functionality use the latest versions browsers, supporting HTML5, AJAX and CSS3.
35
-
36
- For additional features, such as multiple file upload, very large file upload, drag and drop of files, captcha and detailed upload progress bars please consider [Wordpress File Upload Professional](http://www.iptanus.com/support/wordpress-file-upload/ "Wordpress File Upload support page").
37
-
38
- Please visit the **Other Notes** section for customization options of this plugin.
39
-
40
- == Installation ==
41
-
42
- 1. First copy wordpress_file_upload directory inside wp-contents/plugins directory of your wordpress site.
43
- 1. Activate the plugin from Plugins menu of your Dashboard.
44
- 1. In order to use the plugin simply put the shortcode [wordpress_file_upload] in the contents of any page.
45
- 1. If you want more options, go to plugin Settings inside Dashboard, open Shortcode Composer and select the options you want. The composer generates the shortcode automatically. Copy and paste it to the page of your choice.
46
-
47
- == Frequently Asked Questions ==
48
-
49
- = Will the plugin work in a mobile browser? =
50
-
51
- Yes, the plugins will work in most mobile phones (has been tested in iOS, Android and Symbian browsers as well as Opera Mobile)
52
-
53
- = Do I need to have Flash to use then plugin? =
54
-
55
- No, you do not need Flash to use the plugin.
56
-
57
- = I get a SAFE MODE restriction error when I try to upload a file. Is there an alternative? =
58
-
59
- Your domain has probably turned SAFE MODE ON and you have restrictions uploading and accessing files. Wordpress File Upload includes an alternative way to upload files, using FTP access. Simply add the attribute **accessmethod="ftp"** inside the shortcode, together with FTP access information in **ftpinfo** attribute.
60
-
61
- = Can I see the progress of the upload? =
62
-
63
- Yes, you can see the progress of the upload. During uploading a progress bar will appear showing progress info, however this functionality functions only in browsers supporting HTML5 upload progress bar.
64
-
65
- = Can I upload many files at the same time? =
66
-
67
- Yes, but not in the free version. If you want to allow multiple file uploads, please consider the [Professional](http://www.iptanus.com/support/wordpress-file-upload/ "Wordpress File Upload support page") version.
68
-
69
- = Where do files go after upload? =
70
-
71
- Files by default are uploaded inside wp-content directory of your Wordpress website. To change it use attribute uploadpath.
72
-
73
- = Are there filters to restrict uploaded content? =
74
-
75
- Yes, you can control allowed file size and file extensions by using the appropriate attribute (see Other Notes section).
76
-
77
- = Are there any upload file size limitations? =
78
-
79
- Yes, there are file size limitations imposed by the web server or the host. If you want to upload very large files, please consider the [Professional](http://www.iptanus.com/support/wordpress-file-upload/ "Wordpress File Upload support page") version of the plugin, which surpasses size limitations.
80
-
81
- = Who can upload files? =
82
-
83
- By default only administrators can upload files. However you can define which user roles are allowed to upload files, beyond administrators. Even guests can be allowed to upload files, however use this option with care.
84
-
85
- = What security is used for uploading files? =
86
-
87
- The plugin is designed not to expose website information by using sessions. Parameters passing from server to client side are encoded. For higher protection, like use of captcha, please consider the [Professional](http://www.iptanus.com/support/wordpress-file-upload/ "Wordpress File Upload support page") version of the plugin.
88
-
89
- == Screenshots ==
90
-
91
- 1. A screenshot of the plugin in its most simple form.
92
- 2. A screenshot of the plugin showing the progress bar.
93
- 3. A screenshot of the plugin showing the successful upload message.
94
- 4. A screenshot of the plugin with different placement.
95
- 5. A screenshot of the plugin with user fields.
96
-
97
- == Changelog ==
98
-
99
- = 2.1.3 =
100
- * variables %pagetitle% and %pageid% added in uploadpath.
101
- * bug fixes when working with IE8.
102
- * Shortcode Composer saves selected options
103
- * Easier handling of userdata variables in Shortcode Composer
104
- * correction of bug that allowed debugdata to be shown in non-admin users
105
- * reset.css removed from plugin as it was causing breaks in theme's css
106
- * correction of bug with WPFilebase Manager plugin
107
-
108
- = 2.1.2 =
109
- * Several bug fixes and code reconstruction.
110
- * Code modifications so that the plugin can operate even when DEBUG mode is ON.
111
- * New attribute debugmode added to allow better debugging of the plugin when there are errors.
112
-
113
- = 2.1.1 =
114
- * Bug fixes with broken images when Wordpress website is in a subdirectory.
115
- * Replacement of glob function because is not allowed by some servers.
116
-
117
- = 2.0.2 =
118
- * Bug fixes in Dashboard Settings Shortcode Composer.
119
- * Correction of important bug that was breaking page in some cases.
120
- * Minor improvements of user data fields and notification email attributes.
121
-
122
- = 2.0.1 =
123
- This is the initial release of Wordpress File Upload. Since this plugin is the successor of Inline Upload, the whole changelog since the creation of the later is included.
124
-
125
- * Name of the plugin changed to Wordpress File Upload.
126
- * Plugin has been completely restructured to allow additional features.
127
- * A new more advanced message box has been included showing information in a more structured way.
128
- * Error detection and reporting has been improved.
129
- * An administration page has been created in the Dashboard Settings, containing a Shortcode Composer.
130
- * Some more options related to configuration of message showing upload results have been added.
131
- * Several bug fixes.
132
-
133
- = 1.7.14 =
134
- * Userdata attribute changed to allow the creation of more fields and required ones.
135
- * Spanish translation added thanks to Maria Ramos of WebHostingHub.
136
-
137
- = 1.7.13 =
138
- * Added notifyheaders attribute, in order to allow better control of notification email sent (e.g. allow to send HTML email).
139
-
140
- = 1.7.12 =
141
- * Added userdata attribute, in order to allow users to send additional text data along with the uploaded file.
142
-
143
- = 1.7.11 =
144
- * Added single button operation (file will be automatically uploaded when selected without pressing Upload Button).
145
-
146
- = 1.7.10 =
147
- * Fixed bug with functionality of attribute filebaselink for new versions of WP-Filebase plugin.
148
-
149
- = 1.7.9 =
150
- * Fixed problem with functionality of attribute filebaselink for new versions of WP-Filebase plugin.
151
-
152
- = 1.7.8 =
153
- * More than one roles can now be defined in attribute uploadrole, separated by comma (,).
154
-
155
- = 1.7.7 =
156
- * Variable %filename% now works also in redirectlink.
157
-
158
- = 1.7.6 =
159
- * Changes in ftp functionality, added useftpdomain attribute so that it can work with external ftp domains as well.
160
- * Improvement of classic upload (used in IE or when setting forceclassic to true) messaging functionality.
161
- * Minor bug fixes.
162
-
163
- = 1.7.5 =
164
- * Source modified so that it can work with Wordpress sites that are not installed in root.
165
- * Added variable %blogid% for use with multi-site installations.
166
- * Bug fixes related to showing of messages.
167
-
168
- = 1.7.4 =
169
- * Replacement of json2.js with another version.
170
-
171
- = 1.7.3 =
172
- * CSS style changes to resolve conflicts with various theme CSS styles.
173
-
174
- = 1.7.2 =
175
- * Added variable %useremail% used in notifyrecipients, notifysubject and notifymessage attributes.
176
-
177
- = 1.7.1 =
178
- * Added capability to upload files outside wp-content folder.
179
- * Improved error reporting.
180
-
181
- = 1.7 =
182
- * Complete restructuring of plugin HTML code, in order to make it more configurable and customizable.
183
- * Appearance of messages has been improved.
184
- * Added option to put the plugin in testmode.
185
- * Added option to configure the colors of success and fail messages.
186
- * Added option to modify the dimensions of the individual objects of the plugin.
187
- * Added option to change the placement of the individual objects of the plugin.
188
- * Improved error reporting.
189
- * Added localization for error messages.
190
- * Minor bug fixes.
191
-
192
- = 1.6.3 =
193
- * Bug fixes to correct incompatibilities of the new ajax functionality when uploadrole is set to "all".
194
-
195
- = 1.6.2 =
196
- * Bug fixes to correct incompatibilities of the new ajax functionality with redirectlink, filebaselink and adminmessages.
197
-
198
- = 1.6.1 =
199
- * Correction of serious bug that prevented the normal operation of the plugin when the browser of the user supports HTML5 functionality.
200
- * Tags added to the plugin Wordpress page.
201
-
202
- = 1.6 =
203
- * Major lifting of the whole code.
204
- * Added ajax functionality so that file is uploaded without page reload (works in browsers supporting HTML5).
205
- * Added upload progress bar (works in browsers supporting HTML5).
206
- * Added option to allow user to select if wants to use the old form upload functionality.
207
- * File will not be saved again if user presses the Refresh button (or F5) of the page.
208
- * Translation strings updated.
209
- * Bug fixes for problems when there are more than one instances of the plugin in a single page.
210
-
211
- = 1.5 =
212
- * Added option to notify user about upload directory.
213
- * Added option to allow user to select a subfolder to upload the file.
214
-
215
- = 1.4.1 =
216
- * css corrections for bug fixes.
217
-
218
- = 1.4 =
219
- * Added option to attach uploaded file to notification email.
220
- * Added option to customize message on successfull upload (variables %filename% and %filepath% can be used).
221
- * Added option to customize color of message on successfull upload.
222
- * "C:\fakepath\" problem resolved.
223
- * warning message about function create_directory() resolved.
224
- * css enhancements for compatibility with more themes.
225
-
226
- = 1.3 =
227
- * Additional variables added (%filename% and %filepath%).
228
- * All variables can be used inside message subject and message text.
229
- * Added option to determine how to treat dublicates (overwrite existing file, leave existing file, leave both).
230
- * Added option to determine how to rename the uploaded file, when another file already exists in the target directory.
231
- * Added option to create directories and upload files using ftp access, in order to overcome file owner and SAFE MODE restrictions.
232
- * Added the capability to redirect to another web page when a file is uploaded successfully.
233
- * Added the option to show to administrators additional messages about upload errors.
234
- * Bug fixes related to interoperability with WP_Filebase
235
-
236
- = 1.2 =
237
- * Added notification by email when a file is uploaded.
238
- * Added the ability to upload to a variable folder, based on the name of the user currently logged in.
239
-
240
- = 1.1 =
241
- Added the option to allow anyone to upload files, by setting the attribute uploadrole to "all".
242
-
243
- = 1.0 =
244
- Initial version.
245
-
246
- == Upgrade Notice ==
247
-
248
- = 2.1.3 =
249
- Important upgrade to address some serious bugs.
250
-
251
- = 2.1.2 =
252
- Important upgrade to address some bugs.
253
-
254
- = 2.1.1 =
255
- Important upgrade to address some serious bugs.
256
-
257
- = 2.0.2 =
258
- Important upgrade to address some serious bugs.
259
-
260
- = 2.0.1 =
261
- Optional upgrade to add new features.
262
-
263
- = 1.7.14 =
264
- Optional upgrade to add new features.
265
-
266
- = 1.7.13 =
267
- Optional upgrade to add new features.
268
-
269
- = 1.7.12 =
270
- Optional upgrade to add new features.
271
-
272
- = 1.7.11 =
273
- Optional upgrade to add new features.
274
-
275
- = 1.7.10 =
276
- Important upgrade to correct bug with filebaselink attribute functionality.
277
-
278
- = 1.7.9 =
279
- Important upgrade to resolve issue with filebaselink attribute functionality.
280
-
281
- = 1.7.8 =
282
- Optional upgrade to add new features.
283
-
284
- = 1.7.7 =
285
- Optional upgrade to add new features.
286
-
287
- = 1.7.6 =
288
- Optional upgrade to add new features and make minor bug fixes.
289
-
290
- = 1.7.5 =
291
- Important upgrade to resolve issues with Wordpress sites not installed in root.
292
-
293
- = 1.7.4 =
294
- Important upgrade to resolve issues with json2 functionality.
295
-
296
- = 1.7.3 =
297
- Important upgrade to resolve issues with style incompatibilities.
298
-
299
- = 1.7.2 =
300
- Optional upgrade to add new features, related to variables.
301
-
302
- = 1.7.1 =
303
- Optional upgrade to add new features, related to uploadpath and error reporting.
304
-
305
- = 1.7 =
306
- Optional upgrade to add new features, related to appearance of the plugin and error reporting.
307
-
308
- = 1.6.3 =
309
- Important upgrade to correct bugs that prevented normal operation of the plugins in some cases.
310
-
311
- = 1.6.2 =
312
- Important upgrade to correct bugs that prevented normal operation of the plugins in some cases.
313
-
314
- = 1.6.1 =
315
- Important upgrade to correct bug that prevented normal operation of the plugins in some cases.
316
-
317
- = 1.6 =
318
- Optional upgrade to add new features, related to ajax functionality and minor bug fixes.
319
-
320
- = 1.5 =
321
- Optional upgrade to add new features, related to subfolders.
322
-
323
- = 1.4.1 =
324
- Important upgrade to correct a css problem with Firefox.
325
-
326
- = 1.4 =
327
- Important upgrade that introduces some bug fixes and some new capabilities.
328
-
329
- = 1.3 =
330
- Important upgrade that introduces some bug fixes and a lot of new capabilities.
331
-
332
- = 1.2 =
333
- Optional upgrade in order to set additional capabilities.
334
-
335
- = 1.1 =
336
- Optional upgrade in order to set additional capabilities.
337
-
338
- = 1.0 =
339
- Initial version.
340
-
341
- == Attributes ==
342
-
343
- The easiest way to use the plugin is to put the shortcode [wordpress_file_upload] in the page. In this case, the plugin will use the default functionality.
344
-
345
- If you want to customize the plugin (define the upload path, use file filter, change title and button text etc.) then you can use attributes. Go to Dashboard / Settings / Wordpress File Upload and then press Shortcode Composer. By selecting the attributes of your choice, the shortcode will be automatically generated. Then you can copy and paste it in any page.
346
-
347
- A detailed list of attributes, together with instructions is shown below:
348
-
349
- **General Options**
350
-
351
- *Basic Functionalities*
352
-
353
- * **uploadid:** This is the ID of every instance of the plugin inside the same page. Valid values are 1,2,3... Please use a different value for every instance.
354
- * **singlebutton:** If this attribute is set to "true", only Upload Button will be shown and file will be automatically uploaded when selected. Default value is "false".
355
- * **uploadpath:** This is the path of the upload directory. The path must be relative to wp-content folder of your Wordpress website. For instance, if your upload directory is "wp-content/uploads/myuploaddir", then uploadpath must have the value "uploads/myuploaddir". The default value is "uploads", meaning that the files will be uploaded to wp-content/uploads dir. If you put the variable "%username%" inside the uploadpath string, then this variable will be replaced by the username of the user currently logged in. If you want to upload files outside wp-content folder, then put a double dot (..) at the beginning of your uploadpath value.
356
-
357
- *Filters*
358
-
359
- * **uploadrole:** This is the roles that are allowed to upload files. Default role is "administrator". If you use other roles, like "editor", then only users of this role and also of role "administrator" will be able to upload files. You can set multiple roles, separated by comma, e.g. "editor, author". If you set uploadrole to "all" then all users, even guests, will be able to upload files.
360
- * **uploadpatterns:** This is the filter of the uploaded files. Default value is "*.*", meaning that all files can be uploaded. Use this attribute to restrict the types of files that can be uploaded. For instance, in order to upload only pdf files put "\*.pdf". You can use more that one filters, separated by comma, for instance "\*.pdf,\*.doc".
361
- * **maxsize:** This is the maximum size in MBytes of the uploaded files. Use this attribute to restrict the upload of files larger that this value. Default value is "10", meaning that you cannot upload files larger than 10MBytes.
362
-
363
- *Upload Path and Files*
364
-
365
- * **createpath:** If this attribute is set to "true", the upload directory, defined by uploadpath, will be created in case it does not exist. Default value is "false".
366
- * **accessmethod:** This attributes defines the method to create directories and upload files. Default value is "normal". If it is set to "ftp", then the plugin will attempt to create directories and upload files using ftp access. In order to do this, the attribute *ftpinfo* must also be filled with valid ftp access information. Use this attribute when you cannot upload files, access uploaded files or cannot copy or delete uploaded files because of SAFE MODE restrictions, or because the owner of the file is the domain administrator.
367
- * **ftpinfo:** This attribute defines the ftp access information. It has the syntax *username:password@domain*. If username, password or domain contains the characters (:) or (@), then replace them with (\\:) and (\\@) in order to avoid misreading of the attribute.
368
- * **useftpdomain:** This attribute is used when the ftp domain used to upload files is in different domain than Wordpress installation. If it is set to "true" (and also uploadmethod is "ftp"), then the domain that will be used to upload files will be the one defined in ftpinfo attribute. Default value is "false".
369
- * **showtargetfolder:** This attribute defines if a message with the upload directory will be shown. Default value is "false".
370
- * **askforsubfolders:** This attribute defines if the user can select a subfolder to upload the file. Default value is "false". If set to "true", then the user is able to select a subfolder of the path, defined by the attribute *uploadpath*, to upload a file through a drop down list. This attributed is used together with attribute *subfoldertree*, which defines the subfolders.
371
- * **subfoldertree:** This attribute defines the structure of the subfolders that the user can select to upload a file. Default value is "". The format of this attribute is as follows: the subfolders are separated by commas (,), e.g. "subfolder1, subfolder2". It is possible to use nested subfolders (a folder inside another folder). To do this place stars (*) before the name of the subfolder. The number of stars determines nesting level, e.g. "subfolder1, *nested1, *nested2, **nested3". Please note that the first subfolder must be the name of the folder defined by attribute *uploadpath* (only the last part) without any stars, while all the next subfolders must have at least one star. The user has also the capability to use a different name (from the actual subfolder name) to be shown in the drop down list for every subfolder, by separating the actual and shown name using the slash (/) symbol, e.g. "subfolder1, *subfolder2/shownname2, *subfolder3/shownname3".
372
- * **dublicatespolicy:** This attribute defines what to do when the upload file has the same name with another file inside target directory. If it is set to "overwrite" then the upload file will replace the existing file. If it is set to "reject" then the upload operation will be cancelled. If it is set to "maintain both" then the upload file will be saved inside the target directory with another name, in order to keep both files. Default value is "overwrite".
373
- * **uniquepattern:** This attribute defines how to save the upload file when a file with the same name already exists inside the target directory. If it is set to "index" then the upload file will be saved with a numeric suffix, like (1), (2) etc. in order to keep the name of the uploaded file unique. If it is set to "datetimestamp", then the suffix will be an encoded datetime of the upload operation. The plugin ensures that the name of the uploaded file will be unique, in order to avoid accidental replacement of existing files. Default value is "index".
374
-
375
- *Redirection*
376
-
377
- * **redirect:** This attribute defines if the user will be redirected to another web page when the file is uploaded successfully. Default value is "false".
378
- * **redirectlink:** This attribute defines the url of the redirection page. Please use the prefix "http://" if the redirection page is in another domain, otherwise the server will assume that the url is relative to the server path.
379
-
380
- *Other Administrator Options*
381
- * **adminmessages:** This attribute offers the option to administrator users to receive additional information about upload errors. These messages will be visible only to administrators. Default value is "false".
382
- * **forceclassic:** This attribute defines if the plugin will use the old classic functionality to upload files (using forms) or ajax functionality (supported in HTML5). Default value is "false". Please note that if your browser does not support HTML ajax functionality, then the plugin will automatically switch to classic one.
383
- * **testmode:** This attribute defines if the plugin will be shown in test mode. Default value is "false". If it is set to "true", then the plugin will obtain a "dummy" functionality (it will not be able to upload files) and it will appear showing all of its objects (the selection of subfolders, progress bar, a test message), while the buttons will show a "Test Mode" message when pressed. This option can be used to configure the dimensions of the individual objects of the plugin more easily.
384
- * **debugmode:** This attribute defines if the plugin will show debug information. Default value is "false". If it is set to "true", then the plugin will show in the message box any warnings and errors generated by PHP during the upload process. It can be used by administrators for deep debugging. For generation of PHP warnings and errors, global Wordpress WP_DEBUG constant must be enabled.
385
-
386
-
387
- **Placements**
388
-
389
- *Plugin Component Positions*
390
-
391
- * **placements:** This attribute can be used to change the placement of the objects of the plugin. Default value is "title/filename+selectbutton+uploadbutton/subfolders/userdata/progressbar/message". Every line is separated by a slash (/). To put more than one objects to the same line, separate them with a plus (+). The name of every object is shown below.
392
-
393
- **Labels**
394
-
395
- *Title*
396
-
397
- * **uploadtitle:** The title of the plugin. Default value is "Upload a file".
398
-
399
- *Buttons*
400
-
401
- * **selectbutton:** The title of the select button. Default value is "Select File".
402
- * **uploadbutton:** The title of the upload button. Default value is "Upload File".
403
-
404
- *Upload Folder*
405
-
406
- * **targetfolderlabel:** This attribute defines the text for the message for the upload directory. Default value is "Upload Directory".
407
-
408
- *Upload Messages*
409
-
410
- * **successmessage:** This attribute defines the message to be shown upon successful upload. Default value is "File %filename% uploaded successfully". You can use the variables %filename% and %filepath% inside the message, as explained below.
411
- * **warningmessage:** This attribute defines the message to be shown upon successful upload but with warnings. Default value is "File %filename% uploaded successfully but with warnings". You can use the variables %filename% and %filepath% inside the message, as explained below.
412
- * **errormessage:** This attribute defines the message to be shown upon upload failure. Default value is "File %filename% not uploaded". You can use the variables %filename% and %filepath% inside the message, as explained below.
413
- * **waitmessage:** This attribute defines the message to be shown while uploading. Default value is "File %filename% is being uploaded". You can use the variables %filename% and %filepath% inside the message, as explained below.
414
-
415
- **Notifications**
416
-
417
- *Email Notifications*
418
-
419
- * **notify:** If this attribute is set to "true", then an email will be sent to the addresses defined by the attribute *notifyrecipients* to inform them that a new file has been uploaded.
420
- * **notifyrecipients:** This attribute defines the list of email addresses to receive the notification message that a new file has been uploaded. More that one address can be defined, separated by comma (,). You can use variables inside this attribute, as explained below.
421
- * **notifyheaders:** This attribute defines additional headers to be included in the notification email (e.g. set "From", "Cc" and "Bcc" parameters or use HTML code instead of text). Default value is "". For example, in order to send HTML email please set this attribute to "Content-type: text/html".
422
- * **notifysubject:** This attribute defines the subject for the notification message. Default value is "File Upload Notification". You can use variables inside this attribute, as explained below.
423
- * **notifymessage:** This attribute defines the body text for the notification message. Default value is "Dear Recipient, this is an automatic delivery message to notify you that a new file has been uploaded. Best Regards". You can use variables inside this attribute, as explained below.
424
- * **attachfile:** This attribute defines if the uploaded file will be attached to the notification email. Default value is "false".
425
-
426
- **Colors**
427
-
428
- *Upload Message Colors*
429
-
430
- * **successmessagecolor:** This attribute defines the color of the message shown upon successful upload. Default value is "green". This attribute is no longer used but is maintained for backward compatibility. Please use successmessagecolors instead.
431
- * **successmessagecolors:** This attribute defines the colors of the message shown upon successful upload. Default value is "#006600,#EEFFEE,#006666". The first value is the text color, the second the background color and the third the border color.
432
- * **warningmessagecolors:** This attribute defines the colors of the message shown upon successful upload but with warnings. Default value is "#F88017,#FEF2E7,#633309". The first value is the text color, the second the background color and the third the border color.
433
- * **failmessagecolors:** This attribute defines the colors of the message shown upon upload failure. Default value is "#660000,#FFEEEE,#666600". The first value is the text color, the second the background color and the third the border color.
434
- * **waitmessagecolors:** This attribute defines the colors of the message shown while file uploading. Default value is "#666666,#EEEEEE,#333333". The first value is the text color, the second the background color and the third the border color.
435
-
436
- **Dimensions**
437
-
438
- *Plugin Component Widths*
439
-
440
- * **widths:** This attribute can be used to define the width of every individual object of the plugin. Default value is "". To define the width of an individual object, simply put the name of the object and the width, separated by the (:) character (e.g. "title:100px"). To define more than one objects separate them with comma (,).
441
-
442
- *Plugin Component Heights*
443
-
444
- * **heights:** This attribute can be used to define the height of every individual object of the plugin. Default value is "". To define the height of an individual object, simply put the name of the object and the height, separated by the (:) character (e.g. "title:20px"). To define more than one objects separate them with comma (,).
445
-
446
- **Additional Fields**
447
-
448
- *Additional Data Fields*
449
-
450
- * **userdata:** This attribute defines if additional text information will be requested by the user. If set to "true", then an additional textbox will appear, prompting the user to put text data. These data will be sent to email recipients, if email notification has been activated and %userdata% variable exists inside notifymessage attribute. Default value is "false".
451
- * **userdatalabel:** This attribute defines the labels of the userdata fields. Separate each field with slash "/". If you want a field to be required, then preceed an asterisk (*) before the label. Example to create 2 fields, an optional Name and a required Email field: userdatalabel="Name/*Email (required)". Default value is "Your message".
452
-
453
- **Interoperability**
454
-
455
- *Connection With Other Plugins*
456
-
457
- * **filebaselink:** This attribute defines if this plugin will be linked to wp-filebase plugin. Wp-filebase is another plugin with which you can upload files and then show them in your pages in a customizable way. If you set this attribute to "true", then you can upload files inside wp-filebase directories using wordpress_file_upload and then update the databases of wp-filebase, so that it is informed about the new uploads. The default value is "false". Please note that this attribute does not check to see if wp-filebase is installed and active, so be sure to have wp-filebase active if you want to use it.
458
-
459
- You can use any of these attributes to customize the plugin. The way to use these attributes is the following:
460
-
461
- `
462
- [wordpress_file_upload attribute1=value1 attribute2=value2]
463
- `
464
-
465
- Here are some examples:
466
-
467
- `
468
- [wordpress_file_upload uploadtitle="Upload files to the Upload dir"]
469
- [wordpress_file_upload uploadtitle="Upload files to the Upload dir" uploadpath="uploads/myuploaddir"]
470
- [wordpress_file_upload uploadid="1" uploadpath="../myuploaddir"]
471
- [wordpress_file_upload uploadpath="uploads/users/%username%" createpath="true"]
472
- [wordpress_file_upload uploadpath="uploads/myuploaddir" notify="true" notifyrecipients="name1@address1.com, name2@address2.com"]
473
- [wordpress_file_upload uploadpath="/uploads/myuploaddir" askforsubfolders="true" subfoldertree="myuploaddir/My Upload Directory,*subfolder1/Subfolder1 Inside myuploaddir,**inner/2nd Level Nested Dir, *reports/Reports"]
474
- [wordpress_file_upload uploadrole="all" uploadpath="/uploads/filebase/%username%" createpath="false" notify="true" notifyrecipients="myname@domain.com" notifysubject="A new file has been uploaded!" attachfile="true" askforsubfolders="true" subfoldertree="admin/Administrator,*root/Root Folder,**inner, *reports/Reports" filebaselink="true" widths="filename:150px, selectbutton:80px, uploadbutton:80px, progressbar:220px, message:368px, subfolders_label:100px, subfolders_select:125px" placements="title/filename+subfolders/selectbutton+uploadbutton+progressbar/message"]
475
- [wordpress_file_upload uploadpath="uploads/myuploaddir" notify="true" notifyrecipients="name1@address1.com, name2@address2.com" notifymessage="File %filename% has been received, together with fields Name:%userdata0%, Email:%userdata1%" userdata="true" userdatalabel="Name/*Email (required)"]
476
- [wordpress_file_upload uploadpath="uploads/myuploaddir" notify="true" notifyrecipients="name1@address1.com, name2@address2.com" notifymessage="This is a test HTML message body.<br/><br/>This word is <em>italic</em> and this is <strong>bold</strong>." notifyheaders="Content-type: text/html"]
477
- `
478
-
479
- == Variables ==
480
-
481
- From version 1.2 variables are supported inside attributes.
482
-
483
- A variable is a string surrounded by percent characters, in the form *%variable_name%*. This variable is replaced by another string whenever the plugin is executed.
484
-
485
- For instance, if the variable %username% is used inside *uploadpath* attribute, then it will be replaced by the username of the user who is currently logged in every time a file is uploaded. By this way, every user can upload files to a separate folder, without any additional programming.
486
-
487
- For the time being, the following variables are supported:
488
-
489
- * **%username%:** Is replaced by the username of the current user. Can be used inside attributes *uploadpath*, *notifysubject* and *notifymessage*.
490
- * **%useremail%:** Is replaced by the email of the current user. Can be used inside attributes *notifyrecipients*, *notifysubject* and *notifymessage*.
491
- * **%filename%:** Is replaced by the filename (not including path information) of the uploaded file. Can be used inside attributes *notifysubject*, *notifymessage*, *successmessage* and *redirectlink*.
492
- * **%filepath%:** Is replaced by the filepath (full path and filename) of the uploaded file. Can be used inside attributes *notifysubject*, *notifymessage* and *successmessage*.
493
- * **%blogid%:** Is replaced by the blog_id of the current site. Can be used inside attribute *uploadpath*.
494
- * **%userdataXXX%:** Is replaced by the additional message that the user has sent together with the file upload. XXX is the number of the field (starting from 0). The shortcode attribute userdata must have been set to "true". Can be used inside attributes *notifysubject*, *notifymessage*.
495
- * **%n%:** Denotes change of line (equivalent of \n). Can be used inside attributes *notifymessage* and *notifyheaders*. It exists because of problems of using \n inside the classic page editor of Wordpress.
496
- * **%pagetitle%:** Is replaced by the title of the current page. Can be used inside attribute *uploadpath*.
497
- * **%pageid%:** Is replaced by the id of the current page. Can be used inside attribute *uploadpath*.
498
-
499
- == Requirements ==
500
-
501
- The plugin requires to have Javascript enabled in your browser. For Internet Explorer you also need to have Active-X enabled.
502
- Please note that old desktop browsers or mobile browsers may not support all of the plugin's features. In order to get full functionality use the latest versions of browsers, supporting HTML5, AJAX and CSS3.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Wordpress File Upload ===
2
+ Contributors: nickboss
3
+ Donate link: http://www.iptanus.com/support/wordpress-file-upload
4
+ Tags: upload, upload file, upload files, multiple, multiple upload, multiple uploads, captcha, progress bar, form, ajax, directory, HTML5, filelist
5
+ Requires at least: 2.9.2
6
+ Tested up to: 3.8
7
+ Stable tag: "trunk"
8
+ License: GPLv2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
+
11
+ Simple yet powerful plugin to allow users to upload files to your website from any page
12
+
13
+ == Description ==
14
+
15
+ With this plugin you or other users can upload files to your site from any page, easily and securely.
16
+
17
+ Simply put the shortcode [wordpress_file_upload] to the contents of any WordPress page and you will be able to upload files to any directory inside wp-contents of your WordPress site.
18
+
19
+ The new version of the plugin includes a file browser to access the uploaded files from the Dashboard (only for admins currently).
20
+
21
+ Please note that this plugin is the successor of **Inline Upload** plugin.
22
+
23
+ The characteristics of the plugin are:
24
+
25
+ * It does not use flash and handles uploads using various technologies (HTML5, AJAX, classic HTML forms) depending on browser's capabilities, which detects automatically. As a result it can work in any browser, including mobiles phones (even old ones).
26
+ * You can have more than one instances of the shortcode in the same page.
27
+ * It includes a file browser.
28
+ * It includes an overall upload progress bar.
29
+ * It supports localization.
30
+ * It integrates with WP-Filebase.
31
+ * It is highly customizable with many options.
32
+ * It produces notification messages and e-mails.
33
+ * You can create additional fields that the user must fill in along with the uploaded file.
34
+ * It supports redirection to another url after successful upload.
35
+ * You can create you shortcode very easily by using the included Shortcode Composer in the plugin's settings inside Dashboard.
36
+
37
+ Please note that old desktop browsers or mobile browsers may not support all of the above functionalities. In order to get full functionality use the latest versions browsers, supporting HTML5, AJAX and CSS3.
38
+
39
+ For additional features, such as multiple file upload, very large file upload, drag and drop of files, captcha and detailed upload progress bars please consider [Wordpress File Upload Professional](http://www.iptanus.com/support/wordpress-file-upload/ "Wordpress File Upload support page").
40
+
41
+ Please visit the **Other Notes** section for customization options of this plugin.
42
+
43
+ == Installation ==
44
+
45
+ 1. First copy wordpress_file_upload directory inside wp-contents/plugins directory of your wordpress site.
46
+ 1. Activate the plugin from Plugins menu of your Dashboard.
47
+ 1. In order to use the plugin simply put the shortcode [wordpress_file_upload] in the contents of any page.
48
+ 1. If you want more options, go to plugin Settings inside Dashboard, open Shortcode Composer and select the options you want. The composer generates the shortcode automatically. Copy and paste it to the page of your choice.
49
+
50
+ == Frequently Asked Questions ==
51
+
52
+ = Will the plugin work in a mobile browser? =
53
+
54
+ Yes, the plugins will work in most mobile phones (has been tested in iOS, Android and Symbian browsers as well as Opera Mobile)
55
+
56
+ = Do I need to have Flash to use then plugin? =
57
+
58
+ No, you do not need Flash to use the plugin.
59
+
60
+ = I get a SAFE MODE restriction error when I try to upload a file. Is there an alternative? =
61
+
62
+ Your domain has probably turned SAFE MODE ON and you have restrictions uploading and accessing files. Wordpress File Upload includes an alternative way to upload files, using FTP access. Simply add the attribute **accessmethod="ftp"** inside the shortcode, together with FTP access information in **ftpinfo** attribute.
63
+
64
+ = Can I see the progress of the upload? =
65
+
66
+ Yes, you can see the progress of the upload. During uploading a progress bar will appear showing progress info, however this functionality functions only in browsers supporting HTML5 upload progress bar.
67
+
68
+ = Can I upload many files at the same time? =
69
+
70
+ Yes, but not in the free version. If you want to allow multiple file uploads, please consider the [Professional](http://www.iptanus.com/support/wordpress-file-upload/ "Wordpress File Upload support page") version.
71
+
72
+ = Where do files go after upload? =
73
+
74
+ Files by default are uploaded inside wp-content directory of your Wordpress website. To change it use attribute uploadpath.
75
+
76
+ = Are there filters to restrict uploaded content? =
77
+
78
+ Yes, you can control allowed file size and file extensions by using the appropriate attribute (see Other Notes section).
79
+
80
+ = Are there any upload file size limitations? =
81
+
82
+ Yes, there are file size limitations imposed by the web server or the host. If you want to upload very large files, please consider the [Professional](http://www.iptanus.com/support/wordpress-file-upload/ "Wordpress File Upload support page") version of the plugin, which surpasses size limitations.
83
+
84
+ = Who can upload files? =
85
+
86
+ By default only administrators can upload files. However you can define which user roles are allowed to upload files, beyond administrators. Even guests can be allowed to upload files, however use this option with care.
87
+
88
+ = What security is used for uploading files? =
89
+
90
+ The plugin is designed not to expose website information by using sessions. Parameters passing from server to client side are encoded. For higher protection, like use of captcha, please consider the [Professional](http://www.iptanus.com/support/wordpress-file-upload/ "Wordpress File Upload support page") version of the plugin.
91
+
92
+ == Screenshots ==
93
+
94
+ 1. A screenshot of the plugin in its most simple form.
95
+ 2. A screenshot of the plugin showing the progress bar.
96
+ 3. A screenshot of the plugin showing the successful upload message.
97
+ 4. A screenshot of the plugin with different placement.
98
+ 5. A screenshot of the plugin with user fields.
99
+ 6. A screenshot of the shortcode composer.
100
+ 7. A screenshot of the file browser.
101
+
102
+ == Changelog ==
103
+
104
+ = 2.2.1 =
105
+ * added file browser in Dashboard for admins
106
+ * added attribute medialink to allow uploaded files to be shown in Media
107
+ * serious bug fixed that was breaking the plugin because of preg_replace_callback function
108
+ * corrected error in first attempt to upload file when captcha is enabled
109
+
110
+ = 2.1.3 =
111
+ * variables %pagetitle% and %pageid% added in uploadpath.
112
+ * bug fixes when working with IE8.
113
+ * Shortcode Composer saves selected options
114
+ * Easier handling of userdata variables in Shortcode Composer
115
+ * correction of bug that allowed debugdata to be shown in non-admin users
116
+ * reset.css removed from plugin as it was causing breaks in theme's css
117
+ * correction of bug with WPFilebase Manager plugin
118
+
119
+ = 2.1.2 =
120
+ * Several bug fixes and code reconstruction.
121
+ * Code modifications so that the plugin can operate even when DEBUG mode is ON.
122
+ * New attribute debugmode added to allow better debugging of the plugin when there are errors.
123
+
124
+ = 2.1.1 =
125
+ * Bug fixes with broken images when Wordpress website is in a subdirectory.
126
+ * Replacement of glob function because is not allowed by some servers.
127
+
128
+ = 2.0.2 =
129
+ * Bug fixes in Dashboard Settings Shortcode Composer.
130
+ * Correction of important bug that was breaking page in some cases.
131
+ * Minor improvements of user data fields and notification email attributes.
132
+
133
+ = 2.0.1 =
134
+ This is the initial release of Wordpress File Upload. Since this plugin is the successor of Inline Upload, the whole changelog since the creation of the later is included.
135
+
136
+ * Name of the plugin changed to Wordpress File Upload.
137
+ * Plugin has been completely restructured to allow additional features.
138
+ * A new more advanced message box has been included showing information in a more structured way.
139
+ * Error detection and reporting has been improved.
140
+ * An administration page has been created in the Dashboard Settings, containing a Shortcode Composer.
141
+ * Some more options related to configuration of message showing upload results have been added.
142
+ * Several bug fixes.
143
+
144
+ = 1.7.14 =
145
+ * Userdata attribute changed to allow the creation of more fields and required ones.
146
+ * Spanish translation added thanks to Maria Ramos of WebHostingHub.
147
+
148
+ = 1.7.13 =
149
+ * Added notifyheaders attribute, in order to allow better control of notification email sent (e.g. allow to send HTML email).
150
+
151
+ = 1.7.12 =
152
+ * Added userdata attribute, in order to allow users to send additional text data along with the uploaded file.
153
+
154
+ = 1.7.11 =
155
+ * Added single button operation (file will be automatically uploaded when selected without pressing Upload Button).
156
+
157
+ = 1.7.10 =
158
+ * Fixed bug with functionality of attribute filebaselink for new versions of WP-Filebase plugin.
159
+
160
+ = 1.7.9 =
161
+ * Fixed problem with functionality of attribute filebaselink for new versions of WP-Filebase plugin.
162
+
163
+ = 1.7.8 =
164
+ * More than one roles can now be defined in attribute uploadrole, separated by comma (,).
165
+
166
+ = 1.7.7 =
167
+ * Variable %filename% now works also in redirectlink.
168
+
169
+ = 1.7.6 =
170
+ * Changes in ftp functionality, added useftpdomain attribute so that it can work with external ftp domains as well.
171
+ * Improvement of classic upload (used in IE or when setting forceclassic to true) messaging functionality.
172
+ * Minor bug fixes.
173
+
174
+ = 1.7.5 =
175
+ * Source modified so that it can work with Wordpress sites that are not installed in root.
176
+ * Added variable %blogid% for use with multi-site installations.
177
+ * Bug fixes related to showing of messages.
178
+
179
+ = 1.7.4 =
180
+ * Replacement of json2.js with another version.
181
+
182
+ = 1.7.3 =
183
+ * CSS style changes to resolve conflicts with various theme CSS styles.
184
+
185
+ = 1.7.2 =
186
+ * Added variable %useremail% used in notifyrecipients, notifysubject and notifymessage attributes.
187
+
188
+ = 1.7.1 =
189
+ * Added capability to upload files outside wp-content folder.
190
+ * Improved error reporting.
191
+
192
+ = 1.7 =
193
+ * Complete restructuring of plugin HTML code, in order to make it more configurable and customizable.
194
+ * Appearance of messages has been improved.
195
+ * Added option to put the plugin in testmode.
196
+ * Added option to configure the colors of success and fail messages.
197
+ * Added option to modify the dimensions of the individual objects of the plugin.
198
+ * Added option to change the placement of the individual objects of the plugin.
199
+ * Improved error reporting.
200
+ * Added localization for error messages.
201
+ * Minor bug fixes.
202
+
203
+ = 1.6.3 =
204
+ * Bug fixes to correct incompatibilities of the new ajax functionality when uploadrole is set to "all".
205
+
206
+ = 1.6.2 =
207
+ * Bug fixes to correct incompatibilities of the new ajax functionality with redirectlink, filebaselink and adminmessages.
208
+
209
+ = 1.6.1 =
210
+ * Correction of serious bug that prevented the normal operation of the plugin when the browser of the user supports HTML5 functionality.
211
+ * Tags added to the plugin Wordpress page.
212
+
213
+ = 1.6 =
214
+ * Major lifting of the whole code.
215
+ * Added ajax functionality so that file is uploaded without page reload (works in browsers supporting HTML5).
216
+ * Added upload progress bar (works in browsers supporting HTML5).
217
+ * Added option to allow user to select if wants to use the old form upload functionality.
218
+ * File will not be saved again if user presses the Refresh button (or F5) of the page.
219
+ * Translation strings updated.
220
+ * Bug fixes for problems when there are more than one instances of the plugin in a single page.
221
+
222
+ = 1.5 =
223
+ * Added option to notify user about upload directory.
224
+ * Added option to allow user to select a subfolder to upload the file.
225
+
226
+ = 1.4.1 =
227
+ * css corrections for bug fixes.
228
+
229
+ = 1.4 =
230
+ * Added option to attach uploaded file to notification email.
231
+ * Added option to customize message on successfull upload (variables %filename% and %filepath% can be used).
232
+ * Added option to customize color of message on successfull upload.
233
+ * "C:\fakepath\" problem resolved.
234
+ * warning message about function create_directory() resolved.
235
+ * css enhancements for compatibility with more themes.
236
+
237
+ = 1.3 =
238
+ * Additional variables added (%filename% and %filepath%).
239
+ * All variables can be used inside message subject and message text.
240
+ * Added option to determine how to treat dublicates (overwrite existing file, leave existing file, leave both).
241
+ * Added option to determine how to rename the uploaded file, when another file already exists in the target directory.
242
+ * Added option to create directories and upload files using ftp access, in order to overcome file owner and SAFE MODE restrictions.
243
+ * Added the capability to redirect to another web page when a file is uploaded successfully.
244
+ * Added the option to show to administrators additional messages about upload errors.
245
+ * Bug fixes related to interoperability with WP_Filebase
246
+
247
+ = 1.2 =
248
+ * Added notification by email when a file is uploaded.
249
+ * Added the ability to upload to a variable folder, based on the name of the user currently logged in.
250
+
251
+ = 1.1 =
252
+ Added the option to allow anyone to upload files, by setting the attribute uploadrole to "all".
253
+
254
+ = 1.0 =
255
+ Initial version.
256
+
257
+ == Upgrade Notice ==
258
+
259
+ = 2.2.1 =
260
+ Important upgrade to address some serious bugs and include some new features.
261
+
262
+ = 2.1.3 =
263
+ Important upgrade to address some serious bugs.
264
+
265
+ = 2.1.2 =
266
+ Important upgrade to address some bugs.
267
+
268
+ = 2.1.1 =
269
+ Important upgrade to address some serious bugs.
270
+
271
+ = 2.0.2 =
272
+ Important upgrade to address some serious bugs.
273
+
274
+ = 2.0.1 =
275
+ Optional upgrade to add new features.
276
+
277
+ = 1.7.14 =
278
+ Optional upgrade to add new features.
279
+
280
+ = 1.7.13 =
281
+ Optional upgrade to add new features.
282
+
283
+ = 1.7.12 =
284
+ Optional upgrade to add new features.
285
+
286
+ = 1.7.11 =
287
+ Optional upgrade to add new features.
288
+
289
+ = 1.7.10 =
290
+ Important upgrade to correct bug with filebaselink attribute functionality.
291
+
292
+ = 1.7.9 =
293
+ Important upgrade to resolve issue with filebaselink attribute functionality.
294
+
295
+ = 1.7.8 =
296
+ Optional upgrade to add new features.
297
+
298
+ = 1.7.7 =
299
+ Optional upgrade to add new features.
300
+
301
+ = 1.7.6 =
302
+ Optional upgrade to add new features and make minor bug fixes.
303
+
304
+ = 1.7.5 =
305
+ Important upgrade to resolve issues with Wordpress sites not installed in root.
306
+
307
+ = 1.7.4 =
308
+ Important upgrade to resolve issues with json2 functionality.
309
+
310
+ = 1.7.3 =
311
+ Important upgrade to resolve issues with style incompatibilities.
312
+
313
+ = 1.7.2 =
314
+ Optional upgrade to add new features, related to variables.
315
+
316
+ = 1.7.1 =
317
+ Optional upgrade to add new features, related to uploadpath and error reporting.
318
+
319
+ = 1.7 =
320
+ Optional upgrade to add new features, related to appearance of the plugin and error reporting.
321
+
322
+ = 1.6.3 =
323
+ Important upgrade to correct bugs that prevented normal operation of the plugins in some cases.
324
+
325
+ = 1.6.2 =
326
+ Important upgrade to correct bugs that prevented normal operation of the plugins in some cases.
327
+
328
+ = 1.6.1 =
329
+ Important upgrade to correct bug that prevented normal operation of the plugins in some cases.
330
+
331
+ = 1.6 =
332
+ Optional upgrade to add new features, related to ajax functionality and minor bug fixes.
333
+
334
+ = 1.5 =
335
+ Optional upgrade to add new features, related to subfolders.
336
+
337
+ = 1.4.1 =
338
+ Important upgrade to correct a css problem with Firefox.
339
+
340
+ = 1.4 =
341
+ Important upgrade that introduces some bug fixes and some new capabilities.
342
+
343
+ = 1.3 =
344
+ Important upgrade that introduces some bug fixes and a lot of new capabilities.
345
+
346
+ = 1.2 =
347
+ Optional upgrade in order to set additional capabilities.
348
+
349
+ = 1.1 =
350
+ Optional upgrade in order to set additional capabilities.
351
+
352
+ = 1.0 =
353
+ Initial version.
354
+
355
+ == Attributes ==
356
+
357
+ The easiest way to use the plugin is to put the shortcode [wordpress_file_upload] in the page. In this case, the plugin will use the default functionality.
358
+
359
+ If you want to customize the plugin (define the upload path, use file filter, change title and button text etc.) then you can use attributes. Go to Dashboard / Settings / Wordpress File Upload and then press Shortcode Composer. By selecting the attributes of your choice, the shortcode will be automatically generated. Then you can copy and paste it in any page.
360
+
361
+ A detailed list of attributes, together with instructions is shown below:
362
+
363
+ **General Options**
364
+
365
+ *Basic Functionalities*
366
+
367
+ * **uploadid:** This is the ID of every instance of the plugin inside the same page. Valid values are 1,2,3... Please use a different value for every instance.
368
+ * **singlebutton:** If this attribute is set to "true", only Upload Button will be shown and file will be automatically uploaded when selected. Default value is "false".
369
+ * **uploadpath:** This is the path of the upload directory. The path must be relative to wp-content folder of your Wordpress website. For instance, if your upload directory is "wp-content/uploads/myuploaddir", then uploadpath must have the value "uploads/myuploaddir". The default value is "uploads", meaning that the files will be uploaded to wp-content/uploads dir. If you put the variable "%username%" inside the uploadpath string, then this variable will be replaced by the username of the user currently logged in. If you want to upload files outside wp-content folder, then put a double dot (..) at the beginning of your uploadpath value.
370
+
371
+ *Filters*
372
+
373
+ * **uploadrole:** This is the roles that are allowed to upload files. Default role is "administrator". If you use other roles, like "editor", then only users of this role and also of role "administrator" will be able to upload files. You can set multiple roles, separated by comma, e.g. "editor, author". If you set uploadrole to "all" then all users, even guests, will be able to upload files.
374
+ * **uploadpatterns:** This is the filter of the uploaded files. Default value is "*.*", meaning that all files can be uploaded. Use this attribute to restrict the types of files that can be uploaded. For instance, in order to upload only pdf files put "\*.pdf". You can use more that one filters, separated by comma, for instance "\*.pdf,\*.doc".
375
+ * **maxsize:** This is the maximum size in MBytes of the uploaded files. Use this attribute to restrict the upload of files larger that this value. Default value is "10", meaning that you cannot upload files larger than 10MBytes.
376
+
377
+ *Upload Path and Files*
378
+
379
+ * **createpath:** If this attribute is set to "true", the upload directory, defined by uploadpath, will be created in case it does not exist. Default value is "false".
380
+ * **accessmethod:** This attributes defines the method to create directories and upload files. Default value is "normal". If it is set to "ftp", then the plugin will attempt to create directories and upload files using ftp access. In order to do this, the attribute *ftpinfo* must also be filled with valid ftp access information. Use this attribute when you cannot upload files, access uploaded files or cannot copy or delete uploaded files because of SAFE MODE restrictions, or because the owner of the file is the domain administrator.
381
+ * **ftpinfo:** This attribute defines the ftp access information. It has the syntax *username:password@domain*. If username, password or domain contains the characters (:) or (@), then replace them with (\\:) and (\\@) in order to avoid misreading of the attribute.
382
+ * **useftpdomain:** This attribute is used when the ftp domain used to upload files is in different domain than Wordpress installation. If it is set to "true" (and also uploadmethod is "ftp"), then the domain that will be used to upload files will be the one defined in ftpinfo attribute. Default value is "false".
383
+ * **showtargetfolder:** This attribute defines if a message with the upload directory will be shown. Default value is "false".
384
+ * **askforsubfolders:** This attribute defines if the user can select a subfolder to upload the file. Default value is "false". If set to "true", then the user is able to select a subfolder of the path, defined by the attribute *uploadpath*, to upload a file through a drop down list. This attributed is used together with attribute *subfoldertree*, which defines the subfolders.
385
+ * **subfoldertree:** This attribute defines the structure of the subfolders that the user can select to upload a file. Default value is "". The format of this attribute is as follows: the subfolders are separated by commas (,), e.g. "subfolder1, subfolder2". It is possible to use nested subfolders (a folder inside another folder). To do this place stars (*) before the name of the subfolder. The number of stars determines nesting level, e.g. "subfolder1, *nested1, *nested2, **nested3". Please note that the first subfolder must be the name of the folder defined by attribute *uploadpath* (only the last part) without any stars, while all the next subfolders must have at least one star. The user has also the capability to use a different name (from the actual subfolder name) to be shown in the drop down list for every subfolder, by separating the actual and shown name using the slash (/) symbol, e.g. "subfolder1, *subfolder2/shownname2, *subfolder3/shownname3".
386
+ * **dublicatespolicy:** This attribute defines what to do when the upload file has the same name with another file inside target directory. If it is set to "overwrite" then the upload file will replace the existing file. If it is set to "reject" then the upload operation will be cancelled. If it is set to "maintain both" then the upload file will be saved inside the target directory with another name, in order to keep both files. Default value is "overwrite".
387
+ * **uniquepattern:** This attribute defines how to save the upload file when a file with the same name already exists inside the target directory. If it is set to "index" then the upload file will be saved with a numeric suffix, like (1), (2) etc. in order to keep the name of the uploaded file unique. If it is set to "datetimestamp", then the suffix will be an encoded datetime of the upload operation. The plugin ensures that the name of the uploaded file will be unique, in order to avoid accidental replacement of existing files. Default value is "index".
388
+
389
+ *Redirection*
390
+
391
+ * **redirect:** This attribute defines if the user will be redirected to another web page when the file is uploaded successfully. Default value is "false".
392
+ * **redirectlink:** This attribute defines the url of the redirection page. Please use the prefix "http://" if the redirection page is in another domain, otherwise the server will assume that the url is relative to the server path.
393
+
394
+ *Other Administrator Options*
395
+ * **adminmessages:** This attribute offers the option to administrator users to receive additional information about upload errors. These messages will be visible only to administrators. Default value is "false".
396
+ * **forceclassic:** This attribute defines if the plugin will use the old classic functionality to upload files (using forms) or ajax functionality (supported in HTML5). Default value is "false". Please note that if your browser does not support HTML ajax functionality, then the plugin will automatically switch to classic one.
397
+ * **testmode:** This attribute defines if the plugin will be shown in test mode. Default value is "false". If it is set to "true", then the plugin will obtain a "dummy" functionality (it will not be able to upload files) and it will appear showing all of its objects (the selection of subfolders, progress bar, a test message), while the buttons will show a "Test Mode" message when pressed. This option can be used to configure the dimensions of the individual objects of the plugin more easily.
398
+ * **debugmode:** This attribute defines if the plugin will show debug information. Default value is "false". If it is set to "true", then the plugin will show in the message box any warnings and errors generated by PHP during the upload process. It can be used by administrators for deep debugging. For generation of PHP warnings and errors, global Wordpress WP_DEBUG constant must be enabled.
399
+
400
+
401
+ **Placements**
402
+
403
+ *Plugin Component Positions*
404
+
405
+ * **placements:** This attribute can be used to change the placement of the objects of the plugin. Default value is "title/filename+selectbutton+uploadbutton/subfolders/userdata/progressbar/message". Every line is separated by a slash (/). To put more than one objects to the same line, separate them with a plus (+). The name of every object is shown below.
406
+
407
+ **Labels**
408
+
409
+ *Title*
410
+
411
+ * **uploadtitle:** The title of the plugin. Default value is "Upload a file".
412
+
413
+ *Buttons*
414
+
415
+ * **selectbutton:** The title of the select button. Default value is "Select File".
416
+ * **uploadbutton:** The title of the upload button. Default value is "Upload File".
417
+
418
+ *Upload Folder*
419
+
420
+ * **targetfolderlabel:** This attribute defines the text for the message for the upload directory. Default value is "Upload Directory".
421
+
422
+ *Upload Messages*
423
+
424
+ * **successmessage:** This attribute defines the message to be shown upon successful upload. Default value is "File %filename% uploaded successfully". You can use the variables %filename% and %filepath% inside the message, as explained below.
425
+ * **warningmessage:** This attribute defines the message to be shown upon successful upload but with warnings. Default value is "File %filename% uploaded successfully but with warnings". You can use the variables %filename% and %filepath% inside the message, as explained below.
426
+ * **errormessage:** This attribute defines the message to be shown upon upload failure. Default value is "File %filename% not uploaded". You can use the variables %filename% and %filepath% inside the message, as explained below.
427
+ * **waitmessage:** This attribute defines the message to be shown while uploading. Default value is "File %filename% is being uploaded". You can use the variables %filename% and %filepath% inside the message, as explained below.
428
+
429
+ **Notifications**
430
+
431
+ *Email Notifications*
432
+
433
+ * **notify:** If this attribute is set to "true", then an email will be sent to the addresses defined by the attribute *notifyrecipients* to inform them that a new file has been uploaded.
434
+ * **notifyrecipients:** This attribute defines the list of email addresses to receive the notification message that a new file has been uploaded. More that one address can be defined, separated by comma (,). You can use variables inside this attribute, as explained below.
435
+ * **notifyheaders:** This attribute defines additional headers to be included in the notification email (e.g. set "From", "Cc" and "Bcc" parameters or use HTML code instead of text). Default value is "". For example, in order to send HTML email please set this attribute to "Content-type: text/html".
436
+ * **notifysubject:** This attribute defines the subject for the notification message. Default value is "File Upload Notification". You can use variables inside this attribute, as explained below.
437
+ * **notifymessage:** This attribute defines the body text for the notification message. Default value is "Dear Recipient, this is an automatic delivery message to notify you that a new file has been uploaded. Best Regards". You can use variables inside this attribute, as explained below.
438
+ * **attachfile:** This attribute defines if the uploaded file will be attached to the notification email. Default value is "false".
439
+
440
+ **Colors**
441
+
442
+ *Upload Message Colors*
443
+
444
+ * **successmessagecolor:** This attribute defines the color of the message shown upon successful upload. Default value is "green". This attribute is no longer used but is maintained for backward compatibility. Please use successmessagecolors instead.
445
+ * **successmessagecolors:** This attribute defines the colors of the message shown upon successful upload. Default value is "#006600,#EEFFEE,#006666". The first value is the text color, the second the background color and the third the border color.
446
+ * **warningmessagecolors:** This attribute defines the colors of the message shown upon successful upload but with warnings. Default value is "#F88017,#FEF2E7,#633309". The first value is the text color, the second the background color and the third the border color.
447
+ * **failmessagecolors:** This attribute defines the colors of the message shown upon upload failure. Default value is "#660000,#FFEEEE,#666600". The first value is the text color, the second the background color and the third the border color.
448
+ * **waitmessagecolors:** This attribute defines the colors of the message shown while file uploading. Default value is "#666666,#EEEEEE,#333333". The first value is the text color, the second the background color and the third the border color.
449
+
450
+ **Dimensions**
451
+
452
+ *Plugin Component Widths*
453
+
454
+ * **widths:** This attribute can be used to define the width of every individual object of the plugin. Default value is "". To define the width of an individual object, simply put the name of the object and the width, separated by the (:) character (e.g. "title:100px"). To define more than one objects separate them with comma (,).
455
+
456
+ *Plugin Component Heights*
457
+
458
+ * **heights:** This attribute can be used to define the height of every individual object of the plugin. Default value is "". To define the height of an individual object, simply put the name of the object and the height, separated by the (:) character (e.g. "title:20px"). To define more than one objects separate them with comma (,).
459
+
460
+ **Additional Fields**
461
+
462
+ *Additional Data Fields*
463
+
464
+ * **userdata:** This attribute defines if additional text information will be requested by the user. If set to "true", then an additional textbox will appear, prompting the user to put text data. These data will be sent to email recipients, if email notification has been activated and %userdata% variable exists inside notifymessage attribute. Default value is "false".
465
+ * **userdatalabel:** This attribute defines the labels of the userdata fields. Separate each field with slash "/". If you want a field to be required, then preceed an asterisk (*) before the label. Example to create 2 fields, an optional Name and a required Email field: userdatalabel="Name/*Email (required)". Default value is "Your message".
466
+
467
+ **Interoperability**
468
+
469
+ *Connection With Other Plugins*
470
+
471
+ * **filebaselink:** This attribute defines if this plugin will be linked to wp-filebase plugin. Wp-filebase is another plugin with which you can upload files and then show them in your pages in a customizable way. If you set this attribute to "true", then you can upload files inside wp-filebase directories using wordpress_file_upload and then update the databases of wp-filebase, so that it is informed about the new uploads. The default value is "false". Please note that this attribute does not check to see if wp-filebase is installed and active, so be sure to have wp-filebase active if you want to use it.
472
+ * **medialink:** This attribute defines that uploaded files will be added to Media of the Wordpress website when set to "true". Default value is "false". Credits for this functionality to Aaron Olin.
473
+
474
+ You can use any of these attributes to customize the plugin. The way to use these attributes is the following:
475
+
476
+ `
477
+ [wordpress_file_upload attribute1=value1 attribute2=value2]
478
+ `
479
+
480
+ Here are some examples:
481
+
482
+ `
483
+ [wordpress_file_upload uploadtitle="Upload files to the Upload dir"]
484
+ [wordpress_file_upload uploadtitle="Upload files to the Upload dir" uploadpath="uploads/myuploaddir"]
485
+ [wordpress_file_upload uploadid="1" uploadpath="../myuploaddir"]
486
+ [wordpress_file_upload uploadpath="uploads/users/%username%" createpath="true"]
487
+ [wordpress_file_upload uploadpath="uploads/myuploaddir" notify="true" notifyrecipients="name1@address1.com, name2@address2.com"]
488
+ [wordpress_file_upload uploadpath="/uploads/myuploaddir" askforsubfolders="true" subfoldertree="myuploaddir/My Upload Directory,*subfolder1/Subfolder1 Inside myuploaddir,**inner/2nd Level Nested Dir, *reports/Reports"]
489
+ [wordpress_file_upload uploadrole="all" uploadpath="/uploads/filebase/%username%" createpath="false" notify="true" notifyrecipients="myname@domain.com" notifysubject="A new file has been uploaded!" attachfile="true" askforsubfolders="true" subfoldertree="admin/Administrator,*root/Root Folder,**inner, *reports/Reports" filebaselink="true" widths="filename:150px, selectbutton:80px, uploadbutton:80px, progressbar:220px, message:368px, subfolders_label:100px, subfolders_select:125px" placements="title/filename+subfolders/selectbutton+uploadbutton+progressbar/message"]
490
+ [wordpress_file_upload uploadpath="uploads/myuploaddir" notify="true" notifyrecipients="name1@address1.com, name2@address2.com" notifymessage="File %filename% has been received, together with fields Name:%userdata0%, Email:%userdata1%" userdata="true" userdatalabel="Name/*Email (required)"]
491
+ [wordpress_file_upload uploadpath="uploads/myuploaddir" notify="true" notifyrecipients="name1@address1.com, name2@address2.com" notifymessage="This is a test HTML message body.<br/><br/>This word is <em>italic</em> and this is <strong>bold</strong>." notifyheaders="Content-type: text/html"]
492
+ `
493
+
494
+ == Variables ==
495
+
496
+ From version 1.2 variables are supported inside attributes.
497
+
498
+ A variable is a string surrounded by percent characters, in the form *%variable_name%*. This variable is replaced by another string whenever the plugin is executed.
499
+
500
+ For instance, if the variable %username% is used inside *uploadpath* attribute, then it will be replaced by the username of the user who is currently logged in every time a file is uploaded. By this way, every user can upload files to a separate folder, without any additional programming.
501
+
502
+ For the time being, the following variables are supported:
503
+
504
+ * **%username%:** Is replaced by the username of the current user. Can be used inside attributes *uploadpath*, *notifysubject* and *notifymessage*.
505
+ * **%useremail%:** Is replaced by the email of the current user. Can be used inside attributes *notifyrecipients*, *notifysubject* and *notifymessage*.
506
+ * **%filename%:** Is replaced by the filename (not including path information) of the uploaded file. Can be used inside attributes *notifysubject*, *notifymessage*, *successmessage* and *redirectlink*.
507
+ * **%filepath%:** Is replaced by the filepath (full path and filename) of the uploaded file. Can be used inside attributes *notifysubject*, *notifymessage* and *successmessage*.
508
+ * **%blogid%:** Is replaced by the blog_id of the current site. Can be used inside attribute *uploadpath*.
509
+ * **%userdataXXX%:** Is replaced by the additional message that the user has sent together with the file upload. XXX is the number of the field (starting from 0). The shortcode attribute userdata must have been set to "true". Can be used inside attributes *notifysubject*, *notifymessage*.
510
+ * **%n%:** Denotes change of line (equivalent of \n). Can be used inside attributes *notifymessage* and *notifyheaders*. It exists because of problems of using \n inside the classic page editor of Wordpress.
511
+ * **%pagetitle%:** Is replaced by the title of the current page. Can be used inside attribute *uploadpath*.
512
+ * **%pageid%:** Is replaced by the id of the current page. Can be used inside attribute *uploadpath*.
513
+
514
+ == Requirements ==
515
+
516
+ The plugin requires to have Javascript enabled in your browser. For Internet Explorer you also need to have Active-X enabled.
517
+ Please note that old desktop browsers or mobile browsers may not support all of the plugin's features. In order to get full functionality use the latest versions of browsers, supporting HTML5, AJAX and CSS3.
screenshot-6.jpg ADDED
Binary file
screenshot-7.jpg ADDED
Binary file
wfu_response.php CHANGED
@@ -1,20 +1,20 @@
1
- <?php
2
- /*
3
- This script runs every time the user presses the upload button in order to inform the page that
4
- it should process the file upload data (stored in $_FILES variable) when the page reloads
5
- */
6
- session_start();
7
-
8
- if ( isset($_GET['shortcode_id']) && isset($_GET['session_token']) ) {
9
- //check referer using server sessions to avoid CSRF attacks
10
- if ( $_SESSION["wfu_token_".$_GET['shortcode_id']] != $_GET['session_token'] ) die();
11
-
12
- if ( isset($_GET['start_time']) ) {
13
- $_SESSION['wfu_check_refresh_'.$_GET['shortcode_id']] = 'form button pressed';
14
- $_SESSION['wfu_start_time_'.$_GET['shortcode_id']] = $_GET['start_time'];
15
-
16
- die("wfu_response_success:");
17
- }
18
- }
19
- die();
20
- ?>
1
+ <?php
2
+ /*
3
+ This script runs every time the user presses the upload button in order to inform the page that
4
+ it should process the file upload data (stored in $_FILES variable) when the page reloads
5
+ */
6
+ session_start();
7
+
8
+ if ( isset($_GET['shortcode_id']) && isset($_GET['session_token']) ) {
9
+ //check referer using server sessions to avoid CSRF attacks
10
+ if ( $_SESSION["wfu_token_".$_GET['shortcode_id']] != $_GET['session_token'] ) die();
11
+
12
+ if ( isset($_GET['start_time']) ) {
13
+ $_SESSION['wfu_check_refresh_'.$_GET['shortcode_id']] = 'form button pressed';
14
+ $_SESSION['wfu_start_time_'.$_GET['shortcode_id']] = $_GET['start_time'];
15
+
16
+ die("wfu_response_success:");
17
+ }
18
+ }
19
+ die();
20
+ ?>
wordpress_file_upload.php CHANGED
@@ -1,287 +1,287 @@
1
- <?php
2
- session_start();
3
- /*
4
- Plugin Name: Wordpress File Upload
5
- Plugin URI: http://www.iptanus.com/support/wordpress-file-upload
6
- Description: Simple interface to upload files from a page.
7
- Version: 2.1.3
8
- Author: Nickolas Bossinas
9
- Author URI: http://www.iptanus.com
10
- */
11
-
12
- /*
13
- Wordpress File Upload (Wordpress Plugin)
14
- Copyright (C) 2010, 2011, 2012, 2013 Nickolas Bossinas
15
- Contact me at http://www.iptanus.com
16
-
17
- This program is free software: you can redistribute it and/or modify
18
- it under the terms of the GNU General Public License as published by
19
- the Free Software Foundation, either version 3 of the License, or
20
- (at your option) any later version.
21
-
22
- This program is distributed in the hope that it will be useful,
23
- but WITHOUT ANY WARRANTY; without even the implied warranty of
24
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25
- GNU General Public License for more details.
26
-
27
- You should have received a copy of the GNU General Public License
28
- along with this program. If not, see <http://www.gnu.org/licenses/>.
29
- */
30
-
31
- /* do not load plugin if this is the login page */
32
- global $pagenow;
33
- if ( 'wp-login.php' == $pagenow ) return;
34
-
35
- DEFINE("WPFILEUPLOAD_DIR", '/'.PLUGINDIR .'/'.dirname(plugin_basename (__FILE__)).'/');
36
- add_shortcode("wordpress_file_upload", "wordpress_file_upload_handler");
37
- load_plugin_textdomain('wordpress-file-upload', false, dirname(plugin_basename (__FILE__)).'/languages');
38
- /* do not load styles and scripts in admin pages */
39
- if ( is_admin() ) {
40
- if ( $pagenow == "options-general.php" ) {
41
- wp_enqueue_style('wordpress-file-upload-admin-style', WPFILEUPLOAD_DIR.'css/wordpress_file_upload_adminstyle.css',false,'1.0','all');
42
- wp_enqueue_style( 'wp-color-picker' );
43
- wp_enqueue_script('wordpress_file_upload_admin_script', WPFILEUPLOAD_DIR.'js/wordpress_file_upload_adminfunctions.js', array( 'wp-color-picker' ), false, true);
44
- wp_enqueue_script('wordpress_file_upload_classname_script', WPFILEUPLOAD_DIR.'js/getElementsByClassName-1.0.1.js');
45
- wp_localize_script( 'wordpress_file_upload_admin_script', 'AdminParams', array("wfu_ajax_url" => site_url()."/wp-admin/admin-ajax.php") );
46
- }
47
- }
48
- else {
49
- // wp_enqueue_style('wordpress-file-upload-reset', WPFILEUPLOAD_DIR.'css/wordpress_file_upload_reset.css',false,'1.0','all');
50
- wp_enqueue_style('wordpress-file-upload-style', WPFILEUPLOAD_DIR.'css/wordpress_file_upload_style.css',false,'1.0','all');
51
- wp_enqueue_style('wordpress-file-upload-style-safe', WPFILEUPLOAD_DIR.'css/wordpress_file_upload_style_safe.css',false,'1.0','all');
52
- wp_enqueue_script('json_class', WPFILEUPLOAD_DIR.'js/json2.js');
53
- wp_enqueue_script('wordpress_file_upload_script', WPFILEUPLOAD_DIR.'js/wordpress_file_upload_functions.js');
54
- }
55
- add_action('admin_menu', 'wordpress_file_upload_add_admin_pages');
56
- add_action('wp_ajax_wfu_ajax_action', 'wfu_ajax_action_callback');
57
- add_action('wp_ajax_nopriv_wfu_ajax_action', 'wfu_ajax_action_callback');
58
- add_action('wp_ajax_wfu_ajax_action_send_email_notification', 'wfu_ajax_action_send_email_notification');
59
- add_action('wp_ajax_nopriv_wfu_ajax_action_send_email_notification', 'wfu_ajax_action_send_email_notification');
60
- add_action('wp_ajax_wfu_ajax_action_save_shortcode', 'wfu_ajax_action_save_shortcode');
61
- wfu_include_lib();
62
- //foreach ( glob( plugin_dir_path( __FILE__ )."lib/*.php" ) as $file )
63
- // include_once $file;
64
-
65
- function wfu_include_lib() {
66
- if ( $handle = opendir(plugin_dir_path( __FILE__ )."lib/") ) {
67
- $blacklist = array('.', '..');
68
- while ( false !== ($file = readdir($handle)) )
69
- if ( !in_array($file, $blacklist) )
70
- include_once plugin_dir_path( __FILE__ )."lib/".$file;
71
- closedir($handle);
72
- }
73
- }
74
-
75
- /* exit if we are in admin pages (in case of ajax call) */
76
- if ( is_admin() ) return;
77
-
78
- function wordpress_file_upload_handler($incomingfrompost) {
79
- //process incoming attributes assigning defaults if required
80
- $defs = wfu_attribute_definitions();
81
- $defs_indexed = array();
82
- foreach ( $defs as $def ) $defs_indexed[$def["attribute"]] = $def["value"];
83
- $incomingfrompost = shortcode_atts($defs_indexed, $incomingfrompost);
84
- //run function that actually does the work of the plugin
85
- $wordpress_file_upload_output = wordpress_file_upload_function($incomingfrompost);
86
- //send back text to replace shortcode in post
87
- return $wordpress_file_upload_output;
88
- }
89
-
90
- function wordpress_file_upload_function($incomingfromhandler) {
91
- global $post;
92
- global $blog_id;
93
- $params = wfu_plugin_parse_array($incomingfromhandler);
94
- $sid = $params["uploadid"];
95
-
96
- $_SESSION['wfu_token_'.$sid] = uniqid(mt_rand(), TRUE);
97
-
98
- $user = wp_get_current_user();
99
- $widths = wfu_decode_dimensions($params["widths"]);
100
- $heights = wfu_decode_dimensions($params["heights"]);
101
-
102
- $uploadedfile = 'uploadedfile_'.$sid;
103
- $hiddeninput = 'hiddeninput_'.$sid;
104
- $adminerrorcodes = 'adminerrorcodes_'.$sid;
105
- $upload_clickaction = 'wfu_redirect_to_classic('.$sid.', \''.$_SESSION['wfu_token_'.$sid].'\' , 0, 0);';
106
-
107
- //check if user is allowed to view plugin, otherwise do not generate it
108
- $uploadroles = explode(",", $params["uploadrole"]);
109
- foreach ( $uploadroles as &$uploadrole ) {
110
- $uploadrole = strtolower(trim($uploadrole));
111
- }
112
- $plugin_upload_user_role = wfu_get_user_role($user, $uploadroles);
113
- if ( !in_array($plugin_upload_user_role, $uploadroles) && $plugin_upload_user_role != 'administrator' && $params["uploadrole"] != 'all' ) return;
114
-
115
- //activate debug mode only for admins
116
- if ( $plugin_upload_user_role != 'administrator' ) $params["debugmode"] = "false";
117
-
118
- $params["adminmessages"] = ( $params["adminmessages"] == "true" && $plugin_upload_user_role == 'administrator' );
119
- // define variable to hold any additional admin errors coming before processing of files (e.g. due to redirection)
120
- $params["adminerrors"] = "";
121
-
122
- /* Define dynamic upload path from variables */
123
- $search = array ('/%username%/', '/%blogid%/', '/%pageid%/', '/%pagetitle%/');
124
- if ( is_user_logged_in() ) $username = $user->user_login;
125
- else $username = "guests";
126
- $replace = array ($username, $blog_id, $post->ID, get_the_title($post->ID));
127
- $params["uploadpath"] = preg_replace($search, $replace, $params["uploadpath"]);
128
-
129
- /* Determine if userdata fields have been defined */
130
- $userdata_fields = array();
131
- if ( $params["userdata"] == "true" && $params["userdatalabel"] != "" ) {
132
- $userdata_rawfields = explode("/", $params["userdatalabel"]);
133
- foreach ($userdata_rawfields as $userdata_rawitem) {
134
- if ( $userdata_rawitem != "" ) {
135
- $is_required = ( $userdata_rawitem[0] == "*" ? "true" : "false" );
136
- if ( $is_required == "true" ) $userdata_rawitem = substr($userdata_rawitem, 1);
137
- if ( $userdata_rawitem != "" ) {
138
- array_push($userdata_fields, array( "label" => $userdata_rawitem, "required" => $is_required ));
139
- }
140
- }
141
- }
142
-
143
- }
144
- $params["userdata_fields"] = $userdata_fields;
145
-
146
- /* Prepare information about directory or selection of target subdirectory */
147
- $subfolders = wfu_prepare_subfolders_block($params, $widths, $heights);
148
- $subfolders_item = $subfolders['item'];
149
- $params['subfoldersarray'] = $subfolders['paths'];
150
-
151
- //____________________________________________________________________________________________________________________________________________________________________________________
152
-
153
- if ( $params['forceclassic'] != "true" ) {
154
- //**************section to put additional options inside params array**************
155
- $params['subdir_selection_index'] = "-1";
156
- //**************end of section of additional options inside params array**************
157
-
158
-
159
- // below this line no other changes to params array are allowed
160
-
161
-
162
- //**************section to save params as Wordpress options**************
163
- // every params array is indexed (uniquely identified) by three fields:
164
- // - the page that contains the shortcode
165
- // - the id of the shortcode instance (because there may be more than one instances of the shortcode inside a page)
166
- // - the user that views the plugin (because some items of the params array are affected by the user name)
167
- // the wordpress option "wfu_params_index" holds an array of combinations of these three fields, together with a randomly generated string that corresponds to these fields.
168
- // the wordpress option "wfu_params_xxx", where xxx is the randomly generated string, holds the params array (encoded to string) that corresponds to this string.
169
- // the structure of the "wfu_params_index" option is as follows: "a1||b1||c1||d1&&a2||b2||c2||d2&&...", where
170
- // - a is the randomly generated string (16 characters)
171
- // - b is the page id
172
- // - c is the shortcode id
173
- // - d is the user name
174
- $params_index = wfu_generate_current_params_index($sid, $user->user_login);
175
- $params_str = wfu_encode_array_to_string($params);
176
- update_option('wfu_params_'.$params_index, $params_str);
177
- $ajax_params['shortcode_id'] = $sid;
178
- $ajax_params['params_index'] = $params_index;
179
- $ajax_params['debugmode'] = $params["debugmode"];
180
- $ajax_params['is_admin'] = ( $plugin_upload_user_role == 'administrator' ? "true" : "false" );
181
- $ajax_params["fail_colors"] = $params["failmessagecolors"];
182
-
183
- $ajax_params_str = wfu_encode_array_to_string($ajax_params);
184
- $upload_clickaction = 'wfu_HTML5UploadFile('.$sid.', \''.$ajax_params_str.'\', \''.$_SESSION['wfu_token_'.$sid].'\')';
185
- }
186
- $upload_onclick = ' onclick="'.$upload_clickaction.'"';
187
-
188
- /* Prepare the title */
189
- $title_item = wfu_prepare_title_block($params, $widths, $heights);
190
- /* Prepare the text box showing filename */
191
- $textbox_item = wfu_prepare_textbox_block($params, $widths, $heights);
192
- /* Prepare the upload form */
193
- $additional_params = array( );
194
- $uploadform_item = wfu_prepare_uploadform_block($params, $widths, $heights, $upload_clickaction, $additional_params);
195
- /* Prepare the submit button */
196
- $submit_item = wfu_prepare_submit_block($params, $widths, $heights, $upload_clickaction);
197
- /* Prepare the progress bar */
198
- $progressbar_item = wfu_prepare_progressbar_block($params, $widths, $heights);
199
- /* Prepare the message */
200
- $message_item = wfu_prepare_message_block($params, $widths, $heights);
201
- /* Prepare user data */
202
- $userdata_item = wfu_prepare_userdata_block($params, $widths, $heights);
203
-
204
- /* Compose the html code for the plugin */
205
- $wordpress_file_upload_output = "";
206
- $wordpress_file_upload_output .= '<div id="wordpress_file_upload_block_'.$sid.'" class="file_div_clean">';
207
- $itemplaces = explode("/", $params["placements"]);
208
- foreach ( $itemplaces as $section ) {
209
- $items_in_section = explode("+", trim($section));
210
- $section_array = array( );
211
- foreach ( $items_in_section as $item_in_section ) {
212
- $item_in_section = strtolower(trim($item_in_section));
213
- if ( $item_in_section == "title" ) array_push($section_array, $title_item);
214
- elseif ( $item_in_section == "filename" ) array_push($section_array, $textbox_item);
215
- elseif ( $item_in_section == "selectbutton" ) array_push($section_array, $uploadform_item);
216
- elseif ( $item_in_section == "uploadbutton" && $params["singlebutton"] != "true" ) array_push($section_array, $submit_item);
217
- elseif ( $item_in_section == "subfolders" ) array_push($section_array, $subfolders_item);
218
- elseif ( $item_in_section == "progressbar" ) array_push($section_array, $progressbar_item);
219
- elseif ( $item_in_section == "message" ) array_push($section_array, $message_item);
220
- elseif ( $item_in_section == "userdata" && $params["userdata"] == "true" ) array_push($section_array, $userdata_item);
221
- }
222
- $wordpress_file_upload_output .= call_user_func_array("wfu_add_div", $section_array);
223
- }
224
- /* Append mandatory blocks, if have not been included in placements attribute */
225
- if ( $params["userdata"] == "true" && strpos($params["placements"], "userdata") === false ) {
226
- $section_array = array( );
227
- array_push($section_array, $userdata_item);
228
- $wordpress_file_upload_output .= call_user_func_array("wfu_add_div", $section_array);
229
- }
230
- if ( strpos($params["placements"], "selectbutton") === false ) {
231
- $section_array = array( );
232
- array_push($section_array, $uploadform_item);
233
- $wordpress_file_upload_output .= call_user_func_array("wfu_add_div", $section_array);
234
- }
235
- /* Pass constants to javascript */
236
- $consts = wfu_set_javascript_constants();
237
- $handler = 'function() { wfu_Initialize_Consts("'.$consts.'") }';
238
- $wordpress_file_upload_output .= "\n\t".'<script type="text/javascript">if(window.addEventListener) { window.addEventListener("load", '.$handler.', false); } else if(window.attachEvent) { window.attachEvent("onload", '.$handler.'); } else { window["onload"] = '.$handler.'; }</script>';
239
- $wordpress_file_upload_output .= '</div>';
240
- // $wordpress_file_upload_output .= '<div>';
241
- // $wordpress_file_upload_output .= wfu_test_admin();
242
- // $wordpress_file_upload_output .= '</div>';
243
-
244
- // The plugin uses sessions in order to detect if the page was loaded due to file upload or
245
- // because the user pressed the Refresh button (or F5) of the page.
246
- // In the second case we do not want to perform any file upload, so we abort the rest of the script.
247
- if ( $_SESSION['wfu_check_refresh_'.$sid] != "form button pressed" ) {
248
- $_SESSION['wfu_check_refresh_'.$sid] = 'do not process';
249
- return $wordpress_file_upload_output."\n";
250
- }
251
- $_SESSION['wfu_check_refresh_'.$sid] = 'do not process';
252
- $params["upload_start_time"] = $_SESSION['wfu_start_time_'.$sid];
253
-
254
- // The plugin uses two ways to upload the file:
255
- // - The first one uses classic functionality of an HTML form (highest compatibility with browsers but few capabilities).
256
- // - The second uses ajax (HTML5) functionality (medium compatibility with browsers but many capabilities, like no page refresh and progress bar).
257
- // The plugin loads using ajax functionality by default, however if it detects that ajax functionality is not supported, it will automatically switch to classic functionality.
258
- // The next line checks to see if the form was submitted using ajax or classic functionality.
259
- // If the uploaded file variable stored in $_FILES ends with "_redirected", then it means that ajax functionality is not supported and the plugin must switch to classic functionality.
260
- if ( isset($_FILES[$uploadedfile.'_redirected']) ) $params['forceclassic'] = "true";
261
-
262
- if ( $params['forceclassic'] != "true" ) return $wordpress_file_upload_output."\n";
263
-
264
- // The section below is executed when using classic upload methods
265
- if ( isset( $_POST[$adminerrorcodes] ) ) {
266
- $code = $_POST[$adminerrorcodes];
267
- if ( $code == "" ) $params['adminerrors'] = "";
268
- elseif ( $code == "1" || $code == "2" || $code == "3" ) $params['adminerrors'] = constant('WFU_ERROR_REDIRECTION_ERRORCODE'.$code);
269
- else $params['adminerrors'] = WFU_ERROR_REDIRECTION_ERRORCODE0;
270
- }
271
-
272
- $params['subdir_selection_index'] = -1;
273
- if ( isset( $_POST[$hiddeninput] ) ) $params['subdir_selection_index'] = $_POST[$hiddeninput];
274
-
275
- $wfu_process_file_array = wfu_process_files($params, 'no_ajax');
276
- $safe_output = $wfu_process_file_array["general"]['safe_output'];
277
- unset($wfu_process_file_array["general"]['safe_output']);
278
-
279
- $wfu_process_file_array_str = wfu_encode_array_to_string($wfu_process_file_array);
280
- $ProcessUploadComplete_functiondef = 'function(){wfu_ProcessUploadComplete('.$sid.', 1, "'.$wfu_process_file_array_str.'", "no-ajax", "", "", "'.$safe_output.'", ["false", "", "false"]);}';
281
- $wordpress_file_upload_output .= '<script type="text/javascript">window.onload='.$ProcessUploadComplete_functiondef.'</script>';
282
-
283
-
284
- return $wordpress_file_upload_output."\n";
285
- }
286
-
287
- ?>
1
+ <?php
2
+ session_start();
3
+ /*
4
+ Plugin Name: Wordpress File Upload
5
+ Plugin URI: http://www.iptanus.com/support/wordpress-file-upload
6
+ Description: Simple interface to upload files from a page.
7
+ Version: 2.2.1
8
+ Author: Nickolas Bossinas
9
+ Author URI: http://www.iptanus.com
10
+ */
11
+
12
+ /*
13
+ Wordpress File Upload (Wordpress Plugin)
14
+ Copyright (C) 2010-2014 Nickolas Bossinas
15
+ Contact me at http://www.iptanus.com
16
+
17
+ This program is free software: you can redistribute it and/or modify
18
+ it under the terms of the GNU General Public License as published by
19
+ the Free Software Foundation, either version 3 of the License, or
20
+ (at your option) any later version.
21
+
22
+ This program is distributed in the hope that it will be useful,
23
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
24
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25
+ GNU General Public License for more details.
26
+
27
+ You should have received a copy of the GNU General Public License
28
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
29
+ */
30
+
31
+ /* do not load plugin if this is the login page */
32
+ global $pagenow;
33
+ if ( 'wp-login.php' == $pagenow ) return;
34
+
35
+ DEFINE("WPFILEUPLOAD_DIR", '/'.PLUGINDIR .'/'.dirname(plugin_basename (__FILE__)).'/');
36
+ add_shortcode("wordpress_file_upload", "wordpress_file_upload_handler");
37
+ load_plugin_textdomain('wordpress-file-upload', false, dirname(plugin_basename (__FILE__)).'/languages');
38
+ /* do not load styles and scripts in admin pages */
39
+ if ( is_admin() ) {
40
+ if ( $pagenow == "options-general.php" ) {
41
+ wp_enqueue_style('wordpress-file-upload-admin-style', WPFILEUPLOAD_DIR.'css/wordpress_file_upload_adminstyle.css',false,'1.0','all');
42
+ wp_enqueue_style( 'wp-color-picker' );
43
+ wp_enqueue_script('wordpress_file_upload_admin_script', WPFILEUPLOAD_DIR.'js/wordpress_file_upload_adminfunctions.js', array( 'wp-color-picker' ), false, true);
44
+ wp_enqueue_script('wordpress_file_upload_classname_script', WPFILEUPLOAD_DIR.'js/getElementsByClassName-1.0.1.js');
45
+ wp_localize_script( 'wordpress_file_upload_admin_script', 'AdminParams', array("wfu_ajax_url" => site_url()."/wp-admin/admin-ajax.php") );
46
+ }
47
+ }
48
+ else {
49
+ // wp_enqueue_style('wordpress-file-upload-reset', WPFILEUPLOAD_DIR.'css/wordpress_file_upload_reset.css',false,'1.0','all');
50
+ wp_enqueue_style('wordpress-file-upload-style', WPFILEUPLOAD_DIR.'css/wordpress_file_upload_style.css',false,'1.0','all');
51
+ wp_enqueue_style('wordpress-file-upload-style-safe', WPFILEUPLOAD_DIR.'css/wordpress_file_upload_style_safe.css',false,'1.0','all');
52
+ wp_enqueue_script('json_class', WPFILEUPLOAD_DIR.'js/json2.js');
53
+ wp_enqueue_script('wordpress_file_upload_script', WPFILEUPLOAD_DIR.'js/wordpress_file_upload_functions.js');
54
+ }
55
+ add_action('admin_menu', 'wordpress_file_upload_add_admin_pages');
56
+ add_action('wp_ajax_wfu_ajax_action', 'wfu_ajax_action_callback');
57
+ add_action('wp_ajax_nopriv_wfu_ajax_action', 'wfu_ajax_action_callback');
58
+ add_action('wp_ajax_wfu_ajax_action_send_email_notification', 'wfu_ajax_action_send_email_notification');
59
+ add_action('wp_ajax_nopriv_wfu_ajax_action_send_email_notification', 'wfu_ajax_action_send_email_notification');
60
+ add_action('wp_ajax_wfu_ajax_action_save_shortcode', 'wfu_ajax_action_save_shortcode');
61
+ wfu_include_lib();
62
+ //foreach ( glob( plugin_dir_path( __FILE__ )."lib/*.php" ) as $file )
63
+ // include_once $file;
64
+
65
+ function wfu_include_lib() {
66
+ if ( $handle = opendir(plugin_dir_path( __FILE__ )."lib/") ) {
67
+ $blacklist = array('.', '..');
68
+ while ( false !== ($file = readdir($handle)) )
69
+ if ( !in_array($file, $blacklist) )
70
+ include_once plugin_dir_path( __FILE__ )."lib/".$file;
71
+ closedir($handle);
72
+ }
73
+ }
74
+
75
+ /* exit if we are in admin pages (in case of ajax call) */
76
+ if ( is_admin() ) return;
77
+
78
+ function wordpress_file_upload_handler($incomingfrompost) {
79
+ //process incoming attributes assigning defaults if required
80
+ $defs = wfu_attribute_definitions();
81
+ $defs_indexed = array();
82
+ foreach ( $defs as $def ) $defs_indexed[$def["attribute"]] = $def["value"];
83
+ $incomingfrompost = shortcode_atts($defs_indexed, $incomingfrompost);
84
+ //run function that actually does the work of the plugin
85
+ $wordpress_file_upload_output = wordpress_file_upload_function($incomingfrompost);
86
+ //send back text to replace shortcode in post
87
+ return $wordpress_file_upload_output;
88
+ }
89
+
90
+ function wordpress_file_upload_function($incomingfromhandler) {
91
+ global $post;
92
+ global $blog_id;
93
+ $params = wfu_plugin_parse_array($incomingfromhandler);
94
+ $sid = $params["uploadid"];
95
+
96
+ $_SESSION['wfu_token_'.$sid] = uniqid(mt_rand(), TRUE);
97
+
98
+ $user = wp_get_current_user();
99
+ $widths = wfu_decode_dimensions($params["widths"]);
100
+ $heights = wfu_decode_dimensions($params["heights"]);
101
+
102
+ $uploadedfile = 'uploadedfile_'.$sid;
103
+ $hiddeninput = 'hiddeninput_'.$sid;
104
+ $adminerrorcodes = 'adminerrorcodes_'.$sid;
105
+ $upload_clickaction = 'wfu_redirect_to_classic('.$sid.', \''.$_SESSION['wfu_token_'.$sid].'\' , 0, 0);';
106
+
107
+ //check if user is allowed to view plugin, otherwise do not generate it
108
+ $uploadroles = explode(",", $params["uploadrole"]);
109
+ foreach ( $uploadroles as &$uploadrole ) {
110
+ $uploadrole = strtolower(trim($uploadrole));
111
+ }
112
+ $plugin_upload_user_role = wfu_get_user_role($user, $uploadroles);
113
+ if ( !in_array($plugin_upload_user_role, $uploadroles) && $plugin_upload_user_role != 'administrator' && $params["uploadrole"] != 'all' ) return;
114
+
115
+ //activate debug mode only for admins
116
+ if ( $plugin_upload_user_role != 'administrator' ) $params["debugmode"] = "false";
117
+
118
+ $params["adminmessages"] = ( $params["adminmessages"] == "true" && $plugin_upload_user_role == 'administrator' );
119
+ // define variable to hold any additional admin errors coming before processing of files (e.g. due to redirection)
120
+ $params["adminerrors"] = "";
121
+
122
+ /* Define dynamic upload path from variables */
123
+ $search = array ('/%username%/', '/%blogid%/', '/%pageid%/', '/%pagetitle%/');
124
+ if ( is_user_logged_in() ) $username = $user->user_login;
125
+ else $username = "guests";
126
+ $replace = array ($username, $blog_id, $post->ID, get_the_title($post->ID));
127
+ $params["uploadpath"] = preg_replace($search, $replace, $params["uploadpath"]);
128
+
129
+ /* Determine if userdata fields have been defined */
130
+ $userdata_fields = array();
131
+ if ( $params["userdata"] == "true" && $params["userdatalabel"] != "" ) {
132
+ $userdata_rawfields = explode("/", $params["userdatalabel"]);
133
+ foreach ($userdata_rawfields as $userdata_rawitem) {
134
+ if ( $userdata_rawitem != "" ) {
135
+ $is_required = ( $userdata_rawitem[0] == "*" ? "true" : "false" );
136
+ if ( $is_required == "true" ) $userdata_rawitem = substr($userdata_rawitem, 1);
137
+ if ( $userdata_rawitem != "" ) {
138
+ array_push($userdata_fields, array( "label" => $userdata_rawitem, "required" => $is_required ));
139
+ }
140
+ }
141
+ }
142
+
143
+ }
144
+ $params["userdata_fields"] = $userdata_fields;
145
+
146
+ /* Prepare information about directory or selection of target subdirectory */
147
+ $subfolders = wfu_prepare_subfolders_block($params, $widths, $heights);
148
+ $subfolders_item = $subfolders['item'];
149
+ $params['subfoldersarray'] = $subfolders['paths'];
150
+
151
+ //____________________________________________________________________________________________________________________________________________________________________________________
152
+
153
+ if ( $params['forceclassic'] != "true" ) {
154
+ //**************section to put additional options inside params array**************
155
+ $params['subdir_selection_index'] = "-1";
156
+ //**************end of section of additional options inside params array**************
157
+
158
+
159
+ // below this line no other changes to params array are allowed
160
+
161
+
162
+ //**************section to save params as Wordpress options**************
163
+ // every params array is indexed (uniquely identified) by three fields:
164
+ // - the page that contains the shortcode
165
+ // - the id of the shortcode instance (because there may be more than one instances of the shortcode inside a page)
166
+ // - the user that views the plugin (because some items of the params array are affected by the user name)
167
+ // the wordpress option "wfu_params_index" holds an array of combinations of these three fields, together with a randomly generated string that corresponds to these fields.
168
+ // the wordpress option "wfu_params_xxx", where xxx is the randomly generated string, holds the params array (encoded to string) that corresponds to this string.
169
+ // the structure of the "wfu_params_index" option is as follows: "a1||b1||c1||d1&&a2||b2||c2||d2&&...", where
170
+ // - a is the randomly generated string (16 characters)
171
+ // - b is the page id
172
+ // - c is the shortcode id
173
+ // - d is the user name
174
+ $params_index = wfu_generate_current_params_index($sid, $user->user_login);
175
+ $params_str = wfu_encode_array_to_string($params);
176
+ update_option('wfu_params_'.$params_index, $params_str);
177
+ $ajax_params['shortcode_id'] = $sid;
178
+ $ajax_params['params_index'] = $params_index;
179
+ $ajax_params['debugmode'] = $params["debugmode"];
180
+ $ajax_params['is_admin'] = ( $plugin_upload_user_role == 'administrator' ? "true" : "false" );
181
+ $ajax_params["fail_colors"] = $params["failmessagecolors"];
182
+
183
+ $ajax_params_str = wfu_encode_array_to_string($ajax_params);
184
+ $upload_clickaction = 'wfu_HTML5UploadFile('.$sid.', \''.$ajax_params_str.'\', \''.$_SESSION['wfu_token_'.$sid].'\')';
185
+ }
186
+ $upload_onclick = ' onclick="'.$upload_clickaction.'"';
187
+
188
+ /* Prepare the title */
189
+ $title_item = wfu_prepare_title_block($params, $widths, $heights);
190
+ /* Prepare the text box showing filename */
191
+ $textbox_item = wfu_prepare_textbox_block($params, $widths, $heights);
192
+ /* Prepare the upload form */
193
+ $additional_params = array( );
194
+ $uploadform_item = wfu_prepare_uploadform_block($params, $widths, $heights, $upload_clickaction, $additional_params);
195
+ /* Prepare the submit button */
196
+ $submit_item = wfu_prepare_submit_block($params, $widths, $heights, $upload_clickaction);
197
+ /* Prepare the progress bar */
198
+ $progressbar_item = wfu_prepare_progressbar_block($params, $widths, $heights);
199
+ /* Prepare the message */
200
+ $message_item = wfu_prepare_message_block($params, $widths, $heights);
201
+ /* Prepare user data */
202
+ $userdata_item = wfu_prepare_userdata_block($params, $widths, $heights);
203
+
204
+ /* Compose the html code for the plugin */
205
+ $wordpress_file_upload_output = "";
206
+ $wordpress_file_upload_output .= '<div id="wordpress_file_upload_block_'.$sid.'" class="file_div_clean">';
207
+ $itemplaces = explode("/", $params["placements"]);
208
+ foreach ( $itemplaces as $section ) {
209
+ $items_in_section = explode("+", trim($section));
210
+ $section_array = array( );
211
+ foreach ( $items_in_section as $item_in_section ) {
212
+ $item_in_section = strtolower(trim($item_in_section));
213
+ if ( $item_in_section == "title" ) array_push($section_array, $title_item);
214
+ elseif ( $item_in_section == "filename" ) array_push($section_array, $textbox_item);
215
+ elseif ( $item_in_section == "selectbutton" ) array_push($section_array, $uploadform_item);
216
+ elseif ( $item_in_section == "uploadbutton" && $params["singlebutton"] != "true" ) array_push($section_array, $submit_item);
217
+ elseif ( $item_in_section == "subfolders" ) array_push($section_array, $subfolders_item);
218
+ elseif ( $item_in_section == "progressbar" ) array_push($section_array, $progressbar_item);
219
+ elseif ( $item_in_section == "message" ) array_push($section_array, $message_item);
220
+ elseif ( $item_in_section == "userdata" && $params["userdata"] == "true" ) array_push($section_array, $userdata_item);
221
+ }
222
+ $wordpress_file_upload_output .= call_user_func_array("wfu_add_div", $section_array);
223
+ }
224
+ /* Append mandatory blocks, if have not been included in placements attribute */
225
+ if ( $params["userdata"] == "true" && strpos($params["placements"], "userdata") === false ) {
226
+ $section_array = array( );
227
+ array_push($section_array, $userdata_item);
228
+ $wordpress_file_upload_output .= call_user_func_array("wfu_add_div", $section_array);
229
+ }
230
+ if ( strpos($params["placements"], "selectbutton") === false ) {
231
+ $section_array = array( );
232
+ array_push($section_array, $uploadform_item);
233
+ $wordpress_file_upload_output .= call_user_func_array("wfu_add_div", $section_array);
234
+ }
235
+ /* Pass constants to javascript */
236
+ $consts = wfu_set_javascript_constants();
237
+ $handler = 'function() { wfu_Initialize_Consts("'.$consts.'") }';
238
+ $wordpress_file_upload_output .= "\n\t".'<script type="text/javascript">if(window.addEventListener) { window.addEventListener("load", '.$handler.', false); } else if(window.attachEvent) { window.attachEvent("onload", '.$handler.'); } else { window["onload"] = '.$handler.'; }</script>';
239
+ $wordpress_file_upload_output .= '</div>';
240
+ // $wordpress_file_upload_output .= '<div>';
241
+ // $wordpress_file_upload_output .= wfu_test_admin();
242
+ // $wordpress_file_upload_output .= '</div>';
243
+
244
+ // The plugin uses sessions in order to detect if the page was loaded due to file upload or
245
+ // because the user pressed the Refresh button (or F5) of the page.
246
+ // In the second case we do not want to perform any file upload, so we abort the rest of the script.
247
+ if ( $_SESSION['wfu_check_refresh_'.$sid] != "form button pressed" ) {
248
+ $_SESSION['wfu_check_refresh_'.$sid] = 'do not process';
249
+ return $wordpress_file_upload_output."\n";
250
+ }
251
+ $_SESSION['wfu_check_refresh_'.$sid] = 'do not process';
252
+ $params["upload_start_time"] = $_SESSION['wfu_start_time_'.$sid];
253
+
254
+ // The plugin uses two ways to upload the file:
255
+ // - The first one uses classic functionality of an HTML form (highest compatibility with browsers but few capabilities).
256
+ // - The second uses ajax (HTML5) functionality (medium compatibility with browsers but many capabilities, like no page refresh and progress bar).
257
+ // The plugin loads using ajax functionality by default, however if it detects that ajax functionality is not supported, it will automatically switch to classic functionality.
258
+ // The next line checks to see if the form was submitted using ajax or classic functionality.
259
+ // If the uploaded file variable stored in $_FILES ends with "_redirected", then it means that ajax functionality is not supported and the plugin must switch to classic functionality.
260
+ if ( isset($_FILES[$uploadedfile.'_redirected']) ) $params['forceclassic'] = "true";
261
+
262
+ if ( $params['forceclassic'] != "true" ) return $wordpress_file_upload_output."\n";
263
+
264
+ // The section below is executed when using classic upload methods
265
+ if ( isset( $_POST[$adminerrorcodes] ) ) {
266
+ $code = $_POST[$adminerrorcodes];
267
+ if ( $code == "" ) $params['adminerrors'] = "";
268
+ elseif ( $code == "1" || $code == "2" || $code == "3" ) $params['adminerrors'] = constant('WFU_ERROR_REDIRECTION_ERRORCODE'.$code);
269
+ else $params['adminerrors'] = WFU_ERROR_REDIRECTION_ERRORCODE0;
270
+ }
271
+
272
+ $params['subdir_selection_index'] = -1;
273
+ if ( isset( $_POST[$hiddeninput] ) ) $params['subdir_selection_index'] = $_POST[$hiddeninput];
274
+
275
+ $wfu_process_file_array = wfu_process_files($params, 'no_ajax');
276
+ $safe_output = $wfu_process_file_array["general"]['safe_output'];
277
+ unset($wfu_process_file_array["general"]['safe_output']);
278
+
279
+ $wfu_process_file_array_str = wfu_encode_array_to_string($wfu_process_file_array);
280
+ $ProcessUploadComplete_functiondef = 'function(){wfu_ProcessUploadComplete('.$sid.', 1, "'.$wfu_process_file_array_str.'", "no-ajax", "", "", "'.$safe_output.'", ["false", "", "false"]);}';
281
+ $wordpress_file_upload_output .= '<script type="text/javascript">window.onload='.$ProcessUploadComplete_functiondef.'</script>';
282
+
283
+
284
+ return $wordpress_file_upload_output."\n";
285
+ }
286
+
287
+ ?>