Version Description
- added filters and actions before and after each file upload - check below Filters/Actions section for instructions how to use them
- added storage of file info, including user data, in database
- added logging of file actions in database - admins can view the log from the Dashboard
- admins can automatically update the database to reflect the current status of files from the Dashboard
- file browser improvements so that more information about each file (including any user data) are shown
- file browser improvements so that files can be downloaded
- filelist improvements to display correctly long filenames (Pro version)
- filelist improvements to distinguish successful uploads from failed uploads (Pro version)
- improvements of chunked uploads so that files that are not allowed to be uploaded are cancelled faster (Pro version)
- corrected wrong check of file size limit for chunked files (Pro version)
- added postlink attribute so that uploaded files are linked to the current page (or post) as attachments
- added subfolderlabel attribute to define the label of the subfolder selection feature
- several improvements to subfolder selection feature
- default value added to subfolder selection feature
- definition of the subfoldertree attribute in the Shortcode Composer is now done visually
- %userid% variable added inside uploadpath attribute
- userdata variables added inside uploadpath and notifyrecipients attributes
- uploadfolder_label added to dimension items
- user fields feature improvements
- user fields label and input box dimensions are customizable
- captcha prompt label dimensions are customizable (Pro version)
- added gallery attribute to allow the uploaded files to be shown as image gallery below the plugin (Pro version)
- added galleryoptions attribute to define options of the image gallery (Pro version)
- added css attribute and a delicate css editor inside Shortcode Composer to allow better styling of the plugin using custom css (Pro version)
- email feature improved in conjunction with redirection
- improved interoperability with WP-Filebase plugin
- improved functionality of free text attributes (like notifymessage or css) by allowing double-quotes and brackets inside the text (using special variables), that were previously breaking the plugin
Download this release
Release Info
Developer | nickboss |
Plugin | WordPress File Upload |
Version | 2.4.1 |
Comparing to | |
See all releases |
Code changes from version 2.3.1 to 2.4.1
- css/wordpress_file_upload_adminstyle.css +329 -0
- css/wordpress_file_upload_style.css +9 -3
- css/wordpress_file_upload_style_safe.css +3 -3
- images/cancel_12.gif +0 -0
- images/fail_16.png +0 -0
- images/ok_12.gif +0 -0
- images/q_16.png +0 -0
- images/tree_16.gif +0 -0
- js/wordpress_file_upload_adminfunctions.js +879 -5
- js/wordpress_file_upload_functions.js +65 -25
- languages/wordpress-file-upload.pot +106 -80
- lib/wfu_admin.php +94 -647
- lib/wfu_admin_browser.php +662 -0
- lib/wfu_admin_composer.php +410 -0
- lib/wfu_admin_log.php +103 -0
- lib/wfu_ajaxactions.php +108 -0
- lib/wfu_attributes.php +40 -11
- lib/wfu_blocks.php +61 -70
- lib/wfu_constants.php +11 -0
- lib/wfu_functions.php +465 -65
- lib/wfu_processfiles.php +89 -32
- readme.txt +141 -14
- wordpress_file_upload.php +31 -8
css/wordpress_file_upload_adminstyle.css
CHANGED
@@ -161,6 +161,320 @@ span.wfu_ptext_span
|
|
161 |
width: 60px;
|
162 |
}
|
163 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
div.wfu_rolelist_checkall
|
165 |
{
|
166 |
display: inline-block;
|
@@ -571,3 +885,18 @@ span.wfu_save_label_fail
|
|
571 |
font-size: smaller;
|
572 |
opacity: 0;
|
573 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
width: 60px;
|
162 |
}
|
163 |
|
164 |
+
select.wfu_select_folders
|
165 |
+
{
|
166 |
+
height: auto;
|
167 |
+
min-width: 75%;
|
168 |
+
}
|
169 |
+
|
170 |
+
div.wfu_subfolders_inner_shadow
|
171 |
+
{
|
172 |
+
position: absolute;
|
173 |
+
width: 100%;
|
174 |
+
height: 100%;
|
175 |
+
padding: 0;
|
176 |
+
margin: 0;
|
177 |
+
border: none;
|
178 |
+
background-color: rgba(255,255,255,0.8);
|
179 |
+
}
|
180 |
+
|
181 |
+
option.wfu_select_folders_option_default
|
182 |
+
{
|
183 |
+
color: blue;
|
184 |
+
}
|
185 |
+
|
186 |
+
div.wfu_subfolder_nav_container
|
187 |
+
{
|
188 |
+
width: 40px;
|
189 |
+
margin: 0;
|
190 |
+
padding: 0;
|
191 |
+
border: none;
|
192 |
+
background: none;
|
193 |
+
display: inline-block;
|
194 |
+
vertical-align: top;
|
195 |
+
}
|
196 |
+
|
197 |
+
table.wfu_subfolder_nav
|
198 |
+
{
|
199 |
+
table-layout: fixed;
|
200 |
+
width: 100%;
|
201 |
+
margin: 0;
|
202 |
+
padding: 0;
|
203 |
+
border: none;
|
204 |
+
background: none;
|
205 |
+
border-spacing: 1px;
|
206 |
+
}
|
207 |
+
|
208 |
+
table.wfu_subfolder_nav tr
|
209 |
+
{
|
210 |
+
margin: 0;
|
211 |
+
padding: 0;
|
212 |
+
border: none;
|
213 |
+
background: none;
|
214 |
+
}
|
215 |
+
|
216 |
+
table.wfu_subfolder_nav td
|
217 |
+
{
|
218 |
+
margin: 0;
|
219 |
+
padding: 0;
|
220 |
+
border: none;
|
221 |
+
background: none;
|
222 |
+
font-size: small;
|
223 |
+
line-height: 1;
|
224 |
+
text-align: center;
|
225 |
+
}
|
226 |
+
|
227 |
+
table.wfu_subfolder_nav button.button
|
228 |
+
{
|
229 |
+
margin: 0;
|
230 |
+
padding: 0;
|
231 |
+
width: 17px;
|
232 |
+
font-size: smaller;
|
233 |
+
height: 18px;
|
234 |
+
line-height: 1;
|
235 |
+
color: black;
|
236 |
+
font-weight: bold;
|
237 |
+
}
|
238 |
+
|
239 |
+
table.wfu_subfolder_nav button.button:disabled
|
240 |
+
{
|
241 |
+
color: silver;
|
242 |
+
}
|
243 |
+
|
244 |
+
.button.wfu_subfolder_nav_pressed, .button.wfu_subfolder_nav_pressed:hover, .button.wfu_subfolder_nav_pressed:focus
|
245 |
+
{
|
246 |
+
background: royalblue;
|
247 |
+
}
|
248 |
+
|
249 |
+
div.wfu_subfolder_tools_container
|
250 |
+
{
|
251 |
+
width: 75%;
|
252 |
+
margin: 0;
|
253 |
+
padding: 0;
|
254 |
+
border: none;
|
255 |
+
background: none;
|
256 |
+
}
|
257 |
+
|
258 |
+
table.wfu_subfolder_tools
|
259 |
+
{
|
260 |
+
table-layout: fixed;
|
261 |
+
width: 100%;
|
262 |
+
margin: 0;
|
263 |
+
padding: 0;
|
264 |
+
border: none;
|
265 |
+
background: none;
|
266 |
+
}
|
267 |
+
|
268 |
+
table.wfu_subfolder_tools tr
|
269 |
+
{
|
270 |
+
margin: 0;
|
271 |
+
padding: 0;
|
272 |
+
border: none;
|
273 |
+
background: none;
|
274 |
+
}
|
275 |
+
|
276 |
+
table.wfu_subfolder_tools td
|
277 |
+
{
|
278 |
+
margin: 0;
|
279 |
+
padding: 0;
|
280 |
+
border: none;
|
281 |
+
background: none;
|
282 |
+
font-size: smaller;
|
283 |
+
}
|
284 |
+
|
285 |
+
table.wfu_subfolder_tools td div
|
286 |
+
{
|
287 |
+
margin: 0;
|
288 |
+
padding: 0;
|
289 |
+
border: none;
|
290 |
+
background: none;
|
291 |
+
position: relative;
|
292 |
+
}
|
293 |
+
|
294 |
+
table.wfu_subfolder_tools label
|
295 |
+
{
|
296 |
+
display: block;
|
297 |
+
padding: 0;
|
298 |
+
margin: 0;
|
299 |
+
line-height: 1;
|
300 |
+
}
|
301 |
+
|
302 |
+
table.wfu_subfolder_tools input
|
303 |
+
{
|
304 |
+
width: 100%;
|
305 |
+
padding: 0;
|
306 |
+
margin: 0;
|
307 |
+
}
|
308 |
+
|
309 |
+
table.wfu_subfolder_tools input:disabled
|
310 |
+
{
|
311 |
+
width: 100%;
|
312 |
+
padding: 0;
|
313 |
+
margin: 0;
|
314 |
+
color: silver;
|
315 |
+
}
|
316 |
+
|
317 |
+
table.wfu_subfolder_tools button.button
|
318 |
+
{
|
319 |
+
margin: 0;
|
320 |
+
padding: 1px 0 0 0;
|
321 |
+
width: 17px;
|
322 |
+
font-size: smaller;
|
323 |
+
height: 17px;
|
324 |
+
line-height: 1;
|
325 |
+
position: absolute;
|
326 |
+
bottom: 2px;
|
327 |
+
}
|
328 |
+
|
329 |
+
table.wfu_subfolder_tools button.button:disabled
|
330 |
+
{
|
331 |
+
color: silver;
|
332 |
+
}
|
333 |
+
|
334 |
+
table.wfu_subfolder_tools button.button:disabled img
|
335 |
+
{
|
336 |
+
opacity: 0.4;
|
337 |
+
}
|
338 |
+
|
339 |
+
.wfu_subfolder_tools_disabled
|
340 |
+
{
|
341 |
+
color: silver;
|
342 |
+
}
|
343 |
+
|
344 |
+
table.wfu_subfolder_tools td div.wfu_subfolders_browser_container
|
345 |
+
{
|
346 |
+
position: absolute;
|
347 |
+
width: 150px;
|
348 |
+
height: 150px;
|
349 |
+
margin: 0;
|
350 |
+
padding: 0;
|
351 |
+
z-index: 100;
|
352 |
+
border: 1px solid silver;
|
353 |
+
box-shadow: 1px 1px 2px;
|
354 |
+
background-color: white;
|
355 |
+
font-size: inherit;
|
356 |
+
}
|
357 |
+
|
358 |
+
table.wfu_subfolder_tools td div.wfu_subfolders_browser_container table
|
359 |
+
{
|
360 |
+
table-layout: fixed;
|
361 |
+
width: 100%;
|
362 |
+
height: 100%;
|
363 |
+
border: none;
|
364 |
+
background: #eee;
|
365 |
+
margin: 0;
|
366 |
+
padding: 0;
|
367 |
+
border-spacing: 0;
|
368 |
+
font-size: inherit;
|
369 |
+
}
|
370 |
+
|
371 |
+
table.wfu_subfolder_tools td div.wfu_subfolders_browser_container tr
|
372 |
+
{
|
373 |
+
border: none;
|
374 |
+
background: none;
|
375 |
+
margin: 0;
|
376 |
+
padding: 0;
|
377 |
+
font-size: inherit;
|
378 |
+
}
|
379 |
+
|
380 |
+
table.wfu_subfolder_tools td div.wfu_subfolders_browser_container td
|
381 |
+
{
|
382 |
+
border: none;
|
383 |
+
background: none;
|
384 |
+
margin: 0;
|
385 |
+
padding: 2px;
|
386 |
+
line-height: 0;
|
387 |
+
overflow: hidden;
|
388 |
+
font-size: inherit;
|
389 |
+
}
|
390 |
+
|
391 |
+
table.wfu_subfolder_tools td div.wfu_subfolders_browser_container td div
|
392 |
+
{
|
393 |
+
position: relative;
|
394 |
+
border: none;
|
395 |
+
background: none;
|
396 |
+
margin: 0;
|
397 |
+
padding: 0;
|
398 |
+
width: 100%;
|
399 |
+
height: 100%;
|
400 |
+
display: inline-block;
|
401 |
+
line-height: 1;
|
402 |
+
}
|
403 |
+
|
404 |
+
table.wfu_subfolder_tools td div.wfu_subfolders_browser_container td div button.button
|
405 |
+
{
|
406 |
+
font-size: inherit;
|
407 |
+
line-height: 1;
|
408 |
+
height: 17px;
|
409 |
+
padding: 4px;
|
410 |
+
position: relative;
|
411 |
+
width: auto;
|
412 |
+
margin: 0;
|
413 |
+
bottom: auto;
|
414 |
+
}
|
415 |
+
|
416 |
+
table.wfu_subfolder_tools td div.wfu_subfolders_browser_container select
|
417 |
+
{
|
418 |
+
width: 100%;
|
419 |
+
height: 100%;
|
420 |
+
top: 0;
|
421 |
+
bottom: 0;
|
422 |
+
position: absolute;
|
423 |
+
margin: 0;
|
424 |
+
}
|
425 |
+
|
426 |
+
table.wfu_subfolder_tools td div.wfu_subfolders_browser_container label
|
427 |
+
{
|
428 |
+
color: #222;
|
429 |
+
font-weight: bold;
|
430 |
+
position: absolute;
|
431 |
+
top: 0;
|
432 |
+
bottom: 0;
|
433 |
+
height: 10px;
|
434 |
+
margin: auto;
|
435 |
+
}
|
436 |
+
|
437 |
+
table.wfu_subfolder_tools td div.wfu_subfolders_browser_container td div button.button.wfu_folder_browser_cancel
|
438 |
+
{
|
439 |
+
width: 17px;
|
440 |
+
height: 17px;
|
441 |
+
position: absolute;
|
442 |
+
right: 0px;
|
443 |
+
top: 0px;
|
444 |
+
margin: 0;
|
445 |
+
padding: 0;
|
446 |
+
}
|
447 |
+
|
448 |
+
table.wfu_subfolder_tools td div.wfu_subfolders_browser_container td div div.wfu_folder_browser_loading_container
|
449 |
+
{
|
450 |
+
position: absolute;
|
451 |
+
width: 100%;
|
452 |
+
height: 100%;
|
453 |
+
top: 0;
|
454 |
+
bottom: 0;
|
455 |
+
margin: 0;
|
456 |
+
padding: 0;
|
457 |
+
background-color: rgba(255,255,255,0.9);
|
458 |
+
text-align: center;
|
459 |
+
}
|
460 |
+
|
461 |
+
table.wfu_subfolder_tools td div.wfu_subfolders_browser_container td div div.wfu_folder_browser_loading_container label
|
462 |
+
{
|
463 |
+
position: relative;
|
464 |
+
display: block;
|
465 |
+
}
|
466 |
+
|
467 |
+
table.wfu_subfolder_tools td div.wfu_subfolders_browser_container td div div.wfu_folder_browser_loading_container img
|
468 |
+
{
|
469 |
+
position: relative;
|
470 |
+
}
|
471 |
+
|
472 |
+
.button.wfu_folder_browser_cancel img
|
473 |
+
{
|
474 |
+
vertical-align: top;
|
475 |
+
margin-top: 2px;
|
476 |
+
}
|
477 |
+
|
478 |
div.wfu_rolelist_checkall
|
479 |
{
|
480 |
display: inline-block;
|
885 |
font-size: smaller;
|
886 |
opacity: 0;
|
887 |
}
|
888 |
+
|
889 |
+
div.wfu_global_dialog_container
|
890 |
+
{
|
891 |
+
position: fixed;
|
892 |
+
width: 100%;
|
893 |
+
height: 100%;
|
894 |
+
top: 0;
|
895 |
+
left: 0;
|
896 |
+
margin: 0;
|
897 |
+
padding: 0;
|
898 |
+
border: none;
|
899 |
+
background: none;
|
900 |
+
z-index: 1;
|
901 |
+
display: none;
|
902 |
+
}
|
css/wordpress_file_upload_style.css
CHANGED
@@ -397,6 +397,12 @@ select.file_item_clean:disabled
|
|
397 |
color: silver;
|
398 |
}
|
399 |
|
|
|
|
|
|
|
|
|
|
|
|
|
400 |
span.file_title_clean
|
401 |
{
|
402 |
margin: 0px;
|
@@ -422,7 +428,7 @@ label.file_userdata_label
|
|
422 |
|
423 |
input[type="text"].file_userdata_message, input[type="text"].file_userdata_message_required
|
424 |
{
|
425 |
-
width: 60
|
426 |
height: 25px;
|
427 |
margin: 0px;
|
428 |
padding: 0px;
|
@@ -434,7 +440,7 @@ input[type="text"].file_userdata_message, input[type="text"].file_userdata_messa
|
|
434 |
|
435 |
input[type="text"].file_userdata_message:disabled, input[type="text"].file_userdata_message_required:disabled
|
436 |
{
|
437 |
-
width: 60
|
438 |
height: 25px;
|
439 |
margin: 0px;
|
440 |
padding: 0px;
|
@@ -446,7 +452,7 @@ input[type="text"].file_userdata_message:disabled, input[type="text"].file_userd
|
|
446 |
|
447 |
input[type="text"].file_userdata_message_required_empty
|
448 |
{
|
449 |
-
width: 60
|
450 |
height: 25px;
|
451 |
margin: 0px;
|
452 |
padding: 0px;
|
397 |
color: silver;
|
398 |
}
|
399 |
|
400 |
+
select.file_item_clean option
|
401 |
+
{
|
402 |
+
background: white;
|
403 |
+
color: black;
|
404 |
+
}
|
405 |
+
|
406 |
span.file_title_clean
|
407 |
{
|
408 |
margin: 0px;
|
428 |
|
429 |
input[type="text"].file_userdata_message, input[type="text"].file_userdata_message_required
|
430 |
{
|
431 |
+
width: 60%;
|
432 |
height: 25px;
|
433 |
margin: 0px;
|
434 |
padding: 0px;
|
440 |
|
441 |
input[type="text"].file_userdata_message:disabled, input[type="text"].file_userdata_message_required:disabled
|
442 |
{
|
443 |
+
width: 60%;
|
444 |
height: 25px;
|
445 |
margin: 0px;
|
446 |
padding: 0px;
|
452 |
|
453 |
input[type="text"].file_userdata_message_required_empty
|
454 |
{
|
455 |
+
width: 60%;
|
456 |
height: 25px;
|
457 |
margin: 0px;
|
458 |
padding: 0px;
|
css/wordpress_file_upload_style_safe.css
CHANGED
@@ -192,7 +192,7 @@ input.file_input_hidden
|
|
192 |
/* Userdata styles */
|
193 |
input.file_userdata_message, input.file_userdata_message_required
|
194 |
{
|
195 |
-
width: 60
|
196 |
height: 25px;
|
197 |
margin: 0px;
|
198 |
padding: 0px;
|
@@ -204,7 +204,7 @@ input.file_userdata_message, input.file_userdata_message_required
|
|
204 |
|
205 |
input.file_userdata_message:disabled, input.file_userdata_message_required:disabled
|
206 |
{
|
207 |
-
width: 60
|
208 |
height: 25px;
|
209 |
margin: 0px;
|
210 |
padding: 0px;
|
@@ -216,7 +216,7 @@ input.file_userdata_message:disabled, input.file_userdata_message_required:disab
|
|
216 |
|
217 |
input.file_userdata_message_required_empty
|
218 |
{
|
219 |
-
width: 60
|
220 |
height: 25px;
|
221 |
margin: 0px;
|
222 |
padding: 0px;
|
192 |
/* Userdata styles */
|
193 |
input.file_userdata_message, input.file_userdata_message_required
|
194 |
{
|
195 |
+
width: 60%;
|
196 |
height: 25px;
|
197 |
margin: 0px;
|
198 |
padding: 0px;
|
204 |
|
205 |
input.file_userdata_message:disabled, input.file_userdata_message_required:disabled
|
206 |
{
|
207 |
+
width: 60%;
|
208 |
height: 25px;
|
209 |
margin: 0px;
|
210 |
padding: 0px;
|
216 |
|
217 |
input.file_userdata_message_required_empty
|
218 |
{
|
219 |
+
width: 60%;
|
220 |
height: 25px;
|
221 |
margin: 0px;
|
222 |
padding: 0px;
|
images/cancel_12.gif
ADDED
Binary file
|
images/fail_16.png
ADDED
Binary file
|
images/ok_12.gif
ADDED
Binary file
|
images/q_16.png
ADDED
Binary file
|
images/tree_16.gif
ADDED
Binary file
|
js/wordpress_file_upload_adminfunctions.js
CHANGED
@@ -336,6 +336,707 @@ function wfu_admin_recreate_placements_panel(placements_text) {
|
|
336 |
wfu_attach_separator_dragdrop_events();
|
337 |
}
|
338 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
339 |
function wfu_userdata_edit_field(line, label, required) {
|
340 |
var item;
|
341 |
for (var i = 0; i < line.childNodes.length; i ++) {
|
@@ -409,10 +1110,11 @@ function wfu_update_text_value(e) {
|
|
409 |
var item = e.target;
|
410 |
var attribute = item.id.replace("wfu_attribute_", "");
|
411 |
var val = item.value;
|
412 |
-
//
|
413 |
-
|
414 |
-
|
415 |
-
|
|
|
416 |
if (val !== item.oldVal) {
|
417 |
item.oldVal = val;
|
418 |
document.getElementById("wfu_attribute_value_" + attribute).value = val;
|
@@ -572,8 +1274,11 @@ function wfu_Attach_Admin_Events() {
|
|
572 |
for (var i = 0; i < dimension_elements.length; i++) wfu_attach_element_handlers(dimension_elements[i], wfu_update_dimension_value);
|
573 |
var userfield_elements = document.getElementsByName("wfu_userfield_elements");
|
574 |
for (var i = 0; i < userfield_elements.length; i++) wfu_attach_element_handlers(userfield_elements[i], wfu_update_userfield_value);
|
|
|
|
|
575 |
}
|
576 |
|
|
|
577 |
function wfu_insert_variable(obj) {
|
578 |
var attr = obj.className.replace("wfu_variable wfu_variable_", "");
|
579 |
var inp = document.getElementById("wfu_attribute_" + attr);
|
@@ -615,6 +1320,7 @@ function wfu_GetHttpRequestObject() {
|
|
615 |
xmlhttp = window.createRequest();
|
616 |
}
|
617 |
catch (e) {}
|
|
|
618 |
}
|
619 |
return xhr;
|
620 |
}
|
@@ -636,6 +1342,22 @@ function wfu_plugin_encode_string(str) {
|
|
636 |
return newstr;
|
637 |
}
|
638 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
639 |
function wfu_schedule_save_shortcode() {
|
640 |
var d = new Date();
|
641 |
var dt = ShortcodeNextSave - d.getTime();
|
@@ -718,7 +1440,11 @@ function wfu_apply_value(attribute, type, value) {
|
|
718 |
}
|
719 |
else if (type == "text" || type == "ltext" || type == "integer" || type == "float" || type == "mtext" || type == "color" ) {
|
720 |
var item = document.getElementById("wfu_attribute_" + attribute);
|
721 |
-
|
|
|
|
|
|
|
|
|
722 |
if (type == "color") {
|
723 |
var rgb = colourNameToHex(value);
|
724 |
if (!rgb) rgb = value;
|
@@ -739,6 +1465,11 @@ function wfu_apply_value(attribute, type, value) {
|
|
739 |
wfu_admin_radio_clicked(attribute);
|
740 |
}
|
741 |
else if (type == "ptext" ) {
|
|
|
|
|
|
|
|
|
|
|
742 |
var parts = value.split("/");
|
743 |
var singular = parts.length < 1 ? "" : parts[0];
|
744 |
var plural = parts.length < 2 ? singular : parts[1];
|
@@ -836,6 +1567,122 @@ function wfu_apply_value(attribute, type, value) {
|
|
836 |
document.getElementById("wfu_attribute_" + attribute + "_borcolor").value = colors[2];
|
837 |
wfu_update_triplecolor_value({target:item});
|
838 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
839 |
}
|
840 |
|
841 |
function colourNameToHex(colour)
|
@@ -871,3 +1718,30 @@ function colourNameToHex(colour)
|
|
871 |
|
872 |
return false;
|
873 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
336 |
wfu_attach_separator_dragdrop_events();
|
337 |
}
|
338 |
|
339 |
+
function wfu_subfolders_input_changed(e) {
|
340 |
+
e = e || window.event;
|
341 |
+
var item = e.target;
|
342 |
+
var key = item.id.replace("wfu_subfolders_path_", "");
|
343 |
+
key = key.replace("wfu_subfolders_label_", "");
|
344 |
+
|
345 |
+
var list = document.getElementById('wfu_attribute_' + key);
|
346 |
+
if (list.selectedIndex < 0 ) return;
|
347 |
+
var tools_path = document.getElementById('wfu_subfolders_path_' + key);
|
348 |
+
var tools_label = document.getElementById('wfu_subfolders_label_' + key);
|
349 |
+
var tools_ok = document.getElementById('wfu_subfolders_ok_' + key);
|
350 |
+
var old_path_value, old_label_value;
|
351 |
+
var isnewitem = (document.getElementById('wfu_subfolders_isnewitem_' + key).value == "1");
|
352 |
+
if (isnewitem) {
|
353 |
+
old_path_value = "";
|
354 |
+
old_label_value = "";
|
355 |
+
}
|
356 |
+
else {
|
357 |
+
var items = list.data;
|
358 |
+
item = items[list.selectedIndex];
|
359 |
+
old_path_value = item.path;
|
360 |
+
old_label_value = item.label;
|
361 |
+
}
|
362 |
+
if (tools_path.value == old_path_value && tools_label.value == old_label_value) {
|
363 |
+
tools_ok.disabled = true;
|
364 |
+
if (!isnewitem) wfu_subfolders_update_nav(key);
|
365 |
+
}
|
366 |
+
else {
|
367 |
+
tools_ok.disabled = false;
|
368 |
+
var navs = document.getElementsByName('wfu_subfolder_nav_' + key);
|
369 |
+
for (var i = 0; i < navs.length; i++) navs[i].disabled = true;
|
370 |
+
}
|
371 |
+
}
|
372 |
+
|
373 |
+
function wfu_subfolders_up_clicked(key) {
|
374 |
+
var list = document.getElementById('wfu_attribute_' + key);
|
375 |
+
if (list.selectedIndex < 0 ) return;
|
376 |
+
var items = list.data;
|
377 |
+
item = items[list.selectedIndex];
|
378 |
+
// find previous sibling
|
379 |
+
var prevind = item.index - 1;
|
380 |
+
if (prevind < 0) return;
|
381 |
+
var prevpos = -1;
|
382 |
+
var curind = list.selectedIndex - 1;
|
383 |
+
while (curind >= 0) {
|
384 |
+
if (items[curind].level == item.level && items[curind].index == prevind) {
|
385 |
+
prevpos = curind;
|
386 |
+
break;
|
387 |
+
}
|
388 |
+
else curind --;
|
389 |
+
}
|
390 |
+
if (prevpos == -1) return;
|
391 |
+
// find number of children
|
392 |
+
var children_count = 0;
|
393 |
+
curind = list.selectedIndex + 1;
|
394 |
+
while (curind < items.length) {
|
395 |
+
if (items[curind].level > item.level) {
|
396 |
+
children_count ++;
|
397 |
+
curind ++;
|
398 |
+
}
|
399 |
+
else break;
|
400 |
+
}
|
401 |
+
// update list indices
|
402 |
+
items[prevpos].index = item.index;
|
403 |
+
item.index = prevind;
|
404 |
+
// restructure data list
|
405 |
+
list.data = items.slice(0, prevpos).concat(items.slice(list.selectedIndex, list.selectedIndex + 1 + children_count)).
|
406 |
+
concat(items.slice(prevpos, list.selectedIndex)).concat(items.slice(list.selectedIndex + 1 + children_count));
|
407 |
+
// update option contents to match list
|
408 |
+
var val = wfu_update_subfolder_list(key);
|
409 |
+
// move current selection to new position
|
410 |
+
list.selectedIndex = prevpos;
|
411 |
+
// update tool and nav items
|
412 |
+
wfu_subfolders_update_toolnav(key);
|
413 |
+
// update shortcode
|
414 |
+
item = list;
|
415 |
+
if (val !== item.oldVal) {
|
416 |
+
item.oldVal = val;
|
417 |
+
document.getElementById("wfu_attribute_value_" + key).value = val;
|
418 |
+
wfu_generate_shortcode();
|
419 |
+
}
|
420 |
+
}
|
421 |
+
|
422 |
+
function wfu_subfolders_down_clicked(key) {
|
423 |
+
var list = document.getElementById('wfu_attribute_' + key);
|
424 |
+
if (list.selectedIndex < 0 ) return;
|
425 |
+
var items = list.data;
|
426 |
+
item = items[list.selectedIndex];
|
427 |
+
// find next sibling
|
428 |
+
var nextind = item.index + 1;
|
429 |
+
var nextpos = -1;
|
430 |
+
curind = list.selectedIndex + 1;
|
431 |
+
while (curind < items.length) {
|
432 |
+
if (items[curind].level == item.level) {
|
433 |
+
nextpos = curind;
|
434 |
+
break;
|
435 |
+
}
|
436 |
+
else if (items[curind].level < item.level) break;
|
437 |
+
else curind ++;
|
438 |
+
}
|
439 |
+
if (nextpos == -1) return;
|
440 |
+
// find number of children of next
|
441 |
+
var next_children_count = 0;
|
442 |
+
curind = nextpos + 1;
|
443 |
+
while (curind < items.length) {
|
444 |
+
if (items[curind].level > item.level) {
|
445 |
+
next_children_count ++;
|
446 |
+
curind ++;
|
447 |
+
}
|
448 |
+
else break;
|
449 |
+
}
|
450 |
+
// update list indices
|
451 |
+
items[nextpos].index = item.index;
|
452 |
+
item.index = nextind;
|
453 |
+
// restructure data list
|
454 |
+
list.data = items.slice(0, list.selectedIndex).concat(items.slice(nextpos, nextpos + 1 + next_children_count)).
|
455 |
+
concat(items.slice(list.selectedIndex, nextpos)).concat(items.slice(nextpos + 1 + next_children_count));
|
456 |
+
// update option contents to match list
|
457 |
+
var val = wfu_update_subfolder_list(key);
|
458 |
+
// move current selection to new position
|
459 |
+
list.selectedIndex = list.selectedIndex + next_children_count + 1;
|
460 |
+
// update tool and nav items
|
461 |
+
wfu_subfolders_update_toolnav(key);
|
462 |
+
// update shortcode
|
463 |
+
item = list;
|
464 |
+
if (val !== item.oldVal) {
|
465 |
+
item.oldVal = val;
|
466 |
+
document.getElementById("wfu_attribute_value_" + key).value = val;
|
467 |
+
wfu_generate_shortcode();
|
468 |
+
}
|
469 |
+
}
|
470 |
+
|
471 |
+
function wfu_subfolders_left_clicked(key) {
|
472 |
+
var list = document.getElementById('wfu_attribute_' + key);
|
473 |
+
if (list.selectedIndex < 0 ) return;
|
474 |
+
var items = list.data;
|
475 |
+
item = items[list.selectedIndex];
|
476 |
+
// find and reduce level of children
|
477 |
+
curind = list.selectedIndex + 1;
|
478 |
+
while (curind < items.length) {
|
479 |
+
if (items[curind].level > item.level) {
|
480 |
+
items[curind].level --;
|
481 |
+
curind ++;
|
482 |
+
}
|
483 |
+
else break;
|
484 |
+
}
|
485 |
+
item.level --;
|
486 |
+
// update option contents to match list
|
487 |
+
var val = wfu_update_subfolder_list(key);
|
488 |
+
// update list indices
|
489 |
+
list.data = wfu_decode_subfolder_list(key);
|
490 |
+
// update tool and nav items
|
491 |
+
wfu_subfolders_update_toolnav(key);
|
492 |
+
// update shortcode
|
493 |
+
item = list;
|
494 |
+
if (val !== item.oldVal) {
|
495 |
+
item.oldVal = val;
|
496 |
+
document.getElementById("wfu_attribute_value_" + key).value = val;
|
497 |
+
wfu_generate_shortcode();
|
498 |
+
}
|
499 |
+
}
|
500 |
+
|
501 |
+
function wfu_subfolders_right_clicked(key) {
|
502 |
+
var list = document.getElementById('wfu_attribute_' + key);
|
503 |
+
if (list.selectedIndex < 0 ) return;
|
504 |
+
var items = list.data;
|
505 |
+
item = items[list.selectedIndex];
|
506 |
+
// find and increase level of children
|
507 |
+
curind = list.selectedIndex + 1;
|
508 |
+
while (curind < items.length) {
|
509 |
+
if (items[curind].level > item.level) {
|
510 |
+
items[curind].level ++;
|
511 |
+
curind ++;
|
512 |
+
}
|
513 |
+
else break;
|
514 |
+
}
|
515 |
+
item.level ++;
|
516 |
+
// update option contents to match list
|
517 |
+
var val = wfu_update_subfolder_list(key);
|
518 |
+
// update list indices
|
519 |
+
list.data = wfu_decode_subfolder_list(key);
|
520 |
+
// update tool and nav items
|
521 |
+
wfu_subfolders_update_toolnav(key);
|
522 |
+
// update shortcode
|
523 |
+
item = list;
|
524 |
+
if (val !== item.oldVal) {
|
525 |
+
item.oldVal = val;
|
526 |
+
document.getElementById("wfu_attribute_value_" + key).value = val;
|
527 |
+
wfu_generate_shortcode();
|
528 |
+
}
|
529 |
+
}
|
530 |
+
|
531 |
+
function wfu_subfolders_def_clicked(key) {
|
532 |
+
var list = document.getElementById('wfu_attribute_' + key);
|
533 |
+
if (list.selectedIndex < 0 ) return;
|
534 |
+
var items = list.data;
|
535 |
+
item = items[list.selectedIndex];
|
536 |
+
if (item.default) item.default = false;
|
537 |
+
else {
|
538 |
+
for (var i = 0; i < items.length; i++)
|
539 |
+
items[i].default = false;
|
540 |
+
item.default = true;
|
541 |
+
}
|
542 |
+
// update option contents to match list
|
543 |
+
var val = wfu_update_subfolder_list(key);
|
544 |
+
// update tool and nav items
|
545 |
+
wfu_subfolders_update_toolnav(key);
|
546 |
+
// update shortcode
|
547 |
+
item = list;
|
548 |
+
if (val !== item.oldVal) {
|
549 |
+
item.oldVal = val;
|
550 |
+
document.getElementById("wfu_attribute_value_" + key).value = val;
|
551 |
+
wfu_generate_shortcode();
|
552 |
+
}
|
553 |
+
}
|
554 |
+
|
555 |
+
function wfu_subfolders_ok_clicked(key) {
|
556 |
+
var list = document.getElementById('wfu_attribute_' + key);
|
557 |
+
if (list.selectedIndex < 0 ) return;
|
558 |
+
var tools_path = document.getElementById('wfu_subfolders_path_' + key);
|
559 |
+
var tools_label = document.getElementById('wfu_subfolders_label_' + key);
|
560 |
+
if (tools_path.value == "" || tools_label.value == "") {
|
561 |
+
alert("Path or label cannot be empty!");
|
562 |
+
return;
|
563 |
+
}
|
564 |
+
var items = list.data;
|
565 |
+
var isnewitem = (document.getElementById('wfu_subfolders_isnewitem_' + key).value == "1");
|
566 |
+
if (isnewitem) {
|
567 |
+
var newlevel = parseInt(document.getElementById('wfu_subfolders_newitemlevel_' + key).value);
|
568 |
+
var newitem = {label:tools_label.value, path:tools_path.value, level:newlevel, default:false};
|
569 |
+
var newpos = parseInt(document.getElementById('wfu_subfolders_newitemindex_' + key).value);
|
570 |
+
if (newpos >= items.length) items.push(newitem);
|
571 |
+
else items.splice(newpos, 0, newitem);
|
572 |
+
}
|
573 |
+
else {
|
574 |
+
item = items[list.selectedIndex];
|
575 |
+
item.path = tools_path.value;
|
576 |
+
item.label = tools_label.value;
|
577 |
+
}
|
578 |
+
// update option contents to match list
|
579 |
+
var val = wfu_update_subfolder_list(key);
|
580 |
+
// update list indices
|
581 |
+
list.data = wfu_decode_subfolder_list(key);
|
582 |
+
// update tool and nav items
|
583 |
+
wfu_subfolders_update_toolnav(key);
|
584 |
+
// update shortcode
|
585 |
+
item = list;
|
586 |
+
if (val !== item.oldVal) {
|
587 |
+
item.oldVal = val;
|
588 |
+
document.getElementById("wfu_attribute_value_" + key).value = val;
|
589 |
+
wfu_generate_shortcode();
|
590 |
+
}
|
591 |
+
}
|
592 |
+
|
593 |
+
function wfu_subfolders_del_clicked(key) {
|
594 |
+
var list = document.getElementById('wfu_attribute_' + key);
|
595 |
+
if (list.selectedIndex < 0 ) return;
|
596 |
+
var items = list.data;
|
597 |
+
item = items[list.selectedIndex];
|
598 |
+
// find number of children
|
599 |
+
var children_count = 0;
|
600 |
+
curind = list.selectedIndex + 1;
|
601 |
+
while (curind < items.length) {
|
602 |
+
if (items[curind].level > item.level) {
|
603 |
+
children_count ++;
|
604 |
+
curind ++;
|
605 |
+
}
|
606 |
+
else break;
|
607 |
+
}
|
608 |
+
if (children_count > 0)
|
609 |
+
if (!confirm("Children items will be deleted as well. Proceed?")) return;
|
610 |
+
// remove items from list
|
611 |
+
items.splice(list.selectedIndex, 1 + children_count);
|
612 |
+
// update option contents to match list
|
613 |
+
var val = wfu_update_subfolder_list(key);
|
614 |
+
// update list indices
|
615 |
+
list.data = wfu_decode_subfolder_list(key);
|
616 |
+
// update tool and nav items
|
617 |
+
wfu_subfolders_update_toolnav(key);
|
618 |
+
// update shortcode
|
619 |
+
item = list;
|
620 |
+
if (val !== item.oldVal) {
|
621 |
+
item.oldVal = val;
|
622 |
+
document.getElementById("wfu_attribute_value_" + key).value = val;
|
623 |
+
wfu_generate_shortcode();
|
624 |
+
}
|
625 |
+
}
|
626 |
+
|
627 |
+
function wfu_subfolders_add_clicked(key) {
|
628 |
+
var list = document.getElementById('wfu_attribute_' + key);
|
629 |
+
if (list.selectedIndex < 0 ) return;
|
630 |
+
var items = list.data;
|
631 |
+
var curpos = list.selectedIndex;
|
632 |
+
item = items[curpos];
|
633 |
+
var opts = list.options;
|
634 |
+
var opt = document.createElement("option");
|
635 |
+
opt.value = "";
|
636 |
+
opt.innerHTML = "";
|
637 |
+
opts.add(opt, curpos);
|
638 |
+
list.selectedIndex = curpos;
|
639 |
+
|
640 |
+
var tools_container = document.getElementById('wfu_subfolder_tools_' + key);
|
641 |
+
var tools_path = document.getElementById('wfu_subfolders_path_' + key);
|
642 |
+
var tools_label = document.getElementById('wfu_subfolders_label_' + key);
|
643 |
+
var tools_ok = document.getElementById('wfu_subfolders_ok_' + key);
|
644 |
+
var tools_browse = document.getElementById('wfu_subfolders_browse_' + key);
|
645 |
+
tools_container.className = "wfu_subfolder_tools_container";
|
646 |
+
tools_label.disabled = false;
|
647 |
+
tools_ok.disabled = true;
|
648 |
+
document.getElementById('wfu_subfolders_isnewitem_' + key).value = "1";
|
649 |
+
document.getElementById('wfu_subfolders_newitemindex_' + key).value = curpos;
|
650 |
+
document.getElementById('wfu_subfolders_newitemlevel_' + key).value = item.level;
|
651 |
+
document.getElementById('wfu_subfolders_newitemlevel2_' + key).value = "";
|
652 |
+
tools_path.disabled = (item.level == 0);
|
653 |
+
tools_browse.disabled = (item.level == 0);
|
654 |
+
if (item.level == 0) {
|
655 |
+
tools_path.value = "{root}";
|
656 |
+
tools_label.value = "{upload folder}";
|
657 |
+
}
|
658 |
+
else {
|
659 |
+
tools_path.value = "";
|
660 |
+
tools_label.value = "";
|
661 |
+
}
|
662 |
+
var navs = document.getElementsByName('wfu_subfolder_nav_' + key);
|
663 |
+
for (var i = 0; i < navs.length; i++) navs[i].disabled = true;
|
664 |
+
}
|
665 |
+
|
666 |
+
function wfu_subfolders_browse_clicked(key) {
|
667 |
+
var xhr = wfu_GetHttpRequestObject();
|
668 |
+
if (xhr == null) return;
|
669 |
+
var fd = null;
|
670 |
+
try {
|
671 |
+
var fd = new FormData();
|
672 |
+
}
|
673 |
+
catch(e) {}
|
674 |
+
if (fd == null) return;
|
675 |
+
|
676 |
+
var container = document.getElementById('wfu_global_dialog_container');
|
677 |
+
var dialog = document.getElementById('wfu_subfolders_browser_' + key);
|
678 |
+
var btn = document.getElementById('wfu_subfolders_browse_' + key);
|
679 |
+
var shadow = document.getElementById('wfu_subfolders_inner_shadow_' + key);
|
680 |
+
var msgcont = document.getElementById('wfu_subfolders_browser_msgcont_' + key);
|
681 |
+
var msg = document.getElementById('wfu_subfolders_browser_msg_' + key);
|
682 |
+
var img = document.getElementById('wfu_subfolders_browser_img_' + key);
|
683 |
+
var ok = document.getElementById('wfu_subfolders_browser_ok_' + key);
|
684 |
+
var list = document.getElementById('wfu_subfolders_browser_list_' + key);
|
685 |
+
|
686 |
+
while (list.options.length > 0) list.options.remove(0);
|
687 |
+
ok.disabled = true;
|
688 |
+
ok.onclick = function() {wfu_folder_browser_cancel_clicked(key);}
|
689 |
+
msg.innerHTML = "loading folder contents...";
|
690 |
+
img.style.display = "inline";
|
691 |
+
msgcont.style.display = "block";
|
692 |
+
container.style.display = "block";
|
693 |
+
dialog.style.display = "block";
|
694 |
+
dialog.style.left = (btn.offsetLeft + btn.offsetWidth - dialog.offsetWidth) + 'px';
|
695 |
+
dialog.style.top = (btn.offsetTop + btn.offsetHeight - dialog.offsetHeight) + 'px';
|
696 |
+
shadow.style.display = "block";
|
697 |
+
container.onclick = function() {wfu_folder_browser_cancel_clicked(key)};
|
698 |
+
|
699 |
+
var path = document.getElementById('wfu_attribute_uploadpath').value;
|
700 |
+
if (path.substr(path.length - 1) == "/") path = path.substr(0, path.length - 1);
|
701 |
+
var paths = wfu_get_relative_path(key).split(",");
|
702 |
+
var path1 = path + paths[0];
|
703 |
+
if (path1.substr(0) != "/") path1 = "/" + path1;
|
704 |
+
var path2 = "";
|
705 |
+
if (paths.length == 2) path2 = paths[1];
|
706 |
+
|
707 |
+
fd.append("action", "wfu_ajax_action_read_subfolders");
|
708 |
+
fd.append("folder1", wfu_plugin_encode_string(path1));
|
709 |
+
fd.append("folder2", wfu_plugin_encode_string(path2));
|
710 |
+
xhr.key = key;
|
711 |
+
xhr.addEventListener("load", wfu_readfolderComplete, false);
|
712 |
+
xhr.addEventListener("error", wfu_readfolderFailed, false);
|
713 |
+
xhr.addEventListener("abort", wfu_readfolderCanceled, false);
|
714 |
+
|
715 |
+
xhr.open("POST", AdminParams.wfu_ajax_url);
|
716 |
+
xhr.send(fd);
|
717 |
+
}
|
718 |
+
|
719 |
+
function wfu_readfolderComplete(evt) {
|
720 |
+
var key = evt.target.key;
|
721 |
+
var msgcont = document.getElementById('wfu_subfolders_browser_msgcont_' + key);
|
722 |
+
var msg = document.getElementById('wfu_subfolders_browser_msg_' + key);
|
723 |
+
var img = document.getElementById('wfu_subfolders_browser_img_' + key);
|
724 |
+
var list = document.getElementById('wfu_subfolders_browser_list_' + key);
|
725 |
+
var ok = document.getElementById('wfu_subfolders_browser_ok_' + key);
|
726 |
+
var tools_path = document.getElementById('wfu_subfolders_path_' + key);
|
727 |
+
var tools_label = document.getElementById('wfu_subfolders_label_' + key);
|
728 |
+
|
729 |
+
var txt = evt.target.responseText;
|
730 |
+
if (txt != -1) {
|
731 |
+
var pos = txt.indexOf(":");
|
732 |
+
var txt_header = txt.substr(0, pos);
|
733 |
+
var txt_value = txt.substr(pos + 1, txt.length - pos - 1);
|
734 |
+
if (txt_header == 'success') {
|
735 |
+
var filelist = wfu_plugin_decode_string(txt_value);
|
736 |
+
var flist = filelist.split(",");
|
737 |
+
var fcount = 0;
|
738 |
+
var opt;
|
739 |
+
for (var i = 0; i < flist.length; i++) {
|
740 |
+
if (flist[i] != "") {
|
741 |
+
opt = document.createElement("option");
|
742 |
+
opt.value = flist[i];
|
743 |
+
opt.innerHTML = flist[i].replace("*", " ");
|
744 |
+
list.add(opt);
|
745 |
+
fcount ++;
|
746 |
+
}
|
747 |
+
}
|
748 |
+
if (fcount == 0) {
|
749 |
+
opt = document.createElement("option");
|
750 |
+
opt.value = "";
|
751 |
+
opt.innerHTML = "{empty}";
|
752 |
+
opt.disabled = true;
|
753 |
+
list.add(opt);
|
754 |
+
}
|
755 |
+
list.selectedIndex = -1;
|
756 |
+
ok.onclick = function() {
|
757 |
+
var val = list.options[list.selectedIndex].value;
|
758 |
+
var level = parseInt(document.getElementById('wfu_subfolders_newitemlevel_' + key).value);
|
759 |
+
if (val.substr(0, 1) == "*" || level == 0) {
|
760 |
+
document.getElementById('wfu_subfolders_newitemlevel_' + key).value = level + 1;
|
761 |
+
if (level > 0) val = val.substr(1);
|
762 |
+
}
|
763 |
+
tools_path.value = val;
|
764 |
+
tools_label.value = val;
|
765 |
+
wfu_folder_browser_cancel_clicked(key);
|
766 |
+
wfu_subfolders_ok_clicked(key);
|
767 |
+
}
|
768 |
+
msgcont.style.display = "none";
|
769 |
+
}
|
770 |
+
else if (txt_header == 'error') {
|
771 |
+
msg.innerHTML = txt_value;
|
772 |
+
img.style.display = "none";
|
773 |
+
ok.disabled = false;
|
774 |
+
}
|
775 |
+
else {
|
776 |
+
msg.innerHTML = 'Unknown error';
|
777 |
+
img.style.display = "none";
|
778 |
+
ok.disabled = false;
|
779 |
+
}
|
780 |
+
}
|
781 |
+
}
|
782 |
+
|
783 |
+
function wfu_readfolderFailed(evt) {
|
784 |
+
var key = evt.target.key;
|
785 |
+
var msg = document.getElementById('wfu_subfolders_browser_msg_' + key);
|
786 |
+
var img = document.getElementById('wfu_subfolders_browser_img_' + key);
|
787 |
+
var ok = document.getElementById('wfu_subfolders_browser_ok_' + key);
|
788 |
+
msg.innerHTML = 'Unknown error';
|
789 |
+
img.style.display = "none";
|
790 |
+
ok.disabled = false;
|
791 |
+
}
|
792 |
+
|
793 |
+
function wfu_readfolderCanceled(evt) {
|
794 |
+
var key = evt.target.key;
|
795 |
+
var msg = document.getElementById('wfu_subfolders_browser_msg_' + key);
|
796 |
+
var img = document.getElementById('wfu_subfolders_browser_img_' + key);
|
797 |
+
var ok = document.getElementById('wfu_subfolders_browser_ok_' + key);
|
798 |
+
msg.innerHTML = 'Unknown error';
|
799 |
+
img.style.display = "none";
|
800 |
+
ok.disabled = false;
|
801 |
+
}
|
802 |
+
|
803 |
+
function wfu_subfolders_browser_list_changed(key) {
|
804 |
+
var list = document.getElementById('wfu_subfolders_browser_list_' + key);
|
805 |
+
var ok = document.getElementById('wfu_subfolders_browser_ok_' + key);
|
806 |
+
ok.disabled = (list.selectedIndex < 0);
|
807 |
+
}
|
808 |
+
|
809 |
+
function wfu_folder_browser_cancel_clicked(key) {
|
810 |
+
var container = document.getElementById('wfu_global_dialog_container');
|
811 |
+
var dialog = document.getElementById('wfu_subfolders_browser_' + key);
|
812 |
+
var btn = document.getElementById('wfu_subfolders_browse_' + key);
|
813 |
+
var shadow = document.getElementById('wfu_subfolders_inner_shadow_' + key);
|
814 |
+
|
815 |
+
container.onclick = null;
|
816 |
+
shadow.style.display = "none";
|
817 |
+
dialog.style.display = "none";
|
818 |
+
container.style.display = "none";
|
819 |
+
}
|
820 |
+
|
821 |
+
function wfu_get_relative_path(key) {
|
822 |
+
var list = document.getElementById('wfu_attribute_' + key);
|
823 |
+
if (list.selectedIndex < 0) return;
|
824 |
+
var items = list.data;
|
825 |
+
var isnewitem = (document.getElementById('wfu_subfolders_isnewitem_' + key).value == "1");
|
826 |
+
var level;
|
827 |
+
if (isnewitem) level = parseInt(document.getElementById('wfu_subfolders_newitemlevel_' + key).value);
|
828 |
+
else level = items[list.selectedIndex].level;
|
829 |
+
var relpath = "/";
|
830 |
+
var curpos = list.selectedIndex - 1;
|
831 |
+
var curlevel = level;
|
832 |
+
while (curpos >= 0 && curlevel > 1) {
|
833 |
+
if (items[curpos].level < curlevel) {
|
834 |
+
relpath = "/" + items[curpos].path + relpath;
|
835 |
+
curlevel = items[curpos].level;
|
836 |
+
}
|
837 |
+
curpos --;
|
838 |
+
}
|
839 |
+
if (isnewitem && document.getElementById('wfu_subfolders_newitemlevel2_' + key).value == "1" && level > 0 && list.selectedIndex > 0)
|
840 |
+
relpath += "," + items[list.selectedIndex - 1].path;
|
841 |
+
|
842 |
+
return relpath;
|
843 |
+
}
|
844 |
+
|
845 |
+
function wfu_subfolders_changed(key) {
|
846 |
+
wfu_update_subfolder_list(key);
|
847 |
+
wfu_subfolders_update_toolnav(key);
|
848 |
+
}
|
849 |
+
|
850 |
+
function wfu_subfolders_update_toolnav(key) {
|
851 |
+
var list = document.getElementById('wfu_attribute_' + key);
|
852 |
+
var items, item, ind, nextind, prevlevel;
|
853 |
+
var tools_container = document.getElementById('wfu_subfolder_tools_' + key);
|
854 |
+
var tools_path = document.getElementById('wfu_subfolders_path_' + key);
|
855 |
+
var tools_label = document.getElementById('wfu_subfolders_label_' + key);
|
856 |
+
var tools_ok = document.getElementById('wfu_subfolders_ok_' + key);
|
857 |
+
var tools_browse = document.getElementById('wfu_subfolders_browse_' + key);
|
858 |
+
document.getElementById('wfu_subfolders_isnewitem_' + key).value = "";
|
859 |
+
document.getElementById('wfu_subfolders_newitemindex_' + key).value = "";
|
860 |
+
document.getElementById('wfu_subfolders_newitemlevel_' + key).value = "";
|
861 |
+
document.getElementById('wfu_subfolders_newitemlevel2_' + key).value = "";
|
862 |
+
if (list.data == null) {
|
863 |
+
items = wfu_decode_subfolder_list(key);
|
864 |
+
list.data = items;
|
865 |
+
}
|
866 |
+
else items = list.data;
|
867 |
+
if (list.selectedIndex < 0) {
|
868 |
+
tools_container.className = "wfu_subfolder_tools_container wfu_subfolder_tools_disabled";
|
869 |
+
tools_path.disabled = true;
|
870 |
+
tools_label.disabled = true;
|
871 |
+
tools_ok.disabled = true;
|
872 |
+
tools_browse.disabled = true;
|
873 |
+
tools_label.value = "";
|
874 |
+
tools_path.value = "";
|
875 |
+
}
|
876 |
+
else if (list.selectedIndex >= list.options.length - 1) {
|
877 |
+
tools_container.className = "wfu_subfolder_tools_container";
|
878 |
+
tools_label.disabled = false;
|
879 |
+
tools_ok.disabled = true;
|
880 |
+
document.getElementById('wfu_subfolders_isnewitem_' + key).value = "1";
|
881 |
+
document.getElementById('wfu_subfolders_newitemindex_' + key).value = items.length;
|
882 |
+
var level;
|
883 |
+
if (items.length == 0) level = 0;
|
884 |
+
else if (items[items.length - 1].level == 0) level = 1;
|
885 |
+
else level = items[items.length - 1].level;
|
886 |
+
document.getElementById('wfu_subfolders_newitemlevel_' + key).value = level;
|
887 |
+
document.getElementById('wfu_subfolders_newitemlevel2_' + key).value = "1";
|
888 |
+
tools_path.disabled = (level == 0);
|
889 |
+
tools_browse.disabled = false;
|
890 |
+
if (level == 0) {
|
891 |
+
tools_path.value = "{root}";
|
892 |
+
tools_label.value = "{upload folder}";
|
893 |
+
}
|
894 |
+
else {
|
895 |
+
tools_path.value = "";
|
896 |
+
tools_label.value = "";
|
897 |
+
}
|
898 |
+
}
|
899 |
+
else {
|
900 |
+
tools_container.className = "wfu_subfolder_tools_container";
|
901 |
+
tools_label.disabled = false;
|
902 |
+
tools_ok.disabled = true;
|
903 |
+
item = items[list.selectedIndex];
|
904 |
+
tools_path.disabled = (item.level == 0);
|
905 |
+
tools_browse.disabled = (item.level == 0);
|
906 |
+
tools_label.value = item.label;
|
907 |
+
tools_path.value = item.path;
|
908 |
+
}
|
909 |
+
var navs = document.getElementsByName('wfu_subfolder_nav_' + key);
|
910 |
+
if (list.selectedIndex < 0 || list.selectedIndex >= list.options.length - 1) {
|
911 |
+
for (var i = 0; i < navs.length; i++) navs[i].disabled = true;
|
912 |
+
}
|
913 |
+
else {
|
914 |
+
wfu_subfolders_update_nav(key);
|
915 |
+
}
|
916 |
+
}
|
917 |
+
|
918 |
+
function wfu_subfolders_update_nav(key) {
|
919 |
+
var list = document.getElementById('wfu_attribute_' + key);
|
920 |
+
var navs_up = document.getElementById('wfu_subfolders_up_' + key);
|
921 |
+
var navs_down = document.getElementById('wfu_subfolders_down_' + key);
|
922 |
+
var navs_left = document.getElementById('wfu_subfolders_left_' + key);
|
923 |
+
var navs_right = document.getElementById('wfu_subfolders_right_' + key);
|
924 |
+
var navs_add = document.getElementById('wfu_subfolders_add_' + key);
|
925 |
+
var navs_def = document.getElementById('wfu_subfolders_def_' + key);
|
926 |
+
var navs_del = document.getElementById('wfu_subfolders_del_' + key);
|
927 |
+
var items = list.data;
|
928 |
+
var item = items[list.selectedIndex];
|
929 |
+
navs_up.disabled = (item.index <= 0);
|
930 |
+
ind = list.selectedIndex + 1;
|
931 |
+
nextind = 0;
|
932 |
+
while (ind < items.length) {
|
933 |
+
if (items[ind].level == item.level) {
|
934 |
+
nextind = items[ind].index;
|
935 |
+
break;
|
936 |
+
}
|
937 |
+
else if (items[ind].level < item.level) break;
|
938 |
+
else ind ++;
|
939 |
+
}
|
940 |
+
navs_down.disabled = (item.level == 0 || nextind == 0);
|
941 |
+
navs_left.disabled = ((list.selectedIndex == 0 && item.level < 1) || (list.selectedIndex > 0 && item.level <= 1));
|
942 |
+
if (list.selectedIndex >= 1) prevlevel = items[list.selectedIndex - 1].level;
|
943 |
+
else prevlevel = 0;
|
944 |
+
navs_right.disabled = (item.level - prevlevel > 0);
|
945 |
+
navs_add.disabled = (item.level == 0);
|
946 |
+
navs_def.disabled = false;
|
947 |
+
navs_def.className = "button" + (item.default ? " wfu_subfolder_nav_pressed" : "");
|
948 |
+
navs_del.disabled = false;
|
949 |
+
}
|
950 |
+
|
951 |
+
function wfu_decode_subfolder(data) {
|
952 |
+
var ret = {label:"", path:"", level:0, default:false};
|
953 |
+
data = data.trim();
|
954 |
+
var star_count = 0;
|
955 |
+
var is_default = false;
|
956 |
+
while (star_count < data.length) {
|
957 |
+
if (data.substr(star_count, 1) == "*") star_count ++;
|
958 |
+
else break;
|
959 |
+
}
|
960 |
+
data = data.substr(star_count, data.length - star_count);
|
961 |
+
if (data.substr(0, 1) == '&') {
|
962 |
+
data = data.substr(1);
|
963 |
+
is_default = true;
|
964 |
+
}
|
965 |
+
ret.level = star_count;
|
966 |
+
ret.default = is_default;
|
967 |
+
var data_raw = data.split('/');
|
968 |
+
if (data_raw.length == 1) {
|
969 |
+
ret.path = data_raw[0];
|
970 |
+
ret.label = data_raw[0];
|
971 |
+
}
|
972 |
+
else if (data_raw.length > 1) {
|
973 |
+
ret.path = data_raw[0];
|
974 |
+
ret.label = data_raw[1];
|
975 |
+
}
|
976 |
+
if (star_count == 0) {
|
977 |
+
ret.path = "{root}";
|
978 |
+
if (ret.label == "") ret.label = "{upload folder}";
|
979 |
+
}
|
980 |
+
return ret;
|
981 |
+
}
|
982 |
+
|
983 |
+
function wfu_decode_subfolder_list(key) {
|
984 |
+
var opts = document.getElementById('wfu_attribute_' + key).options;
|
985 |
+
var list = Array();
|
986 |
+
var dir_levels = ['root'];
|
987 |
+
var last_index = [0];
|
988 |
+
var subfolder_path;
|
989 |
+
var prev_level = -1;
|
990 |
+
for (var i = 0; i < opts.length - 1; i++) {
|
991 |
+
list.push(wfu_decode_subfolder(wfu_plugin_decode_string(opts[i].value)));
|
992 |
+
if (dir_levels.length > list[i].level) dir_levels[list[i].level] = list[i].path;
|
993 |
+
else dir_levels.push(list[i].path);
|
994 |
+
subfolder_path = "";
|
995 |
+
for ( j = 1; j <= list[i].level; j++) {
|
996 |
+
subfolder_path += dir_levels[j] + '/';
|
997 |
+
}
|
998 |
+
list[i].fullpath = subfolder_path;
|
999 |
+
if (last_index.length <= list[i].level) last_index.push(0);
|
1000 |
+
if (list[i].level > prev_level) list[i].index = 0;
|
1001 |
+
else list[i].index = last_index[list[i].level] + 1;
|
1002 |
+
last_index[list[i].level] = list[i].index;
|
1003 |
+
prev_level = list[i].level;
|
1004 |
+
}
|
1005 |
+
return list;
|
1006 |
+
}
|
1007 |
+
|
1008 |
+
function wfu_update_subfolder_list(key) {
|
1009 |
+
var opts = document.getElementById('wfu_attribute_' + key).options;
|
1010 |
+
var list = document.getElementById('wfu_attribute_' + key);
|
1011 |
+
var items = list.data;
|
1012 |
+
if (items == null) return;
|
1013 |
+
var value_raw, text_raw;
|
1014 |
+
var global_raw = "";
|
1015 |
+
opts.length = items.length + 1;
|
1016 |
+
for (var i = 0; i < items.length; i ++) {
|
1017 |
+
value_raw = "";
|
1018 |
+
text_raw = "";
|
1019 |
+
for (j = 0; j < items[i].level; j ++) {
|
1020 |
+
value_raw += "*";
|
1021 |
+
text_raw += " ";
|
1022 |
+
}
|
1023 |
+
if (items[i].default) {
|
1024 |
+
value_raw += "&";
|
1025 |
+
opts[i].className = "wfu_select_folders_option_default";
|
1026 |
+
}
|
1027 |
+
else opts[i].className = "";
|
1028 |
+
value_raw += items[i].path + '/' + items[i].label;
|
1029 |
+
text_raw += items[i].label;
|
1030 |
+
opts[i].value = wfu_plugin_encode_string(value_raw);
|
1031 |
+
opts[i].innerHTML = text_raw;
|
1032 |
+
if (global_raw != "") global_raw += ",";
|
1033 |
+
global_raw += value_raw;
|
1034 |
+
}
|
1035 |
+
opts[items.length].value = "";
|
1036 |
+
opts[items.length].innerHTML = "";
|
1037 |
+
return global_raw;
|
1038 |
+
}
|
1039 |
+
|
1040 |
function wfu_userdata_edit_field(line, label, required) {
|
1041 |
var item;
|
1042 |
for (var i = 0; i < line.childNodes.length; i ++) {
|
1110 |
var item = e.target;
|
1111 |
var attribute = item.id.replace("wfu_attribute_", "");
|
1112 |
var val = item.value;
|
1113 |
+
//encode some characters not allowed in shortcode, such as line breaks, double quotes (") and brackets ([])
|
1114 |
+
val = val.replace(/(\r\n|\n|\r)/gm,"%n%");
|
1115 |
+
val = val.replace(/\"/gm,"%dq%");
|
1116 |
+
val = val.replace(/\[/gm,"%brl%");
|
1117 |
+
val = val.replace(/\]/gm,"%brr%");
|
1118 |
if (val !== item.oldVal) {
|
1119 |
item.oldVal = val;
|
1120 |
document.getElementById("wfu_attribute_value_" + attribute).value = val;
|
1274 |
for (var i = 0; i < dimension_elements.length; i++) wfu_attach_element_handlers(dimension_elements[i], wfu_update_dimension_value);
|
1275 |
var userfield_elements = document.getElementsByName("wfu_userfield_elements");
|
1276 |
for (var i = 0; i < userfield_elements.length; i++) wfu_attach_element_handlers(userfield_elements[i], wfu_update_userfield_value);
|
1277 |
+
var subfolder_input_elements = document.getElementsByName("wfu_subfolder_tools_input");
|
1278 |
+
for (var i = 0; i < subfolder_input_elements.length; i++) wfu_attach_element_handlers(subfolder_input_elements[i], wfu_subfolders_input_changed);
|
1279 |
}
|
1280 |
|
1281 |
+
|
1282 |
function wfu_insert_variable(obj) {
|
1283 |
var attr = obj.className.replace("wfu_variable wfu_variable_", "");
|
1284 |
var inp = document.getElementById("wfu_attribute_" + attr);
|
1320 |
xmlhttp = window.createRequest();
|
1321 |
}
|
1322 |
catch (e) {}
|
1323 |
+
|
1324 |
}
|
1325 |
return xhr;
|
1326 |
}
|
1342 |
return newstr;
|
1343 |
}
|
1344 |
|
1345 |
+
//wfu_plugin_decode_string: function that decodes an encoded string
|
1346 |
+
function wfu_plugin_decode_string(str) {
|
1347 |
+
var i = 0;
|
1348 |
+
var newstr = "";
|
1349 |
+
var num, val;
|
1350 |
+
while (i < str.length) {
|
1351 |
+
num = parseInt(str.substr(i, 2), 16);
|
1352 |
+
if (num < 128) val = num;
|
1353 |
+
else if (num < 224) val = ((num & 31) << 6) + (parseInt(str.substr((i += 2), 2), 16) & 63);
|
1354 |
+
else val = ((num & 15) << 12) + ((parseInt(str.substr((i += 2), 2), 16) & 63) << 6) + (parseInt(str.substr((i += 2), 2), 16) & 63);
|
1355 |
+
newstr += String.fromCharCode(val);
|
1356 |
+
i += 2;
|
1357 |
+
}
|
1358 |
+
return newstr;
|
1359 |
+
}
|
1360 |
+
|
1361 |
function wfu_schedule_save_shortcode() {
|
1362 |
var d = new Date();
|
1363 |
var dt = ShortcodeNextSave - d.getTime();
|
1440 |
}
|
1441 |
else if (type == "text" || type == "ltext" || type == "integer" || type == "float" || type == "mtext" || type == "color" ) {
|
1442 |
var item = document.getElementById("wfu_attribute_" + attribute);
|
1443 |
+
//decode some characters not allowed in shortcode, such as line breaks, double quotes (") and brackets ([])
|
1444 |
+
value = value.replace(/\%n\%/gm,"\n");
|
1445 |
+
value = value.replace(/\%dq\%/gm,"\"");
|
1446 |
+
value = value.replace(/\%brl\%/gm,"[");
|
1447 |
+
value = value.replace(/\%brr\%/gm,"]");
|
1448 |
if (type == "color") {
|
1449 |
var rgb = colourNameToHex(value);
|
1450 |
if (!rgb) rgb = value;
|
1465 |
wfu_admin_radio_clicked(attribute);
|
1466 |
}
|
1467 |
else if (type == "ptext" ) {
|
1468 |
+
//decode some characters not allowed in shortcode, such as line breaks, double quotes (") and brackets ([])
|
1469 |
+
value = value.replace(/\%n\%/gm,"\n");
|
1470 |
+
value = value.replace(/\%dq\%/gm,"\"");
|
1471 |
+
value = value.replace(/\%brl\%/gm,"[");
|
1472 |
+
value = value.replace(/\%brr\%/gm,"]");
|
1473 |
var parts = value.split("/");
|
1474 |
var singular = parts.length < 1 ? "" : parts[0];
|
1475 |
var plural = parts.length < 2 ? singular : parts[1];
|
1567 |
document.getElementById("wfu_attribute_" + attribute + "_borcolor").value = colors[2];
|
1568 |
wfu_update_triplecolor_value({target:item});
|
1569 |
}
|
1570 |
+
else if (type == "folderlist") {
|
1571 |
+
var items = wfu_parse_folderlist_js(value);
|
1572 |
+
var opts = document.getElementById('wfu_attribute_' + attribute).options;
|
1573 |
+
while (opts.length > 0) opts.remove(0);
|
1574 |
+
var opt, subfolder, subfolder_raw, text, stars, subvalue;
|
1575 |
+
for (var i = 0; i < items.path.length; i++) {
|
1576 |
+
subfolder = items.path[i];
|
1577 |
+
if (subfolder.substr(subfolder.length, 1) == '/') subfolder = subfolder.substr(0, subfolder.length - 1);
|
1578 |
+
subfolder_raw = subfolder.split("/");
|
1579 |
+
subfolder = subfolder_raw[subfolder_raw.length - 1];
|
1580 |
+
stars = parseInt(items.level[i]);
|
1581 |
+
text = "";
|
1582 |
+
subvalue = "";
|
1583 |
+
for (var j = 0; j < stars; j++) {
|
1584 |
+
text += " ";
|
1585 |
+
subvalue += "*";
|
1586 |
+
}
|
1587 |
+
text += items.label[i];
|
1588 |
+
if (items.default[i]) subvalue += "&";
|
1589 |
+
if (subfolder == "") subvalue += "{root}/" + items.label[i];
|
1590 |
+
else subvalue += subfolder + items.label[i];
|
1591 |
+
|
1592 |
+
opt = document.createElement("option");
|
1593 |
+
if (items.default[i]) opt.className = "wfu_select_folders_option_default";
|
1594 |
+
else opt.className = "";
|
1595 |
+
opt.value = wfu_plugin_encode_string(subvalue);
|
1596 |
+
opt.innerHTML = text;
|
1597 |
+
opts.add(opt);
|
1598 |
+
}
|
1599 |
+
opt = document.createElement("option");
|
1600 |
+
opt.value = "";
|
1601 |
+
opt.innerHTML = "";
|
1602 |
+
opts.add(opt);
|
1603 |
+
var list = document.getElementById('wfu_attribute_' + attribute);
|
1604 |
+
// update list indices
|
1605 |
+
list.data = wfu_decode_subfolder_list(attribute);
|
1606 |
+
// update tool and nav items
|
1607 |
+
wfu_subfolders_update_toolnav(attribute);
|
1608 |
+
// update shortcode
|
1609 |
+
item = list;
|
1610 |
+
if (value !== item.oldVal) {
|
1611 |
+
item.oldVal = value;
|
1612 |
+
document.getElementById("wfu_attribute_value_" + attribute).value = value;
|
1613 |
+
wfu_generate_shortcode();
|
1614 |
+
}
|
1615 |
+
}
|
1616 |
+
}
|
1617 |
+
|
1618 |
+
function wfu_parse_folderlist_js(list) {
|
1619 |
+
var ret = Object();
|
1620 |
+
ret.path = Array();
|
1621 |
+
ret.label = Array();
|
1622 |
+
ret.level = Array();
|
1623 |
+
ret.default = Array();
|
1624 |
+
|
1625 |
+
var subfolders = list.split(",");
|
1626 |
+
if (subfolders.length == 0) return ret;
|
1627 |
+
if (subfolders.length == 1 && subfolders[0].trim() == "") return ret;
|
1628 |
+
var dir_levels = ["root"];
|
1629 |
+
var prev_level = 0;
|
1630 |
+
var level0_count = 0;
|
1631 |
+
var _default = -1;
|
1632 |
+
var subfolder, star_count, start_spaces, is_default, subfolder_dir, subfolder_label, subfolder_path;
|
1633 |
+
for (var i = 0; i < subfolders.length; i++) {
|
1634 |
+
subfolder = subfolders[i].trim();
|
1635 |
+
star_count = 0;
|
1636 |
+
start_spaces = "";
|
1637 |
+
is_default = false;
|
1638 |
+
// check for folder level
|
1639 |
+
while (star_count < subfolder.length) {
|
1640 |
+
if ( subfolder.substr(star_count, 1) == "*" ) {
|
1641 |
+
star_count ++;
|
1642 |
+
start_spaces += " ";
|
1643 |
+
}
|
1644 |
+
else break;
|
1645 |
+
}
|
1646 |
+
if (star_count - prev_level <= 1 && (star_count > 0 || level0_count == 0)) {
|
1647 |
+
subfolder = subfolder.substr(star_count, subfolder.length - star_count);
|
1648 |
+
// check for default value
|
1649 |
+
if (subfolder.substr(0, 1) == '&') {
|
1650 |
+
subfolder = subfolder.substr(1);
|
1651 |
+
is_default = true;
|
1652 |
+
}
|
1653 |
+
//split item in folder path and folder name
|
1654 |
+
subfolder_items = subfolder.split("/");
|
1655 |
+
if (subfolder_items.length < 2) subfolder_items.push("");
|
1656 |
+
if (subfolder_items[1] != "") {
|
1657 |
+
subfolder_dir = subfolder_items[0];
|
1658 |
+
subfolder_label = subfolder_items[1];
|
1659 |
+
}
|
1660 |
+
else {
|
1661 |
+
subfolder_dir = subfolder;
|
1662 |
+
subfolder_label = subfolder;
|
1663 |
+
}
|
1664 |
+
if (subfolder_dir != "") {
|
1665 |
+
// set is_default flag to true only for the first default item
|
1666 |
+
if (is_default && _default == -1) _default = ret.path.length;
|
1667 |
+
else is_default = false;
|
1668 |
+
// set flag that root folder has been included (so that it is not included it again)
|
1669 |
+
if (star_count == 0) level0_count = 1;
|
1670 |
+
if (dir_levels.length > star_count) dir_levels[star_count] = subfolder_dir;
|
1671 |
+
else dir_levels.push(subfolder_dir);
|
1672 |
+
subfolder_path = "";
|
1673 |
+
for (var i_count = 1; i_count <= star_count; i_count++) {
|
1674 |
+
subfolder_path += dir_levels[i_count] + '/';
|
1675 |
+
}
|
1676 |
+
ret.path.push(subfolder_path);
|
1677 |
+
ret.label.push(subfolder_label);
|
1678 |
+
ret.level.push(star_count);
|
1679 |
+
ret.default.push(is_default);
|
1680 |
+
prev_level = star_count;
|
1681 |
+
}
|
1682 |
+
}
|
1683 |
+
}
|
1684 |
+
|
1685 |
+
return ret;
|
1686 |
}
|
1687 |
|
1688 |
function colourNameToHex(colour)
|
1718 |
|
1719 |
return false;
|
1720 |
}
|
1721 |
+
|
1722 |
+
function wfu_download_file(ajaxurl_enc, filepath_enc, dataid) {
|
1723 |
+
var url = wfu_plugin_decode_string(ajaxurl_enc) + '?action=wfu_ajax_action_download_file&file=' + filepath_enc + '&dataid=' + dataid;
|
1724 |
+
var IF = document.getElementById("wfu_download_frame");
|
1725 |
+
IF.src = url;
|
1726 |
+
}
|
1727 |
+
|
1728 |
+
function wfu_filedetails_userdata_changed(e) {
|
1729 |
+
var userdata_elements = document.getElementsByName("wfu_filedetails_userdata");
|
1730 |
+
var def, subm;
|
1731 |
+
var changed = false;
|
1732 |
+
for (var i = 0; i < userdata_elements.length; i++) {
|
1733 |
+
def = document.getElementById(userdata_elements[i].id.replace("wfu_filedetails_userdata_value_", "wfu_filedetails_userdata_default_"));
|
1734 |
+
subm = document.getElementById(userdata_elements[i].id.replace("wfu_filedetails_userdata_value_", "wfu_filedetails_userdata_"));
|
1735 |
+
subm.value = userdata_elements[i].value;
|
1736 |
+
if (userdata_elements[i].value != def.value) {
|
1737 |
+
changed = true;
|
1738 |
+
break;
|
1739 |
+
}
|
1740 |
+
}
|
1741 |
+
document.getElementById("dp_filedetails_submit_fields").disabled = !changed;
|
1742 |
+
}
|
1743 |
+
|
1744 |
+
function wfu_Attach_FileDetails_Admin_Events() {
|
1745 |
+
var userdata_elements = document.getElementsByName("wfu_filedetails_userdata");
|
1746 |
+
for (var i = 0; i < userdata_elements.length; i++) wfu_attach_element_handlers(userdata_elements[i], wfu_filedetails_userdata_changed);
|
1747 |
+
}
|
js/wordpress_file_upload_functions.js
CHANGED
@@ -288,24 +288,20 @@ function wfu_selectbutton_clicked(sid) {
|
|
288 |
}
|
289 |
}
|
290 |
|
291 |
-
//
|
292 |
-
function
|
293 |
-
var
|
294 |
-
if (
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
document.body.appendChild(i);
|
300 |
-
return;
|
301 |
}
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
}
|
307 |
}
|
308 |
-
xmlhttp.send(null);
|
309 |
}
|
310 |
|
311 |
//wfu_Redirect: function to redirect to another url
|
@@ -342,10 +338,40 @@ function wfu_uploadProgress(evt) {
|
|
342 |
}
|
343 |
|
344 |
/* wfu_notify_WPFilebase: function to notify WPFilebase plugin about file changes */
|
345 |
-
function wfu_notify_WPFilebase(
|
346 |
-
|
347 |
-
|
348 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
349 |
}
|
350 |
|
351 |
/* wfu_send_email_notification: function to send notification message as ajax request */
|
@@ -437,10 +463,10 @@ function wfu_uploadComplete(evt) {
|
|
437 |
var upload_params = "";
|
438 |
var safe_params = "";
|
439 |
var debug_data = "";
|
|
|
440 |
var result_data = evt.target.responseText;
|
441 |
if (evt.target.responseText != -1) {
|
442 |
var txt = evt.target.responseText;
|
443 |
-
var success_txt = "wfu_fileupload_success:";
|
444 |
var pos = txt.indexOf(success_txt);
|
445 |
if ( pos > -1 ) {
|
446 |
if (this.debugmode == "true") debug_data = txt.substr(0, pos);
|
@@ -637,7 +663,8 @@ function wfu_ProcessUploadComplete(sid, file_id, upload_params, unique_id, param
|
|
637 |
// prepare and execute actions related to WPFilebase, email notifications and redirection if this is the last call
|
638 |
if (G.update_wpfilebase != "") {
|
639 |
G.admin_messages.wpfilebase = "";
|
640 |
-
wfu_notify_WPFilebase(G.update_wpfilebase);
|
|
|
641 |
}
|
642 |
if (G.notify_only_filename_list != "") {
|
643 |
G.admin_messages.notify = "";
|
@@ -647,7 +674,7 @@ function wfu_ProcessUploadComplete(sid, file_id, upload_params, unique_id, param
|
|
647 |
G.notify_only_filename_list = ""; //reset this variable so that repetitive email messages are not sent
|
648 |
}
|
649 |
if (G.errors.redirect != "") G.redirect_link = "";
|
650 |
-
if (G.redirect_link != "") {
|
651 |
// if redirection is executed, then set upload state to redirecting...
|
652 |
G.upload_state = 11;
|
653 |
do_redirect = true;
|
@@ -657,6 +684,7 @@ function wfu_ProcessUploadComplete(sid, file_id, upload_params, unique_id, param
|
|
657 |
|
658 |
// last adjustment of header messages due to json parse error of UploadState or debug messages
|
659 |
var nonadmin_message = G.message;
|
|
|
660 |
var admin_message = wfu_join_strings("<br />",
|
661 |
G.admin_messages.other,
|
662 |
G.admin_messages.wpfilebase,
|
@@ -872,6 +900,9 @@ function wfu_redirect_to_classic(sid, session_token, flag, adminerrorcode) {
|
|
872 |
//check if file has been selected or not
|
873 |
if (wfu_filesselected(sid) == 0) return;
|
874 |
|
|
|
|
|
|
|
875 |
// check if there are empty user data fields that are required
|
876 |
if (!wfu_check_required_userdata(sid)) return;
|
877 |
|
@@ -896,6 +927,8 @@ function wfu_redirect_to_classic_cont(sid, session_token, flag, adminerrorcode,
|
|
896 |
if (adminerrorcode > 0) document.getElementById('adminerrorcodes_' + sid).value = adminerrorcode;
|
897 |
else document.getElementById('adminerrorcodes_' + sid).value = "";
|
898 |
document.getElementById('upfile_' + sid).disabled = false;
|
|
|
|
|
899 |
document.getElementById('uploadform_' + sid).submit();
|
900 |
}
|
901 |
}
|
@@ -1002,6 +1035,9 @@ function wfu_HTML5UploadFile(sid, JSONtext, session_token) {
|
|
1002 |
var numfiles = wfu_filesselected(sid);
|
1003 |
if (numfiles == 0) return;
|
1004 |
|
|
|
|
|
|
|
1005 |
|
1006 |
// check if there are empty user data fields that are required
|
1007 |
if (!wfu_check_required_userdata(sid)) return;
|
@@ -1024,6 +1060,7 @@ function wfu_HTML5UploadFile_cont(sid, JSONobj, session_token, other_params) {
|
|
1024 |
// define POST parameters
|
1025 |
fd.append("uploadedfile_" + sid + suffice, file);
|
1026 |
fd.append("action", "wfu_ajax_action");
|
|
|
1027 |
fd.append("params_index", JSONobj.params_index);
|
1028 |
fd.append("subdir_sel_index", subdir_sel_index);
|
1029 |
fd.append("session_token", session_token);
|
@@ -1080,10 +1117,12 @@ function wfu_HTML5UploadFile_cont(sid, JSONobj, session_token, other_params) {
|
|
1080 |
// get file list
|
1081 |
var inputfile = document.getElementById("upfile_" + sid);
|
1082 |
var farr = inputfile.files;
|
1083 |
-
//fix in case files attribute is not supported
|
1084 |
if (!farr) { if (inputfile.value) farr = [{name:inputfile.value}]; else farr = []; }
|
1085 |
if (typeof inputfile.filearray != "undefined") farr = inputfile.filearray;
|
1086 |
var suffice = "";
|
|
|
|
|
1087 |
/* initialize global object to hold dynamic upload status during upload */
|
1088 |
var rand_str = wfu_randomString(10);
|
1089 |
GlobalData[sid] = {};
|
@@ -1166,7 +1205,7 @@ function wfu_clear(sid) {
|
|
1166 |
textbox.className = 'file_input_textbox';
|
1167 |
}
|
1168 |
var subdir = document.getElementById('selectsubdir_' + sid);
|
1169 |
-
if (subdir) subdir.selectedIndex =
|
1170 |
var userdata_count = wfu_get_userdata_count(sid);
|
1171 |
for (var i = 0; i < userdata_count; i++) {
|
1172 |
document.getElementById('userdata_' + sid + '_message_' + i).value = "";
|
@@ -1201,6 +1240,7 @@ function wfu_reset_message(sid) {
|
|
1201 |
|
1202 |
|
1203 |
function wfu_show_simple_progressbar(sid, effect) {
|
|
|
1204 |
var bar = document.getElementById('progressbar_' + sid + '_animation');
|
1205 |
var barsafe = document.getElementById('progressbar_' + sid + '_imagesafe');
|
1206 |
if (bar) {
|
288 |
}
|
289 |
}
|
290 |
|
291 |
+
//wfu_selectsubdir_check: function that checks if a subdirectory has been selected (when askforsubfolder is on)
|
292 |
+
function wfu_selectsubdir_check(sid) {
|
293 |
+
var sel = document.getElementById("selectsubdir_" + sid);
|
294 |
+
if (!sel) return true;
|
295 |
+
document.getElementById('hiddeninput_' + sid).value = sel.selectedIndex;
|
296 |
+
if (sel.selectedIndex == 0) {
|
297 |
+
sel.style.backgroundColor = 'red';
|
298 |
+
return false;
|
|
|
|
|
299 |
}
|
300 |
+
else {
|
301 |
+
sel.style.backgroundColor = 'transparent';
|
302 |
+
sel.options[0].style.display = "none";
|
303 |
+
return true;
|
|
|
304 |
}
|
|
|
305 |
}
|
306 |
|
307 |
//wfu_Redirect: function to redirect to another url
|
338 |
}
|
339 |
|
340 |
/* wfu_notify_WPFilebase: function to notify WPFilebase plugin about file changes */
|
341 |
+
function wfu_notify_WPFilebase(params_index, session_token) {
|
342 |
+
var xhr = wfu_GetHttpRequestObject();
|
343 |
+
if (xhr == null) {
|
344 |
+
//alternative way of sending GET request using IFRAME, in case AJAX is disabled
|
345 |
+
var i = document.createElement("iframe");
|
346 |
+
i.style.display = "none";
|
347 |
+
i.src = GlobalData.consts.ajax_url + "?action=wfu_ajax_action_notify_wpfilebase¶ms_index=" + params_index + "&session_token=" + session_token;
|
348 |
+
document.body.appendChild(i);
|
349 |
+
return;
|
350 |
+
}
|
351 |
+
|
352 |
+
var url = GlobalData.consts.ajax_url;
|
353 |
+
params = new Array(3);
|
354 |
+
params[0] = new Array(2);
|
355 |
+
params[0][0] = 'action';
|
356 |
+
params[0][1] = 'wfu_ajax_action_notify_wpfilebase';
|
357 |
+
params[1] = new Array(2);
|
358 |
+
params[1][0] = 'params_index';
|
359 |
+
params[1][1] = params_index;
|
360 |
+
params[2] = new Array(2);
|
361 |
+
params[2][0] = 'session_token';
|
362 |
+
params[2][1] = session_token;
|
363 |
+
|
364 |
+
var parameters = '';
|
365 |
+
for (var i = 0; i < params.length; i++) {
|
366 |
+
parameters += (i > 0 ? "&" : "") + params[i][0] + "=" + encodeURI(params[i][1]);
|
367 |
+
}
|
368 |
+
|
369 |
+
xhr.open("POST", url, true);
|
370 |
+
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
371 |
+
xhr.setRequestHeader("Content-length", parameters.length);
|
372 |
+
xhr.setRequestHeader("Connection", "close");
|
373 |
+
xhr.onreadystatechange = function() {}
|
374 |
+
xhr.send(parameters);
|
375 |
}
|
376 |
|
377 |
/* wfu_send_email_notification: function to send notification message as ajax request */
|
463 |
var upload_params = "";
|
464 |
var safe_params = "";
|
465 |
var debug_data = "";
|
466 |
+
var success_txt = "wfu_fileupload_success:";
|
467 |
var result_data = evt.target.responseText;
|
468 |
if (evt.target.responseText != -1) {
|
469 |
var txt = evt.target.responseText;
|
|
|
470 |
var pos = txt.indexOf(success_txt);
|
471 |
if ( pos > -1 ) {
|
472 |
if (this.debugmode == "true") debug_data = txt.substr(0, pos);
|
663 |
// prepare and execute actions related to WPFilebase, email notifications and redirection if this is the last call
|
664 |
if (G.update_wpfilebase != "") {
|
665 |
G.admin_messages.wpfilebase = "";
|
666 |
+
// wfu_notify_WPFilebase(G.update_wpfilebase);
|
667 |
+
wfu_notify_WPFilebase(params_index, session_token);
|
668 |
}
|
669 |
if (G.notify_only_filename_list != "") {
|
670 |
G.admin_messages.notify = "";
|
674 |
G.notify_only_filename_list = ""; //reset this variable so that repetitive email messages are not sent
|
675 |
}
|
676 |
if (G.errors.redirect != "") G.redirect_link = "";
|
677 |
+
if (G.redirect_link != "" && G.last) {
|
678 |
// if redirection is executed, then set upload state to redirecting...
|
679 |
G.upload_state = 11;
|
680 |
do_redirect = true;
|
684 |
|
685 |
// last adjustment of header messages due to json parse error of UploadState or debug messages
|
686 |
var nonadmin_message = G.message;
|
687 |
+
|
688 |
var admin_message = wfu_join_strings("<br />",
|
689 |
G.admin_messages.other,
|
690 |
G.admin_messages.wpfilebase,
|
900 |
//check if file has been selected or not
|
901 |
if (wfu_filesselected(sid) == 0) return;
|
902 |
|
903 |
+
//check if a subfolder has been selected (in case askforsubfolders is on)
|
904 |
+
if (!wfu_selectsubdir_check(sid)) return;
|
905 |
+
|
906 |
// check if there are empty user data fields that are required
|
907 |
if (!wfu_check_required_userdata(sid)) return;
|
908 |
|
927 |
if (adminerrorcode > 0) document.getElementById('adminerrorcodes_' + sid).value = adminerrorcode;
|
928 |
else document.getElementById('adminerrorcodes_' + sid).value = "";
|
929 |
document.getElementById('upfile_' + sid).disabled = false;
|
930 |
+
// set the unique identifier of the current upload
|
931 |
+
document.getElementById('uniqueuploadid_' + sid).value = wfu_randomString(20);
|
932 |
document.getElementById('uploadform_' + sid).submit();
|
933 |
}
|
934 |
}
|
1035 |
var numfiles = wfu_filesselected(sid);
|
1036 |
if (numfiles == 0) return;
|
1037 |
|
1038 |
+
//check if a subfolder has been selected (in case askforsubfolders is on)
|
1039 |
+
if (!wfu_selectsubdir_check(sid)) return;
|
1040 |
+
|
1041 |
|
1042 |
// check if there are empty user data fields that are required
|
1043 |
if (!wfu_check_required_userdata(sid)) return;
|
1060 |
// define POST parameters
|
1061 |
fd.append("uploadedfile_" + sid + suffice, file);
|
1062 |
fd.append("action", "wfu_ajax_action");
|
1063 |
+
fd.append("uniqueuploadid_" + sid, unique_upload_id);
|
1064 |
fd.append("params_index", JSONobj.params_index);
|
1065 |
fd.append("subdir_sel_index", subdir_sel_index);
|
1066 |
fd.append("session_token", session_token);
|
1117 |
// get file list
|
1118 |
var inputfile = document.getElementById("upfile_" + sid);
|
1119 |
var farr = inputfile.files;
|
1120 |
+
// fix in case files attribute is not supported
|
1121 |
if (!farr) { if (inputfile.value) farr = [{name:inputfile.value}]; else farr = []; }
|
1122 |
if (typeof inputfile.filearray != "undefined") farr = inputfile.filearray;
|
1123 |
var suffice = "";
|
1124 |
+
// set the unique identifier of the current upload
|
1125 |
+
var unique_upload_id = wfu_randomString(20);
|
1126 |
/* initialize global object to hold dynamic upload status during upload */
|
1127 |
var rand_str = wfu_randomString(10);
|
1128 |
GlobalData[sid] = {};
|
1205 |
textbox.className = 'file_input_textbox';
|
1206 |
}
|
1207 |
var subdir = document.getElementById('selectsubdir_' + sid);
|
1208 |
+
if (subdir) subdir.selectedIndex = parseInt(document.getElementById('selectsubdirdefault_' + sid).value);
|
1209 |
var userdata_count = wfu_get_userdata_count(sid);
|
1210 |
for (var i = 0; i < userdata_count; i++) {
|
1211 |
document.getElementById('userdata_' + sid + '_message_' + i).value = "";
|
1240 |
|
1241 |
|
1242 |
function wfu_show_simple_progressbar(sid, effect) {
|
1243 |
+
|
1244 |
var bar = document.getElementById('progressbar_' + sid + '_animation');
|
1245 |
var barsafe = document.getElementById('progressbar_' + sid + '_imagesafe');
|
1246 |
if (bar) {
|
languages/wordpress-file-upload.pot
CHANGED
@@ -2,9 +2,9 @@ msgid ""
|
|
2 |
msgstr ""
|
3 |
"Project-Id-Version: Wordpress File Upload\n"
|
4 |
"Report-Msgid-Bugs-To: \n"
|
5 |
-
"POT-Creation-Date: 2014-
|
6 |
-
"PO-Revision-Date: 2014-
|
7 |
-
"Last-Translator: nickboss <
|
8 |
"Language-Team: Iptanus Team <info@iptanus.com>\n"
|
9 |
"Language: en\n"
|
10 |
"MIME-Version: 1.0\n"
|
@@ -56,366 +56,392 @@ msgstr ""
|
|
56 |
msgid "File %filename% is being uploaded"
|
57 |
msgstr ""
|
58 |
|
59 |
-
#: lib/wfu_constants.php:
|
60 |
msgid "Your message"
|
61 |
msgstr ""
|
62 |
|
63 |
-
#: lib/wfu_constants.php:
|
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:
|
70 |
msgid "Error. Invalid ftp information. Check 'ftpinfo' attribute."
|
71 |
msgstr ""
|
72 |
|
73 |
-
#: lib/wfu_constants.php:
|
74 |
msgid ""
|
75 |
"Error. Could not extract ftp information from 'ftpinfo' attribute. Check its "
|
76 |
"syntax."
|
77 |
msgstr ""
|
78 |
|
79 |
-
#: lib/wfu_constants.php:
|
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:
|
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:
|
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:
|
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:
|
106 |
msgid "Targer folder doesn't exist."
|
107 |
msgstr ""
|
108 |
|
109 |
-
#: lib/wfu_constants.php:
|
110 |
msgid "Upload failed! Missing a temporary folder."
|
111 |
msgstr ""
|
112 |
|
113 |
-
#: lib/wfu_constants.php:
|
114 |
msgid "Upload failed! Permission denied to write to target folder."
|
115 |
msgstr ""
|
116 |
|
117 |
-
#: lib/wfu_constants.php:
|
118 |
msgid "File not allowed."
|
119 |
msgstr ""
|
120 |
|
121 |
-
#: lib/wfu_constants.php:
|
122 |
msgid "The uploaded file exceeds the file size limit."
|
123 |
msgstr ""
|
124 |
|
125 |
-
#: lib/wfu_constants.php:
|
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:
|
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:
|
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:
|
144 |
msgid "Upload failed! The uploaded file was only partially uploaded."
|
145 |
msgstr ""
|
146 |
|
147 |
-
#: lib/wfu_constants.php:
|
148 |
msgid "Upload failed! No file was uploaded."
|
149 |
msgstr ""
|
150 |
|
151 |
-
#: lib/wfu_constants.php:
|
152 |
msgid "Upload failed! Failed to write file to disk."
|
153 |
msgstr ""
|
154 |
|
155 |
-
#: lib/wfu_constants.php:
|
156 |
msgid ""
|
157 |
"Upload failed! Error occured while moving temporary file. Please contact "
|
158 |
"administrator."
|
159 |
msgstr ""
|
160 |
|
161 |
-
#: lib/wfu_constants.php:
|
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:
|
169 |
msgid "Upload failed! Error occured while attemting to upload the file."
|
170 |
msgstr ""
|
171 |
|
172 |
-
#: lib/wfu_constants.php:
|
173 |
msgid "Upload failed!"
|
174 |
msgstr ""
|
175 |
|
176 |
-
#: lib/wfu_constants.php:
|
177 |
msgid "No file!"
|
178 |
msgstr ""
|
179 |
|
180 |
-
#: lib/wfu_constants.php:
|
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:
|
187 |
msgid "Upload failed! Unknown error."
|
188 |
msgstr ""
|
189 |
|
190 |
-
#: lib/wfu_constants.php:
|
191 |
msgid "Please contact the administrator."
|
192 |
msgstr ""
|
193 |
|
194 |
-
#: lib/wfu_constants.php:
|
195 |
msgid "No result from remote server!"
|
196 |
msgstr ""
|
197 |
|
198 |
-
#: lib/wfu_constants.php:
|
199 |
msgid " but with warnings"
|
200 |
msgstr ""
|
201 |
|
202 |
-
#: lib/wfu_constants.php:
|
203 |
msgid "Warning: JSON parse error."
|
204 |
msgstr ""
|
205 |
|
206 |
-
#: lib/wfu_constants.php:
|
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:
|
213 |
msgid ""
|
214 |
"UploadStates, passed as JSON string to the handler, could not be parsed."
|
215 |
msgstr ""
|
216 |
|
217 |
-
#: lib/wfu_constants.php:
|
218 |
msgid ""
|
219 |
"Redirection to classic form functionality occurred due to unknown error."
|
220 |
msgstr ""
|
221 |
|
222 |
-
#: lib/wfu_constants.php:
|
223 |
msgid ""
|
224 |
"Redirection to classic form functionality occurred because AJAX is not "
|
225 |
"supported."
|
226 |
msgstr ""
|
227 |
|
228 |
-
#: lib/wfu_constants.php:
|
229 |
msgid ""
|
230 |
"Redirection to classic form functionality occurred because HTML5 is not "
|
231 |
"supported."
|
232 |
msgstr ""
|
233 |
|
234 |
-
#: lib/wfu_constants.php:
|
235 |
msgid ""
|
236 |
"Redirection to classic form functionality occurred due to JSON parse error."
|
237 |
msgstr ""
|
238 |
|
239 |
-
#: lib/wfu_constants.php:
|
240 |
msgid "cannot be empty!"
|
241 |
msgstr ""
|
242 |
|
243 |
-
#: lib/wfu_constants.php:
|
244 |
msgid "Upload skipped! File already exists."
|
245 |
msgstr ""
|
246 |
|
247 |
-
#: lib/wfu_constants.php:
|
248 |
msgid "No files have been selected!"
|
249 |
msgstr ""
|
250 |
|
251 |
-
#: lib/wfu_constants.php:
|
252 |
msgid "WPFilebase Plugin not updated because there were no files uploaded."
|
253 |
msgstr ""
|
254 |
|
255 |
-
#: lib/wfu_constants.php:
|
256 |
msgid "Notification email was not sent because there were no files uploaded."
|
257 |
msgstr ""
|
258 |
|
259 |
-
#: lib/wfu_constants.php:
|
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:
|
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:
|
272 |
msgid ""
|
273 |
"Redirection not executed because redirection link is empty. Please check "
|
274 |
"redirectlink attribute."
|
275 |
msgstr ""
|
276 |
|
277 |
-
#: lib/wfu_constants.php:
|
278 |
msgid ""
|
279 |
"Redirection not executed because not all files were successfully uploaded."
|
280 |
msgstr ""
|
281 |
|
282 |
-
#: lib/wfu_constants.php:
|
283 |
msgid "Test Mode"
|
284 |
msgstr ""
|
285 |
|
286 |
-
#: lib/wfu_constants.php:
|
|
|
|
|
|
|
|
|
287 |
msgid "Upload path: %filepath%"
|
288 |
msgstr ""
|
289 |
|
290 |
-
#: lib/wfu_constants.php:
|
291 |
msgid "Failed upload path: %filepath%"
|
292 |
msgstr ""
|
293 |
|
294 |
-
#: lib/wfu_constants.php:
|
|
|
|
|
|
|
|
|
295 |
msgid "This is a test message"
|
296 |
msgstr ""
|
297 |
|
298 |
-
#: lib/wfu_constants.php:
|
299 |
msgid "This is a test administrator message"
|
300 |
msgstr ""
|
301 |
|
302 |
-
#: lib/wfu_constants.php:
|
303 |
msgid "File testfile 1 under test"
|
304 |
msgstr ""
|
305 |
|
306 |
-
#: lib/wfu_constants.php:
|
307 |
msgid "File testfile 1 message"
|
308 |
msgstr ""
|
309 |
|
310 |
-
#: lib/wfu_constants.php:
|
311 |
msgid "File testfile 1 administrator message"
|
312 |
msgstr ""
|
313 |
|
314 |
-
#: lib/wfu_constants.php:
|
315 |
msgid "File testfile 2 under test"
|
316 |
msgstr ""
|
317 |
|
318 |
-
#: lib/wfu_constants.php:
|
319 |
msgid "File testfile 2 message"
|
320 |
msgstr ""
|
321 |
|
322 |
-
#: lib/wfu_constants.php:
|
323 |
msgid "File testfile 2 administrator message"
|
324 |
msgstr ""
|
325 |
|
326 |
-
#: lib/wfu_constants.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
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:
|
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:
|
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:
|
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:
|
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:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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:
|
364 |
msgid "Insert variable %n% inside text to denote a line change."
|
365 |
msgstr ""
|
366 |
|
367 |
-
#: lib/wfu_constants.php:
|
368 |
msgid "Upload in progress"
|
369 |
msgstr ""
|
370 |
|
371 |
-
#: lib/wfu_constants.php:
|
372 |
msgid "Upload in progress with warnings!"
|
373 |
msgstr ""
|
374 |
|
375 |
-
#: lib/wfu_constants.php:
|
376 |
msgid "Upload in progress but some files already failed!"
|
377 |
msgstr ""
|
378 |
|
379 |
-
#: lib/wfu_constants.php:
|
380 |
msgid "Upload in progress but no files uploaded so far!"
|
381 |
msgstr ""
|
382 |
|
383 |
-
#: lib/wfu_constants.php:
|
384 |
msgid "All files uploaded successfully"
|
385 |
msgstr ""
|
386 |
|
387 |
-
#: lib/wfu_constants.php:
|
388 |
msgid "All files uploaded successfully but there are warnings!"
|
389 |
msgstr ""
|
390 |
|
391 |
-
#: lib/wfu_constants.php:
|
392 |
msgid "File uploaded successfully but there are warnings!"
|
393 |
msgstr ""
|
394 |
|
395 |
-
#: lib/wfu_constants.php:
|
396 |
msgid "Some files failed to upload!"
|
397 |
msgstr ""
|
398 |
|
399 |
-
#: lib/wfu_constants.php:
|
400 |
msgid "All files failed to upload"
|
401 |
msgstr ""
|
402 |
|
403 |
-
#: lib/wfu_constants.php:
|
404 |
msgid "File failed to upload"
|
405 |
msgstr ""
|
406 |
|
407 |
-
#: lib/wfu_constants.php:
|
408 |
msgid "There are no files to upload!"
|
409 |
msgstr ""
|
410 |
|
411 |
-
#: lib/wfu_constants.php:
|
412 |
msgid "Test upload message"
|
413 |
msgstr ""
|
414 |
|
415 |
-
#: lib/wfu_constants.php:
|
416 |
msgid "JSON parse warning!"
|
417 |
msgstr ""
|
418 |
|
419 |
-
#: lib/wfu_constants.php:
|
420 |
msgid "please wait while redirecting..."
|
421 |
msgstr ""
|
2 |
msgstr ""
|
3 |
"Project-Id-Version: Wordpress File Upload\n"
|
4 |
"Report-Msgid-Bugs-To: \n"
|
5 |
+
"POT-Creation-Date: 2014-04-27 14:31+0200\n"
|
6 |
+
"PO-Revision-Date: 2014-04-27 14:31+0200\n"
|
7 |
+
"Last-Translator: nickboss <nickboss@iptanus.com>\n"
|
8 |
"Language-Team: Iptanus Team <info@iptanus.com>\n"
|
9 |
"Language: en\n"
|
10 |
"MIME-Version: 1.0\n"
|
56 |
msgid "File %filename% is being uploaded"
|
57 |
msgstr ""
|
58 |
|
59 |
+
#: lib/wfu_constants.php:52
|
60 |
msgid "Your message"
|
61 |
msgstr ""
|
62 |
|
63 |
+
#: lib/wfu_constants.php:57
|
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:58
|
70 |
msgid "Error. Invalid ftp information. Check 'ftpinfo' attribute."
|
71 |
msgstr ""
|
72 |
|
73 |
+
#: lib/wfu_constants.php:59
|
74 |
msgid ""
|
75 |
"Error. Could not extract ftp information from 'ftpinfo' attribute. Check its "
|
76 |
"syntax."
|
77 |
msgstr ""
|
78 |
|
79 |
+
#: lib/wfu_constants.php:60
|
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:61
|
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:62
|
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:63
|
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:64
|
106 |
msgid "Targer folder doesn't exist."
|
107 |
msgstr ""
|
108 |
|
109 |
+
#: lib/wfu_constants.php:65
|
110 |
msgid "Upload failed! Missing a temporary folder."
|
111 |
msgstr ""
|
112 |
|
113 |
+
#: lib/wfu_constants.php:66
|
114 |
msgid "Upload failed! Permission denied to write to target folder."
|
115 |
msgstr ""
|
116 |
|
117 |
+
#: lib/wfu_constants.php:67
|
118 |
msgid "File not allowed."
|
119 |
msgstr ""
|
120 |
|
121 |
+
#: lib/wfu_constants.php:68
|
122 |
msgid "The uploaded file exceeds the file size limit."
|
123 |
msgstr ""
|
124 |
|
125 |
+
#: lib/wfu_constants.php:69
|
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:70
|
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:71
|
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:72
|
144 |
msgid "Upload failed! The uploaded file was only partially uploaded."
|
145 |
msgstr ""
|
146 |
|
147 |
+
#: lib/wfu_constants.php:73
|
148 |
msgid "Upload failed! No file was uploaded."
|
149 |
msgstr ""
|
150 |
|
151 |
+
#: lib/wfu_constants.php:74
|
152 |
msgid "Upload failed! Failed to write file to disk."
|
153 |
msgstr ""
|
154 |
|
155 |
+
#: lib/wfu_constants.php:75
|
156 |
msgid ""
|
157 |
"Upload failed! Error occured while moving temporary file. Please contact "
|
158 |
"administrator."
|
159 |
msgstr ""
|
160 |
|
161 |
+
#: lib/wfu_constants.php:76
|
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:77
|
169 |
msgid "Upload failed! Error occured while attemting to upload the file."
|
170 |
msgstr ""
|
171 |
|
172 |
+
#: lib/wfu_constants.php:78
|
173 |
msgid "Upload failed!"
|
174 |
msgstr ""
|
175 |
|
176 |
+
#: lib/wfu_constants.php:79
|
177 |
msgid "No file!"
|
178 |
msgstr ""
|
179 |
|
180 |
+
#: lib/wfu_constants.php:80
|
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:81
|
187 |
msgid "Upload failed! Unknown error."
|
188 |
msgstr ""
|
189 |
|
190 |
+
#: lib/wfu_constants.php:82
|
191 |
msgid "Please contact the administrator."
|
192 |
msgstr ""
|
193 |
|
194 |
+
#: lib/wfu_constants.php:83
|
195 |
msgid "No result from remote server!"
|
196 |
msgstr ""
|
197 |
|
198 |
+
#: lib/wfu_constants.php:84
|
199 |
msgid " but with warnings"
|
200 |
msgstr ""
|
201 |
|
202 |
+
#: lib/wfu_constants.php:85 lib/wfu_constants.php:87
|
203 |
msgid "Warning: JSON parse error."
|
204 |
msgstr ""
|
205 |
|
206 |
+
#: lib/wfu_constants.php:86
|
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:88
|
213 |
msgid ""
|
214 |
"UploadStates, passed as JSON string to the handler, could not be parsed."
|
215 |
msgstr ""
|
216 |
|
217 |
+
#: lib/wfu_constants.php:89
|
218 |
msgid ""
|
219 |
"Redirection to classic form functionality occurred due to unknown error."
|
220 |
msgstr ""
|
221 |
|
222 |
+
#: lib/wfu_constants.php:90
|
223 |
msgid ""
|
224 |
"Redirection to classic form functionality occurred because AJAX is not "
|
225 |
"supported."
|
226 |
msgstr ""
|
227 |
|
228 |
+
#: lib/wfu_constants.php:91
|
229 |
msgid ""
|
230 |
"Redirection to classic form functionality occurred because HTML5 is not "
|
231 |
"supported."
|
232 |
msgstr ""
|
233 |
|
234 |
+
#: lib/wfu_constants.php:92
|
235 |
msgid ""
|
236 |
"Redirection to classic form functionality occurred due to JSON parse error."
|
237 |
msgstr ""
|
238 |
|
239 |
+
#: lib/wfu_constants.php:93
|
240 |
msgid "cannot be empty!"
|
241 |
msgstr ""
|
242 |
|
243 |
+
#: lib/wfu_constants.php:96
|
244 |
msgid "Upload skipped! File already exists."
|
245 |
msgstr ""
|
246 |
|
247 |
+
#: lib/wfu_constants.php:97
|
248 |
msgid "No files have been selected!"
|
249 |
msgstr ""
|
250 |
|
251 |
+
#: lib/wfu_constants.php:98
|
252 |
msgid "WPFilebase Plugin not updated because there were no files uploaded."
|
253 |
msgstr ""
|
254 |
|
255 |
+
#: lib/wfu_constants.php:99
|
256 |
msgid "Notification email was not sent because there were no files uploaded."
|
257 |
msgstr ""
|
258 |
|
259 |
+
#: lib/wfu_constants.php:100
|
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:101
|
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:102
|
272 |
msgid ""
|
273 |
"Redirection not executed because redirection link is empty. Please check "
|
274 |
"redirectlink attribute."
|
275 |
msgstr ""
|
276 |
|
277 |
+
#: lib/wfu_constants.php:103
|
278 |
msgid ""
|
279 |
"Redirection not executed because not all files were successfully uploaded."
|
280 |
msgstr ""
|
281 |
|
282 |
+
#: lib/wfu_constants.php:106
|
283 |
msgid "Test Mode"
|
284 |
msgstr ""
|
285 |
|
286 |
+
#: lib/wfu_constants.php:107
|
287 |
+
msgid "select dir..."
|
288 |
+
msgstr ""
|
289 |
+
|
290 |
+
#: lib/wfu_constants.php:108
|
291 |
msgid "Upload path: %filepath%"
|
292 |
msgstr ""
|
293 |
|
294 |
+
#: lib/wfu_constants.php:109
|
295 |
msgid "Failed upload path: %filepath%"
|
296 |
msgstr ""
|
297 |
|
298 |
+
#: lib/wfu_constants.php:110
|
299 |
+
msgid " (required)"
|
300 |
+
msgstr ""
|
301 |
+
|
302 |
+
#: lib/wfu_constants.php:113
|
303 |
msgid "This is a test message"
|
304 |
msgstr ""
|
305 |
|
306 |
+
#: lib/wfu_constants.php:114
|
307 |
msgid "This is a test administrator message"
|
308 |
msgstr ""
|
309 |
|
310 |
+
#: lib/wfu_constants.php:115
|
311 |
msgid "File testfile 1 under test"
|
312 |
msgstr ""
|
313 |
|
314 |
+
#: lib/wfu_constants.php:116
|
315 |
msgid "File testfile 1 message"
|
316 |
msgstr ""
|
317 |
|
318 |
+
#: lib/wfu_constants.php:117
|
319 |
msgid "File testfile 1 administrator message"
|
320 |
msgstr ""
|
321 |
|
322 |
+
#: lib/wfu_constants.php:118
|
323 |
msgid "File testfile 2 under test"
|
324 |
msgstr ""
|
325 |
|
326 |
+
#: lib/wfu_constants.php:119
|
327 |
msgid "File testfile 2 message"
|
328 |
msgstr ""
|
329 |
|
330 |
+
#: lib/wfu_constants.php:120
|
331 |
msgid "File testfile 2 administrator message"
|
332 |
msgstr ""
|
333 |
|
334 |
+
#: lib/wfu_constants.php:123
|
335 |
+
msgid ""
|
336 |
+
"Insert variable %userid% inside text. It will be replaced by the id of the "
|
337 |
+
"current user."
|
338 |
+
msgstr ""
|
339 |
+
|
340 |
+
#: lib/wfu_constants.php:124
|
341 |
msgid ""
|
342 |
"Insert variable %username% inside text. It will be replaced by the username "
|
343 |
"of the current user."
|
344 |
msgstr ""
|
345 |
|
346 |
+
#: lib/wfu_constants.php:125
|
347 |
msgid ""
|
348 |
"Insert variable %useremail% inside text. It will be replaced by the email of "
|
349 |
"the current user."
|
350 |
msgstr ""
|
351 |
|
352 |
+
#: lib/wfu_constants.php:126
|
353 |
msgid ""
|
354 |
"Insert variable %filename% inside text. It will be replaced by the filename "
|
355 |
"of the uploaded file."
|
356 |
msgstr ""
|
357 |
|
358 |
+
#: lib/wfu_constants.php:127
|
359 |
msgid ""
|
360 |
"Insert variable %filepath% inside text. It will be replaced by the full "
|
361 |
"filepath of the uploaded file."
|
362 |
msgstr ""
|
363 |
|
364 |
+
#: lib/wfu_constants.php:128
|
365 |
msgid ""
|
366 |
"Insert variable %blogid% inside text. It will be replaced by the blog id of "
|
367 |
"the website."
|
368 |
msgstr ""
|
369 |
|
370 |
+
#: lib/wfu_constants.php:129
|
371 |
+
msgid ""
|
372 |
+
"Insert variable %pageid% inside text. It will be replaced by the id of the "
|
373 |
+
"current page."
|
374 |
+
msgstr ""
|
375 |
+
|
376 |
+
#: lib/wfu_constants.php:130
|
377 |
+
msgid ""
|
378 |
+
"Insert variable %pagetitle% inside text. It will be replaced by the title of "
|
379 |
+
"the current page."
|
380 |
+
msgstr ""
|
381 |
+
|
382 |
+
#: lib/wfu_constants.php:131
|
383 |
msgid ""
|
384 |
"Insert variable %userdataXXX% inside text. Select the user field from the "
|
385 |
"drop-down list. It will be replaced by the value that the user entered in "
|
386 |
"this field."
|
387 |
msgstr ""
|
388 |
|
389 |
+
#: lib/wfu_constants.php:132
|
390 |
msgid "Insert variable %n% inside text to denote a line change."
|
391 |
msgstr ""
|
392 |
|
393 |
+
#: lib/wfu_constants.php:135
|
394 |
msgid "Upload in progress"
|
395 |
msgstr ""
|
396 |
|
397 |
+
#: lib/wfu_constants.php:136
|
398 |
msgid "Upload in progress with warnings!"
|
399 |
msgstr ""
|
400 |
|
401 |
+
#: lib/wfu_constants.php:137
|
402 |
msgid "Upload in progress but some files already failed!"
|
403 |
msgstr ""
|
404 |
|
405 |
+
#: lib/wfu_constants.php:138
|
406 |
msgid "Upload in progress but no files uploaded so far!"
|
407 |
msgstr ""
|
408 |
|
409 |
+
#: lib/wfu_constants.php:139
|
410 |
msgid "All files uploaded successfully"
|
411 |
msgstr ""
|
412 |
|
413 |
+
#: lib/wfu_constants.php:140
|
414 |
msgid "All files uploaded successfully but there are warnings!"
|
415 |
msgstr ""
|
416 |
|
417 |
+
#: lib/wfu_constants.php:141
|
418 |
msgid "File uploaded successfully but there are warnings!"
|
419 |
msgstr ""
|
420 |
|
421 |
+
#: lib/wfu_constants.php:142
|
422 |
msgid "Some files failed to upload!"
|
423 |
msgstr ""
|
424 |
|
425 |
+
#: lib/wfu_constants.php:143
|
426 |
msgid "All files failed to upload"
|
427 |
msgstr ""
|
428 |
|
429 |
+
#: lib/wfu_constants.php:144
|
430 |
msgid "File failed to upload"
|
431 |
msgstr ""
|
432 |
|
433 |
+
#: lib/wfu_constants.php:145
|
434 |
msgid "There are no files to upload!"
|
435 |
msgstr ""
|
436 |
|
437 |
+
#: lib/wfu_constants.php:146
|
438 |
msgid "Test upload message"
|
439 |
msgstr ""
|
440 |
|
441 |
+
#: lib/wfu_constants.php:147
|
442 |
msgid "JSON parse warning!"
|
443 |
msgstr ""
|
444 |
|
445 |
+
#: lib/wfu_constants.php:148
|
446 |
msgid "please wait while redirecting..."
|
447 |
msgstr ""
|
lib/wfu_admin.php
CHANGED
@@ -4,6 +4,65 @@ 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;
|
@@ -23,6 +82,9 @@ function wordpress_file_upload_manage_dashboard() {
|
|
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 |
}
|
@@ -58,6 +120,17 @@ function wordpress_file_upload_manage_dashboard() {
|
|
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 |
}
|
@@ -65,7 +138,7 @@ function wordpress_file_upload_manage_dashboard() {
|
|
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;
|
@@ -74,9 +147,16 @@ function wfu_manage_settings() {
|
|
74 |
|
75 |
$echo_str = '<div class="wfu_wrap">';
|
76 |
$echo_str .= "\n\t".'<h2>Wordpress File Upload Control Panel</h2>';
|
|
|
|
|
|
|
|
|
|
|
77 |
$echo_str .= "\n\t".'<div style="margin-top:10px;">';
|
78 |
if ( current_user_can( 'manage_options' ) ) $echo_str .= "\n\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser" class="button" title="File browser">File Browser</a>';
|
79 |
$echo_str .= "\n\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=shortcode_composer" class="button" title="Shortcode composer">Shortcode Composer</a>';
|
|
|
|
|
80 |
$echo_str .= "\n\t\t".'<h3 style="margin-bottom: 10px; margin-top: 40px;">Settings</h3>';
|
81 |
$echo_str .= "\n\t\t".'<form enctype="multipart/form-data" name="editsettings" id="editsettings" method="post" action="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=edit_settings" class="validate">';
|
82 |
$echo_str .= "\n\t\t\t".'<input type="hidden" name="action" value="edit_settings">';
|
@@ -84,6 +164,15 @@ function wfu_manage_settings() {
|
|
84 |
$echo_str .= "\n\t\t\t\t".'<tbody>';
|
85 |
$echo_str .= "\n\t\t\t\t\t".'<tr class="form-field">';
|
86 |
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
$echo_str .= "\n\t\t\t\t\t\t\t".'<label for="wfu_basedir">Base Directory</label>';
|
88 |
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
89 |
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
@@ -103,669 +192,27 @@ function wfu_manage_settings() {
|
|
103 |
echo $echo_str;
|
104 |
}
|
105 |
|
106 |
-
function wfu_shortcode_composer() {
|
107 |
-
global $wpdb;
|
108 |
-
global $wp_roles;
|
109 |
-
$siteurl = site_url();
|
110 |
-
|
111 |
-
$components = wfu_component_definitions();
|
112 |
-
|
113 |
-
$cats = wfu_category_definitions();
|
114 |
-
$defs = wfu_attribute_definitions();
|
115 |
-
|
116 |
-
$plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
|
117 |
-
$shortcode_attrs = wfu_shortcode_string_to_array($plugin_options['shortcode']);
|
118 |
-
foreach ( $defs as $key => $def ) {
|
119 |
-
$defs[$key]['default'] = $def['value'];
|
120 |
-
if ( array_key_exists($def['attribute'], $shortcode_attrs) ) {
|
121 |
-
$defs[$key]['value'] = $shortcode_attrs[$def['attribute']];
|
122 |
-
}
|
123 |
-
}
|
124 |
-
|
125 |
-
// index $components
|
126 |
-
$components_indexed = array();
|
127 |
-
foreach ( $components as $component ) $components_indexed[$component['id']] = $component;
|
128 |
-
// index dependiencies
|
129 |
-
$governors = array();
|
130 |
-
|
131 |
-
$echo_str = '<div id="wfu_wrapper" class="wrap">';
|
132 |
-
if ( current_user_can( 'manage_options' ) ) $echo_str .= "\n\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=manage_settings" class="button" title="go back">Go to Settings</a>';
|
133 |
-
$echo_str .= "\n\t".'<h2>Wordpress File Upload Shortcode Composer</h2>';
|
134 |
-
$echo_str .= "\n\t".'<div style="margin-top:10px;">';
|
135 |
-
$echo_str .= "\n\t\t".'<div class="wfu_shortcode_container">';
|
136 |
-
$echo_str .= "\n\t\t\t".'<span><strong>Generated Shortcode</strong></span>';
|
137 |
-
$echo_str .= "\n\t\t\t".'<span id="wfu_save_label" class="wfu_save_label">saved</span>';
|
138 |
-
$echo_str .= "\n\t\t\t".'<textarea id="wfu_shortcode" class="wfu_shortcode" rows="5">[wordpress_file_upload]</textarea>';
|
139 |
-
$echo_str .= "\n\t\t\t".'<div id="wfu_attribute_defaults" style="display:none;">';
|
140 |
-
foreach ( $defs as $def )
|
141 |
-
$echo_str .= "\n\t\t\t\t".'<input id="wfu_attribute_default_'.$def['attribute'].'" type="hidden" value="'.$def['default'].'" />';
|
142 |
-
$echo_str .= "\n\t\t\t".'</div>';
|
143 |
-
$echo_str .= "\n\t\t\t".'<div id="wfu_attribute_values" style="display:none;">';
|
144 |
-
foreach ( $defs as $def )
|
145 |
-
$echo_str .= "\n\t\t\t\t".'<input id="wfu_attribute_value_'.$def['attribute'].'" type="hidden" value="'.$def['value'].'" />';
|
146 |
-
$echo_str .= "\n\t\t\t".'</div>';
|
147 |
-
$echo_str .= "\n\t\t".'</div>';
|
148 |
-
$echo_str .= "\n\t".'</div>';
|
149 |
-
$echo_str .= "\n\t".'<h3 id="wfu_tab_container" class="nav-tab-wrapper">';
|
150 |
-
$is_first = true;
|
151 |
-
foreach ( $cats as $key => $cat ) {
|
152 |
-
$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>';
|
153 |
-
$is_first = false;
|
154 |
-
}
|
155 |
-
$echo_str .= "\n\t".'</h3>';
|
156 |
-
|
157 |
-
$prevcat = "";
|
158 |
-
$prevsubcat = "";
|
159 |
-
$is_first = true;
|
160 |
-
$block_open = false;
|
161 |
-
$subblock_open = false;
|
162 |
-
foreach ( $defs as $def ) {
|
163 |
-
$attr = $def['attribute'];
|
164 |
-
$subblock_active = false;
|
165 |
-
//detect if the dependencies of this attribute will be disabled or not
|
166 |
-
if ( ( $def['type'] == "onoff" && $def['value'] == "true" ) ||
|
167 |
-
( $def['type'] == "radio" && in_array("*".$def['value'], $def['listitems']) ) )
|
168 |
-
$subblock_active = true;
|
169 |
-
// assign dependencies if exist
|
170 |
-
if ( $def['dependencies'] != null )
|
171 |
-
foreach ( $def['dependencies'] as $dependency ) {
|
172 |
-
if ( substr($dependency, 0, 1) == "!" ) //invert state for this dependency if an exclamation mark is defined
|
173 |
-
$governors[substr($dependency, 1)] = array( 'attribute' => $attr, 'active' => !$subblock_active, 'inv' => '_inv' );
|
174 |
-
else
|
175 |
-
$governors[$dependency] = array( 'attribute' => $attr, 'active' => $subblock_active, 'inv' => '' );
|
176 |
-
}
|
177 |
-
//check if this attribute depends on other
|
178 |
-
if ( $governors[$attr] != "" ) $governor = $governors[$attr];
|
179 |
-
else $governor = array( 'attribute' => "independent", 'active' => true, 'inv' => '' );
|
180 |
-
|
181 |
-
//close previous blocks
|
182 |
-
if ( $def['parent'] == "" ) {
|
183 |
-
if ( $subblock_open ) {
|
184 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'</tbody>';
|
185 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</table>';
|
186 |
-
$subblock_open = false;
|
187 |
-
}
|
188 |
-
if ( $block_open ) {
|
189 |
-
$echo_str .= "\n\t\t\t\t\t".'</div></td>';
|
190 |
-
$echo_str .= "\n\t\t\t\t".'</tr>';
|
191 |
-
$block_open = false;
|
192 |
-
}
|
193 |
-
}
|
194 |
-
//check if new category must be generated
|
195 |
-
if ( $def['category'] != $prevcat ) {
|
196 |
-
if ( $prevcat != "" ) {
|
197 |
-
$echo_str .= "\n\t\t\t".'</tbody>';
|
198 |
-
$echo_str .= "\n\t\t".'</table>';
|
199 |
-
$echo_str .= "\n\t".'</div>';
|
200 |
-
}
|
201 |
-
$prevcat = $def['category'];
|
202 |
-
$prevsubcat = "";
|
203 |
-
$echo_str .= "\n\t".'<div id="wfu_container_'.$prevcat.'" class="wfu_container"'.( $is_first ? '' : ' style="display:none;"' ).'">';
|
204 |
-
$echo_str .= "\n\t\t".'<table class="form-table wfu_main_table">';
|
205 |
-
$echo_str .= "\n\t\t\t".'<thead><tr><th></th><td></td><td></td></tr></thead>';
|
206 |
-
$echo_str .= "\n\t\t\t".'<tbody>';
|
207 |
-
$is_first = false;
|
208 |
-
}
|
209 |
-
//check if new sub-category must be generated
|
210 |
-
if ( $def['subcategory'] != $prevsubcat ) {
|
211 |
-
$prevsubcat = $def['subcategory'];
|
212 |
-
$echo_str .= "\n\t\t\t\t".'<tr class="form-field wfu_subcategory">';
|
213 |
-
$echo_str .= "\n\t\t\t\t\t".'<th scope="row" colspan="3">';
|
214 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<h3 style="margin-bottom: 10px; margin-top: 10px;">'.$prevsubcat.'</h3>';
|
215 |
-
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
216 |
-
$echo_str .= "\n\t\t\t\t".'</tr>';
|
217 |
-
}
|
218 |
-
//draw attribute element
|
219 |
-
if ( $def['parent'] == "" ) {
|
220 |
-
$dlp = "\n\t\t\t\t";
|
221 |
-
}
|
222 |
-
else {
|
223 |
-
if ( !$subblock_open ) {
|
224 |
-
$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>';
|
225 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<table class="form-table wfu_inner_table" style="margin:0;">';
|
226 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<tbody>';
|
227 |
-
}
|
228 |
-
$dlp = "\n\t\t\t\t\t\t\t\t";
|
229 |
-
}
|
230 |
-
$echo_str .= $dlp.'<tr class="form-field">';
|
231 |
-
$echo_str .= $dlp."\t".'<th scope="row"><div class="wfu_td_div">';
|
232 |
-
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>';
|
233 |
-
$echo_str .= $dlp."\t\t".'<div class="wfu_restore_container" title="Double-click to restore defaults setting"><img src="'.WFU_IMAGE_ADMIN_RESTOREDEFAULT.'" ondblclick="wfu_apply_value(\''.$attr.'\', \''.$def['type'].'\', \''.$def['default'].'\');" ></div>';
|
234 |
-
$echo_str .= $dlp."\t\t".'<label for="wfu_attribute_'.$attr.'">'.$def['name'].'</label>';
|
235 |
-
$echo_str .= $dlp."\t\t".'<div class="wfu_help_container" title="'.$def['help'].'"><img src="'.WFU_IMAGE_ADMIN_HELP.'" ></div>';
|
236 |
-
$echo_str .= $dlp."\t".'</div></th>';
|
237 |
-
$echo_str .= $dlp."\t".'<td style="vertical-align:top;"><div class="wfu_td_div">';
|
238 |
-
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>';
|
239 |
-
if ( $def['type'] == "onoff" ) {
|
240 |
-
$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.'\');">';
|
241 |
-
$echo_str .= $dlp."\t\t\t".'<div class="wfu_onoff_slider"></div>';
|
242 |
-
$echo_str .= $dlp."\t\t\t".'<span class="wfu_onoff_text">ON</span>';
|
243 |
-
$echo_str .= $dlp."\t\t\t".'<span class="wfu_onoff_text">OFF</span>';
|
244 |
-
$echo_str .= $dlp."\t\t".'</div>';
|
245 |
-
}
|
246 |
-
elseif ( $def['type'] == "text" ) {
|
247 |
-
$echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" value="'.$def['value'].'" />';
|
248 |
-
if ( $def['variables'] != null ) $echo_str .= wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
|
249 |
-
}
|
250 |
-
elseif ( $def['type'] == "placements" ) {
|
251 |
-
$components_used = array();
|
252 |
-
foreach ( $components as $component ) $components_used[$component['id']] = false;
|
253 |
-
$centered_content = '<div style="display:table; width:100%; height:100%;"><div style="display:table-cell; text-align:center; vertical-align:middle;">XXX</div></div>';
|
254 |
-
$echo_str .= $dlp."\t\t".'<div class="wfu_placements_wrapper">';
|
255 |
-
$echo_str .= $dlp."\t\t\t".'<div id="wfu_placements_container" class="wfu_placements_container">';
|
256 |
-
$itemplaces = explode("/", $def['value']);
|
257 |
-
foreach ( $itemplaces as $section ) {
|
258 |
-
$echo_str .= $dlp."\t\t\t\t".'<div class="wfu_component_separator_hor"></div>';
|
259 |
-
$echo_str .= $dlp."\t\t\t\t".'<div class="wfu_component_separator_ver"></div>';
|
260 |
-
$items_in_section = explode("+", trim($section));
|
261 |
-
$section_array = array( );
|
262 |
-
foreach ( $items_in_section as $item_in_section ) {
|
263 |
-
if ( key_exists($item_in_section, $components_indexed) ) {
|
264 |
-
$components_used[$item_in_section] = true;
|
265 |
-
$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>';
|
266 |
-
$echo_str .= $dlp."\t\t\t\t".'<div class="wfu_component_separator_ver"></div>';
|
267 |
-
}
|
268 |
-
}
|
269 |
-
}
|
270 |
-
$echo_str .= $dlp."\t\t\t\t".'<div class="wfu_component_separator_hor"></div>';
|
271 |
-
$echo_str .= $dlp."\t\t\t\t".'<div id="wfu_component_bar_hor" class="wfu_component_bar_hor"></div>';
|
272 |
-
$echo_str .= $dlp."\t\t\t\t".'<div id="wfu_component_bar_ver" class="wfu_component_bar_ver"></div>';
|
273 |
-
$echo_str .= $dlp."\t\t\t".'</div>';
|
274 |
-
$echo_str .= $dlp."\t\t\t".'<div id="wfu_componentlist_container" class="wfu_componentlist_container">';
|
275 |
-
$echo_str .= $dlp."\t\t\t\t".'<div id="wfu_componentlist_dragdrop" class="wfu_componentlist_dragdrop" style="display:none;"></div>';
|
276 |
-
$ii = 1;
|
277 |
-
foreach ( $components as $component ) {
|
278 |
-
$echo_str .= $dlp."\t\t\t\t".'<div id="wfu_component_box_container_'.$component['id'].'" class="wfu_component_box_container">';
|
279 |
-
$echo_str .= $dlp."\t\t\t\t\t".'<div class="wfu_component_box_base">'.str_replace("XXX", $component['name'], $centered_content).'</div>';
|
280 |
-
if ( !$components_used[$component['id']] )
|
281 |
-
$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>';
|
282 |
-
$echo_str .= $dlp."\t\t\t\t".'</div>'.( ($ii++) % 3 == 0 ? '<br />' : '' );
|
283 |
-
}
|
284 |
-
$echo_str .= $dlp."\t\t\t".'</div>';
|
285 |
-
$echo_str .= $dlp."\t\t".'</div>';
|
286 |
-
}
|
287 |
-
elseif ( $def['type'] == "ltext" ) {
|
288 |
-
$echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" class="wfu_long_text" value="'.$def['value'].'" />';
|
289 |
-
if ( $def['variables'] != null ) $echo_str .= wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
|
290 |
-
}
|
291 |
-
elseif ( $def['type'] == "integer" ) {
|
292 |
-
$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'].'" />';
|
293 |
-
}
|
294 |
-
elseif ( $def['type'] == "float" ) {
|
295 |
-
$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'].'" />';
|
296 |
-
}
|
297 |
-
elseif ( $def['type'] == "radio" ) {
|
298 |
-
$echo_str .= $dlp."\t\t";
|
299 |
-
$ii = 0;
|
300 |
-
foreach ( $def['listitems'] as $item )
|
301 |
-
$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 );
|
302 |
-
// $echo_str .= '<input type="button" class="button" value="empty" style="width:auto; margin:-2px 0px 0px 8px;" />';
|
303 |
-
}
|
304 |
-
elseif ( $def['type'] == "ptext" ) {
|
305 |
-
$parts = explode("/", $def['value']);
|
306 |
-
$singular = $parts[0];
|
307 |
-
if ( count($parts) < 2 ) $plural = $singular;
|
308 |
-
else $plural = $parts[1];
|
309 |
-
$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.'" />';
|
310 |
-
if ( $def['variables'] != null ) if ( count($def['variables']) > 0 ) $echo_str .= $dlp."\t\t".'<br /><span class="wfu_ptext_span"> </span>';
|
311 |
-
if ( $def['variables'] != null ) $echo_str .= wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_s_'.$attr);
|
312 |
-
$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.'" />';
|
313 |
-
if ( $def['variables'] != null ) if ( count($def['variables']) > 0 ) $echo_str .= $dlp."\t\t".'<br /><span class="wfu_ptext_span"> </span>';
|
314 |
-
if ( $def['variables'] != null ) $echo_str .= wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_p_'.$attr);
|
315 |
-
}
|
316 |
-
elseif ( $def['type'] == "mtext" ) {
|
317 |
-
$val = str_replace("%n%", "\n", $def['value']);
|
318 |
-
$echo_str .= $dlp."\t\t".'<textarea id="wfu_attribute_'.$attr.'" name="wfu_text_elements" rows="5">'.$val.'</textarea>';
|
319 |
-
if ( $def['variables'] != null ) $echo_str .= wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
|
320 |
-
}
|
321 |
-
elseif ( $def['type'] == "rolelist" ) {
|
322 |
-
$roles = $wp_roles->get_names();
|
323 |
-
$def['value'] = strtolower($def['value']);
|
324 |
-
if ( $def['value'] == "all" ) $selected = array("administrator");
|
325 |
-
else $selected = explode(",", $def['value']);
|
326 |
-
foreach ( $selected as $key => $item ) $selected[$key] = trim($item);
|
327 |
-
$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"' : '' ).'>';
|
328 |
-
foreach ( $roles as $roleid => $rolename )
|
329 |
-
$echo_str .= $dlp."\t\t\t".'<option value="'.$roleid.'"'.( in_array($roleid, $selected) ? ' selected="selected"' : '' ).'>'.$rolename.'</option>';
|
330 |
-
$echo_str .= $dlp."\t\t".'</select>';
|
331 |
-
$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>';
|
332 |
-
}
|
333 |
-
elseif ( $def['type'] == "dimensions" ) {
|
334 |
-
$vals_arr = explode(",", $def['value']);
|
335 |
-
$vals = array();
|
336 |
-
foreach ( $vals_arr as $val_raw ) {
|
337 |
-
list($val_id, $val) = explode(":", $val_raw);
|
338 |
-
$vals[trim($val_id)] = trim($val);
|
339 |
-
}
|
340 |
-
$dims = array();
|
341 |
-
foreach ( $components as $comp ) {
|
342 |
-
if ( $comp['dimensions'] == null ) $dims[$comp['id']] = $comp['name'];
|
343 |
-
else foreach ( $comp['dimensions'] as $dimraw ) {
|
344 |
-
list($dim_id, $dim_name) = explode("/", $dimraw);
|
345 |
-
$dims[$dim_id] = $dim_name;
|
346 |
-
}
|
347 |
-
}
|
348 |
-
foreach ( $dims as $dim_id => $dim_name ) {
|
349 |
-
$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 />';
|
350 |
-
}
|
351 |
-
}
|
352 |
-
elseif ( $def['type'] == "userfields" ) {
|
353 |
-
$fields_arr = explode("/", $def['value']);
|
354 |
-
$fields = array();
|
355 |
-
foreach ( $fields_arr as $field_raw ) {
|
356 |
-
$is_req = ( substr($field_raw, 0, 1) == "*" );
|
357 |
-
if ( $is_req ) $field_raw = substr($field_raw, 1);
|
358 |
-
if ( $field_raw != "" ) array_push($fields, array( "name" => $field_raw, "required" => $is_req ));
|
359 |
-
}
|
360 |
-
if ( count($fields) == 0 ) array_push($fields, array( "name" => "", "required" => false ));
|
361 |
-
$echo_str .= $dlp."\t\t".'<div id="wfu_attribute_'.$attr.'" class="wfu_userdata_container">';
|
362 |
-
foreach ( $fields as $field ) {
|
363 |
-
$echo_str .= $dlp."\t\t\t".'<div class="wfu_userdata_line">';
|
364 |
-
$echo_str .= $dlp."\t\t\t\t".'<input type="text" name="wfu_userfield_elements" value="'.$field['name'].'" />';
|
365 |
-
$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>';
|
366 |
-
$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>';
|
367 |
-
$echo_str .= $dlp."\t\t\t\t".'<input type="checkbox"'.( $field['required'] ? 'checked="checked"' : '' ).' onchange="wfu_update_userfield_value({target:this});" />';
|
368 |
-
$echo_str .= $dlp."\t\t\t\t".'<span>Required</span>';
|
369 |
-
$echo_str .= $dlp."\t\t\t".'</div>';
|
370 |
-
}
|
371 |
-
$echo_str .= $dlp."\t\t".'</div>';
|
372 |
-
}
|
373 |
-
elseif ( $def['type'] == "color" ) {
|
374 |
-
$echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" class="wfu_color_field" value="'.$def['value'].'" />';
|
375 |
-
}
|
376 |
-
elseif ( $def['type'] == "color-triplet" ) {
|
377 |
-
$triplet = explode(",", $def['value']);
|
378 |
-
foreach ( $triplet as $key => $item ) $triplet[$key] = trim($item);
|
379 |
-
if ( count($triplet) == 2 ) $triplet = array( $triplet[0], $triplet[1], "#000000");
|
380 |
-
elseif ( count($triplet) == 1 ) $triplet = array( $triplet[0], "#FFFFFF", "#000000");
|
381 |
-
elseif ( count($triplet) < 3 ) $triplet = array( "#000000", "#FFFFFF", "#000000");
|
382 |
-
$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>';
|
383 |
-
$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>';
|
384 |
-
$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>';
|
385 |
-
}
|
386 |
-
else {
|
387 |
-
$echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" value="'.$def['value'].'" />';
|
388 |
-
if ( $def['variables'] != null ) $echo_str .= wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
|
389 |
-
}
|
390 |
-
$echo_str .= $dlp."\t".'</div></td>';
|
391 |
-
if ( $def['parent'] == "" ) {
|
392 |
-
$echo_str .= $dlp."\t".'<td style="position:relative; vertical-align:top; padding:0;"><div class="wfu_td_div">';
|
393 |
-
$block_open = false;
|
394 |
-
}
|
395 |
-
else {
|
396 |
-
$echo_str .= $dlp.'</tr>';
|
397 |
-
$subblock_open = true;
|
398 |
-
}
|
399 |
-
}
|
400 |
-
if ( $subblock_open ) {
|
401 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</div>';
|
402 |
-
}
|
403 |
-
if ( $block_open ) {
|
404 |
-
$echo_str .= "\n\t\t\t\t\t".'</div></td>';
|
405 |
-
$echo_str .= "\n\t\t\t\t".'</tr>';
|
406 |
-
}
|
407 |
-
$echo_str .= "\n\t\t\t".'</tbody>';
|
408 |
-
$echo_str .= "\n\t\t".'</table>';
|
409 |
-
$handler = 'function() { wfu_Attach_Admin_Events(); }';
|
410 |
-
$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>';
|
411 |
-
$echo_str .= "\n".'</div>';
|
412 |
-
// $echo_str .= "\n\t".'<div style="margin-top:10px;">';
|
413 |
-
// $echo_str .= "\n\t\t".'<label>Final shortcode text</label>';
|
414 |
-
// $echo_str .= "\n\t".'</div>';
|
415 |
-
|
416 |
-
echo $echo_str;
|
417 |
-
}
|
418 |
-
|
419 |
-
function wfu_insert_variables($variables, $class) {
|
420 |
-
$ret = "";
|
421 |
-
foreach ( $variables as $variable )
|
422 |
-
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>';
|
423 |
-
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>';
|
424 |
-
return $ret;
|
425 |
-
}
|
426 |
-
|
427 |
function wfu_update_settings() {
|
428 |
if ( !current_user_can( 'manage_options' ) ) return;
|
429 |
$plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
|
430 |
$new_plugin_options = array();
|
431 |
|
432 |
// $enabled = ( isset($_POST['wfu_enabled']) ? ( $_POST['wfu_enabled'] == "on" ? 1 : 0 ) : 0 );
|
|
|
433 |
if ( isset($_POST['wfu_basedir']) && isset($_POST['submit']) ) {
|
434 |
if ( $_POST['submit'] == "Update" ) {
|
435 |
$new_plugin_options['version'] = '1.0';
|
436 |
$new_plugin_options['shortcode'] = $plugin_options['shortcode'];
|
|
|
437 |
$new_plugin_options['basedir'] = $_POST['wfu_basedir'];
|
438 |
$encoded_options = wfu_encode_plugin_options($new_plugin_options);
|
439 |
update_option( "wordpress_file_upload_options", $encoded_options );
|
|
|
|
|
440 |
}
|
441 |
}
|
442 |
|
443 |
return true;
|
444 |
}
|
445 |
|
446 |
-
function wfu_browse_files($basedir) {
|
447 |
-
if ( !current_user_can( 'manage_options' ) ) return;
|
448 |
-
$siteurl = site_url();
|
449 |
-
//first decode basedir
|
450 |
-
$basedir = wfu_plugin_decode_string($basedir);
|
451 |
-
//then extract sort info from basedir
|
452 |
-
$ret = wfu_extract_sortdata_from_path($basedir);
|
453 |
-
$basedir = $ret['path'];
|
454 |
-
$sort = $ret['sort'];
|
455 |
-
if ( $sort == "" ) $sort = 'name';
|
456 |
-
if ( substr($sort, 0, 1) == '-' ) $order = SORT_DESC;
|
457 |
-
else $order = SORT_ASC;
|
458 |
-
|
459 |
-
//adjust basedir to have a standard format
|
460 |
-
if ( $basedir != "" ) {
|
461 |
-
if ( substr($basedir, -1) != '/' ) $basedir .= '/';
|
462 |
-
if ( !file_exists($basedir) ) $basedir = "";
|
463 |
-
}
|
464 |
-
//set basedit to default value if empty
|
465 |
-
if ( $basedir == "" ) {
|
466 |
-
$plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
|
467 |
-
$basedir = $plugin_options['basedir'];
|
468 |
-
$temp_params = array( 'uploadpath' => $basedir, 'accessmethod' => 'normal', 'ftpinfo' => '', 'useftpdomain' => 'false' );
|
469 |
-
$basedir = wfu_upload_plugin_full_path($temp_params);
|
470 |
-
}
|
471 |
-
//find relative dir
|
472 |
-
$reldir = str_replace(ABSPATH, "root/", $basedir);
|
473 |
-
//save dir route to an array
|
474 |
-
$parts = explode('/', $reldir);
|
475 |
-
$route = array();
|
476 |
-
$prev = "";
|
477 |
-
foreach ( $parts as $part ) {
|
478 |
-
$part = trim($part);
|
479 |
-
if ( $part != "" ) {
|
480 |
-
if ( $part == 'root' && $prev == "" ) $prev = ABSPATH;
|
481 |
-
else $prev .= $part.'/';
|
482 |
-
array_push($route, array( 'item' => $part, 'path' => $prev ));
|
483 |
-
}
|
484 |
-
}
|
485 |
-
//calculate upper directory
|
486 |
-
$updir = substr($basedir, 0, -1);
|
487 |
-
$delim_pos = strrpos($updir, '/');
|
488 |
-
if ( $delim_pos !== false ) $updir = substr($updir, 0, $delim_pos + 1);
|
489 |
-
|
490 |
-
$echo_str = "\n".'<div class="wrap">';
|
491 |
-
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
492 |
-
$echo_str .= "\n\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=manage_settings" class="button" title="go back">Go to Settings</a>';
|
493 |
-
$echo_str .= "\n\t".'</div>';
|
494 |
-
$echo_str .= "\n\t".'<h2 style="margin-bottom: 10px;">File Browser</h2>';
|
495 |
-
$echo_str .= "\n\t".'<div>';
|
496 |
-
$echo_str .= "\n\t\t".'<span><strong>Location:</strong> </span>';
|
497 |
-
foreach ( $route as $item ) {
|
498 |
-
$echo_str .= '<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.wfu_plugin_encode_string($item['path']).'">'.$item['item'].'</a>';
|
499 |
-
$echo_str .= '<span>/</span>';
|
500 |
-
}
|
501 |
-
$echo_str .= "\n\t".'</div>';
|
502 |
-
$echo_str .= "\n\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=create_dir&dir='.wfu_plugin_encode_string($basedir.'[['.$sort.']]').'" class="button" title="create folder" style="margin-top:6px">Create folder</a>';
|
503 |
-
$echo_str .= "\n\t".'<div style="margin-top:10px;">';
|
504 |
-
$echo_str .= "\n\t\t".'<table class="widefat">';
|
505 |
-
$echo_str .= "\n\t\t\t".'<thead>';
|
506 |
-
$echo_str .= "\n\t\t\t\t".'<tr>';
|
507 |
-
$echo_str .= "\n\t\t\t\t\t".'<th scope="col">';
|
508 |
-
$enc_dir = wfu_plugin_encode_string($basedir.'[['.( substr($sort, -4) == 'name' ? ( $order == SORT_ASC ? '-name' : 'name' ) : 'name' ).']]');
|
509 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$enc_dir.'">Name'.( substr($sort, -4) == 'name' ? ( $order == SORT_ASC ? ' ↑' : ' ↓' ) : '' ).'</a>';
|
510 |
-
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
511 |
-
$echo_str .= "\n\t\t\t\t\t".'<th scope="col">';
|
512 |
-
$enc_dir = wfu_plugin_encode_string($basedir.'[['.( substr($sort, -4) == 'size' ? ( $order == SORT_ASC ? '-size' : 'size' ) : 'size' ).']]');
|
513 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$enc_dir.'">Size'.( substr($sort, -4) == 'size' ? ( $order == SORT_ASC ? ' ↑' : ' ↓' ) : '' ).'</a>';
|
514 |
-
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
515 |
-
$echo_str .= "\n\t\t\t\t\t".'<th scope="col">';
|
516 |
-
$enc_dir = wfu_plugin_encode_string($basedir.'[['.( substr($sort, -4) == 'date' ? ( $order == SORT_ASC ? '-date' : 'date' ) : 'date' ).']]');
|
517 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$enc_dir.'">Date'.( substr($sort, -4) == 'date' ? ( $order == SORT_ASC ? ' ↑' : ' ↓' ) : '' ).'</a>';
|
518 |
-
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
519 |
-
$echo_str .= "\n\t\t\t\t".'</tr>';
|
520 |
-
$echo_str .= "\n\t\t\t".'</thead>';
|
521 |
-
$echo_str .= "\n\t\t\t".'<tbody>';
|
522 |
-
|
523 |
-
$dirlist = array();
|
524 |
-
$filelist = array();
|
525 |
-
if ( $handle = opendir($basedir) ) {
|
526 |
-
$blacklist = array('.', '..');
|
527 |
-
while ( false !== ($file = readdir($handle)) )
|
528 |
-
if ( !in_array($file, $blacklist) ) {
|
529 |
-
$filepath = $basedir.$file;
|
530 |
-
$stat = stat($filepath);
|
531 |
-
if ( is_dir($filepath) ) {
|
532 |
-
array_push($dirlist, array( 'name' => $file, 'fullpath' => $filepath, 'mdate' => $stat['mtime'] ));
|
533 |
-
}
|
534 |
-
else {
|
535 |
-
array_push($filelist, array( 'name' => $file, 'fullpath' => $filepath, 'size' => $stat['size'], 'mdate' => $stat['mtime'] ));
|
536 |
-
}
|
537 |
-
}
|
538 |
-
closedir($handle);
|
539 |
-
}
|
540 |
-
$dirsort = ( substr($sort, -4) == 'date' ? 'mdate' : substr($sort, -4) );
|
541 |
-
$filesort = $dirsort;
|
542 |
-
$dirorder = $order;
|
543 |
-
if ( $dirsort == 'size' ) { $dirsort = 'name'; $dirorder = SORT_ASC; }
|
544 |
-
$dirlist = wfu_array_sort($dirlist, $dirsort, $dirorder);
|
545 |
-
$filelist = wfu_array_sort($filelist, $filesort, $order);
|
546 |
-
|
547 |
-
if ( $reldir != "root/" ) {
|
548 |
-
$enc_dir = wfu_plugin_encode_string($updir);
|
549 |
-
$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\';}">';
|
550 |
-
$echo_str .= "\n\t\t\t\t\t".'<td style="padding: 5px 5px 5px 10px;">';
|
551 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<a class="row-title" href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$enc_dir.'" title="go up">..</a>';
|
552 |
-
$echo_str .= "\n\t\t\t\t\t".'</td>';
|
553 |
-
$echo_str .= "\n\t\t\t\t\t".'<td style="padding: 5px 5px 5px 10px;"> </td>';
|
554 |
-
$echo_str .= "\n\t\t\t\t\t".'<td style="padding: 5px 5px 5px 10px;"> </td>';
|
555 |
-
$echo_str .= "\n\t\t\t\t".'</tr>';
|
556 |
-
}
|
557 |
-
$ii = 1;
|
558 |
-
foreach ( $dirlist as $dir ) {
|
559 |
-
$enc_dir = wfu_plugin_encode_string($dir['fullpath'].'[['.$sort.']]');
|
560 |
-
$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\';}">';
|
561 |
-
$echo_str .= "\n\t\t\t\t\t".'<td style="padding: 5px 5px 5px 10px;">';
|
562 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<a class="row-title" href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$enc_dir.'" title="'.$dir['name'].'">'.$dir['name'].'</a>';
|
563 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<div id="wfu_dir_actions_'.$ii.'" name="wfu_dir_actions" style="visibility:hidden;">';
|
564 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<span>';
|
565 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=rename_dir&file='.$enc_dir.'" title="Rename this folder">Rename</a>';
|
566 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".' | ';
|
567 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'</span>';
|
568 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<span>';
|
569 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=delete_dir&file='.$enc_dir.'" title="Delete this folder">Delete</a>';
|
570 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'</span>';
|
571 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</div>';
|
572 |
-
$echo_str .= "\n\t\t\t\t\t".'</td>';
|
573 |
-
$echo_str .= "\n\t\t\t\t\t".'<td style="padding: 5px 5px 5px 10px;"> </td>';
|
574 |
-
$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>';
|
575 |
-
$echo_str .= "\n\t\t\t\t".'</tr>';
|
576 |
-
$ii ++;
|
577 |
-
}
|
578 |
-
foreach ( $filelist as $file ) {
|
579 |
-
$enc_file = wfu_plugin_encode_string($file['fullpath'].'[['.$sort.']]');
|
580 |
-
$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\';}">';
|
581 |
-
$echo_str .= "\n\t\t\t\t\t".'<td style="padding: 5px 5px 5px 10px;">';
|
582 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<span>'.$file['name'].'</span>';
|
583 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<div id="wfu_file_actions_'.$ii.'" name="wfu_file_actions" style="visibility:hidden;">';
|
584 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<span>';
|
585 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=rename_file&file='.$enc_file.'" title="Rename this file">Rename</a>';
|
586 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".' | ';
|
587 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'</span>';
|
588 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<span>';
|
589 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=delete_file&file='.$enc_file.'" title="Delete this file">Delete</a>';
|
590 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'</span>';
|
591 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</div>';
|
592 |
-
$echo_str .= "\n\t\t\t\t\t".'</td>';
|
593 |
-
$echo_str .= "\n\t\t\t\t\t".'<td style="padding: 5px 5px 5px 10px;">'.$file['size'].'</td>';
|
594 |
-
$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>';
|
595 |
-
$echo_str .= "\n\t\t\t\t".'</tr>';
|
596 |
-
$ii ++;
|
597 |
-
}
|
598 |
-
$echo_str .= "\n\t\t\t".'</tbody>';
|
599 |
-
$echo_str .= "\n\t\t".'</table>';
|
600 |
-
$echo_str .= "\n\t".'</div>';
|
601 |
-
$echo_str .= "\n".'</div>';
|
602 |
-
|
603 |
-
return $echo_str;
|
604 |
-
}
|
605 |
-
|
606 |
-
function wfu_rename_file_prompt($file, $type, $error) {
|
607 |
-
if ( !current_user_can( 'manage_options' ) ) return;
|
608 |
-
$siteurl = site_url();
|
609 |
-
$dec_file = wfu_plugin_decode_string($file);
|
610 |
-
//first extract sort info from dec_file
|
611 |
-
$ret = wfu_extract_sortdata_from_path($dec_file);
|
612 |
-
$dec_file = $ret['path'];
|
613 |
-
if ( $type == 'dir' && substr($dec_file, -1) == '/' ) $dec_file = substr($dec_file, 0, -1);
|
614 |
-
$parts = pathinfo($dec_file);
|
615 |
-
$newname = $parts['basename'];
|
616 |
-
$enc_dir = wfu_plugin_encode_string($parts['dirname'].'[['.$ret['sort'].']]');
|
617 |
-
|
618 |
-
$echo_str = "\n".'<div class="wrap">';
|
619 |
-
if ( $error ) {
|
620 |
-
$newname = $_SESSION['wfu_rename_file']['newname'];
|
621 |
-
$echo_str .= "\n\t".'<div class="error">';
|
622 |
-
$echo_str .= "\n\t\t".'<p>'.$_SESSION['wfu_rename_file_error'].'</p>';
|
623 |
-
$echo_str .= "\n\t".'</div>';
|
624 |
-
}
|
625 |
-
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
626 |
-
$echo_str .= "\n\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$enc_dir.'" class="button" title="go back">Go back</a>';
|
627 |
-
$echo_str .= "\n\t".'</div>';
|
628 |
-
$echo_str .= "\n\t".'<h2 style="margin-bottom: 10px;">Rename '.( $type == 'dir' ? 'Folder' : 'File' ).'</h2>';
|
629 |
-
$echo_str .= "\n\t".'<form enctype="multipart/form-data" name="renamefile" id="renamefile" method="post" action="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload" class="validate">';
|
630 |
-
$echo_str .= "\n\t\t".'<input type="hidden" name="action" value="rename'.( $type == 'dir' ? 'dir' : 'file' ).'">';
|
631 |
-
$echo_str .= "\n\t\t".'<input type="hidden" name="dir" value="'.$enc_dir.'">';
|
632 |
-
$echo_str .= "\n\t\t".'<input type="hidden" name="file" value="'.$file.'">';
|
633 |
-
if ( $type == 'dir' ) $echo_str .= "\n\t\t".'<label>Enter new name for folder <strong>'.$dec_file.'</strong></label><br/>';
|
634 |
-
else $echo_str .= "\n\t\t".'<label>Enter new filename for file <strong>'.$dec_file.'</strong></label><br/>';
|
635 |
-
$echo_str .= "\n\t\t".'<input name="wfu_newname" id="wfu_newname" type="text" value="'.$newname.'" style="width:50%;" />';
|
636 |
-
$echo_str .= "\n\t\t".'<p class="submit">';
|
637 |
-
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Rename">';
|
638 |
-
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Cancel">';
|
639 |
-
$echo_str .= "\n\t\t".'</p>';
|
640 |
-
$echo_str .= "\n\t".'</form>';
|
641 |
-
$echo_str .= "\n".'</div>';
|
642 |
-
return $echo_str;
|
643 |
-
}
|
644 |
-
|
645 |
-
function wfu_rename_file($file, $type) {
|
646 |
-
if ( !current_user_can( 'manage_options' ) ) return;
|
647 |
-
$dec_file = wfu_plugin_decode_string($file);
|
648 |
-
$dec_file = wfu_flatten_path($dec_file);
|
649 |
-
if ( $type == 'dir' && substr($dec_file, -1) == '/' ) $dec_file = substr($dec_file, 0, -1);
|
650 |
-
if ( !file_exists($dec_file) ) return wfu_browse_files();
|
651 |
-
$parts = pathinfo($dec_file);
|
652 |
-
$error = "";
|
653 |
-
if ( isset($_POST['wfu_newname']) && isset($_POST['submit']) ) {
|
654 |
-
if ( $_POST['submit'] == "Rename" && $_POST['wfu_newname'] != $parts['basename'] ) {
|
655 |
-
$new_file = $parts['dirname'].'/'.$_POST['wfu_newname'];
|
656 |
-
if ( $_POST['wfu_newname'] == "" ) $error = 'Error: New '.( $type == 'dir' ? 'folder ' : 'file' ).'name cannot be empty!';
|
657 |
-
elseif ( preg_match("/[^A-Za-z0-9.#\-$]/", $_POST['wfu_newname']) ) $error = 'Error: name contains invalid characters! Please correct.';
|
658 |
-
elseif ( file_exists($new_file) ) $error = 'Error: The '.( $type == 'dir' ? 'folder' : 'file' ).' <strong>'.$_POST['wfu_newname'].'</strong> already exists! Please choose another one.';
|
659 |
-
elseif ( rename($dec_file, $new_file) == false ) $error = 'Error: Rename of '.( $type == 'dir' ? 'folder' : 'file' ).' <strong>'.$parts['basename'].'</strong> failed!';
|
660 |
-
}
|
661 |
-
}
|
662 |
-
if ( $error != "" ) {
|
663 |
-
$_SESSION['wfu_rename_file_error'] = $error;
|
664 |
-
$_SESSION['wfu_rename_file']['newname'] = $_POST['wfu_newname'];
|
665 |
-
}
|
666 |
-
return ( $error == "" );
|
667 |
-
}
|
668 |
-
|
669 |
-
function wfu_delete_file_prompt($file, $type) {
|
670 |
-
if ( !current_user_can( 'manage_options' ) ) return;
|
671 |
-
$siteurl = site_url();
|
672 |
-
$dec_file = wfu_plugin_decode_string($file);
|
673 |
-
//first extract sort info from dec_file
|
674 |
-
$ret = wfu_extract_sortdata_from_path($dec_file);
|
675 |
-
$dec_file = $ret['path'];
|
676 |
-
if ( $type == 'dir' && substr($dec_file, -1) == '/' ) $dec_file = substr($dec_file, 0, -1);
|
677 |
-
$parts = pathinfo($dec_file);
|
678 |
-
$enc_dir = wfu_plugin_encode_string($parts['dirname'].'[['.$ret['sort'].']]');
|
679 |
-
|
680 |
-
$echo_str = "\n".'<div class="wrap">';
|
681 |
-
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
682 |
-
$echo_str .= "\n\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$enc_dir.'" class="button" title="go back">Go back</a>';
|
683 |
-
$echo_str .= "\n\t".'</div>';
|
684 |
-
$echo_str .= "\n\t".'<h2 style="margin-bottom: 10px;">Delete '.( $type == 'dir' ? 'Folder' : 'File' ).'</h2>';
|
685 |
-
$echo_str .= "\n\t".'<form enctype="multipart/form-data" name="deletefile" id="deletefile" method="post" action="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload" class="validate">';
|
686 |
-
$echo_str .= "\n\t\t".'<input type="hidden" name="action" value="delete'.( $type == 'dir' ? 'dir' : 'file' ).'">';
|
687 |
-
$echo_str .= "\n\t\t".'<input type="hidden" name="dir" value="'.$enc_dir.'">';
|
688 |
-
$echo_str .= "\n\t\t".'<input type="hidden" name="file" value="'.$file.'">';
|
689 |
-
$echo_str .= "\n\t\t".'<label>Are you sure that you want to delete '.( $type == 'dir' ? 'folder' : 'file' ).' <strong>'.$parts['basename'].'</strong>?</label><br/>';
|
690 |
-
$echo_str .= "\n\t\t".'<p class="submit">';
|
691 |
-
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Delete">';
|
692 |
-
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Cancel">';
|
693 |
-
$echo_str .= "\n\t\t".'</p>';
|
694 |
-
$echo_str .= "\n\t".'</form>';
|
695 |
-
$echo_str .= "\n".'</div>';
|
696 |
-
return $echo_str;
|
697 |
-
}
|
698 |
-
|
699 |
-
function wfu_delete_file($file, $type) {
|
700 |
-
if ( !current_user_can( 'manage_options' ) ) return;
|
701 |
-
$dec_file = wfu_plugin_decode_string($file);
|
702 |
-
$dec_file = wfu_flatten_path($dec_file);
|
703 |
-
if ( $type == 'dir' && substr($dec_file, -1) == '/' ) $dec_file = substr($dec_file, 0, -1);
|
704 |
-
if ( isset($_POST['submit']) ) {
|
705 |
-
if ( $_POST['submit'] == "Delete" ) {
|
706 |
-
if ( $type == 'dir' && $dec_file != "" ) wfu_delTree($dec_file);
|
707 |
-
else unlink($dec_file);
|
708 |
-
}
|
709 |
-
}
|
710 |
-
return true;
|
711 |
-
}
|
712 |
-
|
713 |
-
function wfu_create_dir_prompt($dir, $error) {
|
714 |
-
if ( !current_user_can( 'manage_options' ) ) return;
|
715 |
-
$siteurl = site_url();
|
716 |
-
$dec_dir = wfu_plugin_decode_string($dir);
|
717 |
-
//first extract sort info from dec_dir
|
718 |
-
$ret = wfu_extract_sortdata_from_path($dec_dir);
|
719 |
-
$dec_dir = $ret['path'];
|
720 |
-
if ( substr($dec_dir, -1) != '/' ) $dec_dir .= '/';
|
721 |
-
$newname = '';
|
722 |
-
|
723 |
-
$echo_str = "\n".'<div class="wrap">';
|
724 |
-
if ( $error ) {
|
725 |
-
$newname = $_SESSION['wfu_create_dir']['newname'];
|
726 |
-
$echo_str .= "\n\t".'<div class="error">';
|
727 |
-
$echo_str .= "\n\t\t".'<p>'.$_SESSION['wfu_create_dir_error'].'</p>';
|
728 |
-
$echo_str .= "\n\t".'</div>';
|
729 |
-
}
|
730 |
-
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
731 |
-
$echo_str .= "\n\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$dir.'" class="button" title="go back">Go back</a>';
|
732 |
-
$echo_str .= "\n\t".'</div>';
|
733 |
-
$echo_str .= "\n\t".'<h2 style="margin-bottom: 10px;">Create Folder</h2>';
|
734 |
-
$echo_str .= "\n\t".'<form enctype="multipart/form-data" name="createdir" id="createdir" method="post" action="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload" class="validate">';
|
735 |
-
$echo_str .= "\n\t\t".'<input type="hidden" name="action" value="createdir">';
|
736 |
-
$echo_str .= "\n\t\t".'<input type="hidden" name="dir" value="'.$dir.'">';
|
737 |
-
$echo_str .= "\n\t\t".'<label>Enter the name of the new folder inside <strong>'.$dec_dir.'</strong></label><br/>';
|
738 |
-
$echo_str .= "\n\t\t".'<input name="wfu_newname" id="wfu_newname" type="text" value="'.$newname.'" style="width:50%;" />';
|
739 |
-
$echo_str .= "\n\t\t".'<p class="submit">';
|
740 |
-
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Create">';
|
741 |
-
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Cancel">';
|
742 |
-
$echo_str .= "\n\t\t".'</p>';
|
743 |
-
$echo_str .= "\n\t".'</form>';
|
744 |
-
$echo_str .= "\n".'</div>';
|
745 |
-
return $echo_str;
|
746 |
-
}
|
747 |
-
|
748 |
-
function wfu_create_dir($dir) {
|
749 |
-
if ( !current_user_can( 'manage_options' ) ) return;
|
750 |
-
$dec_dir = wfu_plugin_decode_string($dir);
|
751 |
-
$dec_dir = wfu_flatten_path($dec_dir);
|
752 |
-
if ( substr($dec_dir, -1) != '/' ) $dec_dir .= '/';
|
753 |
-
if ( !file_exists($dec_dir) ) return wfu_browse_files();
|
754 |
-
$error = "";
|
755 |
-
if ( isset($_POST['wfu_newname']) && isset($_POST['submit']) ) {
|
756 |
-
if ( $_POST['submit'] == "Create" ) {
|
757 |
-
$new_dir = $dec_dir.$_POST['wfu_newname'];
|
758 |
-
if ( $_POST['wfu_newname'] == "" ) $error = 'Error: New folder name cannot be empty!';
|
759 |
-
elseif ( preg_match("/[^A-Za-z0-9.#\-$]/", $_POST['wfu_newname']) ) $error = 'Error: name contains invalid characters! Please correct.';
|
760 |
-
elseif ( file_exists($new_dir) ) $error = 'Error: The folder <strong>'.$_POST['wfu_newname'].'</strong> already exists! Please choose another one.';
|
761 |
-
elseif ( mkdir($new_dir) == false ) $error = 'Error: Creation of folder <strong>'.$_POST['wfu_newname'].'</strong> failed!';
|
762 |
-
}
|
763 |
-
}
|
764 |
-
if ( $error != "" ) {
|
765 |
-
$_SESSION['wfu_create_dir_error'] = $error;
|
766 |
-
$_SESSION['wfu_create_dir']['newname'] = $_POST['wfu_newname'];
|
767 |
-
}
|
768 |
-
return ( $error == "" );
|
769 |
-
}
|
770 |
-
|
771 |
?>
|
4 |
add_options_page('Wordpress File Upload', 'Wordpress File Upload', 10, 'wordpress_file_upload', 'wordpress_file_upload_manage_dashboard');
|
5 |
}
|
6 |
|
7 |
+
function wordpress_file_upload_install() {
|
8 |
+
global $wpdb;
|
9 |
+
global $wfu_tb_log_version;
|
10 |
+
global $wfu_tb_userdata_version;
|
11 |
+
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
|
12 |
+
|
13 |
+
$table_name1 = $wpdb->prefix . "wfu_log";
|
14 |
+
$installed_ver = get_option( "wordpress_file_upload_table_log_version" );
|
15 |
+
if( $installed_ver != $wfu_tb_log_version ) {
|
16 |
+
$sql = "CREATE TABLE " . $table_name1 . " (
|
17 |
+
idlog mediumint(9) NOT NULL AUTO_INCREMENT,
|
18 |
+
userid mediumint(9) NOT NULL,
|
19 |
+
uploaduserid mediumint(9) NOT NULL,
|
20 |
+
filepath TEXT NOT NULL,
|
21 |
+
filehash VARCHAR(100) NOT NULL,
|
22 |
+
filesize bigint NOT NULL,
|
23 |
+
uploadid VARCHAR(20) NOT NULL,
|
24 |
+
pageid mediumint(9),
|
25 |
+
sid VARCHAR(10),
|
26 |
+
date_from DATETIME,
|
27 |
+
date_to DATETIME,
|
28 |
+
action VARCHAR(20) NOT NULL,
|
29 |
+
linkedto mediumint(9),
|
30 |
+
PRIMARY KEY (idlog))
|
31 |
+
DEFAULT CHARACTER SET = utf8
|
32 |
+
DEFAULT COLLATE = utf8_general_ci;";
|
33 |
+
dbDelta($sql);
|
34 |
+
update_option("wordpress_file_upload_table_log_version", $wfu_tb_log_version);
|
35 |
+
}
|
36 |
+
|
37 |
+
$table_name2 = $wpdb->prefix . "wfu_userdata";
|
38 |
+
$installed_ver = get_option( "wordpress_file_upload_table_userdata_version" );
|
39 |
+
if( $installed_ver != $wfu_tb_userdata_version ) {
|
40 |
+
$sql = "CREATE TABLE " . $table_name2 . " (
|
41 |
+
iduserdata mediumint(9) NOT NULL AUTO_INCREMENT,
|
42 |
+
uploadid VARCHAR(20) NOT NULL,
|
43 |
+
property VARCHAR(100) NOT NULL,
|
44 |
+
propkey mediumint(9) NOT NULL,
|
45 |
+
propvalue TEXT,
|
46 |
+
date_from DATETIME,
|
47 |
+
date_to DATETIME,
|
48 |
+
PRIMARY KEY (iduserdata))
|
49 |
+
DEFAULT CHARACTER SET = utf8
|
50 |
+
DEFAULT COLLATE = utf8_general_ci;";
|
51 |
+
dbDelta($sql);
|
52 |
+
update_option("wordpress_file_upload_table_userdata_version", $wfu_tb_userdata_version);
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
function wordpress_file_upload_update_db_check() {
|
57 |
+
global $wfu_tb_log_version;
|
58 |
+
global $wfu_tb_userdata_version;
|
59 |
+
update_option("wordpress_file_upload_table_log_version", "0");
|
60 |
+
update_option("wordpress_file_upload_table_userdata_version", "0");
|
61 |
+
if ( get_option('wordpress_file_upload_table_log_version') != $wfu_tb_log_version || get_option('wordpress_file_upload_table_userdata_version') != $wfu_tb_userdata_version ) {
|
62 |
+
wordpress_file_upload_install();
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
// This is the callback function that generates dashboard page content
|
67 |
function wordpress_file_upload_manage_dashboard() {
|
68 |
global $wpdb;
|
82 |
elseif ( $action == 'file_browser' ) {
|
83 |
$echo_str = wfu_browse_files($dir);
|
84 |
}
|
85 |
+
elseif ( $action == 'view_log' ) {
|
86 |
+
$echo_str = wfu_view_log();
|
87 |
+
}
|
88 |
elseif ( $action == 'rename_file' && $file != "" ) {
|
89 |
$echo_str = wfu_rename_file_prompt($file, 'file', false);
|
90 |
}
|
120 |
if ( wfu_create_dir($dir) ) $echo_str = wfu_browse_files($dir);
|
121 |
else $echo_str = wfu_create_dir_prompt($dir, true);
|
122 |
}
|
123 |
+
elseif ( $action == 'file_details' && $file != "" ) {
|
124 |
+
$echo_str = wfu_file_details($file, false);
|
125 |
+
}
|
126 |
+
elseif ( $action == 'edit_filedetails' && $file != "" ) {
|
127 |
+
wfu_edit_filedetails($file);
|
128 |
+
$echo_str = wfu_file_details($file, false);
|
129 |
+
}
|
130 |
+
elseif ( $action == 'sync_db' ) {
|
131 |
+
$affected_items = wfu_sync_database();
|
132 |
+
$echo_str = wfu_manage_settings('Database updated. '.$affected_items.' items where affected.');
|
133 |
+
}
|
134 |
else {
|
135 |
$echo_str = wfu_manage_settings();
|
136 |
}
|
138 |
echo $echo_str;
|
139 |
}
|
140 |
|
141 |
+
function wfu_manage_settings($message = '') {
|
142 |
if ( !current_user_can( 'manage_options' ) ) return wfu_shortcode_composer();
|
143 |
|
144 |
global $wpdb;
|
147 |
|
148 |
$echo_str = '<div class="wfu_wrap">';
|
149 |
$echo_str .= "\n\t".'<h2>Wordpress File Upload Control Panel</h2>';
|
150 |
+
if ( $message != '' ) {
|
151 |
+
$echo_str .= "\n\t".'<div class="updated">';
|
152 |
+
$echo_str .= "\n\t\t".'<p>'.$message.'</p>';
|
153 |
+
$echo_str .= "\n\t".'</div>';
|
154 |
+
}
|
155 |
$echo_str .= "\n\t".'<div style="margin-top:10px;">';
|
156 |
if ( current_user_can( 'manage_options' ) ) $echo_str .= "\n\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser" class="button" title="File browser">File Browser</a>';
|
157 |
$echo_str .= "\n\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=shortcode_composer" class="button" title="Shortcode composer">Shortcode Composer</a>';
|
158 |
+
if ( current_user_can( 'manage_options' ) ) $echo_str .= "\n\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=view_log" class="button" title="View log">View Log</a>';
|
159 |
+
if ( current_user_can( 'manage_options' ) ) $echo_str .= "\n\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=sync_db" class="button" title="Update database to reflect current status of files">Sync Database</a>';
|
160 |
$echo_str .= "\n\t\t".'<h3 style="margin-bottom: 10px; margin-top: 40px;">Settings</h3>';
|
161 |
$echo_str .= "\n\t\t".'<form enctype="multipart/form-data" name="editsettings" id="editsettings" method="post" action="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=edit_settings" class="validate">';
|
162 |
$echo_str .= "\n\t\t\t".'<input type="hidden" name="action" value="edit_settings">';
|
164 |
$echo_str .= "\n\t\t\t\t".'<tbody>';
|
165 |
$echo_str .= "\n\t\t\t\t\t".'<tr class="form-field">';
|
166 |
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
167 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<label for="wfu_hashfiles">Hash Files</label>';
|
168 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
169 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
170 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<input name="wfu_hashfiles" id="wfu_hashfiles" type="checkbox"'.($plugin_options['hashfiles'] == '1' ? ' checked="checked"' : '' ).' style="width:auto;" /> Enables better control of uploaded files, but slows down performance when uploaded files are larger than 100MBytes';
|
171 |
+
$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['hashfiles'] == '1' ? 'Yes' : 'No' ).'</strong></p>';
|
172 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
173 |
+
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
174 |
+
$echo_str .= "\n\t\t\t\t\t".'<tr class="form-field">';
|
175 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
176 |
$echo_str .= "\n\t\t\t\t\t\t\t".'<label for="wfu_basedir">Base Directory</label>';
|
177 |
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
178 |
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
192 |
echo $echo_str;
|
193 |
}
|
194 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
function wfu_update_settings() {
|
196 |
if ( !current_user_can( 'manage_options' ) ) return;
|
197 |
$plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
|
198 |
$new_plugin_options = array();
|
199 |
|
200 |
// $enabled = ( isset($_POST['wfu_enabled']) ? ( $_POST['wfu_enabled'] == "on" ? 1 : 0 ) : 0 );
|
201 |
+
$hashfiles = ( isset($_POST['wfu_hashfiles']) ? ( $_POST['wfu_hashfiles'] == "on" ? 1 : 0 ) : 0 );
|
202 |
if ( isset($_POST['wfu_basedir']) && isset($_POST['submit']) ) {
|
203 |
if ( $_POST['submit'] == "Update" ) {
|
204 |
$new_plugin_options['version'] = '1.0';
|
205 |
$new_plugin_options['shortcode'] = $plugin_options['shortcode'];
|
206 |
+
$new_plugin_options['hashfiles'] = $hashfiles;
|
207 |
$new_plugin_options['basedir'] = $_POST['wfu_basedir'];
|
208 |
$encoded_options = wfu_encode_plugin_options($new_plugin_options);
|
209 |
update_option( "wordpress_file_upload_options", $encoded_options );
|
210 |
+
if ( $new_plugin_options['hashfiles'] == '1' && $plugin_options['hashfiles'] != '1' )
|
211 |
+
wfu_reassign_hashes();
|
212 |
}
|
213 |
}
|
214 |
|
215 |
return true;
|
216 |
}
|
217 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
218 |
?>
|
lib/wfu_admin_browser.php
ADDED
@@ -0,0 +1,662 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function wfu_browse_files($basedir) {
|
4 |
+
$siteurl = site_url();
|
5 |
+
$plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
|
6 |
+
|
7 |
+
if ( !current_user_can( 'manage_options' ) ) return;
|
8 |
+
//first decode basedir
|
9 |
+
$basedir = wfu_plugin_decode_string($basedir);
|
10 |
+
//then extract sort info from basedir
|
11 |
+
$ret = wfu_extract_sortdata_from_path($basedir);
|
12 |
+
$basedir = $ret['path'];
|
13 |
+
$sort = $ret['sort'];
|
14 |
+
if ( $sort == "" ) $sort = 'name';
|
15 |
+
if ( substr($sort, 0, 1) == '-' ) $order = SORT_DESC;
|
16 |
+
else $order = SORT_ASC;
|
17 |
+
|
18 |
+
//adjust basedir to have a standard format
|
19 |
+
if ( $basedir != "" ) {
|
20 |
+
if ( substr($basedir, -1) != '/' ) $basedir .= '/';
|
21 |
+
if ( !file_exists($basedir) ) $basedir = "";
|
22 |
+
}
|
23 |
+
//set basedit to default value if empty
|
24 |
+
if ( $basedir == "" ) {
|
25 |
+
$plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
|
26 |
+
$basedir = $plugin_options['basedir'];
|
27 |
+
$temp_params = array( 'uploadpath' => $basedir, 'accessmethod' => 'normal', 'ftpinfo' => '', 'useftpdomain' => 'false' );
|
28 |
+
$basedir = wfu_upload_plugin_full_path($temp_params);
|
29 |
+
}
|
30 |
+
//find relative dir
|
31 |
+
$reldir = str_replace(ABSPATH, "root/", $basedir);
|
32 |
+
//save dir route to an array
|
33 |
+
$parts = explode('/', $reldir);
|
34 |
+
$route = array();
|
35 |
+
$prev = "";
|
36 |
+
foreach ( $parts as $part ) {
|
37 |
+
$part = trim($part);
|
38 |
+
if ( $part != "" ) {
|
39 |
+
if ( $part == 'root' && $prev == "" ) $prev = ABSPATH;
|
40 |
+
else $prev .= $part.'/';
|
41 |
+
array_push($route, array( 'item' => $part, 'path' => $prev ));
|
42 |
+
}
|
43 |
+
}
|
44 |
+
//calculate upper directory
|
45 |
+
$updir = substr($basedir, 0, -1);
|
46 |
+
$delim_pos = strrpos($updir, '/');
|
47 |
+
if ( $delim_pos !== false ) $updir = substr($updir, 0, $delim_pos + 1);
|
48 |
+
|
49 |
+
$echo_str = "\n".'<div class="wrap">';
|
50 |
+
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
51 |
+
$echo_str .= "\n\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=manage_settings" class="button" title="go back">Go to Settings</a>';
|
52 |
+
$echo_str .= "\n\t".'</div>';
|
53 |
+
$echo_str .= "\n\t".'<h2 style="margin-bottom: 10px;">File Browser</h2>';
|
54 |
+
$echo_str .= "\n\t".'<div>';
|
55 |
+
$echo_str .= "\n\t\t".'<span><strong>Location:</strong> </span>';
|
56 |
+
foreach ( $route as $item ) {
|
57 |
+
$echo_str .= '<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.wfu_plugin_encode_string($item['path']).'">'.$item['item'].'</a>';
|
58 |
+
$echo_str .= '<span>/</span>';
|
59 |
+
}
|
60 |
+
//file browser header
|
61 |
+
$echo_str .= "\n\t".'</div>';
|
62 |
+
$echo_str .= "\n\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=create_dir&dir='.wfu_plugin_encode_string($basedir.'[['.$sort.']]').'" class="button" title="create folder" style="margin-top:6px">Create folder</a>';
|
63 |
+
$echo_str .= "\n\t".'<div style="margin-top:10px;">';
|
64 |
+
$echo_str .= "\n\t\t".'<table class="widefat">';
|
65 |
+
$echo_str .= "\n\t\t\t".'<thead>';
|
66 |
+
$echo_str .= "\n\t\t\t\t".'<tr>';
|
67 |
+
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="30%" style="text-align:left;">';
|
68 |
+
$enc_dir = wfu_plugin_encode_string($basedir.'[['.( substr($sort, -4) == 'name' ? ( $order == SORT_ASC ? '-name' : 'name' ) : 'name' ).']]');
|
69 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$enc_dir.'">Name'.( substr($sort, -4) == 'name' ? ( $order == SORT_ASC ? ' ↑' : ' ↓' ) : '' ).'</a>';
|
70 |
+
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
71 |
+
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="10%" style="text-align:right;">';
|
72 |
+
$enc_dir = wfu_plugin_encode_string($basedir.'[['.( substr($sort, -4) == 'size' ? ( $order == SORT_ASC ? '-size' : 'size' ) : 'size' ).']]');
|
73 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$enc_dir.'">Size'.( substr($sort, -4) == 'size' ? ( $order == SORT_ASC ? ' ↑' : ' ↓' ) : '' ).'</a>';
|
74 |
+
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
75 |
+
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="20%" style="text-align:left;">';
|
76 |
+
$enc_dir = wfu_plugin_encode_string($basedir.'[['.( substr($sort, -4) == 'date' ? ( $order == SORT_ASC ? '-date' : 'date' ) : 'date' ).']]');
|
77 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$enc_dir.'">Date'.( substr($sort, -4) == 'date' ? ( $order == SORT_ASC ? ' ↑' : ' ↓' ) : '' ).'</a>';
|
78 |
+
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
79 |
+
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="10%" style="text-align:center;">';
|
80 |
+
$enc_dir = wfu_plugin_encode_string($basedir.'[['.( substr($sort, -4) == 'user' ? ( $order == SORT_ASC ? '-user' : 'user' ) : 'user' ).']]');
|
81 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$enc_dir.'">Uploaded By'.( substr($sort, -4) == 'user' ? ( $order == SORT_ASC ? ' ↑' : ' ↓' ) : '' ).'</a>';
|
82 |
+
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
83 |
+
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="30%" style="text-align:left;">';
|
84 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<label>User Data</label>';
|
85 |
+
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
86 |
+
$echo_str .= "\n\t\t\t\t".'</tr>';
|
87 |
+
$echo_str .= "\n\t\t\t".'</thead>';
|
88 |
+
$echo_str .= "\n\t\t\t".'<tbody>';
|
89 |
+
|
90 |
+
//find contents of current folder
|
91 |
+
$dirlist = array();
|
92 |
+
$filelist = array();
|
93 |
+
if ( $handle = opendir($basedir) ) {
|
94 |
+
$blacklist = array('.', '..');
|
95 |
+
while ( false !== ($file = readdir($handle)) )
|
96 |
+
if ( !in_array($file, $blacklist) ) {
|
97 |
+
$filepath = $basedir.$file;
|
98 |
+
$stat = stat($filepath);
|
99 |
+
if ( is_dir($filepath) ) {
|
100 |
+
array_push($dirlist, array( 'name' => $file, 'fullpath' => $filepath, 'mdate' => $stat['mtime'] ));
|
101 |
+
}
|
102 |
+
else {
|
103 |
+
//find relative file record in database together with user data
|
104 |
+
$filerec = wfu_get_file_rec($filepath, true);
|
105 |
+
//find user who uploaded the file
|
106 |
+
$username = '';
|
107 |
+
if ( $filerec != null ) $username = wfu_get_username_by_id($filerec->userid);
|
108 |
+
array_push($filelist, array( 'name' => $file, 'fullpath' => $filepath, 'size' => $stat['size'], 'mdate' => $stat['mtime'], 'user' => $username, 'filedata' => $filerec ));
|
109 |
+
}
|
110 |
+
}
|
111 |
+
closedir($handle);
|
112 |
+
}
|
113 |
+
$dirsort = ( substr($sort, -4) == 'date' ? 'mdate' : substr($sort, -4) );
|
114 |
+
$filesort = $dirsort;
|
115 |
+
$dirorder = $order;
|
116 |
+
if ( $dirsort == 'size' ) { $dirsort = 'name'; $dirorder = SORT_ASC; }
|
117 |
+
if ( $dirsort == 'user' ) { $dirsort = 'name'; $dirorder = SORT_ASC; }
|
118 |
+
$dirlist = wfu_array_sort($dirlist, $dirsort, $dirorder);
|
119 |
+
$filelist = wfu_array_sort($filelist, $filesort, $order);
|
120 |
+
|
121 |
+
//show subfolders first
|
122 |
+
if ( $reldir != "root/" ) {
|
123 |
+
$enc_dir = wfu_plugin_encode_string($updir);
|
124 |
+
$echo_str .= "\n\t\t\t\t".'<tr>';
|
125 |
+
$echo_str .= "\n\t\t\t\t\t".'<td width="30%" style="padding: 5px 5px 5px 10px; text-align:left;">';
|
126 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<a class="row-title" href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$enc_dir.'" title="go up">..</a>';
|
127 |
+
$echo_str .= "\n\t\t\t\t\t".'</td>';
|
128 |
+
$echo_str .= "\n\t\t\t\t\t".'<td width="10%" style="padding: 5px 5px 5px 10px; text-align:right;"> </td>';
|
129 |
+
$echo_str .= "\n\t\t\t\t\t".'<td width="20%" style="padding: 5px 5px 5px 10px; text-align:left;"> </td>';
|
130 |
+
$echo_str .= "\n\t\t\t\t\t".'<td width="10%" style="padding: 5px 5px 5px 10px; text-align:center;"> </td>';
|
131 |
+
$echo_str .= "\n\t\t\t\t\t".'<td width="30%" style="padding: 5px 5px 5px 10px; text-align:left;"> </td>';
|
132 |
+
$echo_str .= "\n\t\t\t\t".'</tr>';
|
133 |
+
}
|
134 |
+
$ii = 1;
|
135 |
+
foreach ( $dirlist as $dir ) {
|
136 |
+
$enc_dir = wfu_plugin_encode_string($dir['fullpath'].'[['.$sort.']]');
|
137 |
+
$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\';}">';
|
138 |
+
$echo_str .= "\n\t\t\t\t\t".'<td width="30%" style="padding: 5px 5px 5px 10px; text-align:left;">';
|
139 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<a class="row-title" href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$enc_dir.'" title="'.$dir['name'].'">'.$dir['name'].'</a>';
|
140 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<div id="wfu_dir_actions_'.$ii.'" name="wfu_dir_actions" style="visibility:hidden;">';
|
141 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<span>';
|
142 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=rename_dir&file='.$enc_dir.'" title="Rename this folder">Rename</a>';
|
143 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".' | ';
|
144 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'</span>';
|
145 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<span>';
|
146 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=delete_dir&file='.$enc_dir.'" title="Delete this folder">Delete</a>';
|
147 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'</span>';
|
148 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</div>';
|
149 |
+
$echo_str .= "\n\t\t\t\t\t".'</td>';
|
150 |
+
$echo_str .= "\n\t\t\t\t\t".'<td width="10%" style="padding: 5px 5px 5px 10px; text-align:right;"> </td>';
|
151 |
+
$echo_str .= "\n\t\t\t\t\t".'<td width="20%" style="padding: 5px 5px 5px 10px; text-align:left;">'.date("d/m/Y H:i:s", $dir['mdate']).'</td>';
|
152 |
+
$echo_str .= "\n\t\t\t\t\t".'<td width="10%" style="padding: 5px 5px 5px 10px; text-align:center;"> </td>';
|
153 |
+
$echo_str .= "\n\t\t\t\t\t".'<td width="30%" style="padding: 5px 5px 5px 10px; text-align:left;"> </td>';
|
154 |
+
$echo_str .= "\n\t\t\t\t".'</tr>';
|
155 |
+
$ii ++;
|
156 |
+
}
|
157 |
+
//show contained files
|
158 |
+
foreach ( $filelist as $file ) {
|
159 |
+
$enc_file = wfu_plugin_encode_string($file['fullpath'].'[['.$sort.']]');
|
160 |
+
$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\';}">';
|
161 |
+
$echo_str .= "\n\t\t\t\t\t".'<td width="30%" style="padding: 5px 5px 5px 10px; text-align:left;">';
|
162 |
+
if ( $file['filedata'] != null )
|
163 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<a class="row-title" href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_details&file='.$enc_file.'" title="View and edit file details" style="font-weight:normal;">'.$file['name'].'</a>';
|
164 |
+
else
|
165 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<span>'.$file['name'].'</span>';
|
166 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<div id="wfu_file_actions_'.$ii.'" name="wfu_file_actions" style="visibility:hidden;">';
|
167 |
+
if ( $file['filedata'] != null ) {
|
168 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<span>';
|
169 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_details&file='.$enc_file.'" title="View and edit file details">Details</a>';
|
170 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".' | ';
|
171 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'</span>';
|
172 |
+
}
|
173 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<span>';
|
174 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=rename_file&file='.$enc_file.'" title="Rename this file">Rename</a>';
|
175 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".' | ';
|
176 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'</span>';
|
177 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<span>';
|
178 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=delete_file&file='.$enc_file.'" title="Delete this file">Delete</a>';
|
179 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".' | ';
|
180 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'</span>';
|
181 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<span>';
|
182 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<a href="javascript:wfu_download_file(\''.wfu_plugin_encode_string(WFU_AJAX_URL).'\', \''.wfu_plugin_encode_string($file['fullpath']).'\', '.( $file['filedata'] != null ? $file['filedata']->idlog : '0' ).');" title="Download this file">Download</a>';
|
183 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'</span>';
|
184 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</div>';
|
185 |
+
$echo_str .= "\n\t\t\t\t\t".'</td>';
|
186 |
+
$echo_str .= "\n\t\t\t\t\t".'<td width="10%" style="padding: 5px 5px 5px 10px; text-align:right;">'.$file['size'].'</td>';
|
187 |
+
$echo_str .= "\n\t\t\t\t\t".'<td width="20%" style="padding: 5px 5px 5px 10px; text-align:left;">'.date("d/m/Y H:i:s", $file['mdate']).'</td>';
|
188 |
+
$echo_str .= "\n\t\t\t\t\t".'<td width="10%" style="padding: 5px 5px 5px 10px; text-align:center;">'.$file['user'].'</td>';
|
189 |
+
$echo_str .= "\n\t\t\t\t\t".'<td width="30%" style="padding: 5px 5px 5px 10px; text-align:left;">';
|
190 |
+
if ( $file['filedata'] != null ) {
|
191 |
+
if ( count($file['filedata']->userdata) > 0 ) {
|
192 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<select multiple="multiple" style="width:100%; height:40px; background:none; font-size:small;">';
|
193 |
+
foreach ( $file['filedata']->userdata as $userdata )
|
194 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<option>'.$userdata->property.': '.$userdata->propvalue.'</option>';
|
195 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</select>';
|
196 |
+
}
|
197 |
+
}
|
198 |
+
$echo_str .= "\n\t\t\t\t\t".'</td>';
|
199 |
+
$echo_str .= "\n\t\t\t\t".'</tr>';
|
200 |
+
$ii ++;
|
201 |
+
}
|
202 |
+
$echo_str .= "\n\t\t\t".'</tbody>';
|
203 |
+
$echo_str .= "\n\t\t".'</table>';
|
204 |
+
$echo_str .= "\n\t\t".'<iframe id="wfu_download_frame" style="display: none;"></iframe>';
|
205 |
+
$echo_str .= "\n\t".'</div>';
|
206 |
+
$echo_str .= "\n".'</div>';
|
207 |
+
|
208 |
+
return $echo_str;
|
209 |
+
}
|
210 |
+
|
211 |
+
function wfu_current_user_allowed_action($action, $filepath) {
|
212 |
+
//first get file data from database, if exist
|
213 |
+
$filerec = wfu_get_file_rec($filepath, false);
|
214 |
+
|
215 |
+
$user = wp_get_current_user();
|
216 |
+
if ( 0 == $user->ID ) return null;
|
217 |
+
else $is_admin = current_user_can('manage_options');
|
218 |
+
if ( !$is_admin ) {
|
219 |
+
return null;
|
220 |
+
}
|
221 |
+
return $user;
|
222 |
+
}
|
223 |
+
|
224 |
+
function wfu_rename_file_prompt($file, $type, $error) {
|
225 |
+
$siteurl = site_url();
|
226 |
+
|
227 |
+
$dec_file = wfu_plugin_decode_string($file);
|
228 |
+
//first extract sort info from dec_file
|
229 |
+
$ret = wfu_extract_sortdata_from_path($dec_file);
|
230 |
+
$dec_file = $ret['path'];
|
231 |
+
if ( $type == 'dir' && substr($dec_file, -1) == '/' ) $dec_file = substr($dec_file, 0, -1);
|
232 |
+
|
233 |
+
//check if user is allowed to perform this action
|
234 |
+
if ( wfu_current_user_allowed_action('rename', $dec_file) == null ) return;
|
235 |
+
|
236 |
+
$parts = pathinfo($dec_file);
|
237 |
+
$newname = $parts['basename'];
|
238 |
+
$enc_dir = wfu_plugin_encode_string($parts['dirname'].'[['.$ret['sort'].']]');
|
239 |
+
|
240 |
+
$echo_str = "\n".'<div class="wrap">';
|
241 |
+
if ( $error ) {
|
242 |
+
$newname = $_SESSION['wfu_rename_file']['newname'];
|
243 |
+
$echo_str .= "\n\t".'<div class="error">';
|
244 |
+
$echo_str .= "\n\t\t".'<p>'.$_SESSION['wfu_rename_file_error'].'</p>';
|
245 |
+
$echo_str .= "\n\t".'</div>';
|
246 |
+
}
|
247 |
+
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
248 |
+
$echo_str .= "\n\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$enc_dir.'" class="button" title="go back">Go back</a>';
|
249 |
+
$echo_str .= "\n\t".'</div>';
|
250 |
+
$echo_str .= "\n\t".'<h2 style="margin-bottom: 10px;">Rename '.( $type == 'dir' ? 'Folder' : 'File' ).'</h2>';
|
251 |
+
$echo_str .= "\n\t".'<form enctype="multipart/form-data" name="renamefile" id="renamefile" method="post" action="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload" class="validate">';
|
252 |
+
$echo_str .= "\n\t\t".'<input type="hidden" name="action" value="rename'.( $type == 'dir' ? 'dir' : 'file' ).'">';
|
253 |
+
$echo_str .= "\n\t\t".'<input type="hidden" name="dir" value="'.$enc_dir.'">';
|
254 |
+
$echo_str .= "\n\t\t".'<input type="hidden" name="file" value="'.$file.'">';
|
255 |
+
if ( $type == 'dir' ) $echo_str .= "\n\t\t".'<label>Enter new name for folder <strong>'.$dec_file.'</strong></label><br/>';
|
256 |
+
else $echo_str .= "\n\t\t".'<label>Enter new filename for file <strong>'.$dec_file.'</strong></label><br/>';
|
257 |
+
$echo_str .= "\n\t\t".'<input name="wfu_newname" id="wfu_newname" type="text" value="'.$newname.'" style="width:50%;" />';
|
258 |
+
$echo_str .= "\n\t\t".'<p class="submit">';
|
259 |
+
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Rename">';
|
260 |
+
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Cancel">';
|
261 |
+
$echo_str .= "\n\t\t".'</p>';
|
262 |
+
$echo_str .= "\n\t".'</form>';
|
263 |
+
$echo_str .= "\n".'</div>';
|
264 |
+
return $echo_str;
|
265 |
+
}
|
266 |
+
|
267 |
+
function wfu_rename_file($file, $type) {
|
268 |
+
$dec_file = wfu_plugin_decode_string($file);
|
269 |
+
$dec_file = wfu_flatten_path($dec_file);
|
270 |
+
if ( $type == 'dir' && substr($dec_file, -1) == '/' ) $dec_file = substr($dec_file, 0, -1);
|
271 |
+
if ( !file_exists($dec_file) ) return wfu_browse_files();
|
272 |
+
|
273 |
+
//check if user is allowed to perform this action
|
274 |
+
$user = wfu_current_user_allowed_action('rename', $dec_file);
|
275 |
+
if ( $user == null ) return;
|
276 |
+
|
277 |
+
$parts = pathinfo($dec_file);
|
278 |
+
$error = "";
|
279 |
+
if ( isset($_POST['wfu_newname']) && isset($_POST['submit']) ) {
|
280 |
+
if ( $_POST['submit'] == "Rename" && $_POST['wfu_newname'] != $parts['basename'] ) {
|
281 |
+
$new_file = $parts['dirname'].'/'.$_POST['wfu_newname'];
|
282 |
+
$relativepath = str_replace(ABSPATH, '', $new_file);
|
283 |
+
if ( substr($relativepath, 0, 1) != '/' ) $relativepath = '/'.$relativepath;
|
284 |
+
if ( $_POST['wfu_newname'] == "" ) $error = 'Error: New '.( $type == 'dir' ? 'folder ' : 'file' ).'name cannot be empty!';
|
285 |
+
elseif ( preg_match("/[^A-Za-z0-9.#\-$]/", $_POST['wfu_newname']) ) $error = 'Error: name contains invalid characters! Please correct.';
|
286 |
+
elseif ( file_exists($new_file) ) $error = 'Error: The '.( $type == 'dir' ? 'folder' : 'file' ).' <strong>'.$_POST['wfu_newname'].'</strong> already exists! Please choose another one.';
|
287 |
+
else {
|
288 |
+
//pre-log rename action
|
289 |
+
if ( $type == 'file' ) $retid = wfu_log_action('rename:'.$new_file, $dec_file, $user->ID, '', 0, '', null);
|
290 |
+
//perform rename action
|
291 |
+
if ( rename($dec_file, $new_file) == false ) $error = 'Error: Rename of '.( $type == 'dir' ? 'folder' : 'file' ).' <strong>'.$parts['basename'].'</strong> failed!';
|
292 |
+
//revert log action if file was not renamed
|
293 |
+
if ( $type == 'file' && !file_exists($new_file) ) wfu_revert_log_action($retid);
|
294 |
+
}
|
295 |
+
}
|
296 |
+
}
|
297 |
+
if ( $error != "" ) {
|
298 |
+
$_SESSION['wfu_rename_file_error'] = $error;
|
299 |
+
$_SESSION['wfu_rename_file']['newname'] = $_POST['wfu_newname'];
|
300 |
+
}
|
301 |
+
return ( $error == "" );
|
302 |
+
}
|
303 |
+
|
304 |
+
function wfu_delete_file_prompt($file, $type) {
|
305 |
+
$siteurl = site_url();
|
306 |
+
|
307 |
+
$dec_file = wfu_plugin_decode_string($file);
|
308 |
+
//first extract sort info from dec_file
|
309 |
+
$ret = wfu_extract_sortdata_from_path($dec_file);
|
310 |
+
$dec_file = $ret['path'];
|
311 |
+
if ( $type == 'dir' && substr($dec_file, -1) == '/' ) $dec_file = substr($dec_file, 0, -1);
|
312 |
+
|
313 |
+
//check if user is allowed to perform this action
|
314 |
+
if ( wfu_current_user_allowed_action('delete', $dec_file) == null ) return;
|
315 |
+
|
316 |
+
$parts = pathinfo($dec_file);
|
317 |
+
$enc_dir = wfu_plugin_encode_string($parts['dirname'].'[['.$ret['sort'].']]');
|
318 |
+
|
319 |
+
$echo_str = "\n".'<div class="wrap">';
|
320 |
+
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
321 |
+
$echo_str .= "\n\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$enc_dir.'" class="button" title="go back">Go back</a>';
|
322 |
+
$echo_str .= "\n\t".'</div>';
|
323 |
+
$echo_str .= "\n\t".'<h2 style="margin-bottom: 10px;">Delete '.( $type == 'dir' ? 'Folder' : 'File' ).'</h2>';
|
324 |
+
$echo_str .= "\n\t".'<form enctype="multipart/form-data" name="deletefile" id="deletefile" method="post" action="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload" class="validate">';
|
325 |
+
$echo_str .= "\n\t\t".'<input type="hidden" name="action" value="delete'.( $type == 'dir' ? 'dir' : 'file' ).'">';
|
326 |
+
$echo_str .= "\n\t\t".'<input type="hidden" name="dir" value="'.$enc_dir.'">';
|
327 |
+
$echo_str .= "\n\t\t".'<input type="hidden" name="file" value="'.$file.'">';
|
328 |
+
$echo_str .= "\n\t\t".'<label>Are you sure that you want to delete '.( $type == 'dir' ? 'folder' : 'file' ).' <strong>'.$parts['basename'].'</strong>?</label><br/>';
|
329 |
+
$echo_str .= "\n\t\t".'<p class="submit">';
|
330 |
+
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Delete">';
|
331 |
+
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Cancel">';
|
332 |
+
$echo_str .= "\n\t\t".'</p>';
|
333 |
+
$echo_str .= "\n\t".'</form>';
|
334 |
+
$echo_str .= "\n".'</div>';
|
335 |
+
return $echo_str;
|
336 |
+
}
|
337 |
+
|
338 |
+
function wfu_delete_file($file, $type) {
|
339 |
+
$dec_file = wfu_plugin_decode_string($file);
|
340 |
+
$dec_file = wfu_flatten_path($dec_file);
|
341 |
+
if ( $type == 'dir' && substr($dec_file, -1) == '/' ) $dec_file = substr($dec_file, 0, -1);
|
342 |
+
|
343 |
+
//check if user is allowed to perform this action
|
344 |
+
$user = wfu_current_user_allowed_action('delete', $dec_file);
|
345 |
+
if ( $user == null ) return;
|
346 |
+
|
347 |
+
if ( isset($_POST['submit']) ) {
|
348 |
+
if ( $_POST['submit'] == "Delete" ) {
|
349 |
+
//pre-log delete action
|
350 |
+
if ( $type == 'file' ) $retid = wfu_log_action('delete', $dec_file, $user->ID, '', 0, '', null);
|
351 |
+
if ( $type == 'dir' && $dec_file != "" ) wfu_delTree($dec_file);
|
352 |
+
else unlink($dec_file);
|
353 |
+
//revert log action if file has not been deleted
|
354 |
+
if ( $type == 'file' && file_exists($dec_file) ) wfu_revert_log_action($retid);
|
355 |
+
}
|
356 |
+
}
|
357 |
+
return true;
|
358 |
+
}
|
359 |
+
|
360 |
+
function wfu_create_dir_prompt($dir, $error) {
|
361 |
+
$siteurl = site_url();
|
362 |
+
|
363 |
+
if ( !current_user_can( 'manage_options' ) ) return;
|
364 |
+
|
365 |
+
$dec_dir = wfu_plugin_decode_string($dir);
|
366 |
+
//first extract sort info from dec_dir
|
367 |
+
$ret = wfu_extract_sortdata_from_path($dec_dir);
|
368 |
+
$dec_dir = $ret['path'];
|
369 |
+
if ( substr($dec_dir, -1) != '/' ) $dec_dir .= '/';
|
370 |
+
$newname = '';
|
371 |
+
|
372 |
+
$echo_str = "\n".'<div class="wrap">';
|
373 |
+
if ( $error ) {
|
374 |
+
$newname = $_SESSION['wfu_create_dir']['newname'];
|
375 |
+
$echo_str .= "\n\t".'<div class="error">';
|
376 |
+
$echo_str .= "\n\t\t".'<p>'.$_SESSION['wfu_create_dir_error'].'</p>';
|
377 |
+
$echo_str .= "\n\t".'</div>';
|
378 |
+
}
|
379 |
+
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
380 |
+
$echo_str .= "\n\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$dir.'" class="button" title="go back">Go back</a>';
|
381 |
+
$echo_str .= "\n\t".'</div>';
|
382 |
+
$echo_str .= "\n\t".'<h2 style="margin-bottom: 10px;">Create Folder</h2>';
|
383 |
+
$echo_str .= "\n\t".'<form enctype="multipart/form-data" name="createdir" id="createdir" method="post" action="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload" class="validate">';
|
384 |
+
$echo_str .= "\n\t\t".'<input type="hidden" name="action" value="createdir">';
|
385 |
+
$echo_str .= "\n\t\t".'<input type="hidden" name="dir" value="'.$dir.'">';
|
386 |
+
$echo_str .= "\n\t\t".'<label>Enter the name of the new folder inside <strong>'.$dec_dir.'</strong></label><br/>';
|
387 |
+
$echo_str .= "\n\t\t".'<input name="wfu_newname" id="wfu_newname" type="text" value="'.$newname.'" style="width:50%;" />';
|
388 |
+
$echo_str .= "\n\t\t".'<p class="submit">';
|
389 |
+
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Create">';
|
390 |
+
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Cancel">';
|
391 |
+
$echo_str .= "\n\t\t".'</p>';
|
392 |
+
$echo_str .= "\n\t".'</form>';
|
393 |
+
$echo_str .= "\n".'</div>';
|
394 |
+
return $echo_str;
|
395 |
+
}
|
396 |
+
|
397 |
+
function wfu_create_dir($dir) {
|
398 |
+
if ( !current_user_can( 'manage_options' ) ) return;
|
399 |
+
|
400 |
+
$dec_dir = wfu_plugin_decode_string($dir);
|
401 |
+
$dec_dir = wfu_flatten_path($dec_dir);
|
402 |
+
if ( substr($dec_dir, -1) != '/' ) $dec_dir .= '/';
|
403 |
+
if ( !file_exists($dec_dir) ) return wfu_browse_files();
|
404 |
+
$error = "";
|
405 |
+
if ( isset($_POST['wfu_newname']) && isset($_POST['submit']) ) {
|
406 |
+
if ( $_POST['submit'] == "Create" ) {
|
407 |
+
$new_dir = $dec_dir.$_POST['wfu_newname'];
|
408 |
+
if ( $_POST['wfu_newname'] == "" ) $error = 'Error: New folder name cannot be empty!';
|
409 |
+
elseif ( preg_match("/[^A-Za-z0-9.#\-$]/", $_POST['wfu_newname']) ) $error = 'Error: name contains invalid characters! Please correct.';
|
410 |
+
elseif ( file_exists($new_dir) ) $error = 'Error: The folder <strong>'.$_POST['wfu_newname'].'</strong> already exists! Please choose another one.';
|
411 |
+
elseif ( mkdir($new_dir) == false ) $error = 'Error: Creation of folder <strong>'.$_POST['wfu_newname'].'</strong> failed!';
|
412 |
+
}
|
413 |
+
}
|
414 |
+
if ( $error != "" ) {
|
415 |
+
$_SESSION['wfu_create_dir_error'] = $error;
|
416 |
+
$_SESSION['wfu_create_dir']['newname'] = $_POST['wfu_newname'];
|
417 |
+
}
|
418 |
+
return ( $error == "" );
|
419 |
+
}
|
420 |
+
|
421 |
+
function wfu_file_details($file, $errorstatus) {
|
422 |
+
global $wpdb;
|
423 |
+
$table_name1 = $wpdb->prefix . "wfu_log";
|
424 |
+
$siteurl = site_url();
|
425 |
+
|
426 |
+
//extract file browser data from $file variable
|
427 |
+
$dec_file = wfu_plugin_decode_string($file);
|
428 |
+
$ret = wfu_extract_sortdata_from_path($dec_file);
|
429 |
+
$filepath = $ret['path'];
|
430 |
+
|
431 |
+
//get file data from database with user data
|
432 |
+
$filedata = wfu_get_file_rec($filepath, true);
|
433 |
+
if ( $filedata == null ) return;
|
434 |
+
|
435 |
+
//check if user is allowed to perform this action
|
436 |
+
$user = wfu_current_user_allowed_action('details', $filepath);
|
437 |
+
if ( $user == null ) return;
|
438 |
+
|
439 |
+
//get the username of the uploader
|
440 |
+
$uploadername = wfu_get_username_by_id($filedata->uploaduserid);
|
441 |
+
|
442 |
+
//extract sort info and construct contained dir
|
443 |
+
$parts = pathinfo($filepath);
|
444 |
+
$enc_dir = wfu_plugin_encode_string($parts['dirname'].'[['.$ret['sort'].']]');
|
445 |
+
|
446 |
+
$stat = stat($filepath);
|
447 |
+
|
448 |
+
$echo_str = '<div class="regev_wrap">';
|
449 |
+
if ( $errorstatus == 'error' ) {
|
450 |
+
$echo_str .= "\n\t".'<div class="error">';
|
451 |
+
$echo_str .= "\n\t\t".'<p>'.$_SESSION['wfu_filedetails_error'].'</p>';
|
452 |
+
$echo_str .= "\n\t".'</div>';
|
453 |
+
}
|
454 |
+
//show file detais
|
455 |
+
$echo_str .= "\n\t".'<h2>Detais of File: '.$parts['basename'].'</h2>';
|
456 |
+
$echo_str .= "\n\t".'<div style="margin-top:10px;">';
|
457 |
+
$echo_str .= "\n\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$enc_dir.'" class="button" title="go back">Go back</a>';
|
458 |
+
$echo_str .= "\n\t\t".'<form enctype="multipart/form-data" name="editfiledetails" id="editfiledetails" method="post" action="/wp-admin/options-general.php?page=wordpress_file_upload&action=edit_filedetails" class="validate">';
|
459 |
+
$echo_str .= "\n\t\t\t".'<h3 style="margin-bottom: 10px; margin-top: 40px;">Upload Details</h3>';
|
460 |
+
$echo_str .= "\n\t\t\t".'<input type="hidden" name="action" value="edit_filedetails" />';
|
461 |
+
$echo_str .= "\n\t\t\t".'<input type="hidden" name="dir" value="'.$enc_dir.'">';
|
462 |
+
$echo_str .= "\n\t\t\t".'<input type="hidden" name="file" value="'.$file.'">';
|
463 |
+
$echo_str .= "\n\t\t\t".'<table class="form-table">';
|
464 |
+
$echo_str .= "\n\t\t\t\t".'<tbody>';
|
465 |
+
$echo_str .= "\n\t\t\t\t\t".'<tr class="form-field">';
|
466 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
467 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<label>Full Path</label>';
|
468 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
469 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
470 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<input type="text" value="'.$filepath.'" readonly="readonly" />';
|
471 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
472 |
+
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
473 |
+
$echo_str .= "\n\t\t\t\t\t".'<tr class="form-field">';
|
474 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
475 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<label>Uploaded From User</label>';
|
476 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
477 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
478 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<input type="text" value="'.$uploadername.'" readonly="readonly" style="width:auto;" />';
|
479 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
480 |
+
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
481 |
+
$echo_str .= "\n\t\t\t\t\t".'<tr class="form-field">';
|
482 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
483 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<label>File Size</label>';
|
484 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
485 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
486 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<input type="text" value="'.$filedata->filesize.'" readonly="readonly" style="width:auto;" />';
|
487 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
488 |
+
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
489 |
+
$echo_str .= "\n\t\t\t\t\t".'<tr class="form-field">';
|
490 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
491 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<label>File Date</label>';
|
492 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
493 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
494 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<input type="text" value="'.date("d/m/Y H:i:s", $stat['mtime']).'" readonly="readonly" style="width:auto;" />';
|
495 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
496 |
+
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
497 |
+
$echo_str .= "\n\t\t\t\t\t".'<tr class="form-field">';
|
498 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
499 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<label>Uploaded From Page</label>';
|
500 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
501 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
502 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<input type="text" value="'.get_the_title($filedata->pageid).' ('.$filedata->pageid.')'.'" readonly="readonly" style="width:50%;" />';
|
503 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
504 |
+
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
505 |
+
$echo_str .= "\n\t\t\t\t\t".'<tr class="form-field">';
|
506 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
507 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<label>Upload Plugin ID</label>';
|
508 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
509 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
510 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<input type="text" value="'.$filedata->sid.'" readonly="readonly" style="width:auto;" />';
|
511 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
512 |
+
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
513 |
+
$echo_str .= "\n\t\t\t\t".'</tbody>';
|
514 |
+
$echo_str .= "\n\t\t\t".'</table>';
|
515 |
+
//show history details
|
516 |
+
$echo_str .= "\n\t\t\t".'<h3 style="margin-bottom: 10px; margin-top: 40px;">File History</h3>';
|
517 |
+
$echo_str .= "\n\t\t\t".'<table class="form-table">';
|
518 |
+
$echo_str .= "\n\t\t\t\t".'<tbody>';
|
519 |
+
$echo_str .= "\n\t\t\t\t\t".'<tr class="form-field">';
|
520 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
521 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<label></label>';
|
522 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
523 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
524 |
+
//read all linked records
|
525 |
+
$filerecs = array();
|
526 |
+
array_push($filerecs, $filedata);
|
527 |
+
$currec = $filedata;
|
528 |
+
while ( $currec->linkedto > 0 ) {
|
529 |
+
$currec = $wpdb->get_row('SELECT * FROM '.$table_name1.' WHERE idlog = '.$currec->linkedto);
|
530 |
+
if ( $currec != null ) array_push($filerecs, $currec);
|
531 |
+
else break;
|
532 |
+
}
|
533 |
+
//construct report from db records
|
534 |
+
$rep = '';
|
535 |
+
foreach ( $filerecs as $filerec ) {
|
536 |
+
$username = wfu_get_username_by_id($filerec->userid);
|
537 |
+
$fileparts = pathinfo($filerec->filepath);
|
538 |
+
if ( $rep != '' ) $rep .= "<br />";
|
539 |
+
$rep .= '<strong>['.$filerec->date_from.']</strong> ';
|
540 |
+
if ( $filerec->action == 'upload' )
|
541 |
+
$rep .= 'File uploaded with name <strong>'.$fileparts['basename'].'</strong> by user <strong>'.$username.'</strong>';
|
542 |
+
elseif ( $filerec->action == 'download' )
|
543 |
+
$rep .= 'File downloaded by user <strong>'.$username.'</strong>';
|
544 |
+
elseif ( $filerec->action == 'rename' )
|
545 |
+
$rep .= 'File renamed to <strong>'.$fileparts['basename'].'</strong> by user <strong>'.$username.'</strong>';
|
546 |
+
elseif ( $filerec->action == 'delete' )
|
547 |
+
$rep .= 'File deleted by user <strong>'.$username.'</strong>';
|
548 |
+
elseif ( $filerec->action == 'modify' )
|
549 |
+
$rep .= 'File userdata modified by user <strong>'.$username.'</strong>';
|
550 |
+
}
|
551 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<div style="border:1px solid #dfdfdf; border-radius:3px; width:50%; overflow:scroll; padding:6px; height:100px; background-color:#eee;">';
|
552 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<span style="white-space:nowrap;">'.$rep.'</span>';
|
553 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'</div>';
|
554 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
555 |
+
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
556 |
+
$echo_str .= "\n\t\t\t\t".'</tbody>';
|
557 |
+
$echo_str .= "\n\t\t\t".'</table>';
|
558 |
+
|
559 |
+
$echo_str .= "\n\t\t\t".'<h3 style="margin-bottom: 10px; margin-top: 40px;">User Data Details</h3>';
|
560 |
+
$echo_str .= "\n\t\t\t".'<table class="form-table">';
|
561 |
+
$echo_str .= "\n\t\t\t\t".'<tbody>';
|
562 |
+
if ( count($filedata->userdata) > 0 ) {
|
563 |
+
foreach ( $filedata->userdata as $userdata ) {
|
564 |
+
$echo_str .= "\n\t\t\t\t\t".'<tr class="form-field">';
|
565 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
566 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<label>'.$userdata->property.'</label>';
|
567 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
568 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
569 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<input id="wfu_filedetails_userdata_value_'.$userdata->propkey.'" name="wfu_filedetails_userdata" type="text" value="'.$userdata->propvalue.'" />';
|
570 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<input id="wfu_filedetails_userdata_default_'.$userdata->propkey.'" type="hidden" value="'.$userdata->propvalue.'" />';
|
571 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<input id="wfu_filedetails_userdata_'.$userdata->propkey.'" name="wfu_filedetails_userdata_'.$userdata->propkey.'" type="hidden" value="'.$userdata->propvalue.'" />';
|
572 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
573 |
+
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
574 |
+
}
|
575 |
+
}
|
576 |
+
else {
|
577 |
+
$echo_str .= "\n\t\t\t\t\t".'<tr class="form-field">';
|
578 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
579 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<label>No user data</label>';
|
580 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
581 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<td></td>';
|
582 |
+
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
583 |
+
}
|
584 |
+
$echo_str .= "\n\t\t\t\t".'</tbody>';
|
585 |
+
$echo_str .= "\n\t\t\t".'</table>';
|
586 |
+
$echo_str .= "\n\t\t\t".'<p class="submit">';
|
587 |
+
$echo_str .= "\n\t\t\t\t".'<input id="dp_filedetails_submit_fields" type="submit" class="button-primary" name="submit" value="Update" disabled="disabled" />';
|
588 |
+
$echo_str .= "\n\t\t\t".'</p>';
|
589 |
+
$echo_str .= "\n\t\t".'</form>';
|
590 |
+
$echo_str .= "\n\t".'</div>';
|
591 |
+
$handler = 'function() { wfu_Attach_FileDetails_Admin_Events(); }';
|
592 |
+
$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>';
|
593 |
+
$echo_str .= '</div>';
|
594 |
+
|
595 |
+
return $echo_str;
|
596 |
+
}
|
597 |
+
|
598 |
+
function wfu_edit_filedetails($file) {
|
599 |
+
global $wpdb;
|
600 |
+
$table_name2 = $wpdb->prefix . "wfu_userdata";
|
601 |
+
|
602 |
+
$dec_file = wfu_plugin_decode_string($file);
|
603 |
+
$dec_file = wfu_flatten_path($dec_file);
|
604 |
+
|
605 |
+
//check if user is allowed to perform this action
|
606 |
+
$user = wfu_current_user_allowed_action('modify', $dec_file);
|
607 |
+
if ( $user == null ) return;
|
608 |
+
|
609 |
+
//get file data from database with user data
|
610 |
+
$filedata = wfu_get_file_rec($dec_file, true);
|
611 |
+
if ( $filedata == null ) return;
|
612 |
+
|
613 |
+
if ( isset($_POST['submit']) ) {
|
614 |
+
if ( $_POST['submit'] == "Update" ) {
|
615 |
+
//check for errors
|
616 |
+
$is_error = false;
|
617 |
+
foreach ( $filedata->userdata as $userdata ) {
|
618 |
+
if ( !isset($_POST['wfu_filedetails_userdata_'.$userdata->propkey]) ) {
|
619 |
+
$is_error = true;
|
620 |
+
break;
|
621 |
+
}
|
622 |
+
}
|
623 |
+
if ( !$is_error ) {
|
624 |
+
$now_date = date('Y-m-d H:i:s');
|
625 |
+
$userdata_count = 0;
|
626 |
+
foreach ( $filedata->userdata as $userdata ) {
|
627 |
+
$userdata_count ++;
|
628 |
+
//make existing userdata record obsolete
|
629 |
+
$wpdb->update($table_name2,
|
630 |
+
array( 'date_to' => $now_date ),
|
631 |
+
array( 'uploadid' => $userdata->uploadid, 'propkey' => $userdata->propkey ),
|
632 |
+
array( '%s' ),
|
633 |
+
array( '%s', '%s' )
|
634 |
+
);
|
635 |
+
//insert new userdata record
|
636 |
+
$wpdb->insert($table_name2,
|
637 |
+
array(
|
638 |
+
'uploadid' => $userdata->uploadid,
|
639 |
+
'property' => $userdata->property,
|
640 |
+
'propkey' => $userdata->propkey,
|
641 |
+
'propvalue' => $_POST['wfu_filedetails_userdata_'.$userdata->propkey],
|
642 |
+
'date_from' => $now_date,
|
643 |
+
'date_to' => 0
|
644 |
+
),
|
645 |
+
array(
|
646 |
+
'%s',
|
647 |
+
'%s',
|
648 |
+
'%d',
|
649 |
+
'%s',
|
650 |
+
'%s',
|
651 |
+
'%s'
|
652 |
+
)
|
653 |
+
);
|
654 |
+
}
|
655 |
+
if ( $userdata_count > 0 ) wfu_log_action('modify:'.$now_date, $dec_file, $user->ID, '', 0, '', null);
|
656 |
+
}
|
657 |
+
}
|
658 |
+
}
|
659 |
+
return true;
|
660 |
+
}
|
661 |
+
|
662 |
+
?>
|
lib/wfu_admin_composer.php
ADDED
@@ -0,0 +1,410 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function wfu_shortcode_composer() {
|
4 |
+
global $wpdb;
|
5 |
+
global $wp_roles;
|
6 |
+
$siteurl = site_url();
|
7 |
+
|
8 |
+
$components = wfu_component_definitions();
|
9 |
+
|
10 |
+
$cats = wfu_category_definitions();
|
11 |
+
$defs = wfu_attribute_definitions();
|
12 |
+
|
13 |
+
$plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
|
14 |
+
$shortcode_attrs = wfu_shortcode_string_to_array($plugin_options['shortcode']);
|
15 |
+
foreach ( $defs as $key => $def ) {
|
16 |
+
$defs[$key]['default'] = $def['value'];
|
17 |
+
if ( array_key_exists($def['attribute'], $shortcode_attrs) ) {
|
18 |
+
$defs[$key]['value'] = $shortcode_attrs[$def['attribute']];
|
19 |
+
}
|
20 |
+
}
|
21 |
+
|
22 |
+
// index $components
|
23 |
+
$components_indexed = array();
|
24 |
+
foreach ( $components as $component ) $components_indexed[$component['id']] = $component;
|
25 |
+
// index dependiencies
|
26 |
+
$governors = array();
|
27 |
+
|
28 |
+
$echo_str = '<div id="wfu_wrapper" class="wrap">';
|
29 |
+
if ( current_user_can( 'manage_options' ) ) $echo_str .= "\n\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=manage_settings" class="button" title="go back">Go to Settings</a>';
|
30 |
+
$echo_str .= "\n\t".'<h2>Wordpress File Upload Shortcode Composer</h2>';
|
31 |
+
$echo_str .= "\n\t".'<div style="margin-top:10px;">';
|
32 |
+
$echo_str .= "\n\t\t".'<div class="wfu_shortcode_container">';
|
33 |
+
$echo_str .= "\n\t\t\t".'<span><strong>Generated Shortcode</strong></span>';
|
34 |
+
$echo_str .= "\n\t\t\t".'<span id="wfu_save_label" class="wfu_save_label">saved</span>';
|
35 |
+
$echo_str .= "\n\t\t\t".'<textarea id="wfu_shortcode" class="wfu_shortcode" rows="5">[wordpress_file_upload]</textarea>';
|
36 |
+
$echo_str .= "\n\t\t\t".'<div id="wfu_attribute_defaults" style="display:none;">';
|
37 |
+
foreach ( $defs as $def )
|
38 |
+
$echo_str .= "\n\t\t\t\t".'<input id="wfu_attribute_default_'.$def['attribute'].'" type="hidden" value="'.$def['default'].'" />';
|
39 |
+
$echo_str .= "\n\t\t\t".'</div>';
|
40 |
+
$echo_str .= "\n\t\t\t".'<div id="wfu_attribute_values" style="display:none;">';
|
41 |
+
foreach ( $defs as $def )
|
42 |
+
$echo_str .= "\n\t\t\t\t".'<input id="wfu_attribute_value_'.$def['attribute'].'" type="hidden" value="'.$def['value'].'" />';
|
43 |
+
$echo_str .= "\n\t\t\t".'</div>';
|
44 |
+
$echo_str .= "\n\t\t".'</div>';
|
45 |
+
$echo_str .= "\n\t".'</div>';
|
46 |
+
$echo_str .= "\n\t".'<h3 id="wfu_tab_container" class="nav-tab-wrapper">';
|
47 |
+
$is_first = true;
|
48 |
+
foreach ( $cats as $key => $cat ) {
|
49 |
+
$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>';
|
50 |
+
$is_first = false;
|
51 |
+
}
|
52 |
+
$echo_str .= "\n\t".'</h3>';
|
53 |
+
|
54 |
+
$prevcat = "";
|
55 |
+
$prevsubcat = "";
|
56 |
+
$is_first = true;
|
57 |
+
$block_open = false;
|
58 |
+
$subblock_open = false;
|
59 |
+
foreach ( $defs as $def ) {
|
60 |
+
$attr = $def['attribute'];
|
61 |
+
$subblock_active = false;
|
62 |
+
//detect if the dependencies of this attribute will be disabled or not
|
63 |
+
if ( ( $def['type'] == "onoff" && $def['value'] == "true" ) ||
|
64 |
+
( $def['type'] == "radio" && in_array("*".$def['value'], $def['listitems']) ) )
|
65 |
+
$subblock_active = true;
|
66 |
+
// assign dependencies if exist
|
67 |
+
if ( $def['dependencies'] != null )
|
68 |
+
foreach ( $def['dependencies'] as $dependency ) {
|
69 |
+
if ( substr($dependency, 0, 1) == "!" ) //invert state for this dependency if an exclamation mark is defined
|
70 |
+
$governors[substr($dependency, 1)] = array( 'attribute' => $attr, 'active' => !$subblock_active, 'inv' => '_inv' );
|
71 |
+
else
|
72 |
+
$governors[$dependency] = array( 'attribute' => $attr, 'active' => $subblock_active, 'inv' => '' );
|
73 |
+
}
|
74 |
+
//check if this attribute depends on other
|
75 |
+
if ( $governors[$attr] != "" ) $governor = $governors[$attr];
|
76 |
+
else $governor = array( 'attribute' => "independent", 'active' => true, 'inv' => '' );
|
77 |
+
|
78 |
+
//close previous blocks
|
79 |
+
if ( $def['parent'] == "" ) {
|
80 |
+
if ( $subblock_open ) {
|
81 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'</tbody>';
|
82 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</table>';
|
83 |
+
$subblock_open = false;
|
84 |
+
}
|
85 |
+
if ( $block_open ) {
|
86 |
+
$echo_str .= "\n\t\t\t\t\t".'</div></td>';
|
87 |
+
$echo_str .= "\n\t\t\t\t".'</tr>';
|
88 |
+
$block_open = false;
|
89 |
+
}
|
90 |
+
}
|
91 |
+
//check if new category must be generated
|
92 |
+
if ( $def['category'] != $prevcat ) {
|
93 |
+
if ( $prevcat != "" ) {
|
94 |
+
$echo_str .= "\n\t\t\t".'</tbody>';
|
95 |
+
$echo_str .= "\n\t\t".'</table>';
|
96 |
+
$echo_str .= "\n\t".'</div>';
|
97 |
+
}
|
98 |
+
$prevcat = $def['category'];
|
99 |
+
$prevsubcat = "";
|
100 |
+
$echo_str .= "\n\t".'<div id="wfu_container_'.$prevcat.'" class="wfu_container"'.( $is_first ? '' : ' style="display:none;"' ).'">';
|
101 |
+
$echo_str .= "\n\t\t".'<table class="form-table wfu_main_table">';
|
102 |
+
$echo_str .= "\n\t\t\t".'<thead><tr><th></th><td></td><td></td></tr></thead>';
|
103 |
+
$echo_str .= "\n\t\t\t".'<tbody>';
|
104 |
+
$is_first = false;
|
105 |
+
}
|
106 |
+
//check if new sub-category must be generated
|
107 |
+
if ( $def['subcategory'] != $prevsubcat ) {
|
108 |
+
$prevsubcat = $def['subcategory'];
|
109 |
+
$echo_str .= "\n\t\t\t\t".'<tr class="form-field wfu_subcategory">';
|
110 |
+
$echo_str .= "\n\t\t\t\t\t".'<th scope="row" colspan="3">';
|
111 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<h3 style="margin-bottom: 10px; margin-top: 10px;">'.$prevsubcat.'</h3>';
|
112 |
+
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
113 |
+
$echo_str .= "\n\t\t\t\t".'</tr>';
|
114 |
+
}
|
115 |
+
//draw attribute element
|
116 |
+
if ( $def['parent'] == "" ) {
|
117 |
+
$dlp = "\n\t\t\t\t";
|
118 |
+
}
|
119 |
+
else {
|
120 |
+
if ( !$subblock_open ) {
|
121 |
+
$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>';
|
122 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<table class="form-table wfu_inner_table" style="margin:0;">';
|
123 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<tbody>';
|
124 |
+
}
|
125 |
+
$dlp = "\n\t\t\t\t\t\t\t\t";
|
126 |
+
}
|
127 |
+
$echo_str .= $dlp.'<tr class="form-field">';
|
128 |
+
$echo_str .= $dlp."\t".'<th scope="row"><div class="wfu_td_div">';
|
129 |
+
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>';
|
130 |
+
$echo_str .= $dlp."\t\t".'<div class="wfu_restore_container" title="Double-click to restore defaults setting"><img src="'.WFU_IMAGE_ADMIN_RESTOREDEFAULT.'" ondblclick="wfu_apply_value(\''.$attr.'\', \''.$def['type'].'\', \''.$def['default'].'\');" ></div>';
|
131 |
+
$echo_str .= $dlp."\t\t".'<label for="wfu_attribute_'.$attr.'">'.$def['name'].'</label>';
|
132 |
+
$echo_str .= $dlp."\t\t".'<div class="wfu_help_container" title="'.$def['help'].'"><img src="'.WFU_IMAGE_ADMIN_HELP.'" ></div>';
|
133 |
+
$echo_str .= $dlp."\t".'</div></th>';
|
134 |
+
$echo_str .= $dlp."\t".'<td style="vertical-align:top;"><div class="wfu_td_div">';
|
135 |
+
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>';
|
136 |
+
if ( $def['type'] == "onoff" ) {
|
137 |
+
$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.'\');">';
|
138 |
+
$echo_str .= $dlp."\t\t\t".'<div class="wfu_onoff_slider"></div>';
|
139 |
+
$echo_str .= $dlp."\t\t\t".'<span class="wfu_onoff_text">ON</span>';
|
140 |
+
$echo_str .= $dlp."\t\t\t".'<span class="wfu_onoff_text">OFF</span>';
|
141 |
+
$echo_str .= $dlp."\t\t".'</div>';
|
142 |
+
}
|
143 |
+
elseif ( $def['type'] == "text" ) {
|
144 |
+
$val = str_replace(array( "%n%", "%dq%", "%brl%", "%brr%" ), array( "\n", """, "[", "]" ), $def['value']);
|
145 |
+
$echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" value="'.$val.'" />';
|
146 |
+
if ( $def['variables'] != null ) $echo_str .= wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
|
147 |
+
}
|
148 |
+
elseif ( $def['type'] == "placements" ) {
|
149 |
+
$components_used = array();
|
150 |
+
foreach ( $components as $component ) $components_used[$component['id']] = false;
|
151 |
+
$centered_content = '<div style="display:table; width:100%; height:100%;"><div style="display:table-cell; text-align:center; vertical-align:middle;">XXX</div></div>';
|
152 |
+
$echo_str .= $dlp."\t\t".'<div class="wfu_placements_wrapper">';
|
153 |
+
$echo_str .= $dlp."\t\t\t".'<div id="wfu_placements_container" class="wfu_placements_container">';
|
154 |
+
$itemplaces = explode("/", $def['value']);
|
155 |
+
foreach ( $itemplaces as $section ) {
|
156 |
+
$echo_str .= $dlp."\t\t\t\t".'<div class="wfu_component_separator_hor"></div>';
|
157 |
+
$echo_str .= $dlp."\t\t\t\t".'<div class="wfu_component_separator_ver"></div>';
|
158 |
+
$items_in_section = explode("+", trim($section));
|
159 |
+
$section_array = array( );
|
160 |
+
foreach ( $items_in_section as $item_in_section ) {
|
161 |
+
if ( key_exists($item_in_section, $components_indexed) ) {
|
162 |
+
$components_used[$item_in_section] = true;
|
163 |
+
$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>';
|
164 |
+
$echo_str .= $dlp."\t\t\t\t".'<div class="wfu_component_separator_ver"></div>';
|
165 |
+
}
|
166 |
+
}
|
167 |
+
}
|
168 |
+
$echo_str .= $dlp."\t\t\t\t".'<div class="wfu_component_separator_hor"></div>';
|
169 |
+
$echo_str .= $dlp."\t\t\t\t".'<div id="wfu_component_bar_hor" class="wfu_component_bar_hor"></div>';
|
170 |
+
$echo_str .= $dlp."\t\t\t\t".'<div id="wfu_component_bar_ver" class="wfu_component_bar_ver"></div>';
|
171 |
+
$echo_str .= $dlp."\t\t\t".'</div>';
|
172 |
+
$echo_str .= $dlp."\t\t\t".'<div id="wfu_componentlist_container" class="wfu_componentlist_container">';
|
173 |
+
$echo_str .= $dlp."\t\t\t\t".'<div id="wfu_componentlist_dragdrop" class="wfu_componentlist_dragdrop" style="display:none;"></div>';
|
174 |
+
$ii = 1;
|
175 |
+
foreach ( $components as $component ) {
|
176 |
+
$echo_str .= $dlp."\t\t\t\t".'<div id="wfu_component_box_container_'.$component['id'].'" class="wfu_component_box_container">';
|
177 |
+
$echo_str .= $dlp."\t\t\t\t\t".'<div class="wfu_component_box_base">'.str_replace("XXX", $component['name'], $centered_content).'</div>';
|
178 |
+
if ( !$components_used[$component['id']] )
|
179 |
+
$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>';
|
180 |
+
$echo_str .= $dlp."\t\t\t\t".'</div>'.( ($ii++) % 3 == 0 ? '<br />' : '' );
|
181 |
+
}
|
182 |
+
$echo_str .= $dlp."\t\t\t".'</div>';
|
183 |
+
$echo_str .= $dlp."\t\t".'</div>';
|
184 |
+
}
|
185 |
+
elseif ( $def['type'] == "ltext" ) {
|
186 |
+
$val = str_replace(array( "%n%", "%dq%", "%brl%", "%brr%" ), array( "\n", """, "[", "]" ), $def['value']);
|
187 |
+
$echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" class="wfu_long_text" value="'.$val.'" />';
|
188 |
+
if ( $def['variables'] != null ) $echo_str .= wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
|
189 |
+
}
|
190 |
+
elseif ( $def['type'] == "integer" ) {
|
191 |
+
$val = str_replace(array( "%n%", "%dq%", "%brl%", "%brr%" ), array( "\n", """, "[", "]" ), $def['value']);
|
192 |
+
$echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="number" name="wfu_text_elements" class="wfu_short_text" min="1" value="'.$val.'" />';
|
193 |
+
}
|
194 |
+
elseif ( $def['type'] == "float" ) {
|
195 |
+
$val = str_replace(array( "%n%", "%dq%", "%brl%", "%brr%" ), array( "\n", """, "[", "]" ), $def['value']);
|
196 |
+
$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="'.$val.'" />';
|
197 |
+
}
|
198 |
+
elseif ( $def['type'] == "radio" ) {
|
199 |
+
$echo_str .= $dlp."\t\t";
|
200 |
+
$ii = 0;
|
201 |
+
foreach ( $def['listitems'] as $item )
|
202 |
+
$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 );
|
203 |
+
// $echo_str .= '<input type="button" class="button" value="empty" style="width:auto; margin:-2px 0px 0px 8px;" />';
|
204 |
+
}
|
205 |
+
elseif ( $def['type'] == "ptext" ) {
|
206 |
+
$val = str_replace(array( "%n%", "%dq%", "%brl%", "%brr%" ), array( "\n", """, "[", "]" ), $def['value']);
|
207 |
+
$parts = explode("/", $val);
|
208 |
+
$singular = $parts[0];
|
209 |
+
if ( count($parts) < 2 ) $plural = $singular;
|
210 |
+
else $plural = $parts[1];
|
211 |
+
$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.'" />';
|
212 |
+
if ( $def['variables'] != null ) if ( count($def['variables']) > 0 ) $echo_str .= $dlp."\t\t".'<br /><span class="wfu_ptext_span"> </span>';
|
213 |
+
if ( $def['variables'] != null ) $echo_str .= wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_s_'.$attr);
|
214 |
+
$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.'" />';
|
215 |
+
if ( $def['variables'] != null ) if ( count($def['variables']) > 0 ) $echo_str .= $dlp."\t\t".'<br /><span class="wfu_ptext_span"> </span>';
|
216 |
+
if ( $def['variables'] != null ) $echo_str .= wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_p_'.$attr);
|
217 |
+
}
|
218 |
+
elseif ( $def['type'] == "mtext" ) {
|
219 |
+
$val = str_replace(array( "%n%", "%dq%", "%brl%", "%brr%" ), array( "\n", """, "[", "]" ), $def['value']);
|
220 |
+
$echo_str .= $dlp."\t\t".'<textarea id="wfu_attribute_'.$attr.'" name="wfu_text_elements" rows="5">'.$val.'</textarea>';
|
221 |
+
if ( $def['variables'] != null ) $echo_str .= wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
|
222 |
+
}
|
223 |
+
elseif ( $def['type'] == "folderlist" ) {
|
224 |
+
$echo_str .= $dlp."\t\t".'<div id="wfu_subfolders_inner_shadow_'.$attr.'" class="wfu_subfolders_inner_shadow" style="display:none;"></div>';
|
225 |
+
$echo_str .= $dlp."\t\t".'<select id="wfu_attribute_'.$attr.'" class="wfu_select_folders" size="7" onchange="wfu_subfolders_changed(\''.$attr.'\');">';
|
226 |
+
// $def['value'] = 'admin,*&guests,*users,**user1/User1, **user2/User 2, ***user5, ***user6, *user3, **user4';
|
227 |
+
$subfolders = wfu_parse_folderlist($def['value']);
|
228 |
+
foreach ($subfolders['path'] as $ind => $subfolder) {
|
229 |
+
if ( substr($subfolder, -1) == '/' ) $subfolder = substr($subfolder, 0, -1);
|
230 |
+
$subfolder_raw = explode('/', $subfolder);
|
231 |
+
$subfolder = $subfolder_raw[count($subfolder_raw) - 1];
|
232 |
+
$text = str_repeat(" ", intval($subfolders['level'][$ind])).$subfolders['label'][$ind];
|
233 |
+
$subvalue = str_repeat("*", intval($subfolders['level'][$ind])).( $subfolders['default'][$ind] ? '&' : '' ).( $subfolder == "" ? '{root}' : $subfolder ).'/'.$subfolders['label'][$ind];
|
234 |
+
$echo_str .= $dlp."\t\t\t".'<option class="'.( $subfolders['default'][$ind] ? 'wfu_select_folders_option_default' : '' ).'" value="'.wfu_plugin_encode_string($subvalue).'">'.$text.'</option>';
|
235 |
+
}
|
236 |
+
$echo_str .= $dlp."\t\t\t".'<option value=""></option>';
|
237 |
+
$echo_str .= $dlp."\t\t".'</select>';
|
238 |
+
$echo_str .= $dlp."\t\t".'<div id="wfu_subfolder_nav_'.$attr.'" class="wfu_subfolder_nav_container">';
|
239 |
+
$echo_str .= $dlp."\t\t\t".'<table class="wfu_subfolder_nav"><tbody>';
|
240 |
+
$echo_str .= $dlp."\t\t\t\t".'<tr><td><button id="wfu_subfolders_up_'.$attr.'" name="wfu_subfolder_nav_'.$attr.'" class="button" disabled="disabled" title="move item up" onclick="wfu_subfolders_up_clicked(\''.$attr.'\');">↑</button></tr></td>';
|
241 |
+
$echo_str .= $dlp."\t\t\t\t".'<tr><td><button id="wfu_subfolders_left_'.$attr.'" name="wfu_subfolder_nav_'.$attr.'" class="button" title="make it parent" disabled="disabled" style="height:14px;" onclick="wfu_subfolders_left_clicked(\''.$attr.'\');">←</button>';
|
242 |
+
$echo_str .= $dlp."\t\t\t\t".'<button id="wfu_subfolders_right_'.$attr.'" name="wfu_subfolder_nav_'.$attr.'" class="button" title="make it child" disabled="disabled" style="height:14px;" onclick="wfu_subfolders_right_clicked(\''.$attr.'\');">→</button></tr></td>';
|
243 |
+
$echo_str .= $dlp."\t\t\t\t".'<tr><td><button id="wfu_subfolders_down_'.$attr.'" name="wfu_subfolder_nav_'.$attr.'" class="button" title="move item down" disabled="disabled" onclick="wfu_subfolders_down_clicked(\''.$attr.'\');">↓</button></tr></td>';
|
244 |
+
$echo_str .= $dlp."\t\t\t\t".'<tr><td style="line-height:0;"><button class="button" style="visibility:hidden; height:10px;"></button></tr></td>';
|
245 |
+
$echo_str .= $dlp."\t\t\t\t".'<tr><td><button id="wfu_subfolders_add_'.$attr.'" name="wfu_subfolder_nav_'.$attr.'" class="button" title="add new item" disabled="disabled" style="height:14px;" onclick="wfu_subfolders_add_clicked(\''.$attr.'\');">+</button></tr></td>';
|
246 |
+
$echo_str .= $dlp."\t\t\t\t".'<tr><td><button id="wfu_subfolders_def_'.$attr.'" name="wfu_subfolder_nav_'.$attr.'" class="button" title="make it default" disabled="disabled" style="height:14px;" onclick="wfu_subfolders_def_clicked(\''.$attr.'\');">♦</button></tr></td>';
|
247 |
+
$echo_str .= $dlp."\t\t\t\t".'<tr><td><button id="wfu_subfolders_del_'.$attr.'" name="wfu_subfolder_nav_'.$attr.'" class="button" title="delete item" disabled="disabled" style="height:14px;" onclick="wfu_subfolders_del_clicked(\''.$attr.'\');">-</button></tr></td>';
|
248 |
+
$echo_str .= $dlp."\t\t\t".'</tbody></table>';
|
249 |
+
$echo_str .= $dlp."\t\t".'</div>';
|
250 |
+
$echo_str .= $dlp."\t\t".'<div id="wfu_subfolder_tools_'.$attr.'" class="wfu_subfolder_tools_container wfu_subfolder_tools_disabled">';
|
251 |
+
$echo_str .= $dlp."\t\t\t".'<table class="wfu_subfolder_tools"><tbody><tr>';
|
252 |
+
$echo_str .= $dlp."\t\t\t\t".'<td style="width:40%;">';
|
253 |
+
$echo_str .= $dlp."\t\t\t\t\t".'<label>Label</label>';
|
254 |
+
$echo_str .= $dlp."\t\t\t\t\t".'<input id="wfu_subfolders_label_'.$attr.'" name="wfu_subfolder_tools_input" type="text" disabled="disabled" />';
|
255 |
+
$echo_str .= $dlp."\t\t\t\t".'</td>';
|
256 |
+
$echo_str .= $dlp."\t\t\t\t".'<td style="width:60%;"><div style="padding-right:36px;">';
|
257 |
+
$echo_str .= $dlp."\t\t\t\t\t".'<label>Path</label>';
|
258 |
+
$echo_str .= $dlp."\t\t\t\t\t".'<input id="wfu_subfolders_path_'.$attr.'" name="wfu_subfolder_tools_input" type="text" disabled="disabled" />';
|
259 |
+
$echo_str .= $dlp."\t\t\t\t\t".'<button id="wfu_subfolders_browse_'.$attr.'" class="button" title="browse folders" style="right:18px;" disabled="disabled" onclick="wfu_subfolders_browse_clicked(\''.$attr.'\');"><img src="'.WFU_IMAGE_ADMIN_SUBFOLDER_BROWSE.'" ></button>';
|
260 |
+
$echo_str .= $dlp."\t\t\t\t\t".'<button id="wfu_subfolders_ok_'.$attr.'" class="button" title="save changes" style="right:0px;" disabled="disabled" onclick="wfu_subfolders_ok_clicked(\''.$attr.'\');"><img src="'.WFU_IMAGE_ADMIN_SUBFOLDER_OK.'" ></button>';
|
261 |
+
// file browser dialog
|
262 |
+
$echo_str .= $dlp."\t\t\t\t\t".'<div id="wfu_subfolders_browser_'.$attr.'" class="wfu_subfolders_browser_container" style="display:none;">';
|
263 |
+
$echo_str .= $dlp."\t\t\t\t\t\t".'<table><tbody>';
|
264 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t".'<tr><td style="height:15px;">';
|
265 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t\t".'<div>';
|
266 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t\t\t".'<label>Folder Browser</label>';
|
267 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t\t\t".'<button class="button wfu_folder_browser_cancel" onclick="wfu_folder_browser_cancel_clicked(\''.$attr.'\');"><img src="'.WFU_IMAGE_ADMIN_SUBFOLDER_CANCEL.'" ></button>';
|
268 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t\t".'</div>';
|
269 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t".'</td></tr>';
|
270 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t".'<tr><td style="height:106px;">';
|
271 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t\t".'<div>';
|
272 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t\t\t".'<select id="wfu_subfolders_browser_list_'.$attr.'" size="2" onchange="wfu_subfolders_browser_list_changed(\''.$attr.'\');">';
|
273 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t\t\t\t".'<option>Value</option>';
|
274 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t\t\t\t".'<option>Value2</option>';
|
275 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t\t\t\t".'<option>Value3</option>';
|
276 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t\t\t".'</select>';
|
277 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t\t\t".'<div id="wfu_subfolders_browser_msgcont_'.$attr.'" class="wfu_folder_browser_loading_container" style="padding-top:40px;">';
|
278 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t\t\t\t".'<label id="wfu_subfolders_browser_msg_'.$attr.'" style="margin-bottom:4px;">loading folder contents...</label>';
|
279 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t\t\t\t".'<img id="wfu_subfolders_browser_img_'.$attr.'" src="'.WFU_IMAGE_ADMIN_SUBFOLDER_LOADING.'" ></button>';
|
280 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t\t\t".'</div>';
|
281 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t\t".'</div>';
|
282 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t".'</td></tr>';
|
283 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t".'<tr><td align="right" style="height:15px;">';
|
284 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t\t".'<div>';
|
285 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t\t\t".'<button class="button" onclick="wfu_folder_browser_cancel_clicked(\''.$attr.'\');">Cancel</button>';
|
286 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t\t\t".'<button id="wfu_subfolders_browser_ok_'.$attr.'" class="button">Ok</button>';
|
287 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t\t".'</div>';
|
288 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t".'</td></tr>';
|
289 |
+
$echo_str .= $dlp."\t\t\t\t\t\t".'</tbody></table>';
|
290 |
+
$echo_str .= $dlp."\t\t\t\t\t".'</div>';
|
291 |
+
|
292 |
+
$echo_str .= $dlp."\t\t\t\t".'</div></td>';
|
293 |
+
$echo_str .= $dlp."\t\t\t".'</tr></tbody></table>';
|
294 |
+
$echo_str .= $dlp."\t\t\t".'<input id="wfu_subfolders_isnewitem_'.$attr.'" type="hidden" value="" />';
|
295 |
+
$echo_str .= $dlp."\t\t\t".'<input id="wfu_subfolders_newitemindex_'.$attr.'" type="hidden" value="" />';
|
296 |
+
$echo_str .= $dlp."\t\t\t".'<input id="wfu_subfolders_newitemlevel_'.$attr.'" type="hidden" value="" />';
|
297 |
+
$echo_str .= $dlp."\t\t\t".'<input id="wfu_subfolders_newitemlevel2_'.$attr.'" type="hidden" value="" />';
|
298 |
+
$echo_str .= $dlp."\t\t".'</div>';
|
299 |
+
}
|
300 |
+
elseif ( $def['type'] == "rolelist" ) {
|
301 |
+
$roles = $wp_roles->get_names();
|
302 |
+
$def['value'] = strtolower($def['value']);
|
303 |
+
if ( $def['value'] == "all" ) $selected = array("administrator");
|
304 |
+
else $selected = explode(",", $def['value']);
|
305 |
+
foreach ( $selected as $key => $item ) $selected[$key] = trim($item);
|
306 |
+
$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"' : '' ).'>';
|
307 |
+
foreach ( $roles as $roleid => $rolename )
|
308 |
+
$echo_str .= $dlp."\t\t\t".'<option value="'.$roleid.'"'.( in_array($roleid, $selected) ? ' selected="selected"' : '' ).'>'.$rolename.'</option>';
|
309 |
+
$echo_str .= $dlp."\t\t".'</select>';
|
310 |
+
$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>';
|
311 |
+
}
|
312 |
+
elseif ( $def['type'] == "dimensions" ) {
|
313 |
+
$vals_arr = explode(",", $def['value']);
|
314 |
+
$vals = array();
|
315 |
+
foreach ( $vals_arr as $val_raw ) {
|
316 |
+
list($val_id, $val) = explode(":", $val_raw);
|
317 |
+
$vals[trim($val_id)] = trim($val);
|
318 |
+
}
|
319 |
+
$dims = array();
|
320 |
+
foreach ( $components as $comp ) {
|
321 |
+
if ( $comp['dimensions'] == null ) $dims[$comp['id']] = $comp['name'];
|
322 |
+
else foreach ( $comp['dimensions'] as $dimraw ) {
|
323 |
+
list($dim_id, $dim_name) = explode("/", $dimraw);
|
324 |
+
$dims[$dim_id] = $dim_name;
|
325 |
+
}
|
326 |
+
}
|
327 |
+
foreach ( $dims as $dim_id => $dim_name ) {
|
328 |
+
$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 />';
|
329 |
+
}
|
330 |
+
}
|
331 |
+
elseif ( $def['type'] == "userfields" ) {
|
332 |
+
$fields_arr = explode("/", $def['value']);
|
333 |
+
$fields = array();
|
334 |
+
foreach ( $fields_arr as $field_raw ) {
|
335 |
+
$is_req = ( substr($field_raw, 0, 1) == "*" );
|
336 |
+
if ( $is_req ) $field_raw = substr($field_raw, 1);
|
337 |
+
if ( $field_raw != "" ) array_push($fields, array( "name" => $field_raw, "required" => $is_req ));
|
338 |
+
}
|
339 |
+
if ( count($fields) == 0 ) array_push($fields, array( "name" => "", "required" => false ));
|
340 |
+
$echo_str .= $dlp."\t\t".'<div id="wfu_attribute_'.$attr.'" class="wfu_userdata_container">';
|
341 |
+
foreach ( $fields as $field ) {
|
342 |
+
$echo_str .= $dlp."\t\t\t".'<div class="wfu_userdata_line">';
|
343 |
+
$echo_str .= $dlp."\t\t\t\t".'<input type="text" name="wfu_userfield_elements" value="'.$field['name'].'" />';
|
344 |
+
$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>';
|
345 |
+
$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>';
|
346 |
+
$echo_str .= $dlp."\t\t\t\t".'<input type="checkbox"'.( $field['required'] ? 'checked="checked"' : '' ).' onchange="wfu_update_userfield_value({target:this});" />';
|
347 |
+
$echo_str .= $dlp."\t\t\t\t".'<span>Required</span>';
|
348 |
+
$echo_str .= $dlp."\t\t\t".'</div>';
|
349 |
+
}
|
350 |
+
$echo_str .= $dlp."\t\t".'</div>';
|
351 |
+
}
|
352 |
+
elseif ( $def['type'] == "color" ) {
|
353 |
+
$val = str_replace(array( "%n%", "%dq%", "%brl%", "%brr%" ), array( "\n", """, "[", "]" ), $def['value']);
|
354 |
+
$echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" class="wfu_color_field" value="'.$val.'" />';
|
355 |
+
}
|
356 |
+
elseif ( $def['type'] == "color-triplet" ) {
|
357 |
+
$triplet = explode(",", $def['value']);
|
358 |
+
foreach ( $triplet as $key => $item ) $triplet[$key] = trim($item);
|
359 |
+
if ( count($triplet) == 2 ) $triplet = array( $triplet[0], $triplet[1], "#000000");
|
360 |
+
elseif ( count($triplet) == 1 ) $triplet = array( $triplet[0], "#FFFFFF", "#000000");
|
361 |
+
elseif ( count($triplet) < 3 ) $triplet = array( "#000000", "#FFFFFF", "#000000");
|
362 |
+
$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>';
|
363 |
+
$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>';
|
364 |
+
$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>';
|
365 |
+
}
|
366 |
+
else {
|
367 |
+
$echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" value="'.$def['value'].'" />';
|
368 |
+
if ( $def['variables'] != null ) $echo_str .= wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
|
369 |
+
}
|
370 |
+
$echo_str .= $dlp."\t".'</div></td>';
|
371 |
+
if ( $def['parent'] == "" ) {
|
372 |
+
$echo_str .= $dlp."\t".'<td style="position:relative; vertical-align:top; padding:0;"><div class="wfu_td_div">';
|
373 |
+
$block_open = false;
|
374 |
+
}
|
375 |
+
else {
|
376 |
+
$echo_str .= $dlp.'</tr>';
|
377 |
+
$subblock_open = true;
|
378 |
+
}
|
379 |
+
}
|
380 |
+
if ( $subblock_open ) {
|
381 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</div>';
|
382 |
+
}
|
383 |
+
if ( $block_open ) {
|
384 |
+
$echo_str .= "\n\t\t\t\t\t".'</div></td>';
|
385 |
+
$echo_str .= "\n\t\t\t\t".'</tr>';
|
386 |
+
}
|
387 |
+
$echo_str .= "\n\t\t\t".'</tbody>';
|
388 |
+
$echo_str .= "\n\t\t".'</table>';
|
389 |
+
$echo_str .= "\n\t".'</div>';
|
390 |
+
$echo_str .= "\n\t".'<div id="wfu_global_dialog_container" class="wfu_global_dialog_container">';
|
391 |
+
$echo_str .= "\n\t".'</div>';
|
392 |
+
$handler = 'function() { wfu_Attach_Admin_Events(); }';
|
393 |
+
$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>';
|
394 |
+
$echo_str .= "\n".'</div>';
|
395 |
+
// $echo_str .= "\n\t".'<div style="margin-top:10px;">';
|
396 |
+
// $echo_str .= "\n\t\t".'<label>Final shortcode text</label>';
|
397 |
+
// $echo_str .= "\n\t".'</div>';
|
398 |
+
|
399 |
+
echo $echo_str;
|
400 |
+
}
|
401 |
+
|
402 |
+
function wfu_insert_variables($variables, $class) {
|
403 |
+
$ret = "";
|
404 |
+
foreach ( $variables as $variable )
|
405 |
+
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>';
|
406 |
+
elseif ( $variable != "%n%" && $variable != "%dq%" && $variable != "%brl%" && $variable != "%brr%" ) $ret .= $dlp."\t\t".'<span class="'.$class.'" title="'.constant("WFU_VARIABLE_TITLE_".strtoupper(str_replace("%", "", $variable))).'" ondblclick="wfu_insert_variable(this);">'.$variable.'</span>';
|
407 |
+
return $ret;
|
408 |
+
}
|
409 |
+
|
410 |
+
?>
|
lib/wfu_admin_log.php
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function wfu_view_log() {
|
4 |
+
global $wpdb;
|
5 |
+
$siteurl = site_url();
|
6 |
+
$table_name1 = $wpdb->prefix . "wfu_log";
|
7 |
+
$table_name2 = $wpdb->prefix . "wfu_userdata";
|
8 |
+
$plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
|
9 |
+
|
10 |
+
if ( !current_user_can( 'manage_options' ) ) return;
|
11 |
+
|
12 |
+
$echo_str = "\n".'<div class="wrap">';
|
13 |
+
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
14 |
+
$echo_str .= "\n\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=manage_settings" class="button" title="go back">Go to Settings</a>';
|
15 |
+
$echo_str .= "\n\t".'</div>';
|
16 |
+
$echo_str .= "\n\t".'<h2 style="margin-bottom: 10px;">History Log</h2>';
|
17 |
+
$echo_str .= "\n\t".'<div style="margin-top:10px;">';
|
18 |
+
$echo_str .= "\n\t\t".'<table class="widefat">';
|
19 |
+
$echo_str .= "\n\t\t\t".'<thead>';
|
20 |
+
$echo_str .= "\n\t\t\t\t".'<tr>';
|
21 |
+
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="5%" style="text-align:center;">';
|
22 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<label>#</label>';
|
23 |
+
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
24 |
+
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="15%" style="text-align:left;">';
|
25 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<label>Date</label>';
|
26 |
+
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
27 |
+
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="10%" style="text-align:center;">';
|
28 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<label>Action</label>';
|
29 |
+
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
30 |
+
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="30%" style="text-align:left;">';
|
31 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<label>File</label>';
|
32 |
+
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
33 |
+
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="15%" style="text-align:center;">';
|
34 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<label>User</label>';
|
35 |
+
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
36 |
+
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="25%" style="text-align:left;">';
|
37 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<label>Remarks</label>';
|
38 |
+
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
39 |
+
$echo_str .= "\n\t\t\t\t".'</tr>';
|
40 |
+
$echo_str .= "\n\t\t\t".'</thead>';
|
41 |
+
$echo_str .= "\n\t\t\t".'<tbody>';
|
42 |
+
|
43 |
+
$filerecs = $wpdb->get_results('SELECT * FROM '.$table_name1.' ORDER BY date_from DESC');
|
44 |
+
$userdatarecs = $wpdb->get_results('SELECT * FROM '.$table_name2);
|
45 |
+
$i = 0;
|
46 |
+
foreach ( $filerecs as $filerec ) {
|
47 |
+
$remarks = '';
|
48 |
+
$filepath = ABSPATH;
|
49 |
+
if ( substr($filepath, -1) == '/' ) $filepath = substr($filepath, 0, -1);
|
50 |
+
$filepath .= $filerec->filepath;
|
51 |
+
$enc_file = wfu_plugin_encode_string($filepath.'[[name]]');
|
52 |
+
if ( $filerec->action == 'rename' ) {
|
53 |
+
$prevfilepath = '';
|
54 |
+
foreach ( $filerecs as $key => $prevfilerec ) {
|
55 |
+
if ( $prevfilerec->idlog == $filerec->linkedto ) {
|
56 |
+
$prevfilepath = $prevfilerec->filepath;
|
57 |
+
break;
|
58 |
+
}
|
59 |
+
}
|
60 |
+
if ( $prevfilepath != '' )
|
61 |
+
$remarks = "\n\t\t\t\t\t\t".'<label>Previous filepath: '.$prevfilepath.'</label>';
|
62 |
+
}
|
63 |
+
elseif ( $filerec->action == 'upload' || $filerec->action == 'modify' ) {
|
64 |
+
foreach ( $userdatarecs as $userdata ) {
|
65 |
+
if ( $userdata->uploadid == $filerec->uploadid && $userdata->date_from == $filerec->date_from )
|
66 |
+
$remarks .= "\n\t\t\t\t\t\t\t".'<option>'.$userdata->property.': '.$userdata->propvalue.'</option>';
|
67 |
+
}
|
68 |
+
if ( $remarks != '' ) {
|
69 |
+
$remarks = "\n\t\t\t\t\t\t".'<select multiple="multiple" style="width:100%; height:40px; background:none; font-size:small;">'.$remarks;
|
70 |
+
$remarks .= "\n\t\t\t\t\t\t".'</select>';
|
71 |
+
}
|
72 |
+
}
|
73 |
+
elseif ( $filerec->action == 'other' ) {
|
74 |
+
$info = $filerec->filepath;
|
75 |
+
$filerec->filepath = '';
|
76 |
+
$remarks = "\n\t\t\t\t\t\t".'<textarea style="width:100%; resize:vertical; background:none;" readonly="readonly">'.$info.'</textarea>';
|
77 |
+
}
|
78 |
+
$i ++;
|
79 |
+
$otheraction = ( $filerec->action == 'other' );
|
80 |
+
$echo_str .= "\n\t\t\t\t".'<tr>';
|
81 |
+
$echo_str .= "\n\t\t\t\t\t".'<td style="padding: 5px 5px 5px 10px; text-align:center;">'.$i.'</td>';
|
82 |
+
$echo_str .= "\n\t\t\t\t\t".'<td style="padding: 5px 5px 5px 10px; text-align:left;">'.$filerec->date_from.'</td>';
|
83 |
+
$echo_str .= "\n\t\t\t\t\t".'<td style="padding: 5px 5px 5px 10px; text-align:center;">'.$filerec->action.'</td>';
|
84 |
+
if ( !$otheraction ) {
|
85 |
+
$echo_str .= "\n\t\t\t\t\t".'<td style="padding: 5px 5px 5px 10px; text-align:left;">';
|
86 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<a class="row-title" href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_details&file='.$enc_file.'" title="View and edit file details" style="font-weight:normal;">'.$filerec->filepath.'</a>';
|
87 |
+
$echo_str .= "\n\t\t\t\t\t".'</td>';
|
88 |
+
$echo_str .= "\n\t\t\t\t\t".'<td style="padding: 5px 5px 5px 10px; text-align:center;">'.wfu_get_username_by_id($filerec->userid).'</td>';
|
89 |
+
}
|
90 |
+
$echo_str .= "\n\t\t\t\t\t".'<td style="padding: 5px 5px 5px 10px; text-align:left;"'.( $otheraction ? ' colspan="3"' : '' ).'>';
|
91 |
+
$echo_str .= $remarks;
|
92 |
+
$echo_str .= "\n\t\t\t\t\t".'</td>';
|
93 |
+
$echo_str .= "\n\t\t\t\t".'</tr>';
|
94 |
+
}
|
95 |
+
$echo_str .= "\n\t\t\t".'</tbody>';
|
96 |
+
$echo_str .= "\n\t\t".'</table>';
|
97 |
+
$echo_str .= "\n\t".'</div>';
|
98 |
+
$echo_str .= "\n".'</div>';
|
99 |
+
|
100 |
+
return $echo_str;
|
101 |
+
}
|
102 |
+
|
103 |
+
?>
|
lib/wfu_ajaxactions.php
CHANGED
@@ -109,4 +109,112 @@ function wfu_ajax_action_save_shortcode() {
|
|
109 |
die("save_shortcode_success");
|
110 |
}
|
111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
?>
|
109 |
die("save_shortcode_success");
|
110 |
}
|
111 |
|
112 |
+
function wfu_ajax_action_read_subfolders() {
|
113 |
+
if ( !isset($_POST['folder1']) || !isset($_POST['folder2']) ) die();
|
114 |
+
$temp_params = array( 'uploadpath' => wfu_plugin_decode_string($_POST['folder1']), 'accessmethod' => 'normal', 'ftpinfo' => '', 'useftpdomain' => 'false' );
|
115 |
+
$path = wfu_upload_plugin_full_path($temp_params);
|
116 |
+
|
117 |
+
if ( !is_dir($path) ) die("error:Parent folder is not valid! Cannot retrieve subfolder list.");
|
118 |
+
|
119 |
+
$path2 = wfu_plugin_decode_string($_POST['folder2']);
|
120 |
+
$dirlist = "";
|
121 |
+
if ( $handle = opendir($path) ) {
|
122 |
+
$blacklist = array('.', '..');
|
123 |
+
while ( false !== ($file = readdir($handle)) )
|
124 |
+
if ( !in_array($file, $blacklist) ) {
|
125 |
+
$filepath = $path.$file;
|
126 |
+
if ( is_dir($filepath) ) {
|
127 |
+
if ( $file == $path2 ) $file = '[['.$file.']]';
|
128 |
+
$dirlist .= ( $dirlist == "" ? "" : "," ).$file;
|
129 |
+
}
|
130 |
+
}
|
131 |
+
closedir($handle);
|
132 |
+
}
|
133 |
+
if ( $path2 != "" ) {
|
134 |
+
$dirlist2 = $path2;
|
135 |
+
$path .= $path2."/";
|
136 |
+
if ( is_dir($path) ) {
|
137 |
+
if ( $handle = opendir($path) ) {
|
138 |
+
$blacklist = array('.', '..');
|
139 |
+
while ( false !== ($file = readdir($handle)) )
|
140 |
+
if ( !in_array($file, $blacklist) ) {
|
141 |
+
$filepath = $path.$file;
|
142 |
+
if ( is_dir($filepath) )
|
143 |
+
$dirlist2 .= ",*".$file;
|
144 |
+
}
|
145 |
+
closedir($handle);
|
146 |
+
}
|
147 |
+
}
|
148 |
+
$dirlist = str_replace('[['.$path2.']]', $dirlist2, $dirlist);
|
149 |
+
}
|
150 |
+
|
151 |
+
die("success:".wfu_plugin_encode_string($dirlist));
|
152 |
+
}
|
153 |
+
|
154 |
+
function wfu_ajax_action_download_file() {
|
155 |
+
$file_enc = (isset($_POST['file']) ? $_POST['file'] : (isset($_GET['file']) ? $_GET['file'] : ''));
|
156 |
+
$dataid = (isset($_POST['dataid']) ? $_POST['dataid'] : (isset($_GET['dataid']) ? $_GET['dataid'] : '-1'));
|
157 |
+
if ( $file_enc == '' || $dataid == '-1' ) die();
|
158 |
+
|
159 |
+
$filepath = wfu_plugin_decode_string($file_enc);
|
160 |
+
|
161 |
+
//check if user is allowed to perform this action
|
162 |
+
$user = wfu_current_user_allowed_action('download', $filepath);
|
163 |
+
if ( $user == null ) die();
|
164 |
+
|
165 |
+
//check that file exists
|
166 |
+
if ( !file_exists($filepath) ) die('<script language="javascript">alert("Error! File does not exist.");</script>');
|
167 |
+
|
168 |
+
$file_parts = pathinfo($filepath);
|
169 |
+
$fname = $file_parts['basename'];
|
170 |
+
$fsize = filesize($filepath);
|
171 |
+
$contents = "";
|
172 |
+
//send headers
|
173 |
+
header("Pragma: public");
|
174 |
+
header("Expires: 0");
|
175 |
+
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
176 |
+
header("Cache-Control: public");
|
177 |
+
header("Content-Description: File Transfer");
|
178 |
+
header("Content-Type: application/octet-stream");
|
179 |
+
header("Content-Disposition: attachment; filename=\"".$fname."\"");
|
180 |
+
header("Content-Transfer-Encoding: binary");
|
181 |
+
header("Content-Length: ".$fsize);
|
182 |
+
flush();
|
183 |
+
//send file contents
|
184 |
+
$failed = false;
|
185 |
+
$file = @fopen($filepath,"rb");
|
186 |
+
if ( $file ) {
|
187 |
+
while( !feof($file) ) {
|
188 |
+
print fread($file, 1024*8);
|
189 |
+
flush();
|
190 |
+
if ( connection_status() != 0 ) {
|
191 |
+
$failed = true;
|
192 |
+
break;
|
193 |
+
}
|
194 |
+
}
|
195 |
+
@fclose($file);
|
196 |
+
}
|
197 |
+
else $failed = true;
|
198 |
+
|
199 |
+
if ( !$failed ) {
|
200 |
+
wfu_log_action('download', $filepath, $user->ID, '', 0, '', null);
|
201 |
+
die();
|
202 |
+
}
|
203 |
+
else die('<script language="javascript">alert("Error! Could not download file.");</script>');
|
204 |
+
}
|
205 |
+
|
206 |
+
function wfu_ajax_action_notify_wpfilebase() {
|
207 |
+
$params_index = (isset($_POST['params_index']) ? $_POST['params_index'] : (isset($_GET['params_index']) ? $_GET['params_index'] : ''));
|
208 |
+
$session_token = (isset($_POST['session_token']) ? $_POST['session_token'] : (isset($_GET['session_token']) ? $_GET['session_token'] : ''));
|
209 |
+
if ( $params_index == '' || $session_token == '' ) die();
|
210 |
+
|
211 |
+
$arr = wfu_get_params_fields_from_index($params_index);
|
212 |
+
//check referer using server sessions to avoid CSRF attacks
|
213 |
+
if ( $_SESSION["wfu_token_".$arr['shortcode_id']] != $session_token ) die();
|
214 |
+
|
215 |
+
do_action('wpfilebase_sync');
|
216 |
+
|
217 |
+
die();
|
218 |
+
}
|
219 |
+
|
220 |
?>
|
lib/wfu_attributes.php
CHANGED
@@ -34,7 +34,7 @@ function wfu_component_definitions() {
|
|
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(
|
@@ -48,7 +48,7 @@ function wfu_component_definitions() {
|
|
48 |
"id" => "userdata",
|
49 |
"name" => "User Fields",
|
50 |
"mode" => "free",
|
51 |
-
"dimensions" =>
|
52 |
"help" => "Displays additional fields that the user must fill-in together with the uploaded files."
|
53 |
),
|
54 |
array(
|
@@ -123,7 +123,7 @@ function wfu_attribute_definitions() {
|
|
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(
|
@@ -248,14 +248,14 @@ function wfu_attribute_definitions() {
|
|
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" => "
|
259 |
"listitems" => null,
|
260 |
"value" => WFU_SUBFOLDERTREE,
|
261 |
"mode" => "free",
|
@@ -448,6 +448,20 @@ function wfu_attribute_definitions() {
|
|
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",
|
@@ -529,7 +543,7 @@ function wfu_attribute_definitions() {
|
|
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(
|
@@ -543,7 +557,7 @@ function wfu_attribute_definitions() {
|
|
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(
|
@@ -571,7 +585,7 @@ function wfu_attribute_definitions() {
|
|
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(
|
@@ -736,12 +750,27 @@ function wfu_attribute_definitions() {
|
|
736 |
"value" => WFU_MEDIALINK,
|
737 |
"mode" => "free",
|
738 |
"category" => "interoperability",
|
739 |
-
"subcategory" => "Connection With Other
|
740 |
"parent" => "",
|
741 |
"dependencies" => null,
|
742 |
"variables" => null,
|
743 |
-
"help" => "If enabled then the
|
744 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
745 |
);
|
746 |
|
747 |
wfu_array_remove_nulls($defs);
|
34 |
"id" => "subfolders",
|
35 |
"name" => "Subfolders",
|
36 |
"mode" => "free",
|
37 |
+
"dimensions" => array("uploadfolder_label/Upload Folder Label", "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(
|
48 |
"id" => "userdata",
|
49 |
"name" => "User Fields",
|
50 |
"mode" => "free",
|
51 |
+
"dimensions" => array("userdata/User Fields", "userdata_label/User Fields Label", "userdata_value/User Fields Value"),
|
52 |
"help" => "Displays additional fields that the user must fill-in together with the uploaded files."
|
53 |
),
|
54 |
array(
|
123 |
"subcategory" => "Basic Functionalities",
|
124 |
"parent" => "",
|
125 |
"dependencies" => null,
|
126 |
+
"variables" => array("%userid%", "%username%", "%blogid%", "%pageid%", "%pagetitle%", "%userdataXXX%"),
|
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(
|
248 |
"category" => "general",
|
249 |
"subcategory" => "Upload Path and Files",
|
250 |
"parent" => "",
|
251 |
+
"dependencies" => array("subfoldertree", "subfolderlabel"),
|
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" => "folderlist",
|
259 |
"listitems" => null,
|
260 |
"value" => WFU_SUBFOLDERTREE,
|
261 |
"mode" => "free",
|
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" => "Select Subfolder Label",
|
453 |
+
"attribute" => "subfolderlabel",
|
454 |
+
"type" => "text",
|
455 |
+
"listitems" => null,
|
456 |
+
"value" => WFU_SUBFOLDERLABEL,
|
457 |
+
"mode" => "free",
|
458 |
+
"category" => "labels",
|
459 |
+
"subcategory" => "Upload Folder",
|
460 |
+
"parent" => "",
|
461 |
+
"dependencies" => null,
|
462 |
+
"variables" => null,
|
463 |
+
"help" => "This is the label of the subfolder dropdown list. It is active when askforsubfolders attribute is on."
|
464 |
+
),
|
465 |
array(
|
466 |
"name" => "Success Upload Message",
|
467 |
"attribute" => "successmessage",
|
543 |
"subcategory" => "Email Notifications",
|
544 |
"parent" => "notify",
|
545 |
"dependencies" => null,
|
546 |
+
"variables" => array("%useremail%", "%userdataXXX%", "%n%", "%dq%"),
|
547 |
"help" => "Defines the recipients of the email notification. Can be dynamic by using variables. Please check Documentation on how to use variables in atributes."
|
548 |
),
|
549 |
array(
|
557 |
"subcategory" => "Email Notifications",
|
558 |
"parent" => "notify",
|
559 |
"dependencies" => null,
|
560 |
+
"variables" => array("%n%", "%dq%"),
|
561 |
"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."
|
562 |
),
|
563 |
array(
|
585 |
"subcategory" => "Email Notifications",
|
586 |
"parent" => "notify",
|
587 |
"dependencies" => null,
|
588 |
+
"variables" => array("%username%", "%useremail%", "%filename%", "%filepath%", "%userdataXXX%", "%n%", "%dq%"),
|
589 |
"help" => "Defines the email body. Can be dynamic by using variables. Please check Documentation on how to use variables in atributes."
|
590 |
),
|
591 |
array(
|
750 |
"value" => WFU_MEDIALINK,
|
751 |
"mode" => "free",
|
752 |
"category" => "interoperability",
|
753 |
+
"subcategory" => "Connection With Other Wordpress Features",
|
754 |
"parent" => "",
|
755 |
"dependencies" => null,
|
756 |
"variables" => null,
|
757 |
+
"help" => "If enabled then the uploaded files will be added to the Media library of your Wordpress website. Please note that the upload path must be inside the wp-content/uploads directory (which is the default upload path)."
|
758 |
+
),
|
759 |
+
array(
|
760 |
+
"name" => "Attach Uploaded Files To Post",
|
761 |
+
"attribute" => "postlink",
|
762 |
+
"type" => "onoff",
|
763 |
+
"listitems" => null,
|
764 |
+
"value" => WFU_POSTLINK,
|
765 |
+
"mode" => "free",
|
766 |
+
"category" => "interoperability",
|
767 |
+
"subcategory" => "Connection With Other Wordpress Features",
|
768 |
+
"parent" => "",
|
769 |
+
"dependencies" => null,
|
770 |
+
"variables" => null,
|
771 |
+
"help" => "If enabled then the uploaded files will be added to the current post as attachments. Please note that the upload path must be inside the wp-content/uploads directory (which is the default upload path)."
|
772 |
+
),
|
773 |
+
null
|
774 |
);
|
775 |
|
776 |
wfu_array_remove_nulls($defs);
|
lib/wfu_blocks.php
CHANGED
@@ -4,79 +4,60 @@
|
|
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 |
-
|
11 |
-
if ( $
|
|
|
12 |
if ( $styles1 != "" ) $styles1 = ' style="'.$styles1.'"';
|
13 |
-
$
|
14 |
-
if ( $
|
15 |
-
if ( $
|
16 |
-
$
|
|
|
|
|
|
|
17 |
$subfolder_paths = array ( );
|
18 |
-
|
|
|
|
|
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 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
$subfolders_item["
|
35 |
-
$subfolders_item["
|
36 |
-
$
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
$
|
41 |
-
$
|
42 |
-
$
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
}
|
50 |
-
|
51 |
-
|
52 |
-
$
|
53 |
-
if ( $
|
54 |
-
|
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".$
|
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;
|
@@ -147,6 +128,7 @@ function wfu_prepare_uploadform_block($params, $widths, $heights, $clickaction,
|
|
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="" />';
|
@@ -219,19 +201,28 @@ function wfu_prepare_userdata_block($params, $widths, $heights) {
|
|
219 |
|
220 |
$userdata_item["title"] = 'wordpress_file_upload_userdata_'.$sid;
|
221 |
$userdata_item["hidden"] = false;
|
222 |
-
$
|
223 |
-
if ( $widths["userdata"] != "" ) $
|
224 |
-
if ( $heights["userdata"] != "" ) $
|
225 |
-
if ( $
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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"'.$
|
229 |
-
$
|
|
|
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 |
|
4 |
function wfu_prepare_subfolders_block($params, $widths, $heights) {
|
5 |
$sid = $params["uploadid"];
|
6 |
$selectsubdir = 'selectsubdir_'.$sid;
|
7 |
+
$defaultvalue = 'selectsubdirdefault_'.$sid;
|
8 |
$hiddeninput = 'hiddeninput_'.$sid;
|
9 |
$subfolders_item = null;
|
10 |
$styles1 = "";
|
11 |
+
$styles2 = "";
|
12 |
+
if ( $widths["uploadfolder_label"] != "" ) $styles1 .= 'width: '.$widths["uploadfolder_label"].'; display:inline-block;';
|
13 |
+
if ( $heights["uploadfolder_label"] != "" ) $styles1 .= 'height: '.$heights["uploadfolder_label"].'; ';
|
14 |
if ( $styles1 != "" ) $styles1 = ' style="'.$styles1.'"';
|
15 |
+
if ( $widths["subfolders_label"] != "" ) $styles2 .= 'width: '.$widths["subfolders_label"].'; display:inline-block;';
|
16 |
+
if ( $heights["subfolders_label"] != "" ) $styles2 .= 'height: '.$heights["subfolders_label"].'; ';
|
17 |
+
if ( $styles2 != "" ) $styles2 = ' style="'.$styles2.'"';
|
18 |
+
$styles3 = "border: 1px solid; border-color: #BBBBBB;";
|
19 |
+
if ( $widths["subfolders_select"] != "" ) $styles3 .= 'width: '.$widths["subfolders_select"].'; ';
|
20 |
+
if ( $heights["subfolders_select"] != "" ) $styles3 .= 'height: '.$heights["subfolders_select"].'; ';
|
21 |
+
$styles3 = ' style="'.$styles3.'"';
|
22 |
$subfolder_paths = array ( );
|
23 |
+
$linebr = "";
|
24 |
+
if ( $params["showtargetfolder"] == "true" || $params["askforsubfolders"] == "true" ) {
|
25 |
+
$linebr = '<br />';
|
26 |
$subfolders_item["title"] = 'wordpress_file_upload_subfolders_'.$sid;
|
27 |
$subfolders_item["hidden"] = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
}
|
29 |
+
$i = 1;
|
30 |
+
if ( $params["showtargetfolder"] == "true" ) {
|
31 |
+
$upload_directory = wfu_upload_plugin_directory($params["uploadpath"]);
|
32 |
+
$subfolders_item["line".$i++] = '<span'.$styles1.'>'.$params["targetfolderlabel"].': <strong>'.$upload_directory.'</strong></span>'.$linebr;
|
33 |
+
}
|
34 |
+
if ( $params["askforsubfolders"] == "true" ) {
|
35 |
+
$subfolders_item["line".$i++] = '<span class="file_item_clean"'.$styles2.'>'.$params["subfolderlabel"].' </span>';
|
36 |
+
$subfolders_item["line".$i++] = '<select class="file_item_clean"'.$styles3.' id="'.$selectsubdir.'" onchange="wfu_selectsubdir_check('.$sid.');">';
|
37 |
+
if ( $params["testmode"] == "true" ) {
|
38 |
+
$subfolders_item["line".$i++] = "\t".'<option>'.WFU_NOTIFY_TESTMODE.'</option>';
|
39 |
+
}
|
40 |
+
else {
|
41 |
+
$zeroind = $i;
|
42 |
+
$subfolders_item["line".$i++] = "\t".'<option>'.WFU_SUBDIR_SELECTDIR.'</option>';
|
43 |
+
array_push($subfolder_paths, "");
|
44 |
+
$subfolders = wfu_parse_folderlist($params["subfoldertree"]);
|
45 |
+
if ( count($subfolders['path']) == 0 ) {
|
46 |
+
array_push($subfolders['path'], "");
|
47 |
+
array_push($subfolders['label'], wfu_upload_plugin_directory($params["uploadpath"]));
|
48 |
+
array_push($subfolders['level'], 0);
|
49 |
+
array_push($subfolders['default'], false);
|
50 |
}
|
51 |
+
$default = -1;
|
52 |
+
foreach ($subfolders['path'] as $ind => $subfolder) {
|
53 |
+
array_push($subfolder_paths, $subfolder);
|
54 |
+
if ( $subfolders['default'][$ind] ) $default = intval($ind) + 1;
|
55 |
+
$subfolders_item["line".$i++] = "\t".'<option'.( $subfolders['default'][$ind] ? ' selected="selected"' : '' ).'>'.str_repeat(" ", intval($subfolders['level'][$ind])).$subfolders['label'][$ind].'</option>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
}
|
57 |
+
if ( $default != -1 ) $subfolders_item["line".$zeroind] = "\t".'<option style="display:none;">'.WFU_SUBDIR_SELECTDIR.'</option>';
|
58 |
}
|
59 |
+
$subfolders_item["line".$i++] = '</select>';
|
60 |
+
$subfolders_item["line".$i++] = '<input id="'.$defaultvalue.'" type="hidden" value="'.$default.'" />';
|
|
|
|
|
|
|
|
|
|
|
61 |
}
|
62 |
|
63 |
$subfolders['item'] = $subfolders_item;
|
128 |
else
|
129 |
$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.');"'.' />';
|
130 |
$uploadform_item["line".$i++] = "\t".'<input type="hidden" id="hiddeninput_'.$sid.'" name="hiddeninput_'.$sid.'" value="" />';
|
131 |
+
$uploadform_item["line".$i++] = "\t".'<input type="hidden" id="uniqueuploadid_'.$sid.'" name="uniqueuploadid_'.$sid.'" value="" />';
|
132 |
$uploadform_item["line".$i++] = "\t".'<input type="hidden" id="adminerrorcodes_'.$sid.'" name="adminerrorcodes_'.$sid.'" value="" />';
|
133 |
foreach ($params["userdata_fields"] as $userdata_key => $userdata_field)
|
134 |
$uploadform_item["line".$i++] = "\t".'<input type="hidden" id="hiddeninput_'.$sid.'_userdata_'.$userdata_key.'" name="hiddeninput_'.$sid.'_userdata_'.$userdata_key.'" value="" />';
|
201 |
|
202 |
$userdata_item["title"] = 'wordpress_file_upload_userdata_'.$sid;
|
203 |
$userdata_item["hidden"] = false;
|
204 |
+
$styles1 = "";
|
205 |
+
if ( $widths["userdata"] != "" ) $styles1 .= 'width: '.$widths["userdata"].'; ';
|
206 |
+
if ( $heights["userdata"] != "" ) $styles1 .= 'height: '.$heights["userdata"].'; ';
|
207 |
+
if ( $styles1 != "" ) $styles1 = ' style="'.$styles1.'"';
|
208 |
+
$styles2 = "";
|
209 |
+
if ( $widths["userdata_label"] != "" ) $styles2 .= 'width: '.$widths["userdata_label"].'; ';
|
210 |
+
if ( $heights["userdata_label"] != "" ) $styles2 .= 'height: '.$heights["userdata_label"].'; ';
|
211 |
+
if ( $styles2 != "" ) $styles2 = ' style="'.$styles2.'"';
|
212 |
+
$styles3 = "";
|
213 |
+
if ( $widths["userdata_value"] != "" ) $styles3 .= 'width: '.$widths["userdata_value"].'; ';
|
214 |
+
if ( $heights["userdata_value"] != "" ) $styles3 .= 'height: '.$heights["userdata_value"].'; ';
|
215 |
+
if ( $styles3 != "" ) $styles3 = ' style="'.$styles3.'"';
|
216 |
$i = 1;
|
217 |
foreach ($params["userdata_fields"] as $userdata_key => $userdata_field) {
|
218 |
+
$userdata_item["line".$i++] = '<div id="'.$userdata.'_'.$userdata_key.'" class="file_userdata_container"'.$styles1.'>';
|
219 |
+
$userdata_item_label = $userdata_field["label"].( $userdata_field["required"] == "true" ? WFU_USERDATA_REQUIREDLABEL : "" );
|
220 |
+
$userdata_item["line".$i++] = "\t".'<label id="'.$userdata.'_label_'.$userdata_key.'" for="'.$userdata.'_message_'.$userdata_key.'" class="file_userdata_label"'.$styles2.'>'.$userdata_item_label.'</label>';
|
221 |
$userdata_item_class = ( $userdata_field["required"] == "true" ? "file_userdata_message_required" : "file_userdata_message" );
|
222 |
if ( $params["testmode"] == "true" )
|
223 |
+
$userdata_item["line".$i++] = "\t".'<input type="text" id="'.$userdata.'_message_'.$userdata_key.'" class="'.$userdata_item_class.'" value="Test message" readonly="readonly"'.$styles3.' />';
|
224 |
else
|
225 |
+
$userdata_item["line".$i++] = "\t".'<input type="text" id="'.$userdata.'_message_'.$userdata_key.'" class="'.$userdata_item_class.'" value=""'.$styles3.' 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\';}" />';
|
226 |
$userdata_item["line".$i++] = '</div>';
|
227 |
}
|
228 |
|
lib/wfu_constants.php
CHANGED
@@ -40,6 +40,7 @@ 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");
|
@@ -50,6 +51,7 @@ DEFINE("WFU_PLACEMENTS", "title/filename+selectbutton+uploadbutton/subfolders"."
|
|
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"));
|
@@ -102,8 +104,10 @@ DEFINE("WFU_WARNING_REDIRECT_NOTEXECUTED_FILESFAILED", __("Redirection not execu
|
|
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'));
|
@@ -116,11 +120,14 @@ DEFINE("WFU_TESTMESSAGE_FILE2_MESSAGE", __('File testfile 2 message', 'wordpress
|
|
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 |
|
@@ -164,6 +171,10 @@ DEFINE("WFU_IMAGE_ADMIN_HELP", $siteurl.WPFILEUPLOAD_DIR.'images/help_16.png');
|
|
164 |
DEFINE("WFU_IMAGE_ADMIN_RESTOREDEFAULT", $siteurl.WPFILEUPLOAD_DIR.'images/restore_16.png');
|
165 |
DEFINE("WFU_IMAGE_ADMIN_USERDATA_ADD", $siteurl.WPFILEUPLOAD_DIR.'images/add_12.png');
|
166 |
DEFINE("WFU_IMAGE_ADMIN_USERDATA_REMOVE", $siteurl.WPFILEUPLOAD_DIR.'images/remove_12.png');
|
|
|
|
|
|
|
|
|
167 |
DEFINE("WFU_IMAGE_SIMPLE_PROGBAR", $siteurl.WPFILEUPLOAD_DIR.'images/progbar.gif');
|
168 |
|
169 |
function wfu_set_javascript_constants() {
|
40 |
DEFINE("WFU_SHOWTARGETFOLDER", "false");
|
41 |
DEFINE("WFU_TARGETFOLDERLABEL", "Upload Directory");
|
42 |
DEFINE("WFU_ASKFORSUBFOLDERS", "false");
|
43 |
+
DEFINE("WFU_SUBFOLDERLABEL", "Select Subfolder");
|
44 |
DEFINE("WFU_SUBFOLDERTREE", "");
|
45 |
DEFINE("WFU_FORCECLASSIC", "false");
|
46 |
DEFINE("WFU_TESTMODE", "false");
|
51 |
DEFINE("WFU_USERDATA", "false");
|
52 |
DEFINE("WFU_USERDATALABEL", __('Your message', 'wordpress-file-upload'));
|
53 |
DEFINE("WFU_MEDIALINK", "false");
|
54 |
+
DEFINE("WFU_POSTLINK", "false");
|
55 |
|
56 |
//define plugin errors
|
57 |
DEFINE("WFU_ERROR_ADMIN_FTPDIR_RESOLVE", __("Error. Could not resolve ftp target filedir. Check the domain in 'ftpinfo' attribute.", "wordpress-file-upload"));
|
104 |
|
105 |
//define plugin messages
|
106 |
DEFINE("WFU_NOTIFY_TESTMODE", __("Test Mode", "wordpress-file-upload"));
|
107 |
+
DEFINE("WFU_SUBDIR_SELECTDIR", __("select dir...", "wordpress-file-upload"));
|
108 |
DEFINE("WFU_SUCCESSMESSAGE_DETAILS", __('Upload path: %filepath%', 'wordpress-file-upload'));
|
109 |
DEFINE("WFU_FAILMESSAGE_DETAILS", __('Failed upload path: %filepath%', 'wordpress-file-upload'));
|
110 |
+
DEFINE("WFU_USERDATA_REQUIREDLABEL", __(' (required)', 'wordpress-file-upload'));
|
111 |
|
112 |
//define plugin test messages
|
113 |
DEFINE("WFU_TESTMESSAGE_MESSAGE", __('This is a test message', 'wordpress-file-upload'));
|
120 |
DEFINE("WFU_TESTMESSAGE_FILE2_ADMINMESSAGE", __('File testfile 2 administrator message', 'wordpress-file-upload'));
|
121 |
|
122 |
//define tool tip constants
|
123 |
+
DEFINE("WFU_VARIABLE_TITLE_USERID", __("Insert variable %userid% inside text. It will be replaced by the id of the current user.", "wordpress-file-upload"));
|
124 |
DEFINE("WFU_VARIABLE_TITLE_USERNAME", __("Insert variable %username% inside text. It will be replaced by the username of the current user.", "wordpress-file-upload"));
|
125 |
DEFINE("WFU_VARIABLE_TITLE_USEREMAIL", __("Insert variable %useremail% inside text. It will be replaced by the email of the current user.", "wordpress-file-upload"));
|
126 |
DEFINE("WFU_VARIABLE_TITLE_FILENAME", __("Insert variable %filename% inside text. It will be replaced by the filename of the uploaded file.", "wordpress-file-upload"));
|
127 |
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"));
|
128 |
DEFINE("WFU_VARIABLE_TITLE_BLOGID", __("Insert variable %blogid% inside text. It will be replaced by the blog id of the website.", "wordpress-file-upload"));
|
129 |
+
DEFINE("WFU_VARIABLE_TITLE_PAGEID", __("Insert variable %pageid% inside text. It will be replaced by the id of the current page.", "wordpress-file-upload"));
|
130 |
+
DEFINE("WFU_VARIABLE_TITLE_PAGETITLE", __("Insert variable %pagetitle% inside text. It will be replaced by the title of the current page.", "wordpress-file-upload"));
|
131 |
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"));
|
132 |
DEFINE("WFU_VARIABLE_TITLE_N", __("Insert variable %n% inside text to denote a line change.", "wordpress-file-upload"));
|
133 |
|
171 |
DEFINE("WFU_IMAGE_ADMIN_RESTOREDEFAULT", $siteurl.WPFILEUPLOAD_DIR.'images/restore_16.png');
|
172 |
DEFINE("WFU_IMAGE_ADMIN_USERDATA_ADD", $siteurl.WPFILEUPLOAD_DIR.'images/add_12.png');
|
173 |
DEFINE("WFU_IMAGE_ADMIN_USERDATA_REMOVE", $siteurl.WPFILEUPLOAD_DIR.'images/remove_12.png');
|
174 |
+
DEFINE("WFU_IMAGE_ADMIN_SUBFOLDER_BROWSE", $siteurl.WPFILEUPLOAD_DIR.'images/tree_16.gif');
|
175 |
+
DEFINE("WFU_IMAGE_ADMIN_SUBFOLDER_OK", $siteurl.WPFILEUPLOAD_DIR.'images/ok_12.gif');
|
176 |
+
DEFINE("WFU_IMAGE_ADMIN_SUBFOLDER_CANCEL", $siteurl.WPFILEUPLOAD_DIR.'images/cancel_12.gif');
|
177 |
+
DEFINE("WFU_IMAGE_ADMIN_SUBFOLDER_LOADING", $siteurl.WPFILEUPLOAD_DIR.'images/refresh_16.gif');
|
178 |
DEFINE("WFU_IMAGE_SIMPLE_PROGBAR", $siteurl.WPFILEUPLOAD_DIR.'images/progbar.gif');
|
179 |
|
180 |
function wfu_set_javascript_constants() {
|
lib/wfu_functions.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
//********************* String Functions
|
4 |
|
5 |
function wfu_upload_plugin_clean($label) {
|
6 |
/**
|
@@ -12,6 +12,7 @@ function wfu_upload_plugin_clean($label) {
|
|
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 |
|
@@ -74,7 +75,7 @@ function wfu_create_string($size) {
|
|
74 |
return $str;
|
75 |
}
|
76 |
|
77 |
-
//********************* Array Functions
|
78 |
|
79 |
function wfu_encode_array_to_string($arr) {
|
80 |
$arr_str = json_encode($arr);
|
@@ -194,12 +195,13 @@ function wfu_array_sort($array, $on, $order=SORT_ASC) {
|
|
194 |
return $new_array;
|
195 |
}
|
196 |
|
197 |
-
//********************* Plugin Options Functions
|
198 |
|
199 |
function wfu_encode_plugin_options($plugin_options) {
|
200 |
$encoded_options = 'version='.$plugin_options['version'].';';
|
201 |
$encoded_options .= 'shortcode='.wfu_plugin_encode_string($plugin_options['shortcode']).';';
|
202 |
-
|
|
|
203 |
return $encoded_options;
|
204 |
}
|
205 |
|
@@ -285,7 +287,74 @@ function wfu_delTree($dir) {
|
|
285 |
return rmdir($dir);
|
286 |
}
|
287 |
|
288 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
289 |
|
290 |
function wfu_get_user_role($user, $param_roles) {
|
291 |
if ( !empty( $user->roles ) && is_array( $user->roles ) ) {
|
@@ -310,7 +379,383 @@ function wfu_get_user_role($user, $param_roles) {
|
|
310 |
return $result_role;
|
311 |
}
|
312 |
|
313 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
314 |
|
315 |
function wfu_generate_current_params_index($shortcode_id, $user_login) {
|
316 |
global $post;
|
@@ -363,6 +808,7 @@ function wfu_get_params_fields_from_index($params_index) {
|
|
363 |
function wfu_decode_dimensions($dimensions_str) {
|
364 |
$components = wfu_component_definitions();
|
365 |
$dimensions = array();
|
|
|
366 |
foreach ( $components as $comp ) {
|
367 |
if ( $comp['dimensions'] == null ) $dimensions[$comp['id']] = "";
|
368 |
else foreach ( $comp['dimensions'] as $dimraw ) {
|
@@ -381,7 +827,7 @@ function wfu_decode_dimensions($dimensions_str) {
|
|
381 |
return $dimensions;
|
382 |
}
|
383 |
|
384 |
-
//********************* Plugin Design Functions
|
385 |
|
386 |
function wfu_add_div() {
|
387 |
$items_count = func_num_args();
|
@@ -420,7 +866,7 @@ function wfu_add_div() {
|
|
420 |
return $div;
|
421 |
}
|
422 |
|
423 |
-
//********************* Email Functions
|
424 |
|
425 |
function wfu_send_notification_email($user, $only_filename_list, $target_path_list, $attachment_list, $userdata_fields, $params) {
|
426 |
if ( 0 == $user->ID ) {
|
@@ -454,71 +900,25 @@ function wfu_send_notification_email($user, $only_filename_list, $target_path_li
|
|
454 |
return ( $notify_sent ? "" : WFU_WARNING_NOTIFY_NOTSENT_UNKNOWNERROR );
|
455 |
}
|
456 |
|
457 |
-
//********************* Media Functions
|
458 |
|
459 |
// function wfu_process_media_insert contribution from Aaron Olin
|
460 |
-
function wfu_process_media_insert($file_path){
|
461 |
-
$
|
462 |
-
$ext = strtolower( pathinfo($file_path, PATHINFO_EXTENSION) );
|
463 |
-
|
464 |
-
switch($ext){
|
465 |
-
case 'pdf':
|
466 |
-
$filetype = 'application/pdf';
|
467 |
-
break;
|
468 |
-
// images
|
469 |
-
case 'bmp':
|
470 |
-
$filetype = 'image/bmp';
|
471 |
-
break;
|
472 |
-
case 'gif':
|
473 |
-
$filetype = 'image/gif';
|
474 |
-
break;
|
475 |
-
case ( preg_match('~\b(jpg|jpeg)\b~i', $ext) ) ? true : false :
|
476 |
-
$filetype = 'image/jpeg';
|
477 |
-
break;
|
478 |
-
case 'png':
|
479 |
-
$filetype = 'image/png';
|
480 |
-
break;
|
481 |
-
// office apps
|
482 |
-
case ( preg_match('~\b(doc|docx)\b~i', $ext) ) ? true : false :
|
483 |
-
$filetype = 'application/msword';
|
484 |
-
break;
|
485 |
-
case ( preg_match('~\b(ppt|pptx)\b~i', $ext) ) ? true : false :
|
486 |
-
$filetype = 'application/vnd.ms-powerpoint';
|
487 |
-
break;
|
488 |
-
case ( preg_match('~\b(xls|xlsx)\b~i', $ext) ) ? true : false :
|
489 |
-
$filetype = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
|
490 |
-
break;
|
491 |
-
// compression
|
492 |
-
case 'zip':
|
493 |
-
$filetype = 'application/zip';
|
494 |
-
break;
|
495 |
-
case 'rar':
|
496 |
-
$filetype = 'application/rar';
|
497 |
-
break;
|
498 |
-
|
499 |
-
default:
|
500 |
-
$filetype = 'application/msword';
|
501 |
-
break; }
|
502 |
|
503 |
$attachment = array(
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
'post_status' => 'inherit'
|
509 |
);
|
510 |
|
511 |
-
|
512 |
-
$attach_id = wp_insert_attachment( $attachment, $file_path);
|
513 |
|
514 |
// If file is an image, process the default thumbnails for previews
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
require_once(ABSPATH . 'wp-admin/includes/media.php');
|
519 |
-
$attach_data = wp_generate_attachment_metadata( $attach_id, $file_path );
|
520 |
-
$update_attach = wp_update_attachment_metadata( $attach_id, $attach_data );
|
521 |
-
}
|
522 |
|
523 |
return $attach_id;
|
524 |
}
|
1 |
<?php
|
2 |
|
3 |
+
//********************* String Functions ***************************************************************************************************
|
4 |
|
5 |
function wfu_upload_plugin_clean($label) {
|
6 |
/**
|
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 |
+
// $label = preg_replace('/[\\/\?%\*:\|\"<>]/', '-', $label);
|
16 |
return $label;
|
17 |
}
|
18 |
|
75 |
return $str;
|
76 |
}
|
77 |
|
78 |
+
//********************* Array Functions ****************************************************************************************************
|
79 |
|
80 |
function wfu_encode_array_to_string($arr) {
|
81 |
$arr_str = json_encode($arr);
|
195 |
return $new_array;
|
196 |
}
|
197 |
|
198 |
+
//********************* Plugin Options Functions *******************************************************************************************
|
199 |
|
200 |
function wfu_encode_plugin_options($plugin_options) {
|
201 |
$encoded_options = 'version='.$plugin_options['version'].';';
|
202 |
$encoded_options .= 'shortcode='.wfu_plugin_encode_string($plugin_options['shortcode']).';';
|
203 |
+
$encoded_options .= 'hashfiles='.$plugin_options['hashfiles'].';';
|
204 |
+
$encoded_options .= 'basedir='.wfu_plugin_encode_string($plugin_options['basedir']);
|
205 |
return $encoded_options;
|
206 |
}
|
207 |
|
287 |
return rmdir($dir);
|
288 |
}
|
289 |
|
290 |
+
function wfu_parse_folderlist($subfoldertree) {
|
291 |
+
$ret['path'] = array();
|
292 |
+
$ret['label'] = array();
|
293 |
+
$ret['level'] = array();
|
294 |
+
$ret['default'] = array();
|
295 |
+
|
296 |
+
$subfolders = explode(",", $subfoldertree);
|
297 |
+
if ( count($subfolders) == 0 ) return $ret;
|
298 |
+
if ( count($subfolders) == 1 && trim($subfolders[0]) == "" ) return $ret;
|
299 |
+
$dir_levels = array ( "root" );
|
300 |
+
$prev_level = 0;
|
301 |
+
$level0_count = 0;
|
302 |
+
$default = -1;
|
303 |
+
foreach ($subfolders as $subfolder) {
|
304 |
+
$subfolder = trim($subfolder);
|
305 |
+
$star_count = 0;
|
306 |
+
$start_spaces = "";
|
307 |
+
$is_default = false;
|
308 |
+
//check for folder level
|
309 |
+
while ( $star_count < strlen($subfolder) ) {
|
310 |
+
if ( substr($subfolder, $star_count, 1) == "*" ) {
|
311 |
+
$star_count ++;
|
312 |
+
$start_spaces .= " ";
|
313 |
+
}
|
314 |
+
else break;
|
315 |
+
}
|
316 |
+
if ( $star_count - $prev_level <= 1 && ( $star_count > 0 || $level0_count == 0 ) ) {
|
317 |
+
$subfolder = substr($subfolder, $star_count, strlen($subfolder) - $star_count);
|
318 |
+
// check for default value
|
319 |
+
if ( substr($subfolder, 0, 1) == '&' ) {
|
320 |
+
$subfolder = substr($subfolder, 1);
|
321 |
+
$is_default = true;
|
322 |
+
}
|
323 |
+
//split item in folder path and folder name
|
324 |
+
$subfolder_items = explode('/', $subfolder);
|
325 |
+
if ( $subfolder_items[1] != "" ) {
|
326 |
+
$subfolder_dir = $subfolder_items[0];
|
327 |
+
$subfolder_label = $subfolder_items[1];
|
328 |
+
}
|
329 |
+
else {
|
330 |
+
$subfolder_dir = $subfolder;
|
331 |
+
$subfolder_label = $subfolder;
|
332 |
+
}
|
333 |
+
if ( $subfolder_dir != "" ) {
|
334 |
+
// set is_default flag to true only for the first default item
|
335 |
+
if ( $is_default && $default == -1 ) $default = count($ret['path']);
|
336 |
+
else $is_default = false;
|
337 |
+
// set flag that root folder has been included (so that it is not included it again)
|
338 |
+
if ( $star_count == 0 ) $level0_count = 1;
|
339 |
+
if ( count($dir_levels) > $star_count ) $dir_levels[$star_count] = $subfolder_dir;
|
340 |
+
else array_push($dir_levels, $subfolder_dir);
|
341 |
+
$subfolder_path = "";
|
342 |
+
for ( $i_count = 1; $i_count <= $star_count; $i_count++) {
|
343 |
+
$subfolder_path .= $dir_levels[$i_count].'/';
|
344 |
+
}
|
345 |
+
array_push($ret['path'], $subfolder_path);
|
346 |
+
array_push($ret['label'], $subfolder_label);
|
347 |
+
array_push($ret['level'], $star_count);
|
348 |
+
array_push($ret['default'], $is_default);
|
349 |
+
$prev_level = $star_count;
|
350 |
+
}
|
351 |
+
}
|
352 |
+
}
|
353 |
+
|
354 |
+
return $ret;
|
355 |
+
}
|
356 |
+
|
357 |
+
//********************* User Functions *****************************************************************************************************
|
358 |
|
359 |
function wfu_get_user_role($user, $param_roles) {
|
360 |
if ( !empty( $user->roles ) && is_array( $user->roles ) ) {
|
379 |
return $result_role;
|
380 |
}
|
381 |
|
382 |
+
//*********************** DB Functions *****************************************************************************************************
|
383 |
+
|
384 |
+
//log action to database
|
385 |
+
function wfu_log_action($action, $filepath, $userid, $uploadid, $pageid, $sid, $userdata) {
|
386 |
+
global $wpdb;
|
387 |
+
$table_name1 = $wpdb->prefix . "wfu_log";
|
388 |
+
$table_name2 = $wpdb->prefix . "wfu_userdata";
|
389 |
+
$plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
|
390 |
+
|
391 |
+
if ( !file_exists($filepath) && substr($action, 0, 5) != 'other' ) return;
|
392 |
+
$parts = pathinfo($filepath);
|
393 |
+
$relativepath = str_replace(ABSPATH, '', $filepath);
|
394 |
+
if ( substr($relativepath, 0, 1) != '/' ) $relativepath = '/'.$relativepath;
|
395 |
+
|
396 |
+
$retid = 0;
|
397 |
+
if ( $action == 'upload' ) {
|
398 |
+
// calculate and store file hash if this setting is enabled from Settings
|
399 |
+
$filehash = '';
|
400 |
+
if ( $plugin_options['hashfiles'] == '1' ) $filehash = md5_file($filepath);
|
401 |
+
// calculate file size
|
402 |
+
$filesize = filesize($filepath);
|
403 |
+
// first make obsolete records having the same file path because the old file has been replaced
|
404 |
+
$wpdb->update($table_name1,
|
405 |
+
array( 'date_to' => date('Y-m-d H:i:s') ),
|
406 |
+
array( 'filepath' => $relativepath ),
|
407 |
+
array( '%s'),
|
408 |
+
array( '%s')
|
409 |
+
);
|
410 |
+
// attempt to create new log record
|
411 |
+
$now_date = date('Y-m-d H:i:s');
|
412 |
+
if ( $wpdb->insert($table_name1,
|
413 |
+
array(
|
414 |
+
'userid' => $userid,
|
415 |
+
'uploaduserid' => $userid,
|
416 |
+
'filepath' => $relativepath,
|
417 |
+
'filehash' => $filehash,
|
418 |
+
'filesize' => $filesize,
|
419 |
+
'uploadid' => $uploadid,
|
420 |
+
'pageid' => $pageid,
|
421 |
+
'sid' => $sid,
|
422 |
+
'date_from' => $now_date,
|
423 |
+
'date_to' => 0,
|
424 |
+
'action' => 'upload'
|
425 |
+
),
|
426 |
+
array(
|
427 |
+
'%d',
|
428 |
+
'%d',
|
429 |
+
'%s',
|
430 |
+
'%s',
|
431 |
+
'%d',
|
432 |
+
'%s',
|
433 |
+
'%d',
|
434 |
+
'%s',
|
435 |
+
'%s',
|
436 |
+
'%s',
|
437 |
+
'%s'
|
438 |
+
)) !== false ) {
|
439 |
+
$retid = $wpdb->insert_id;
|
440 |
+
// if new log record has been created, also create user data records
|
441 |
+
if ( $userdata != null && $uploadid != '' ) {
|
442 |
+
foreach ( $userdata as $userdata_key => $userdata_field ) {
|
443 |
+
$existing = $wpdb->get_row('SELECT * FROM '.$table_name2.' WHERE uploadid = \''.$uploadid.'\' AND property = \''.$userdata_key.'\'');
|
444 |
+
if ($existing == null)
|
445 |
+
$wpdb->insert($table_name2,
|
446 |
+
array(
|
447 |
+
'uploadid' => $uploadid,
|
448 |
+
'property' => $userdata_field['label'],
|
449 |
+
'propkey' => $userdata_key,
|
450 |
+
'propvalue' => $userdata_field['value'],
|
451 |
+
'date_from' => $now_date,
|
452 |
+
'date_to' => 0
|
453 |
+
),
|
454 |
+
array(
|
455 |
+
'%s',
|
456 |
+
'%s',
|
457 |
+
'%d',
|
458 |
+
'%s',
|
459 |
+
'%s',
|
460 |
+
'%s'
|
461 |
+
)
|
462 |
+
);
|
463 |
+
}
|
464 |
+
}
|
465 |
+
}
|
466 |
+
}
|
467 |
+
//for rename action the $action variable is of the form: $action = 'rename:'.$newfilepath; in order to pass the new file path
|
468 |
+
elseif ( substr($action, 0, 6) == 'rename' ) {
|
469 |
+
//get new filepath
|
470 |
+
$newfilepath = substr($action, 7);
|
471 |
+
$relativepath = str_replace(ABSPATH, '', $newfilepath);
|
472 |
+
if ( substr($relativepath, 0, 1) != '/' ) $relativepath = '/'.$relativepath;
|
473 |
+
//get stored file data from database without user data
|
474 |
+
$filerec = wfu_get_file_rec($filepath, false);
|
475 |
+
//log action only if there are previous stored file data
|
476 |
+
if ( $filerec != null ) {
|
477 |
+
$now_date = date('Y-m-d H:i:s');
|
478 |
+
//make previous record obsolete
|
479 |
+
$wpdb->update($table_name1,
|
480 |
+
array( 'date_to' => $now_date ),
|
481 |
+
array( 'idlog' => $filerec->idlog ),
|
482 |
+
array( '%s' ),
|
483 |
+
array( '%d' )
|
484 |
+
);
|
485 |
+
//insert new rename record
|
486 |
+
if ( $wpdb->insert($table_name1,
|
487 |
+
array(
|
488 |
+
'userid' => $userid,
|
489 |
+
'uploaduserid' => $filerec->uploaduserid,
|
490 |
+
'filepath' => $relativepath,
|
491 |
+
'filehash' => $filerec->filehash,
|
492 |
+
'filesize' => $filerec->filesize,
|
493 |
+
'uploadid' => $filerec->uploadid,
|
494 |
+
'pageid' => $filerec->pageid,
|
495 |
+
'sid' => $filerec->sid,
|
496 |
+
'date_from' => $now_date,
|
497 |
+
'date_to' => 0,
|
498 |
+
'action' => 'rename',
|
499 |
+
'linkedto' => $filerec->idlog
|
500 |
+
),
|
501 |
+
array( '%d','%d', '%s', '%s', '%d', '%s', '%d', '%s', '%s', '%s', '%s', '%d' ) ) !== false )
|
502 |
+
$retid = $wpdb->insert_id;
|
503 |
+
}
|
504 |
+
}
|
505 |
+
elseif ( $action == 'delete' ) {
|
506 |
+
//get stored file data from database without user data
|
507 |
+
$filerec = wfu_get_file_rec($filepath, false);
|
508 |
+
//log action only if there are previous stored file data
|
509 |
+
if ( $filerec != null ) {
|
510 |
+
$now_date = date('Y-m-d H:i:s');
|
511 |
+
//make previous record obsolete
|
512 |
+
$wpdb->update($table_name1,
|
513 |
+
array( 'date_to' => $now_date ),
|
514 |
+
array( 'idlog' => $filerec->idlog ),
|
515 |
+
array( '%s' ),
|
516 |
+
array( '%d' )
|
517 |
+
);
|
518 |
+
//insert new delete record
|
519 |
+
if ( $wpdb->insert($table_name1,
|
520 |
+
array(
|
521 |
+
'userid' => $userid,
|
522 |
+
'uploaduserid' => $filerec->uploaduserid,
|
523 |
+
'filepath' => $filerec->filepath,
|
524 |
+
'filehash' => $filerec->filehash,
|
525 |
+
'filesize' => $filerec->filesize,
|
526 |
+
'uploadid' => $filerec->uploadid,
|
527 |
+
'pageid' => $filerec->pageid,
|
528 |
+
'sid' => $filerec->sid,
|
529 |
+
'date_from' => $now_date,
|
530 |
+
'date_to' => $now_date,
|
531 |
+
'action' => 'delete',
|
532 |
+
'linkedto' => $filerec->idlog
|
533 |
+
),
|
534 |
+
array( '%d','%d', '%s', '%s', '%d', '%s', '%d', '%s', '%s', '%s', '%s', '%d' )) != false )
|
535 |
+
$retid = $wpdb->insert_id;
|
536 |
+
}
|
537 |
+
}
|
538 |
+
elseif ( $action == 'download' ) {
|
539 |
+
//get stored file data from database without user data
|
540 |
+
$filerec = wfu_get_file_rec($filepath, false);
|
541 |
+
//log action only if there are previous stored file data
|
542 |
+
if ( $filerec != null ) {
|
543 |
+
$now_date = date('Y-m-d H:i:s');
|
544 |
+
//make previous record obsolete
|
545 |
+
$wpdb->update($table_name1,
|
546 |
+
array( 'date_to' => $now_date ),
|
547 |
+
array( 'idlog' => $filerec->idlog ),
|
548 |
+
array( '%s' ),
|
549 |
+
array( '%d' )
|
550 |
+
);
|
551 |
+
//insert new download record
|
552 |
+
if ( $wpdb->insert($table_name1,
|
553 |
+
array(
|
554 |
+
'userid' => $userid,
|
555 |
+
'uploaduserid' => $filerec->uploaduserid,
|
556 |
+
'filepath' => $filerec->filepath,
|
557 |
+
'filehash' => $filerec->filehash,
|
558 |
+
'filesize' => $filerec->filesize,
|
559 |
+
'uploadid' => $filerec->uploadid,
|
560 |
+
'pageid' => $filerec->pageid,
|
561 |
+
'sid' => $filerec->sid,
|
562 |
+
'date_from' => $now_date,
|
563 |
+
'date_to' => 0,
|
564 |
+
'action' => 'download',
|
565 |
+
'linkedto' => $filerec->idlog
|
566 |
+
),
|
567 |
+
array( '%d','%d', '%s', '%s', '%d', '%s', '%d', '%s', '%s', '%s', '%s', '%d' )) != false )
|
568 |
+
$retid = $wpdb->insert_id;
|
569 |
+
}
|
570 |
+
}
|
571 |
+
//for modify action the $action variable is of the form: $action = 'modify:'.$now_date; in order to pass the exact modify date
|
572 |
+
elseif ( substr($action, 0, 6) == 'modify' ) {
|
573 |
+
$now_date = substr($action, 7);
|
574 |
+
//get stored file data from database without user data
|
575 |
+
$filerec = wfu_get_file_rec($filepath, false);
|
576 |
+
//log action only if there are previous stored file data
|
577 |
+
if ( $filerec != null ) {
|
578 |
+
//make previous record obsolete
|
579 |
+
$wpdb->update($table_name1,
|
580 |
+
array( 'date_to' => $now_date ),
|
581 |
+
array( 'idlog' => $filerec->idlog ),
|
582 |
+
array( '%s' ),
|
583 |
+
array( '%d' )
|
584 |
+
);
|
585 |
+
//insert new modify record
|
586 |
+
if ( $wpdb->insert($table_name1,
|
587 |
+
array(
|
588 |
+
'userid' => $userid,
|
589 |
+
'uploaduserid' => $filerec->uploaduserid,
|
590 |
+
'filepath' => $filerec->filepath,
|
591 |
+
'filehash' => $filerec->filehash,
|
592 |
+
'filesize' => $filerec->filesize,
|
593 |
+
'uploadid' => $filerec->uploadid,
|
594 |
+
'pageid' => $filerec->pageid,
|
595 |
+
'sid' => $filerec->sid,
|
596 |
+
'date_from' => $now_date,
|
597 |
+
'date_to' => 0,
|
598 |
+
'action' => 'modify',
|
599 |
+
'linkedto' => $filerec->idlog
|
600 |
+
),
|
601 |
+
array( '%d','%d', '%s', '%s', '%d', '%s', '%d', '%s', '%s', '%s', '%s', '%d' )) != false )
|
602 |
+
$retid = $wpdb->insert_id;
|
603 |
+
}
|
604 |
+
}
|
605 |
+
elseif ( substr($action, 0, 5) == 'other' ) {
|
606 |
+
$info = substr($action, 6);
|
607 |
+
$now_date = date('Y-m-d H:i:s');
|
608 |
+
//insert new download record
|
609 |
+
if ( $wpdb->insert($table_name1,
|
610 |
+
array(
|
611 |
+
'userid' => $userid,
|
612 |
+
'uploaduserid' => -1,
|
613 |
+
'filepath' => $info,
|
614 |
+
'filehash' => '',
|
615 |
+
'filesize' => 0,
|
616 |
+
'uploadid' => '',
|
617 |
+
'pageid' => 0,
|
618 |
+
'sid' => '',
|
619 |
+
'date_from' => $now_date,
|
620 |
+
'date_to' => $now_date,
|
621 |
+
'action' => 'other',
|
622 |
+
'linkedto' => -1
|
623 |
+
),
|
624 |
+
array( '%d','%d', '%s', '%s', '%d', '%s', '%d', '%s', '%s', '%s', '%s', '%d' )) != false )
|
625 |
+
$retid = $wpdb->insert_id;
|
626 |
+
}
|
627 |
+
return $retid;
|
628 |
+
}
|
629 |
+
|
630 |
+
//revert previously saved action
|
631 |
+
function wfu_revert_log_action($idlog) {
|
632 |
+
global $wpdb;
|
633 |
+
$table_name1 = $wpdb->prefix . "wfu_log";
|
634 |
+
|
635 |
+
$filerec = $wpdb->get_row('SELECT * FROM '.$table_name1.' WHERE idlog = '.$idlog);
|
636 |
+
if ( $filerec != null ) {
|
637 |
+
$prevfilerec = $wpdb->get_row('SELECT * FROM '.$table_name1.' WHERE idlog = '.$filerec->idlog);
|
638 |
+
if ( $prevfilerec != null ) {
|
639 |
+
$wpdb->update($table_name1,
|
640 |
+
array( 'date_to' => date('Y-m-d H:i:s') ),
|
641 |
+
array( 'idlog' => $filerec->idlog ),
|
642 |
+
array( '%s' ),
|
643 |
+
array( '%d' )
|
644 |
+
);
|
645 |
+
$wpdb->update($table_name1,
|
646 |
+
array( 'date_to' => 0 ),
|
647 |
+
array( 'idlog' => $prevfilerec->idlog ),
|
648 |
+
array( '%s' ),
|
649 |
+
array( '%d' )
|
650 |
+
);
|
651 |
+
}
|
652 |
+
}
|
653 |
+
}
|
654 |
+
|
655 |
+
//find user by its id and return a non-empty username
|
656 |
+
function wfu_get_username_by_id($id) {
|
657 |
+
$user = get_user_by('id', $id);
|
658 |
+
if ( $user == false && $id > 0 ) $username = 'unknown';
|
659 |
+
elseif ( $user == false ) $username = 'guest';
|
660 |
+
else $username = $user->user_login;
|
661 |
+
return $username;
|
662 |
+
}
|
663 |
+
|
664 |
+
//get the most current database record for file $filepath and also include any userdata if $include_userdata is true
|
665 |
+
function wfu_get_file_rec($filepath, $include_userdata) {
|
666 |
+
global $wpdb;
|
667 |
+
$table_name1 = $wpdb->prefix . "wfu_log";
|
668 |
+
$table_name2 = $wpdb->prefix . "wfu_userdata";
|
669 |
+
$plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
|
670 |
+
|
671 |
+
if ( !file_exists($filepath) ) return null;
|
672 |
+
|
673 |
+
$relativepath = str_replace(ABSPATH, '', $filepath);
|
674 |
+
if ( substr($relativepath, 0, 1) != '/' ) $relativepath = '/'.$relativepath;
|
675 |
+
//if file hash is enabled, then search file based on its path and hash, otherwise find file based on its path and size
|
676 |
+
if ( $plugin_options['hashfiles'] == '1' ) {
|
677 |
+
$filehash = md5_file($filepath);
|
678 |
+
$filerec = $wpdb->get_row('SELECT * FROM '.$table_name1.' WHERE filepath = \''.$relativepath.'\' AND filehash = \''.$filehash.'\' AND date_to = 0 ORDER BY date_from DESC');
|
679 |
+
}
|
680 |
+
else {
|
681 |
+
$stat = stat($filepath);
|
682 |
+
$filerec = $wpdb->get_row('SELECT * FROM '.$table_name1.' WHERE filepath = \''.$relativepath.'\' AND filesize = '.$stat['size'].' AND date_to = 0 ORDER BY date_from DESC');
|
683 |
+
}
|
684 |
+
//get user data
|
685 |
+
if ( $filerec != null && $include_userdata ) {
|
686 |
+
$filerec->userdata = null;
|
687 |
+
if ( $filerec->uploadid != '' ) {
|
688 |
+
$filerec->userdata = $wpdb->get_results('SELECT * FROM '.$table_name2.' WHERE uploadid = \''.$filerec->uploadid.'\' AND date_to = 0');
|
689 |
+
}
|
690 |
+
}
|
691 |
+
return $filerec;
|
692 |
+
}
|
693 |
+
|
694 |
+
//reassign file hashes for all valid files in the database
|
695 |
+
function wfu_reassign_hashes() {
|
696 |
+
global $wpdb;
|
697 |
+
$table_name1 = $wpdb->prefix . "wfu_log";
|
698 |
+
$plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
|
699 |
+
if ( $plugin_options['hashfiles'] == '1' ) {
|
700 |
+
$filerecs = $wpdb->get_results('SELECT * FROM '.$table_name1.' WHERE filehash = \'\' AND date_to = 0');
|
701 |
+
foreach( $filerecs as $filerec ) {
|
702 |
+
//calculate full file path
|
703 |
+
$filepath = ABSPATH;
|
704 |
+
if ( substr($filepath, -1) == '/' ) $filepath = substr($filepath, 0, -1);
|
705 |
+
$filepath .= $filerec->filepath;
|
706 |
+
if ( file_exists($filepath) ) {
|
707 |
+
$filehash = md5_file($filepath);
|
708 |
+
$wpdb->update($table_name1,
|
709 |
+
array( 'filehash' => $filehash ),
|
710 |
+
array( 'idlog' => $filerec->idlog ),
|
711 |
+
array( '%s' ),
|
712 |
+
array( '%d' )
|
713 |
+
);
|
714 |
+
}
|
715 |
+
}
|
716 |
+
}
|
717 |
+
}
|
718 |
+
|
719 |
+
//update database to reflect the current status of files
|
720 |
+
function wfu_sync_database() {
|
721 |
+
global $wpdb;
|
722 |
+
$table_name1 = $wpdb->prefix . "wfu_log";
|
723 |
+
$plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
|
724 |
+
|
725 |
+
$filerecs = $wpdb->get_results('SELECT * FROM '.$table_name1.' WHERE action <> \'other\' AND date_to = 0');
|
726 |
+
$obsolete_count = 0;
|
727 |
+
foreach( $filerecs as $filerec ) {
|
728 |
+
$obsolete = true;
|
729 |
+
//calculate full file path
|
730 |
+
$filepath = ABSPATH;
|
731 |
+
if ( substr($filepath, -1) == '/' ) $filepath = substr($filepath, 0, -1);
|
732 |
+
$filepath .= $filerec->filepath;
|
733 |
+
if ( file_exists($filepath) ) {
|
734 |
+
if ( $plugin_options['hashfiles'] == '1' ) {
|
735 |
+
$filehash = md5_file($filepath);
|
736 |
+
if ( $filehash == $filerec->filehash ) $obsolete = false;
|
737 |
+
}
|
738 |
+
else {
|
739 |
+
$filesize = filesize($filepath);
|
740 |
+
if ( $filesize == $filerec->filesize ) $obsolete = false;
|
741 |
+
}
|
742 |
+
}
|
743 |
+
if ( $obsolete ) {
|
744 |
+
$now_date = date('Y-m-d H:i:s');
|
745 |
+
//make previous record obsolete
|
746 |
+
$wpdb->update($table_name1,
|
747 |
+
array( 'date_to' => $now_date ),
|
748 |
+
array( 'idlog' => $filerec->idlog ),
|
749 |
+
array( '%s' ),
|
750 |
+
array( '%d' )
|
751 |
+
);
|
752 |
+
$obsolete_count ++;
|
753 |
+
}
|
754 |
+
}
|
755 |
+
return $obsolete_count;
|
756 |
+
}
|
757 |
+
|
758 |
+
//********************* Shortcode Options Functions ****************************************************************************************
|
759 |
|
760 |
function wfu_generate_current_params_index($shortcode_id, $user_login) {
|
761 |
global $post;
|
808 |
function wfu_decode_dimensions($dimensions_str) {
|
809 |
$components = wfu_component_definitions();
|
810 |
$dimensions = array();
|
811 |
+
|
812 |
foreach ( $components as $comp ) {
|
813 |
if ( $comp['dimensions'] == null ) $dimensions[$comp['id']] = "";
|
814 |
else foreach ( $comp['dimensions'] as $dimraw ) {
|
827 |
return $dimensions;
|
828 |
}
|
829 |
|
830 |
+
//********************* Plugin Design Functions ********************************************************************************************
|
831 |
|
832 |
function wfu_add_div() {
|
833 |
$items_count = func_num_args();
|
866 |
return $div;
|
867 |
}
|
868 |
|
869 |
+
//********************* Email Functions ****************************************************************************************************
|
870 |
|
871 |
function wfu_send_notification_email($user, $only_filename_list, $target_path_list, $attachment_list, $userdata_fields, $params) {
|
872 |
if ( 0 == $user->ID ) {
|
900 |
return ( $notify_sent ? "" : WFU_WARNING_NOTIFY_NOTSENT_UNKNOWNERROR );
|
901 |
}
|
902 |
|
903 |
+
//********************* Media Functions ****************************************************************************************************
|
904 |
|
905 |
// function wfu_process_media_insert contribution from Aaron Olin
|
906 |
+
function wfu_process_media_insert($file_path, $page_id){
|
907 |
+
$filetype = wp_check_filetype( basename( $file_path ), null );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
908 |
|
909 |
$attachment = array(
|
910 |
+
'post_mime_type' => $filetype['type'],
|
911 |
+
'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $file_path ) ),
|
912 |
+
'post_content' => '',
|
913 |
+
'post_status' => 'inherit'
|
|
|
914 |
);
|
915 |
|
916 |
+
$attach_id = wp_insert_attachment( $attachment, $file_path, $page_id );
|
|
|
917 |
|
918 |
// If file is an image, process the default thumbnails for previews
|
919 |
+
require_once(ABSPATH . 'wp-admin/includes/image.php');
|
920 |
+
$attach_data = wp_generate_attachment_metadata( $attach_id, $file_path );
|
921 |
+
$update_attach = wp_update_attachment_metadata( $attach_id, $attach_data );
|
|
|
|
|
|
|
|
|
922 |
|
923 |
return $attach_id;
|
924 |
}
|
lib/wfu_processfiles.php
CHANGED
@@ -13,6 +13,7 @@ function wfu_process_files($params, $method) {
|
|
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;
|
@@ -73,7 +74,7 @@ function wfu_process_files($params, $method) {
|
|
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'] >=
|
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 |
}
|
@@ -94,50 +95,78 @@ function wfu_process_files($params, $method) {
|
|
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 |
-
/*
|
103 |
-
|
104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
}
|
106 |
-
|
107 |
-
|
108 |
-
$
|
109 |
-
|
110 |
-
|
111 |
-
|
|
|
112 |
if ( is_dir( wfu_upload_plugin_full_path($params) ) ) {
|
113 |
$upload_path_ok = true;
|
114 |
}
|
115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
|
|
122 |
}
|
123 |
-
}
|
124 |
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
|
134 |
-
|
135 |
-
|
136 |
-
|
|
|
137 |
}
|
138 |
}
|
139 |
else {
|
140 |
-
|
141 |
$upload_error = $fileprops['error'];
|
142 |
if ( $upload_error == 1 ) {
|
143 |
$message_text = WFU_ERROR_FILE_PHP_SIZE;
|
@@ -159,7 +188,8 @@ function wfu_process_files($params, $method) {
|
|
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;
|
@@ -178,6 +208,11 @@ function wfu_process_files($params, $method) {
|
|
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
|
@@ -230,6 +265,11 @@ function wfu_process_files($params, $method) {
|
|
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
|
@@ -362,9 +402,26 @@ function wfu_process_files($params, $method) {
|
|
362 |
|
363 |
$params_output_array[0] = $file_output;
|
364 |
|
365 |
-
/*
|
366 |
-
|
367 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
368 |
}
|
369 |
}
|
370 |
|
13 |
$user_email = $user->user_email;
|
14 |
$is_admin = current_user_can('manage_options');
|
15 |
}
|
16 |
+
$uniqueuploadid = ( isset($_POST['uniqueuploadid_'.$sid]) ? $_POST['uniqueuploadid_'.$sid] : "" );
|
17 |
|
18 |
$suppress_admin_messages = ( $params["adminmessages"] != "true" || !$is_admin );
|
19 |
$success_count = 0;
|
74 |
$params_output_array["general"]['files_count'] = $files_count;
|
75 |
|
76 |
/* append subfolder name to upload path */
|
77 |
+
if ( $params["askforsubfolders"] == "true" && $params['subdir_selection_index'] >= 1 ) {
|
78 |
if ( substr($params["uploadpath"], -1, 1) == "/" ) $params["uploadpath"] .= $params['subfoldersarray'][$params['subdir_selection_index']];
|
79 |
else $params["uploadpath"] .= '/'.$params['subfoldersarray'][$params['subdir_selection_index']];
|
80 |
}
|
95 |
$file_output['message_type'] = "";
|
96 |
$file_output['admin_messages'] = "";
|
97 |
|
98 |
+
/* generate unique id for each file in order to use it in filter actions for identifying each separate file */
|
99 |
+
$file_unique_id = wfu_create_random_string(20);
|
100 |
+
|
101 |
/* Get uploaded file size in Mbytes */
|
102 |
$upload_file_size = filesize($fileprops['tmp_name']) / 1024 / 1024;
|
103 |
|
104 |
if ( $upload_file_size > 0 ) {
|
105 |
|
106 |
+
/* Section to perform filter action wfu_before_file_check before file is checked in order to perform
|
107 |
+
any filename or userdata modifications or reject the upload of the file by setting error_message item
|
108 |
+
of $ret_data array to a non-empty value */
|
109 |
+
$filter_error_message = '';
|
110 |
+
if ( $file_unique_id != '' ) {
|
111 |
+
$target_path = wfu_upload_plugin_full_path($params).$fileprops['name'];
|
112 |
+
$changable_data['file_path'] = $target_path;
|
113 |
+
$changable_data['user_data'] = $userdata_fields;
|
114 |
+
$changable_data['error_message'] = $filter_error_message;
|
115 |
+
$additional_data['file_unique_id'] = $file_unique_id;
|
116 |
+
$additional_data['file_size'] = filesize($fileprops['tmp_name']);
|
117 |
+
$additional_data['user_id'] = $user->ID;
|
118 |
+
$additional_data['page_id'] = $params["pageid"];
|
119 |
+
$ret_data = apply_filters('wfu_before_file_check', $changable_data, $additional_data);
|
120 |
+
$fileprops['name'] = str_replace(wfu_upload_plugin_full_path($params), '', $ret_data['file_path']);
|
121 |
+
$userdata_fields = $ret_data['user_data'];
|
122 |
+
$filter_error_message = $ret_data['error_message'];
|
123 |
}
|
124 |
+
if ( $filter_error_message != '' ) {
|
125 |
+
$file_output['message_type'] = "error";
|
126 |
+
$file_output['message'] = wfu_join_strings("<br />", $file_output['message'], $filter_error_message);
|
127 |
+
}
|
128 |
+
else {
|
129 |
+
|
130 |
+
/* Check if upload path exist */
|
131 |
if ( is_dir( wfu_upload_plugin_full_path($params) ) ) {
|
132 |
$upload_path_ok = true;
|
133 |
}
|
134 |
+
/* Attempt to create path if user has selected to do so */
|
135 |
+
else if ( $params["createpath"] == "true" ) {
|
136 |
+
$wfu_create_directory_ret = wfu_create_directory(wfu_upload_plugin_full_path($params), $params["accessmethod"], $params["ftpinfo"]);
|
137 |
+
if ( $wfu_create_directory_ret != "" ) {
|
138 |
+
$file_output['admin_messages'] = wfu_join_strings("<br />", $file_output['admin_messages'], $wfu_create_directory_ret);
|
139 |
+
}
|
140 |
+
if ( is_dir( wfu_upload_plugin_full_path($params) ) ) {
|
141 |
+
$upload_path_ok = true;
|
142 |
+
}
|
143 |
+
}
|
144 |
|
145 |
+
/* File name control */
|
146 |
+
foreach ($allowed_patterns as $allowed_pattern) {
|
147 |
+
if ( wfu_upload_plugin_wildcard_match( $allowed_pattern, $fileprops['name']) ) {
|
148 |
+
$allowed_file_ok = true;
|
149 |
+
break ;
|
150 |
+
}
|
151 |
}
|
|
|
152 |
|
153 |
+
/* File size control */
|
154 |
+
if ( $upload_file_size <= $params["maxsize"] ) {
|
155 |
+
$size_file_ok = true;
|
156 |
+
}
|
157 |
|
158 |
+
if ( !$upload_path_ok or !$allowed_file_ok or !$size_file_ok ) {
|
159 |
+
$file_output['message_type'] = "error";
|
160 |
+
$file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_ERROR_UPLOAD_FAILED);
|
161 |
|
162 |
+
if ( !$upload_path_ok ) $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_ERROR_DIR_EXIST);
|
163 |
+
if ( !$allowed_file_ok ) $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_ERROR_FILE_ALLOW);
|
164 |
+
if ( !$size_file_ok ) $file_output['message'] = wfu_join_strings("<br />", $file_output['message'], WFU_ERROR_FILE_PLUGIN_SIZE);
|
165 |
+
}
|
166 |
}
|
167 |
}
|
168 |
else {
|
169 |
+
// This block is executed when there is an error
|
170 |
$upload_error = $fileprops['error'];
|
171 |
if ( $upload_error == 1 ) {
|
172 |
$message_text = WFU_ERROR_FILE_PHP_SIZE;
|
188 |
$file_output['message'] = wfu_join_strings("<br />", $file_output['message'], $message_text);
|
189 |
}
|
190 |
|
191 |
+
// if ( $upload_path_ok and $allowed_file_ok and $size_file_ok ) {
|
192 |
+
if ( $file_output['message_type'] != "error" ) {
|
193 |
|
194 |
if ( is_uploaded_file($fileprops['tmp_name']) ) {
|
195 |
$file_copied = false;
|
208 |
//redirect echo in internal buffer to receive and process any unwanted warning messages from wfu_upload_file
|
209 |
ob_start();
|
210 |
ob_clean();
|
211 |
+
/* Apply wfu_before_file_upload filter right before the upload, in order to allow the user to change the file name.
|
212 |
+
If additional data are required, such as user_id or userdata values, they can be retrieved by implementing the
|
213 |
+
previous filter wfu_before_file_check, corresponding them to the unique file id */
|
214 |
+
if ( $file_unique_id != '' ) $target_path = apply_filters('wfu_before_file_upload', $target_path, $file_unique_id);
|
215 |
+
//move the uploaded file to its final destination
|
216 |
$wfu_upload_file_ret = wfu_upload_file($source_path, $target_path, $params["accessmethod"], $params["ftpinfo"]);
|
217 |
$file_copied = $wfu_upload_file_ret["uploaded"];
|
218 |
//process warning messages from wfu_upload_file
|
265 |
//redirect echo in internal buffer to receive and process any unwanted warning messages from move_uploaded_file
|
266 |
ob_start();
|
267 |
ob_clean();
|
268 |
+
/* Apply wfu_before_file_upload filter right before the upload, in order to allow the user to change the file name.
|
269 |
+
If additional data are required, such as user_id or userdata values, they can be retrieved by implementing the
|
270 |
+
previous filter wfu_before_file_check, corresponding them to the unique file id */
|
271 |
+
if ( $file_unique_id != '' ) $target_path = apply_filters('wfu_before_file_upload', $target_path, $file_unique_id);
|
272 |
+
//move the uploaded file to its final destination
|
273 |
$wfu_upload_file_ret = wfu_upload_file($source_path, $target_path, $params["accessmethod"], $params["ftpinfo"]);
|
274 |
$file_copied = $wfu_upload_file_ret["uploaded"];
|
275 |
//process warning messages from move_uploaded_file
|
402 |
|
403 |
$params_output_array[0] = $file_output;
|
404 |
|
405 |
+
/* Apply wfu_after_file_upload action after failed upload, in order to allow the user to perform any post-upload actions.
|
406 |
+
If additional data are required, such as user_id or userdata values or filepath, they can be retrieved by implementing
|
407 |
+
the previous filters wfu_before_file_check and wfu_before_file_upload, corresponding them to the unique file id */
|
408 |
+
if ( $file_unique_id != '' && $file_output['message_type'] == "error" ) {
|
409 |
+
do_action('wfu_after_file_upload', $file_unique_id, $file_output['message_type'], $file_output['message'], $file_output['admin_messages']);
|
410 |
+
}
|
411 |
+
|
412 |
+
/* log file upload action if file has finished uploading successfully */
|
413 |
+
if ( $file_finished_successfully ) {
|
414 |
+
wfu_log_action('upload', $target_path, $user->ID, $uniqueuploadid, $params['pageid'], $sid, $userdata_fields);
|
415 |
+
/* Apply wfu_after_file_upload action after successfull upload, in order to allow the user to perform any post-upload actions.
|
416 |
+
If additional data are required, such as user_id or userdata values or filepath, they can be retrieved by implementing
|
417 |
+
the previous filters wfu_before_file_check and wfu_before_file_upload, corresponding them to the unique file id */
|
418 |
+
do_action('wfu_after_file_upload', $file_unique_id, $file_output['message_type'], $file_output['message'], $file_output['admin_messages']);
|
419 |
+
}
|
420 |
+
|
421 |
+
/* add file to Media or attach file to current post if any of these options is activated and the file has finished uploading successfully */
|
422 |
+
if ( ( $params["medialink"] == "true" || $params["postlink"] == "true" ) && $file_finished_successfully ) {
|
423 |
+
$pageid = ( $params["postlink"] == "true" ? $params['pageid'] : 0 );
|
424 |
+
wfu_process_media_insert($target_path, $pageid);
|
425 |
}
|
426 |
}
|
427 |
|
readme.txt
CHANGED
@@ -1,14 +1,14 @@
|
|
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.1
|
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 |
|
@@ -16,7 +16,9 @@ With this plugin you or other users can upload files to your site from any page,
|
|
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
|
|
|
|
|
20 |
|
21 |
Please note that this plugin is the successor of **Inline Upload** plugin.
|
22 |
|
@@ -24,19 +26,22 @@ 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 multilingual characters and localization.
|
30 |
-
* It integrates with WP-Filebase.
|
31 |
-
*
|
|
|
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
|
40 |
|
41 |
Please visit the **Other Notes** section for customization options of this plugin.
|
42 |
|
@@ -89,6 +94,10 @@ By default only administrators can upload files. However you can define which us
|
|
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.
|
@@ -101,6 +110,35 @@ The plugin is designed not to expose website information by using sessions. Para
|
|
101 |
|
102 |
== Changelog ==
|
103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
= 2.3.1 =
|
105 |
* added option to restore default value for each attribute in Shortcode Composer
|
106 |
* added support for multilingual characters
|
@@ -241,8 +279,8 @@ This is the initial release of Wordpress File Upload. Since this plugin is the s
|
|
241 |
|
242 |
= 1.4 =
|
243 |
* Added option to attach uploaded file to notification email.
|
244 |
-
* Added option to customize message on
|
245 |
-
* Added option to customize color of message on
|
246 |
* "C:\fakepath\" problem resolved.
|
247 |
* warning message about function create_directory() resolved.
|
248 |
* css enhancements for compatibility with more themes.
|
@@ -250,7 +288,7 @@ This is the initial release of Wordpress File Upload. Since this plugin is the s
|
|
250 |
= 1.3 =
|
251 |
* Additional variables added (%filename% and %filepath%).
|
252 |
* All variables can be used inside message subject and message text.
|
253 |
-
* Added option to determine how to treat
|
254 |
* Added option to determine how to rename the uploaded file, when another file already exists in the target directory.
|
255 |
* Added option to create directories and upload files using ftp access, in order to overcome file owner and SAFE MODE restrictions.
|
256 |
* Added the capability to redirect to another web page when a file is uploaded successfully.
|
@@ -269,6 +307,9 @@ Initial version.
|
|
269 |
|
270 |
== Upgrade Notice ==
|
271 |
|
|
|
|
|
|
|
272 |
= 2.3.1 =
|
273 |
Upgrade to add some features and address some minor bugs.
|
274 |
|
@@ -492,7 +533,11 @@ A detailed list of attributes, together with instructions is shown below:
|
|
492 |
*Connection With Other Plugins*
|
493 |
|
494 |
* **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.
|
|
|
|
|
|
|
495 |
* **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.
|
|
|
496 |
|
497 |
You can use any of these attributes to customize the plugin. The way to use these attributes is the following:
|
498 |
|
@@ -518,23 +563,105 @@ Here are some examples:
|
|
518 |
|
519 |
From version 1.2 variables are supported inside attributes.
|
520 |
|
521 |
-
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.
|
522 |
|
523 |
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.
|
524 |
|
525 |
For the time being, the following variables are supported:
|
526 |
|
|
|
527 |
* **%username%:** Is replaced by the username of the current user. Can be used inside attributes *uploadpath*, *notifysubject* and *notifymessage*.
|
528 |
* **%useremail%:** Is replaced by the email of the current user. Can be used inside attributes *notifyrecipients*, *notifysubject* and *notifymessage*.
|
529 |
* **%filename%:** Is replaced by the filename (not including path information) of the uploaded file. Can be used inside attributes *notifysubject*, *notifymessage*, *successmessage* and *redirectlink*.
|
530 |
* **%filepath%:** Is replaced by the filepath (full path and filename) of the uploaded file. Can be used inside attributes *notifysubject*, *notifymessage* and *successmessage*.
|
531 |
* **%blogid%:** Is replaced by the blog_id of the current site. Can be used inside attribute *uploadpath*.
|
532 |
-
* **%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*.
|
533 |
-
* **%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.
|
534 |
* **%pagetitle%:** Is replaced by the title of the current page. Can be used inside attribute *uploadpath*.
|
535 |
* **%pageid%:** Is replaced by the id of the current page. Can be used inside attribute *uploadpath*.
|
536 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
537 |
== Requirements ==
|
538 |
|
539 |
The plugin requires to have Javascript enabled in your browser. For Internet Explorer you also need to have Active-X enabled.
|
540 |
-
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, gallery, image gallery, browser, file browser, gallery, image gallery, shortcode, logging, file logging
|
5 |
Requires at least: 2.9.2
|
6 |
Tested up to: 3.8.1
|
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 very powerful plugin to allow users to upload files to your website from any page and manage the uploaded files
|
12 |
|
13 |
== Description ==
|
14 |
|
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 plugin includes a file browser to access and manage the uploaded files from the Dashboard (only for admins currently).
|
20 |
+
|
21 |
+
Current version supports filters and actions before and after file upload, in order to extend its capabilities.
|
22 |
|
23 |
Please note that this plugin is the successor of **Inline Upload** plugin.
|
24 |
|
26 |
|
27 |
* 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).
|
28 |
* You can have more than one instances of the shortcode in the same page.
|
|
|
29 |
* It includes an overall upload progress bar.
|
30 |
* It supports multilingual characters and localization.
|
31 |
+
* It integrates with WP-Filebase plugin.
|
32 |
+
* Uploaded files can be added to Media or be attached to the current page.
|
33 |
+
* It is highly customizable with many (more than 50) options.
|
34 |
* It produces notification messages and e-mails.
|
35 |
* You can create additional fields that the user must fill in along with the uploaded file.
|
36 |
* It supports redirection to another url after successful upload.
|
37 |
+
* It supports filters and actions before and after file upload, so that programmers can extend the plugin and make it cooperate with other plugins.
|
38 |
+
* It supports logging of upload events or management of files, which can be viewed by admins through the Dashboard.
|
39 |
* You can create you shortcode very easily by using the included Shortcode Composer in the plugin's settings inside Dashboard.
|
40 |
+
* It includes a file browser in the Dashboard, from where admins can view the uploaded file and manage them.
|
41 |
|
42 |
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.
|
43 |
|
44 |
+
For additional features, such as multiple file upload, very large file upload, drag and drop of files, captcha, detailed upload progress bars, image gallery and custom css please consider [Wordpress File Upload Professional](http://www.iptanus.com/support/wordpress-file-upload/ "Wordpress File Upload support page").
|
45 |
|
46 |
Please visit the **Other Notes** section for customization options of this plugin.
|
47 |
|
94 |
|
95 |
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.
|
96 |
|
97 |
+
= How can I view the uploaded files? =
|
98 |
+
|
99 |
+
Administrators can view and manage the uploaded files from the File Browser that exists inside the plugin's Settings inside Dashboard, or use an FTP client. Other users can view their uploaded files by combining this plugin with WP-Filebase plugin. If you want to show the uploaded files as an image gallery please consider the [Professional](http://www.iptanus.com/support/wordpress-file-upload/ "Wordpress File Upload support page") version of the plugin.
|
100 |
+
|
101 |
== Screenshots ==
|
102 |
|
103 |
1. A screenshot of the plugin in its most simple form.
|
110 |
|
111 |
== Changelog ==
|
112 |
|
113 |
+
= 2.4.1 =
|
114 |
+
* added filters and actions before and after each file upload - check below Filters/Actions section for instructions how to use them
|
115 |
+
* added storage of file info, including user data, in database
|
116 |
+
* added logging of file actions in database - admins can view the log from the Dashboard
|
117 |
+
* admins can automatically update the database to reflect the current status of files from the Dashboard
|
118 |
+
* file browser improvements so that more information about each file (including any user data) are shown
|
119 |
+
* file browser improvements so that files can be downloaded
|
120 |
+
* filelist improvements to display correctly long filenames (Pro version)
|
121 |
+
* filelist improvements to distinguish successful uploads from failed uploads (Pro version)
|
122 |
+
* improvements of chunked uploads so that files that are not allowed to be uploaded are cancelled faster (Pro version)
|
123 |
+
* corrected wrong check of file size limit for chunked files (Pro version)
|
124 |
+
* added postlink attribute so that uploaded files are linked to the current page (or post) as attachments
|
125 |
+
* added subfolderlabel attribute to define the label of the subfolder selection feature
|
126 |
+
* several improvements to subfolder selection feature
|
127 |
+
* default value added to subfolder selection feature
|
128 |
+
* definition of the subfoldertree attribute in the Shortcode Composer is now done visually
|
129 |
+
* %userid% variable added inside uploadpath attribute
|
130 |
+
* userdata variables added inside uploadpath and notifyrecipients attributes
|
131 |
+
* uploadfolder_label added to dimension items
|
132 |
+
* user fields feature improvements
|
133 |
+
* user fields label and input box dimensions are customizable
|
134 |
+
* captcha prompt label dimensions are customizable (Pro version)
|
135 |
+
* added gallery attribute to allow the uploaded files to be shown as image gallery below the plugin (Pro version)
|
136 |
+
* added galleryoptions attribute to define options of the image gallery (Pro version)
|
137 |
+
* added css attribute and a delicate css editor inside Shortcode Composer to allow better styling of the plugin using custom css (Pro version)
|
138 |
+
* email feature improved in conjunction with redirection
|
139 |
+
* improved interoperability with WP-Filebase plugin
|
140 |
+
* improved functionality of free text attributes (like notifymessage or css) by allowing double-quotes and brackets inside the text (using special variables), that were previously breaking the plugin
|
141 |
+
|
142 |
= 2.3.1 =
|
143 |
* added option to restore default value for each attribute in Shortcode Composer
|
144 |
* added support for multilingual characters
|
279 |
|
280 |
= 1.4 =
|
281 |
* Added option to attach uploaded file to notification email.
|
282 |
+
* Added option to customize message on successful upload (variables %filename% and %filepath% can be used).
|
283 |
+
* Added option to customize color of message on successful upload.
|
284 |
* "C:\fakepath\" problem resolved.
|
285 |
* warning message about function create_directory() resolved.
|
286 |
* css enhancements for compatibility with more themes.
|
288 |
= 1.3 =
|
289 |
* Additional variables added (%filename% and %filepath%).
|
290 |
* All variables can be used inside message subject and message text.
|
291 |
+
* Added option to determine how to treat duplicates (overwrite existing file, leave existing file, leave both).
|
292 |
* Added option to determine how to rename the uploaded file, when another file already exists in the target directory.
|
293 |
* Added option to create directories and upload files using ftp access, in order to overcome file owner and SAFE MODE restrictions.
|
294 |
* Added the capability to redirect to another web page when a file is uploaded successfully.
|
307 |
|
308 |
== Upgrade Notice ==
|
309 |
|
310 |
+
= 2.4.1 =
|
311 |
+
Upgrade to add many features and address some minor bugs.
|
312 |
+
|
313 |
= 2.3.1 =
|
314 |
Upgrade to add some features and address some minor bugs.
|
315 |
|
533 |
*Connection With Other Plugins*
|
534 |
|
535 |
* **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.
|
536 |
+
|
537 |
+
*Connection With Other Wordpress Features*
|
538 |
+
|
539 |
* **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.
|
540 |
+
* **postlink:** This attribute defines that uploaded files will be added to the current page (or post) as attachments when set to "true". Default value is "false".
|
541 |
|
542 |
You can use any of these attributes to customize the plugin. The way to use these attributes is the following:
|
543 |
|
563 |
|
564 |
From version 1.2 variables are supported inside attributes.
|
565 |
|
566 |
+
A variable is a string surrounded by percent characters, in the form *%variable_name%*. This variable is dynamically replaced by another string whenever the plugin is executed.
|
567 |
|
568 |
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.
|
569 |
|
570 |
For the time being, the following variables are supported:
|
571 |
|
572 |
+
* **%userid%:** Is replaced by the id of the current user. Can be used inside attribute *uploadpath*.
|
573 |
* **%username%:** Is replaced by the username of the current user. Can be used inside attributes *uploadpath*, *notifysubject* and *notifymessage*.
|
574 |
* **%useremail%:** Is replaced by the email of the current user. Can be used inside attributes *notifyrecipients*, *notifysubject* and *notifymessage*.
|
575 |
* **%filename%:** Is replaced by the filename (not including path information) of the uploaded file. Can be used inside attributes *notifysubject*, *notifymessage*, *successmessage* and *redirectlink*.
|
576 |
* **%filepath%:** Is replaced by the filepath (full path and filename) of the uploaded file. Can be used inside attributes *notifysubject*, *notifymessage* and *successmessage*.
|
577 |
* **%blogid%:** Is replaced by the blog_id of the current site. Can be used inside attribute *uploadpath*.
|
578 |
+
* **%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 *uploadpath*, *notifysubject*, *notifymessage* and *notifyrecipients*.
|
|
|
579 |
* **%pagetitle%:** Is replaced by the title of the current page. Can be used inside attribute *uploadpath*.
|
580 |
* **%pageid%:** Is replaced by the id of the current page. Can be used inside attribute *uploadpath*.
|
581 |
|
582 |
+
In addition, some special variables, which are used to replace literals not allowed in shortcodes (such as double quotes or brackets), are also supported. They can be used in attributes that receive free text (like button labels, email notification body etc.). These special variables are:
|
583 |
+
|
584 |
+
* **%n%:** When used inside an attribute (e.g. inside *notifymessage*) it will be replaced by a change-of-line character (\n).
|
585 |
+
* **%dq%:** When used inside an attribute it will be replaced by a double quote (").
|
586 |
+
* **%brl%:** When used inside an attribute it will be replaced by an opening bracket ([).
|
587 |
+
* **%brr%:** When used inside an attribute it will be replaced by a closing bracket (]).
|
588 |
+
|
589 |
+
== Filters / Actions ==
|
590 |
+
|
591 |
+
From version 2.4.1 filters and actions are supported in order to allow programmers to integrate Wordpress File Upload plugin with other plugins.
|
592 |
+
|
593 |
+
The following filters are supported:
|
594 |
+
|
595 |
+
**wfu_before_file_check**
|
596 |
+
|
597 |
+
It is executed before file is uploaded and before any internal file checks, in order to allow the filter to perform its own checks or change some basic upload parameters, such as filename or userdata. You can use it as follows:
|
598 |
+
|
599 |
+
`
|
600 |
+
add_filter('wfu_before_file_check', 'wfu_before_file_check_handler', 10, 2);
|
601 |
+
|
602 |
+
//The following function takes two parameters, $changable_data and $additional_data.
|
603 |
+
// $changable_data is an array that can be modified by the filter and contains the items:
|
604 |
+
// file_path: the full path of the uploaded file
|
605 |
+
// user_data: an array of user data values, if userdata are activated
|
606 |
+
// error_message: if this is non-zero, then upload of the file will be cancelled showing this error message to the user
|
607 |
+
// $additional_data is an array with additional data to be used by the filter (but cannot be modified) as follows:
|
608 |
+
// file_unique_id: this id is unique for each individual file upload and can be used to identify each separate upload
|
609 |
+
// file_size: the size of the uploaded file
|
610 |
+
// user_id: the id of the user that submitted the file for upload
|
611 |
+
// page_id: the id of the page from where the upload was performed (because there may be upload plugins in more than one page)
|
612 |
+
// shortcode_id: the id of the upload plugin (because more than one upload plugins can exist in the same page)
|
613 |
+
//The function must return the final $changable_data.
|
614 |
+
function wfu_before_file_check_handler($changable_data, $additional_data) {
|
615 |
+
// Add code here...
|
616 |
+
return $changable_data;
|
617 |
+
}
|
618 |
+
`
|
619 |
+
|
620 |
+
**wfu_before_file_upload**
|
621 |
+
|
622 |
+
It is executed right before file is uploaded, in order to allow the filter to change the file name. You can use it as follows:
|
623 |
+
|
624 |
+
`
|
625 |
+
add_filter('wfu_before_file_upload', 'wfu_before_file_upload_handler', 10, 2);
|
626 |
+
|
627 |
+
//The following function takes two parameters, $file_path and $file_unique_id.
|
628 |
+
// $file_path is the filename of the uploaded file (after all internal checks have been applied) and can be modified by the filter.
|
629 |
+
// $file_unique_id is is unique for each individual file upload and can be used to identify each separate upload.
|
630 |
+
//The function must return the final $file_path.
|
631 |
+
//If additional data are required (such as user id or userdata) you can get them by implementing the previous filter
|
632 |
+
//wfu_before_file_check and link both filters by $file_unique_id parameter.
|
633 |
+
//Please note that no filename validity checks will be performed after the filter. The filter must ensure that filename is valid.
|
634 |
+
function wfu_before_file_upload_handler($file_path, $file_unique_id) {
|
635 |
+
// Add code here...
|
636 |
+
return $file_path;
|
637 |
+
}
|
638 |
+
`
|
639 |
+
|
640 |
+
The following actions are supported:
|
641 |
+
|
642 |
+
**wfu_after_file_upload**
|
643 |
+
|
644 |
+
It is executed after the upload process for each individual file has finished, in order to allow additional actions to be executed. You can use it as follows:
|
645 |
+
|
646 |
+
`
|
647 |
+
add_action('wfu_after_file_upload', 'wfu_after_file_upload_handler', 10, 4);
|
648 |
+
|
649 |
+
//The following function takes four parameters, $file_unique_id, $upload_result, $error_message and $error_admin_messages.
|
650 |
+
// $file_unique_id is is unique for each individual file upload and can be used to identify each separate upload.
|
651 |
+
// $upload_result is is result of the upload process:
|
652 |
+
// success: the upload was successful
|
653 |
+
// warning: the upload was successful but with warning messages
|
654 |
+
// error: the upload failed
|
655 |
+
// $error_message: contains any warning or error messages generated during the upload process
|
656 |
+
// $admin_messages: contains any more detailed error messages for administrators generated during the upload process
|
657 |
+
//If additional data are required (such as user id, userdata or filename) you can get them by implementing the previous filters
|
658 |
+
//wfu_before_file_check or wfu_before_file_upload and link both filters by $file_unique_id parameter.
|
659 |
+
function wfu_after_file_upload_handler($file_unique_id, $upload_result, $error_message, $error_admin_messages) {
|
660 |
+
// Add code here...
|
661 |
+
}
|
662 |
+
`
|
663 |
+
|
664 |
== Requirements ==
|
665 |
|
666 |
The plugin requires to have Javascript enabled in your browser. For Internet Explorer you also need to have Active-X enabled.
|
667 |
+
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.
|
wordpress_file_upload.php
CHANGED
@@ -4,7 +4,7 @@ session_start();
|
|
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.
|
8 |
Author: Nickolas Bossinas
|
9 |
Author URI: http://www.iptanus.com
|
10 |
*/
|
@@ -28,6 +28,10 @@ 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 |
$uri = $_SERVER['REQUEST_URI'];
|
33 |
if ( strpos($uri, 'wp-login.php') !== false ) return;
|
@@ -42,7 +46,8 @@ if ( is_admin() ) {
|
|
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 |
-
|
|
|
46 |
}
|
47 |
}
|
48 |
else {
|
@@ -53,14 +58,19 @@ else {
|
|
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/") ) {
|
@@ -92,6 +102,8 @@ function wordpress_file_upload_function($incomingfromhandler) {
|
|
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 |
|
@@ -120,10 +132,10 @@ function wordpress_file_upload_function($incomingfromhandler) {
|
|
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 */
|
@@ -233,6 +245,7 @@ function wordpress_file_upload_function($incomingfromhandler) {
|
|
233 |
array_push($section_array, $uploadform_item);
|
234 |
$wordpress_file_upload_output .= call_user_func_array("wfu_add_div", $section_array);
|
235 |
}
|
|
|
236 |
/* Pass constants to javascript */
|
237 |
$consts = wfu_set_javascript_constants();
|
238 |
$handler = 'function() { wfu_Initialize_Consts("'.$consts.'") }';
|
@@ -247,6 +260,7 @@ function wordpress_file_upload_function($incomingfromhandler) {
|
|
247 |
// In the second case we do not want to perform any file upload, so we abort the rest of the script.
|
248 |
if ( $_SESSION['wfu_check_refresh_'.$sid] != "form button pressed" ) {
|
249 |
$_SESSION['wfu_check_refresh_'.$sid] = 'do not process';
|
|
|
250 |
return $wordpress_file_upload_output."\n";
|
251 |
}
|
252 |
$_SESSION['wfu_check_refresh_'.$sid] = 'do not process';
|
@@ -260,7 +274,10 @@ function wordpress_file_upload_function($incomingfromhandler) {
|
|
260 |
// 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.
|
261 |
if ( isset($_FILES[$uploadedfile.'_redirected']) ) $params['forceclassic'] = "true";
|
262 |
|
263 |
-
if ( $params['forceclassic'] != "true" )
|
|
|
|
|
|
|
264 |
|
265 |
// The section below is executed when using classic upload methods
|
266 |
if ( isset( $_POST[$adminerrorcodes] ) ) {
|
@@ -280,9 +297,15 @@ function wordpress_file_upload_function($incomingfromhandler) {
|
|
280 |
$wfu_process_file_array_str = wfu_encode_array_to_string($wfu_process_file_array);
|
281 |
$ProcessUploadComplete_functiondef = 'function(){wfu_ProcessUploadComplete('.$sid.', 1, "'.$wfu_process_file_array_str.'", "no-ajax", "", "", "'.$safe_output.'", ["false", "", "false"]);}';
|
282 |
$wordpress_file_upload_output .= '<script type="text/javascript">window.onload='.$ProcessUploadComplete_functiondef.'</script>';
|
283 |
-
|
284 |
|
|
|
285 |
return $wordpress_file_upload_output."\n";
|
286 |
}
|
287 |
|
|
|
|
|
|
|
|
|
|
|
|
|
288 |
?>
|
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.4.1
|
8 |
Author: Nickolas Bossinas
|
9 |
Author URI: http://www.iptanus.com
|
10 |
*/
|
28 |
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
29 |
*/
|
30 |
|
31 |
+
//set global db variables
|
32 |
+
$wfu_tb_log_version = "1.0";
|
33 |
+
$wfu_tb_userdata_version = "1.0";
|
34 |
+
|
35 |
/* do not load plugin if this is the login page */
|
36 |
$uri = $_SERVER['REQUEST_URI'];
|
37 |
if ( strpos($uri, 'wp-login.php') !== false ) return;
|
46 |
wp_enqueue_style( 'wp-color-picker' );
|
47 |
wp_enqueue_script('wordpress_file_upload_admin_script', WPFILEUPLOAD_DIR.'js/wordpress_file_upload_adminfunctions.js', array( 'wp-color-picker' ), false, true);
|
48 |
wp_enqueue_script('wordpress_file_upload_classname_script', WPFILEUPLOAD_DIR.'js/getElementsByClassName-1.0.1.js');
|
49 |
+
$AdminParams = array("wfu_ajax_url" => site_url()."/wp-admin/admin-ajax.php");
|
50 |
+
wp_localize_script( 'wordpress_file_upload_admin_script', 'AdminParams', $AdminParams );
|
51 |
}
|
52 |
}
|
53 |
else {
|
58 |
wp_enqueue_script('wordpress_file_upload_script', WPFILEUPLOAD_DIR.'js/wordpress_file_upload_functions.js');
|
59 |
}
|
60 |
add_action('admin_menu', 'wordpress_file_upload_add_admin_pages');
|
61 |
+
register_activation_hook(__FILE__,'wordpress_file_upload_install');
|
62 |
+
add_action('plugins_loaded', 'wordpress_file_upload_update_db_check');
|
63 |
+
//ajax actions
|
64 |
add_action('wp_ajax_wfu_ajax_action', 'wfu_ajax_action_callback');
|
65 |
add_action('wp_ajax_nopriv_wfu_ajax_action', 'wfu_ajax_action_callback');
|
66 |
add_action('wp_ajax_wfu_ajax_action_send_email_notification', 'wfu_ajax_action_send_email_notification');
|
67 |
add_action('wp_ajax_nopriv_wfu_ajax_action_send_email_notification', 'wfu_ajax_action_send_email_notification');
|
68 |
+
add_action('wp_ajax_wfu_ajax_action_notify_wpfilebase', 'wfu_ajax_action_notify_wpfilebase');
|
69 |
+
add_action('wp_ajax_nopriv_wfu_ajax_action_notify_wpfilebase', 'wfu_ajax_action_notify_wpfilebase');
|
70 |
add_action('wp_ajax_wfu_ajax_action_save_shortcode', 'wfu_ajax_action_save_shortcode');
|
71 |
+
add_action('wp_ajax_wfu_ajax_action_read_subfolders', 'wfu_ajax_action_read_subfolders');
|
72 |
+
add_action('wp_ajax_wfu_ajax_action_download_file', 'wfu_ajax_action_download_file');
|
73 |
wfu_include_lib();
|
|
|
|
|
74 |
|
75 |
function wfu_include_lib() {
|
76 |
if ( $handle = opendir(plugin_dir_path( __FILE__ )."lib/") ) {
|
102 |
global $blog_id;
|
103 |
$params = wfu_plugin_parse_array($incomingfromhandler);
|
104 |
$sid = $params["uploadid"];
|
105 |
+
// store current page id in params array
|
106 |
+
$params["pageid"] = $post->ID;
|
107 |
|
108 |
$_SESSION['wfu_token_'.$sid] = uniqid(mt_rand(), TRUE);
|
109 |
|
132 |
$params["adminerrors"] = "";
|
133 |
|
134 |
/* Define dynamic upload path from variables */
|
135 |
+
$search = array ('/%userid%/', '/%username%/', '/%blogid%/', '/%pageid%/', '/%pagetitle%/');
|
136 |
if ( is_user_logged_in() ) $username = $user->user_login;
|
137 |
else $username = "guests";
|
138 |
+
$replace = array ($user->ID, $username, $blog_id, $post->ID, get_the_title($post->ID));
|
139 |
$params["uploadpath"] = preg_replace($search, $replace, $params["uploadpath"]);
|
140 |
|
141 |
/* Determine if userdata fields have been defined */
|
245 |
array_push($section_array, $uploadform_item);
|
246 |
$wordpress_file_upload_output .= call_user_func_array("wfu_add_div", $section_array);
|
247 |
}
|
248 |
+
|
249 |
/* Pass constants to javascript */
|
250 |
$consts = wfu_set_javascript_constants();
|
251 |
$handler = 'function() { wfu_Initialize_Consts("'.$consts.'") }';
|
260 |
// In the second case we do not want to perform any file upload, so we abort the rest of the script.
|
261 |
if ( $_SESSION['wfu_check_refresh_'.$sid] != "form button pressed" ) {
|
262 |
$_SESSION['wfu_check_refresh_'.$sid] = 'do not process';
|
263 |
+
$wordpress_file_upload_output .= wfu_post_plugin_actions($params);
|
264 |
return $wordpress_file_upload_output."\n";
|
265 |
}
|
266 |
$_SESSION['wfu_check_refresh_'.$sid] = 'do not process';
|
274 |
// 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.
|
275 |
if ( isset($_FILES[$uploadedfile.'_redirected']) ) $params['forceclassic'] = "true";
|
276 |
|
277 |
+
if ( $params['forceclassic'] != "true" ) {
|
278 |
+
$wordpress_file_upload_output .= wfu_post_plugin_actions($params);
|
279 |
+
return $wordpress_file_upload_output."\n";
|
280 |
+
}
|
281 |
|
282 |
// The section below is executed when using classic upload methods
|
283 |
if ( isset( $_POST[$adminerrorcodes] ) ) {
|
297 |
$wfu_process_file_array_str = wfu_encode_array_to_string($wfu_process_file_array);
|
298 |
$ProcessUploadComplete_functiondef = 'function(){wfu_ProcessUploadComplete('.$sid.', 1, "'.$wfu_process_file_array_str.'", "no-ajax", "", "", "'.$safe_output.'", ["false", "", "false"]);}';
|
299 |
$wordpress_file_upload_output .= '<script type="text/javascript">window.onload='.$ProcessUploadComplete_functiondef.'</script>';
|
|
|
300 |
|
301 |
+
$wordpress_file_upload_output .= wfu_post_plugin_actions($params);
|
302 |
return $wordpress_file_upload_output."\n";
|
303 |
}
|
304 |
|
305 |
+
function wfu_post_plugin_actions($params) {
|
306 |
+
$echo_str = '';
|
307 |
+
|
308 |
+
return $echo_str;
|
309 |
+
}
|
310 |
+
|
311 |
?>
|