Version Description
- COOKIEHASH bug corrected
- credentials in FTP paths are stripped from the paths
- corrected File Detais to File Details
- regex "/
Download this release
Release Info
Developer | nickboss |
Plugin | WordPress File Upload |
Version | 4.15.0 |
Comparing to | |
See all releases |
Code changes from version 4.14.4 to 4.15.0
- lib/wfu_admin.php +3 -3
- lib/wfu_admin_browser.php +1660 -1660
- lib/wfu_admin_composer.php +963 -963
- lib/wfu_admin_log.php +203 -202
- lib/wfu_admin_maintenance.php +561 -561
- lib/wfu_admin_settings.php +329 -329
- lib/wfu_admin_uploadedfiles.php +675 -675
- lib/wfu_ajaxactions.php +1343 -1343
- lib/wfu_attributes.php +1853 -1853
- lib/wfu_blocks.php +817 -817
- lib/wfu_constants.php +521 -504
- lib/wfu_functions.php +0 -1992
lib/wfu_admin.php
CHANGED
@@ -744,7 +744,7 @@ function wfu_manage_mainmenu($message = '') {
|
|
744 |
$echo_str .= "\n\t\t\t\t\t".'<td colspan="2" style="width:100px;">';
|
745 |
$rel_path = ABSWPFILEUPLOAD_DIR.'release_notes.txt';
|
746 |
$rel_notes = '';
|
747 |
-
if (
|
748 |
$echo_str .= "\n\t\t\t\t\t\t".'<div style="text-align:justify;">'.$rel_notes.'</div>';
|
749 |
$echo_str .= "\n\t\t\t\t\t".'</td>';
|
750 |
$echo_str .= "\n\t\t\t\t".'</tr>';
|
@@ -1012,8 +1012,8 @@ function wfu_manage_instances_of_shortcode($tag, $title, $slug, $inc) {
|
|
1012 |
}
|
1013 |
|
1014 |
$list = wfu_construct_post_list($posts);
|
1015 |
-
$pagelist = wfu_flatten_post_list($list["page"]);
|
1016 |
-
$postlist = wfu_flatten_post_list($list["post"]);
|
1017 |
|
1018 |
$echo_str = "\n\t\t".'<h3 style="margin-bottom: 10px; margin-top: 40px;">'.$title.'</h3>';
|
1019 |
$onchange_js = 'document.getElementById(\'wfu_add_plugin_ok_'.$inc.'\').disabled = !((document.getElementById(\'wfu_page_type_'.$inc.'\').value == \'page\' && document.getElementById(\'wfu_page_list_'.$inc.'\').value != \'\') || (document.getElementById(\'wfu_page_type_'.$inc.'\').value == \'post\' && document.getElementById(\'wfu_post_list_'.$inc.'\').value != \'\'));';
|
744 |
$echo_str .= "\n\t\t\t\t\t".'<td colspan="2" style="width:100px;">';
|
745 |
$rel_path = ABSWPFILEUPLOAD_DIR.'release_notes.txt';
|
746 |
$rel_notes = '';
|
747 |
+
if ( wfu_file_exists($rel_path, "wfu_manage_mainmenu") ) $rel_notes = file_get_contents($rel_path);
|
748 |
$echo_str .= "\n\t\t\t\t\t\t".'<div style="text-align:justify;">'.$rel_notes.'</div>';
|
749 |
$echo_str .= "\n\t\t\t\t\t".'</td>';
|
750 |
$echo_str .= "\n\t\t\t\t".'</tr>';
|
1012 |
}
|
1013 |
|
1014 |
$list = wfu_construct_post_list($posts);
|
1015 |
+
$pagelist = ( isset($list["page"]) ? wfu_flatten_post_list($list["page"]) : array() );
|
1016 |
+
$postlist = ( isset($list["post"]) ? wfu_flatten_post_list($list["post"]) : array() );
|
1017 |
|
1018 |
$echo_str = "\n\t\t".'<h3 style="margin-bottom: 10px; margin-top: 40px;">'.$title.'</h3>';
|
1019 |
$onchange_js = 'document.getElementById(\'wfu_add_plugin_ok_'.$inc.'\').disabled = !((document.getElementById(\'wfu_page_type_'.$inc.'\').value == \'page\' && document.getElementById(\'wfu_page_list_'.$inc.'\').value != \'\') || (document.getElementById(\'wfu_page_type_'.$inc.'\').value == \'post\' && document.getElementById(\'wfu_post_list_'.$inc.'\').value != \'\'));';
|
lib/wfu_admin_browser.php
CHANGED
@@ -1,1661 +1,1661 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* File Browser Page in Dashboard Area of Plugin
|
5 |
-
*
|
6 |
-
* This file contains functions related to File Browser page of plugin's
|
7 |
-
* Dashboard area.
|
8 |
-
*
|
9 |
-
* @link /lib/wfu_admin_browser.php
|
10 |
-
*
|
11 |
-
* @package WordPress File Upload Plugin
|
12 |
-
* @subpackage Core Components
|
13 |
-
* @since 3.7.1
|
14 |
-
*/
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Display the File Browser Page.
|
18 |
-
*
|
19 |
-
* This function displays the File Browser page of the plugin's Dashboard area.
|
20 |
-
*
|
21 |
-
* @since 2.2.1
|
22 |
-
*
|
23 |
-
* @param string $basedir_code A code string corresponding to the folder to be
|
24 |
-
* displayed.
|
25 |
-
* @param integer $page Optional. The page to display in case folder contents
|
26 |
-
* are paginated.
|
27 |
-
* @param bool $only_table_rows Optional. Return only the HTML code of the table
|
28 |
-
* rows.
|
29 |
-
*
|
30 |
-
* @return string The HTML output of the plugin's File Browser Dashboard page.
|
31 |
-
*/
|
32 |
-
function wfu_browse_files($basedir_code, $page = -1, $only_table_rows = false) {
|
33 |
-
$siteurl = site_url();
|
34 |
-
$plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
|
35 |
-
$user = wp_get_current_user();
|
36 |
-
//store session variables for use from the downloader
|
37 |
-
|
38 |
-
if ( !current_user_can( 'manage_options' ) ) return;
|
39 |
-
|
40 |
-
//first decode basedir_code
|
41 |
-
$basedir = wfu_get_filepath_from_safe($basedir_code);
|
42 |
-
//clean session array holding dir and file paths if it is too big
|
43 |
-
if ( WFU_USVAR_exists('wfu_filepath_safe_storage') && count(WFU_USVAR('wfu_filepath_safe_storage')) > WFU_VAR("WFU_PHP_ARRAY_MAXLEN") ) WFU_USVAR_store('wfu_filepath_safe_storage', array());
|
44 |
-
|
45 |
-
//basedir may also contain information about the sorting of the displayed
|
46 |
-
//elements, as well as a filename that needs to be located and get focus on
|
47 |
-
//the browser;
|
48 |
-
//sorting information is enclosed in double brackets: [[sort_info]]
|
49 |
-
//filename information is enclosed in double braces: {{filename}}
|
50 |
-
$sort = "";
|
51 |
-
$located_file = "";
|
52 |
-
$located_file_found = false;
|
53 |
-
$filter = "";
|
54 |
-
if ( $basedir !== false ) {
|
55 |
-
$ret = wfu_extract_sortdata_from_path($basedir);
|
56 |
-
$basedir = $ret['path'];
|
57 |
-
$sort = $ret['sort'];
|
58 |
-
$located_file = $ret['file'];
|
59 |
-
$filter = $ret['filter'];
|
60 |
-
}
|
61 |
-
if ( $sort == "" ) $sort = 'name';
|
62 |
-
if ( substr($sort, 0, 1) == '-' ) $order = SORT_DESC;
|
63 |
-
else $order = SORT_ASC;
|
64 |
-
//if page is not -1, then do not locate a file
|
65 |
-
if ( $located_file != "" && $page > -1 ) $located_file = "";
|
66 |
-
//adjust page to be larger than zero
|
67 |
-
if ( $page < 1 ) $page = 1;
|
68 |
-
|
69 |
-
//adjust basedir to have a standard format
|
70 |
-
if ( $basedir !== false ) {
|
71 |
-
if ( substr($basedir, -1) != '/' ) $basedir .= '/';
|
72 |
-
if ( substr($basedir, 0, 1) == '/' ) $basedir = substr($basedir, 1);
|
73 |
-
//calculate the absolute path of basedir knowing that basedir is relative to website root
|
74 |
-
$basedir = wfu_path_rel2abs($basedir);
|
75 |
-
if ( !
|
76 |
-
}
|
77 |
-
//set basedit to default value if empty
|
78 |
-
if ( $basedir === false ) {
|
79 |
-
$plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
|
80 |
-
$basedir = ( isset($plugin_options['basedir']) ? $plugin_options['basedir'] : "" );
|
81 |
-
$temp_params = array( 'uploadpath' => $basedir, 'accessmethod' => 'normal', 'ftpinfo' => '', 'useftpdomain' => 'false' );
|
82 |
-
$basedir = wfu_upload_plugin_full_path($temp_params);
|
83 |
-
}
|
84 |
-
//find relative dir
|
85 |
-
$reldir = str_replace(wfu_abspath(), "root/", $basedir);
|
86 |
-
//save dir route to an array
|
87 |
-
$parts = explode('/', $reldir);
|
88 |
-
$route = array();
|
89 |
-
$prev = "";
|
90 |
-
foreach ( $parts as $part ) {
|
91 |
-
$part = trim($part);
|
92 |
-
if ( $part != "" ) {
|
93 |
-
// if ( $part == 'root' && $prev == "" ) $prev = wfu_abspath();
|
94 |
-
if ( $part == 'root' && $prev == "" ) $prev = "";
|
95 |
-
else $prev .= $part.'/';
|
96 |
-
array_push($route, array( 'item' => $part, 'path' => $prev ));
|
97 |
-
}
|
98 |
-
}
|
99 |
-
//calculate upper directory
|
100 |
-
$updir = substr($basedir, 0, -1);
|
101 |
-
$delim_pos = strrpos($updir, '/');
|
102 |
-
if ( $delim_pos !== false ) $updir = substr($updir, 0, $delim_pos + 1);
|
103 |
-
|
104 |
-
//define referer (with sort data) to point to this url for use by the elements
|
105 |
-
$referer = $siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$basedir_code;
|
106 |
-
$referer_code = wfu_safe_store_filepath($referer.'[['.$sort.']]');
|
107 |
-
//define header parameters that can be later used when defining file actions
|
108 |
-
$header_params = array();
|
109 |
-
|
110 |
-
//find contents of current folder taking into account pagination, if it is
|
111 |
-
//activated; contents are found following an optimized procedure as follows:
|
112 |
-
// 1. all dirs and files are found and stored in separate arrays
|
113 |
-
// 2. if pagination is activated then it is checked if there are any dirs
|
114 |
-
// in the current page
|
115 |
-
// 3. if dir sorting is name then dirs are sorted
|
116 |
-
// 4. if dir sorting is date then stat is called for all dirs and then they
|
117 |
-
// are sorted
|
118 |
-
// 5. if pagination is activated then dirs array is sliced to keep only the
|
119 |
-
// ones belonging to the current page and then stat is called if it has
|
120 |
-
// not already been called
|
121 |
-
// 6. if there is room in the page for showing files, then files are also
|
122 |
-
// processed
|
123 |
-
// 7. if file sorting is name then files are sorted
|
124 |
-
// 8. if file sorting is date or size then stat is called for all files and
|
125 |
-
// then they are sorted
|
126 |
-
// 9. if file sorting is user then db record is retrieved for all files and
|
127 |
-
// then they are sorted
|
128 |
-
// 10. if pagination is activated then files array is sliced to keep only
|
129 |
-
// the ones fitting in the page; then stat is called and/or db record is
|
130 |
-
// retrieved
|
131 |
-
//first calculate dirs and files arrays
|
132 |
-
$dirlist = array();
|
133 |
-
$dirlist_include = true;
|
134 |
-
$dirlist_perpage = array();
|
135 |
-
$dirstat_ok = false;
|
136 |
-
$filelist = array();
|
137 |
-
$filestat_ok = false;
|
138 |
-
$filerec_ok = false;
|
139 |
-
if ( $handle = opendir($basedir) ) {
|
140 |
-
$blacklist = array('.', '..');
|
141 |
-
while ( false !== ($file = readdir($handle)) )
|
142 |
-
if ( !in_array($file, $blacklist) ) {
|
143 |
-
$filepath = $basedir.$file;
|
144 |
-
if ( is_dir($filepath) ) array_push($dirlist, array( 'name' => $file, 'fullpath' => $filepath ));
|
145 |
-
else array_push($filelist, array( 'name' => $file, 'fullpath' => $filepath ));
|
146 |
-
}
|
147 |
-
closedir($handle);
|
148 |
-
}
|
149 |
-
$dirlist_count = count($dirlist);
|
150 |
-
$filelist_count = count($filelist);
|
151 |
-
//get pagination details and determine if any dirs will be shown
|
152 |
-
$maxrows = (int)WFU_VAR("WFU_ADMINBROWSER_TABLE_MAXROWS");
|
153 |
-
$files_total = $dirlist_count + $filelist_count;
|
154 |
-
if ( $maxrows > 0 ) {
|
155 |
-
$pages = max(ceil($files_total / $maxrows), 1);
|
156 |
-
if ( $page > $pages ) $page = $pages;
|
157 |
-
//if first item index passes number of dirs then do not include dirs
|
158 |
-
if ( ($page - 1) * $maxrows >= $dirlist_count ) $dirlist_include = false;
|
159 |
-
//if a filename has been defined to get focus, then $dirlist_include
|
160 |
-
//needs to be true in order to calculate the dirs of every page
|
161 |
-
if ( $located_file != "" ) $dirlist_include = true;
|
162 |
-
}
|
163 |
-
//process dirs if they are included in page
|
164 |
-
if ( $dirlist_include ) {
|
165 |
-
//adjust sort details
|
166 |
-
$dirsort = ( substr($sort, -4) == 'date' ? 'mdate' : substr($sort, -4) );
|
167 |
-
$dirorder = $order;
|
168 |
-
if ( $dirsort == 'size' ) { $dirsort = 'name'; $dirorder = SORT_ASC; }
|
169 |
-
if ( $dirsort == 'user' ) { $dirsort = 'name'; $dirorder = SORT_ASC; }
|
170 |
-
switch ( $dirsort ) {
|
171 |
-
case "name": $dirsort .= ":s"; break;
|
172 |
-
case "mdate": $dirsort .= ":n"; break;
|
173 |
-
}
|
174 |
-
//if dir sort is mdate or if a file needs to be located then first
|
175 |
-
//calculate stat
|
176 |
-
if ( substr($dirsort, 0, 5) == 'mdate' || $located_file != "" ) {
|
177 |
-
foreach ( $dirlist as &$dir ) {
|
178 |
-
$stat =
|
179 |
-
$dir['mdate'] = $stat['mtime'];
|
180 |
-
}
|
181 |
-
unset($dir);
|
182 |
-
$dirstat_ok = true;
|
183 |
-
}
|
184 |
-
//sort dirs
|
185 |
-
$dirlist = wfu_array_sort($dirlist, $dirsort, $dirorder);
|
186 |
-
//if pagination is activated then slice dirs array to keep only the
|
187 |
-
//items belonging in the current page
|
188 |
-
if ( $maxrows > 0 ) {
|
189 |
-
//before slicing we store the items in $dirlist_perpage array
|
190 |
-
$i = $maxrows;
|
191 |
-
$ipage = 0;
|
192 |
-
foreach ( $dirlist as $dir ) {
|
193 |
-
if ( $i >= $maxrows ) {
|
194 |
-
$i = 0;
|
195 |
-
$ipage ++;
|
196 |
-
$dirlist_perpage[$ipage] = array();
|
197 |
-
}
|
198 |
-
array_push($dirlist_perpage[$ipage], $dir);
|
199 |
-
$i ++;
|
200 |
-
}
|
201 |
-
//now we slice $dirlist
|
202 |
-
$dirlist = array_slice($dirlist, ($page - 1) * $maxrows, $maxrows);
|
203 |
-
}
|
204 |
-
//calculate stat for the remaining dirs array, if it has not already
|
205 |
-
//been done
|
206 |
-
if ( !$dirstat_ok ) {
|
207 |
-
foreach ( $dirlist as &$dir ) {
|
208 |
-
$stat =
|
209 |
-
$dir['mdate'] = $stat['mtime'];
|
210 |
-
}
|
211 |
-
unset($dir);
|
212 |
-
}
|
213 |
-
}
|
214 |
-
else $dirlist = array();
|
215 |
-
//determine if any files will be included in page; in case pagination is
|
216 |
-
//activated then the remaining places need to be more than zero
|
217 |
-
$files_included = ( $maxrows > 0 ? ( $maxrows - count($dirlist) > 0 ) : true );
|
218 |
-
//if a filename has been defined to get focus, then $files_included
|
219 |
-
//needs to be true in order to re-calculate the page
|
220 |
-
if ( $located_file != "" ) $files_included = true;
|
221 |
-
if ( $files_included ) {
|
222 |
-
//adjust sort details
|
223 |
-
$filesort = ( substr($sort, -4) == 'date' ? 'mdate' : substr($sort, -4) );
|
224 |
-
switch ( $filesort ) {
|
225 |
-
case "name": $filesort .= ":s"; break;
|
226 |
-
case "size": $filesort .= ":n"; break;
|
227 |
-
case "mdate": $filesort .= ":n"; break;
|
228 |
-
case "user": $filesort .= ":s"; break;
|
229 |
-
}
|
230 |
-
//if file sort is size or mdate then first calculate stat
|
231 |
-
if ( substr($filesort, 0, 4) == 'size' || substr($filesort, 0, 5) == 'mdate' ) {
|
232 |
-
foreach ( $filelist as &$file ) {
|
233 |
-
$stat =
|
234 |
-
$file['size'] = $stat['size'];
|
235 |
-
$file['mdate'] = $stat['mtime'];
|
236 |
-
}
|
237 |
-
unset($file);
|
238 |
-
$filestat_ok = true;
|
239 |
-
}
|
240 |
-
//if file sort is user then first calculate db records
|
241 |
-
elseif ( substr($filesort, 0, 4) == 'user' ) {
|
242 |
-
foreach ( $filelist as &$file ) {
|
243 |
-
//find relative file record in database together with user data;
|
244 |
-
//if the file is php, then file record is null meaning that the file
|
245 |
-
//can only be viewed; if file record is not found then the file can
|
246 |
-
//again only be viewed
|
247 |
-
if ( preg_match("/\.php$/", $file['fullpath']) ) $filerec = null;
|
248 |
-
else $filerec = wfu_get_file_rec($file['fullpath'], true);
|
249 |
-
//find user who uploaded the file
|
250 |
-
$username = ( $filerec != null ? wfu_get_username_by_id($filerec->uploaduserid) : '' );
|
251 |
-
$file['user'] = $username;
|
252 |
-
$file['filedata'] = $filerec;
|
253 |
-
}
|
254 |
-
unset($file);
|
255 |
-
$filerec_ok = true;
|
256 |
-
}
|
257 |
-
//sort files
|
258 |
-
$filelist = wfu_array_sort($filelist, $filesort, $order);
|
259 |
-
//if pagination is activated and a file needs to receive focus, then we
|
260 |
-
//need to calculate the page where the file is shown
|
261 |
-
if ( $maxrows > 0 && $located_file != "" ) {
|
262 |
-
$i = $dirlist_count;
|
263 |
-
foreach ( $filelist as $key => $file ) {
|
264 |
-
if ( $file['name'] == $located_file ) {
|
265 |
-
$located_file_found = true;
|
266 |
-
$filelist[$key]['highlighted'] = 1;
|
267 |
-
break;
|
268 |
-
}
|
269 |
-
$i ++;
|
270 |
-
}
|
271 |
-
if ( $located_file_found ) {
|
272 |
-
$page = floor( $i / $maxrows ) + 1;
|
273 |
-
if ( isset($dirlist_perpage[$page]) ) $dirlist = $dirlist_perpage[$page];
|
274 |
-
else $dirlist = array();
|
275 |
-
}
|
276 |
-
}
|
277 |
-
//if pagination is activated then slice files array to keep only the items
|
278 |
-
//belonging in the current page
|
279 |
-
if ( $maxrows > 0 )
|
280 |
-
$filelist = array_slice($filelist, max(($page - 1) * $maxrows - $dirlist_count, 0), $maxrows - count($dirlist));
|
281 |
-
if ( !$filestat_ok || !$filerec_ok ) {
|
282 |
-
foreach ( $filelist as &$file ) {
|
283 |
-
if ( !$filestat_ok ) {
|
284 |
-
$stat =
|
285 |
-
$file['size'] = $stat['size'];
|
286 |
-
$file['mdate'] = $stat['mtime'];
|
287 |
-
}
|
288 |
-
if ( !$filerec_ok ) {
|
289 |
-
if ( preg_match("/\.php$/", $file['fullpath']) ) $filerec = null;
|
290 |
-
else $filerec = wfu_get_file_rec($file['fullpath'], true);
|
291 |
-
$username = ( $filerec != null ? wfu_get_username_by_id($filerec->uploaduserid) : '' );
|
292 |
-
$file['user'] = $username;
|
293 |
-
$file['filedata'] = $filerec;
|
294 |
-
}
|
295 |
-
}
|
296 |
-
unset($file);
|
297 |
-
}
|
298 |
-
}
|
299 |
-
else $filelist = array();
|
300 |
-
|
301 |
-
//start html output
|
302 |
-
$echo_str = "";
|
303 |
-
if ( !$only_table_rows ) {
|
304 |
-
$echo_str .= "\n".'<div class="wrap">';
|
305 |
-
$echo_str .= "\n\t".'<h2>Wordpress File Upload Control Panel</h2>';
|
306 |
-
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
307 |
-
$echo_str .= wfu_generate_dashboard_menu("\n\t\t", "File Browser");
|
308 |
-
$echo_str .= "\n\t".'<div>';
|
309 |
-
$echo_str .= "\n\t\t".'<span><strong>Location:</strong> </span>';
|
310 |
-
foreach ( $route as $item ) {
|
311 |
-
// store dir path that we need to pass to other functions in session, instead of exposing it in the url
|
312 |
-
$dir_code = wfu_safe_store_filepath($item['path']);
|
313 |
-
$echo_str .= '<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$dir_code.'">'.$item['item'].'</a>';
|
314 |
-
$echo_str .= '<span>/</span>';
|
315 |
-
}
|
316 |
-
//file browser header
|
317 |
-
$echo_str .= "\n\t".'</div>';
|
318 |
-
// $dir_code = wfu_safe_store_filepath(wfu_path_abs2rel($basedir).'[['.$sort.']]');
|
319 |
-
// $echo_str .= "\n\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=create_dir&dir='.$dir_code.'" class="button" title="create folder" style="margin-top:6px">Create folder</a>';
|
320 |
-
$echo_str .= "\n\t".'<div style="margin-top:10px; position:relative;">';
|
321 |
-
$echo_str .= wfu_add_loading_overlay("\n\t\t", "adminbrowser");
|
322 |
-
$adminbrowser_nonce = wp_create_nonce( 'wfu-adminbrowser-page' );
|
323 |
-
$echo_str .= "\n\t\t".'<div class="wfu_adminbrowser_header" style="width: 100%;">';
|
324 |
-
$bulkactions = array(
|
325 |
-
array( "name" => "move", "title" => "Move" ),
|
326 |
-
array( "name" => "delete", "title" => "Delete" ),
|
327 |
-
array( "name" => "include", "title" => "Include" )
|
328 |
-
);
|
329 |
-
$echo_str .= wfu_add_bulkactions_header("\n\t\t\t", "adminbrowser", $bulkactions);
|
330 |
-
if ( $maxrows > 0 ) {
|
331 |
-
$echo_str .= wfu_add_pagination_header("\n\t\t\t", "adminbrowser", $page, $pages, $adminbrowser_nonce);
|
332 |
-
}
|
333 |
-
$echo_str .= "\n\t\t\t".'<input id="wfu_adminbrowser_action_url" type="hidden" value="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload" />';
|
334 |
-
$echo_str .= "\n\t\t\t".'<input id="wfu_adminbrowser_code" type="hidden" value="'.$basedir_code.'" />';
|
335 |
-
$echo_str .= "\n\t\t\t".'<input id="wfu_adminbrowser_referer" type="hidden" value="'.$referer_code.'" />';
|
336 |
-
$echo_str .= "\n\t\t\t".'<input id="wfu_download_file_nonce" type="hidden" value="'.wp_create_nonce('wfu_download_file_invoker').'" />';
|
337 |
-
$echo_str .= "\n\t\t\t".'<input id="wfu_include_file_nonce" type="hidden" value="'.wp_create_nonce('wfu_include_file').'" />';
|
338 |
-
$echo_str .= "\n\t\t".'</div>';
|
339 |
-
$echo_str .= "\n\t\t".'<table id="wfu_adminbrowser_table" class="wfu-adminbrowser wp-list-table widefat fixed striped">';
|
340 |
-
$echo_str .= "\n\t\t\t".'<thead>';
|
341 |
-
$echo_str .= "\n\t\t\t\t".'<tr>';
|
342 |
-
$echo_str .= "\n\t\t\t\t\t".'<td scope="col" width="5%" class="manage-column check-column">';
|
343 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<input id="wfu_select_all_visible" type="checkbox" onchange="wfu_adminbrowser_select_all_visible_changed();" style="-webkit-appearance:checkbox;" />';
|
344 |
-
$echo_str .= "\n\t\t\t\t\t".'</td>';
|
345 |
-
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="25%" class="manage-column column-primary">';
|
346 |
-
$dir_code = wfu_safe_store_filepath(wfu_path_abs2rel($basedir).'[['.( substr($sort, -4) == 'name' ? ( $order == SORT_ASC ? '-name' : 'name' ) : 'name' ).']]');
|
347 |
-
$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='.$dir_code.'">Name'.( substr($sort, -4) == 'name' ? ( $order == SORT_ASC ? ' ↑' : ' ↓' ) : '' ).'</a>';
|
348 |
-
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
349 |
-
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="10%" class="manage-column">';
|
350 |
-
$dir_code = wfu_safe_store_filepath(wfu_path_abs2rel($basedir).'[['.( substr($sort, -4) == 'size' ? ( $order == SORT_ASC ? '-size' : 'size' ) : 'size' ).']]');
|
351 |
-
$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='.$dir_code.'">Size'.( substr($sort, -4) == 'size' ? ( $order == SORT_ASC ? ' ↑' : ' ↓' ) : '' ).'</a>';
|
352 |
-
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
353 |
-
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="20%" class="manage-column">';
|
354 |
-
$dir_code = wfu_safe_store_filepath(wfu_path_abs2rel($basedir).'[['.( substr($sort, -4) == 'date' ? ( $order == SORT_ASC ? '-date' : 'date' ) : 'date' ).']]');
|
355 |
-
$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='.$dir_code.'">Date'.( substr($sort, -4) == 'date' ? ( $order == SORT_ASC ? ' ↑' : ' ↓' ) : '' ).'</a>';
|
356 |
-
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
357 |
-
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="10%" class="manage-column">';
|
358 |
-
$dir_code = wfu_safe_store_filepath(wfu_path_abs2rel($basedir).'[['.( substr($sort, -4) == 'user' ? ( $order == SORT_ASC ? '-user' : 'user' ) : 'user' ).']]');
|
359 |
-
$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='.$dir_code.'">Uploaded By'.( substr($sort, -4) == 'user' ? ( $order == SORT_ASC ? ' ↑' : ' ↓' ) : '' ).'</a>';
|
360 |
-
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
361 |
-
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="30%" class="manage-column">';
|
362 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<label>User Data</label>';
|
363 |
-
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
364 |
-
$echo_str .= "\n\t\t\t\t".'</tr>';
|
365 |
-
$echo_str .= "\n\t\t\t".'</thead>';
|
366 |
-
$echo_str .= "\n\t\t\t".'<tbody>';
|
367 |
-
}
|
368 |
-
|
369 |
-
//show subfolders first
|
370 |
-
if ( $reldir != "root/" ) {
|
371 |
-
$dir_code = wfu_safe_store_filepath(wfu_path_abs2rel($updir));
|
372 |
-
$echo_str .= "\n\t\t\t\t".'<tr>';
|
373 |
-
$echo_str .= "\n\t\t\t\t\t".'<th class="check-column"><input type="checkbox" disabled="disabled" /></th>';
|
374 |
-
$echo_str .= "\n\t\t\t\t\t".'<td class="column-primary" data-colname="Name">';
|
375 |
-
$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='.$dir_code.'" title="go up">..</a>';
|
376 |
-
$echo_str .= "\n\t\t\t\t\t".'</td>';
|
377 |
-
$echo_str .= "\n\t\t\t\t\t".'<td data-colname="Size"> </td>';
|
378 |
-
$echo_str .= "\n\t\t\t\t\t".'<td data-colname="Date"> </td>';
|
379 |
-
$echo_str .= "\n\t\t\t\t\t".'<td data-colname="Uploaded By"> </td>';
|
380 |
-
$echo_str .= "\n\t\t\t\t\t".'<td data-colname="User Data"> </td>';
|
381 |
-
$echo_str .= "\n\t\t\t\t".'</tr>';
|
382 |
-
}
|
383 |
-
$ii = 1;
|
384 |
-
foreach ( $dirlist as $dir ) {
|
385 |
-
$dir_code = wfu_prepare_to_batch_safe_store_filepath(wfu_path_abs2rel($dir['fullpath']).'[['.$sort.']]');
|
386 |
-
$echo_str .= "\n\t\t\t\t".'<tr onmouseover="var actions=document.getElementsByName(\'wfu_dir_actions\'); for (var i=0; i<actions.length; i++) {actions[i].style.visibility=\'hidden\';} document.getElementById(\'wfu_dir_actions_'.$ii.'\').style.visibility=\'visible\'" onmouseout="var actions=document.getElementsByName(\'wfu_dir_actions\'); for (var i=0; i<actions.length; i++) {actions[i].style.visibility=\'hidden\';}">';
|
387 |
-
$echo_str .= "\n\t\t\t\t\t".'<th class="check-column"><input type="checkbox" disabled="disabled" /></th>';
|
388 |
-
$echo_str .= "\n\t\t\t\t\t".'<td class="column-primary" data-colname="Name">';
|
389 |
-
$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='.$dir_code.'" title="'.$dir['name'].'">'.$dir['name'].'</a>';
|
390 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<div id="wfu_dir_actions_'.$ii.'" name="wfu_dir_actions" style="visibility:hidden;">';
|
391 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<span style="visibility:hidden;">';
|
392 |
-
$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_browser&dir=">Noaction</a>';
|
393 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".' | ';
|
394 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'</span>';
|
395 |
-
// $echo_str .= "\n\t\t\t\t\t\t\t".'<span>';
|
396 |
-
// $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='.$dir_code.'" title="Rename this folder">Rename</a>';
|
397 |
-
// $echo_str .= "\n\t\t\t\t\t\t\t\t".' | ';
|
398 |
-
// $echo_str .= "\n\t\t\t\t\t\t\t".'</span>';
|
399 |
-
// $echo_str .= "\n\t\t\t\t\t\t\t".'<span>';
|
400 |
-
// $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='.$dir_code.'" title="Delete this folder">Delete</a>';
|
401 |
-
// $echo_str .= "\n\t\t\t\t\t\t\t".'</span>';
|
402 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</div>';
|
403 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<button type="button" class="toggle-row"><span class="screen-reader-text">Show more details</span></button>';
|
404 |
-
$echo_str .= "\n\t\t\t\t\t".'</td>';
|
405 |
-
$echo_str .= "\n\t\t\t\t\t".'<td data-colname="Size"> </td>';
|
406 |
-
$echo_str .= "\n\t\t\t\t\t".'<td data-colname="Date">'.get_date_from_gmt(date("Y-m-d H:i:s", $dir['mdate']), "d/m/Y H:i:s").'</td>';
|
407 |
-
$echo_str .= "\n\t\t\t\t\t".'<td data-colname="Uploaded By"> </td>';
|
408 |
-
$echo_str .= "\n\t\t\t\t\t".'<td data-colname="User Data"> </td>';
|
409 |
-
$echo_str .= "\n\t\t\t\t".'</tr>';
|
410 |
-
$ii ++;
|
411 |
-
}
|
412 |
-
//store dir paths to safe
|
413 |
-
wfu_batch_safe_store_filepaths();
|
414 |
-
//show contained files
|
415 |
-
foreach ( $filelist as $file ) {
|
416 |
-
$is_included = ( $file['filedata'] != null );
|
417 |
-
$can_be_included = ( $plugin_options['includeotherfiles'] == "1" ) && !wfu_file_extension_blacklisted($file['name']);
|
418 |
-
$highlighted = ( isset($file['highlighted']) && $file['highlighted'] == 1 );
|
419 |
-
$file_code = '';
|
420 |
-
if ( $is_included || $can_be_included ) $file_code = wfu_prepare_to_batch_safe_store_filepath(wfu_path_abs2rel($file['fullpath']).'[['.$sort.']]');
|
421 |
-
$echo_str .= "\n\t\t\t\t".'<tr '.( $highlighted ? 'class="wfu-highlighted" ' : '' ).'onmouseover="var actions=document.getElementsByName(\'wfu_file_actions\'); for (var i=0; i<actions.length; i++) {actions[i].style.visibility=\'hidden\';} document.getElementById(\'wfu_file_actions_'.$ii.'\').style.visibility=\'visible\'" onmouseout="var actions=document.getElementsByName(\'wfu_file_actions\'); for (var i=0; i<actions.length; i++) {actions[i].style.visibility=\'hidden\';}">';
|
422 |
-
$echo_str .= "\n\t\t\t\t\t".'<th class="check-column">';
|
423 |
-
if ( $is_included || $can_be_included ) $echo_str .= "\n\t\t\t\t\t\t".'<input class="wfu_selectors'.( $is_included ? ' wfu_included' : '' ).' wfu_selcode_'.$file_code.'" type="checkbox" onchange="wfu_adminbrowser_selector_changed(this);" />';
|
424 |
-
else $echo_str .= "\n\t\t\t\t\t\t".'<input type="checkbox" disabled="disabled" />';
|
425 |
-
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
426 |
-
$echo_str .= "\n\t\t\t\t\t".'<td class="column-primary" data-colname="Name">';
|
427 |
-
if ( $is_included || $can_be_included )
|
428 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<a id="wfu_file_link_'.$ii.'" class="row-title" href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_details&file='.$file_code.'" title="View and edit file details" style="font-weight:normal;'.( $is_included ? '' : ' display:none;' ).'">'.$file['name'].'</a>';
|
429 |
-
if ( !$is_included )
|
430 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<span id="wfu_file_flat_'.$ii.'">'.$file['name'].'</span>';
|
431 |
-
//set additional $file properties for generating file actions
|
432 |
-
$file["index"] = $ii;
|
433 |
-
$file["code"] = $file_code;
|
434 |
-
$file["referer_code"] = $referer_code;
|
435 |
-
$file_actions = wfu_adminbrowser_file_actions($file, $header_params);
|
436 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<div id="wfu_file_actions_'.$ii.'" name="wfu_file_actions" style="visibility:hidden;">';
|
437 |
-
if ( $is_included || $can_be_included ) {
|
438 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<div id="wfu_file_is_included_actions_'.$ii.'" style="display:'.( $is_included ? 'block' : 'none' ).';">';
|
439 |
-
//add file actions for files already included
|
440 |
-
$array_keys = array_keys($file_actions["is_included"]);
|
441 |
-
$lastkey = array_pop($array_keys);
|
442 |
-
foreach ( $file_actions["is_included"] as $key => $action ) {
|
443 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<span>';
|
444 |
-
foreach ( $action as $line )
|
445 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t\t".$line;
|
446 |
-
if ( $key != $lastkey ) $echo_str .= "\n\t\t\t\t\t\t\t\t\t".' | ';
|
447 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'</span>';
|
448 |
-
}
|
449 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'</div>';
|
450 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<div id="wfu_file_can_be_included_actions_'.$ii.'" style="display:'.( $is_included ? 'none' : 'block' ).';">';
|
451 |
-
//add file actions for files that can be included
|
452 |
-
$array_keys = array_keys($file_actions["can_be_included"]);
|
453 |
-
$lastkey = array_pop($array_keys);
|
454 |
-
foreach ( $file_actions["can_be_included"] as $key => $action ) {
|
455 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<span>';
|
456 |
-
foreach ( $action as $line )
|
457 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t\t".$line;
|
458 |
-
if ( $key != $lastkey ) $echo_str .= "\n\t\t\t\t\t\t\t\t\t".' | ';
|
459 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'</span>';
|
460 |
-
}
|
461 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'</div>';
|
462 |
-
}
|
463 |
-
else {
|
464 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<span style="visibility:hidden;">';
|
465 |
-
$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_browser&dir=">Noaction</a>';
|
466 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".' | ';
|
467 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'</span>';
|
468 |
-
}
|
469 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</div>';
|
470 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<div id="wfu_file_download_container_'.$ii.'" style="display: none;"></div>';
|
471 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<button type="button" class="toggle-row"><span class="screen-reader-text">Show more details</span></button>';
|
472 |
-
$echo_str .= "\n\t\t\t\t\t".'</td>';
|
473 |
-
$echo_str .= "\n\t\t\t\t\t".'<td data-colname="Size">'.$file['size'].'</td>';
|
474 |
-
$echo_str .= "\n\t\t\t\t\t".'<td data-colname="Date">'.get_date_from_gmt(date("Y-m-d H:i:s", $file['mdate']), "d/m/Y H:i:s").'</td>';
|
475 |
-
$echo_str .= "\n\t\t\t\t\t".'<td data-colname="Uploaded By">'.$file['user'].'</td>';
|
476 |
-
$echo_str .= "\n\t\t\t\t\t".'<td data-colname="User Data">';
|
477 |
-
if ( $is_included ) {
|
478 |
-
if ( is_array($file['filedata']->userdata) && count($file['filedata']->userdata) > 0 ) {
|
479 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<select multiple="multiple" style="width:100%; height:40px; background:none; font-size:small;">';
|
480 |
-
foreach ( $file['filedata']->userdata as $userdata )
|
481 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<option>'.$userdata->property.': '.$userdata->propvalue.'</option>';
|
482 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</select>';
|
483 |
-
}
|
484 |
-
}
|
485 |
-
$echo_str .= "\n\t\t\t\t\t".'</td>';
|
486 |
-
$echo_str .= "\n\t\t\t\t".'</tr>';
|
487 |
-
$ii ++;
|
488 |
-
}
|
489 |
-
//store file paths to safe
|
490 |
-
wfu_batch_safe_store_filepaths();
|
491 |
-
|
492 |
-
if ( !$only_table_rows ) {
|
493 |
-
$echo_str .= "\n\t\t\t".'</tbody>';
|
494 |
-
$echo_str .= "\n\t\t".'</table>';
|
495 |
-
$echo_str .= "\n\t\t".'<iframe id="wfu_download_frame" style="display: none;"></iframe>';
|
496 |
-
$echo_str .= "\n\t".'</div>';
|
497 |
-
$echo_str .= "\n\t".'</div>';
|
498 |
-
$echo_str .= "\n".'</div>';
|
499 |
-
}
|
500 |
-
if ( $located_file_found ) {
|
501 |
-
$handler = 'function() { wfu_focus_table_on_highlighted_file("wfu_adminbrowser_table"); }';
|
502 |
-
$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>';
|
503 |
-
}
|
504 |
-
|
505 |
-
return $echo_str;
|
506 |
-
}
|
507 |
-
|
508 |
-
/**
|
509 |
-
* Add Actions to Displayed Files.
|
510 |
-
*
|
511 |
-
* This function sets the actions that can be applied on the displayed files.
|
512 |
-
* Filters can customize these actions.
|
513 |
-
*
|
514 |
-
* @since 4.1.0
|
515 |
-
*
|
516 |
-
* @param array $file An array containing properties of the file.
|
517 |
-
* @param array $params An array of custom parameters to pass to file actions
|
518 |
-
* filter.
|
519 |
-
*
|
520 |
-
* @return array An array of actions that can be executed on the file.
|
521 |
-
*/
|
522 |
-
function wfu_adminbrowser_file_actions($file, $params) {
|
523 |
-
$siteurl = site_url();
|
524 |
-
$actions = array(
|
525 |
-
"is_included" => array(),
|
526 |
-
"can_be_included" => array()
|
527 |
-
);
|
528 |
-
//add file actions if file is already included
|
529 |
-
$actions["is_included"] += array(
|
530 |
-
array( '<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_details&file='.$file["code"].'" title="View and edit file details">Details</a>' ),
|
531 |
-
array( '<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=rename_file&file='.$file["code"].'" title="Rename this file">Rename</a>' ),
|
532 |
-
array( '<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=move_file&file='.$file["code"].'" title="Move this file">Move</a>' ),
|
533 |
-
array( '<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=delete_file&file='.$file["code"].'&referer='.$file["referer_code"].'" title="Delete this file">Delete</a>' ),
|
534 |
-
array( '<a href="javascript:wfu_download_file(\''.$file["code"].'\', '.$file["index"].');" title="Download this file">Download</a>' )
|
535 |
-
);
|
536 |
-
//add file actions if file can be included
|
537 |
-
$actions["can_be_included"] += array(
|
538 |
-
array(
|
539 |
-
'<a id="wfu_include_file_'.$file["index"].'_a" href="javascript:wfu_include_file(\''.$file["code"].'\', '.$file["index"].');" title="Include file in plugin\'s database">Include File</a>',
|
540 |
-
'<img id="wfu_include_file_'.$file["index"].'_img" src="'.WFU_IMAGE_ADMIN_SUBFOLDER_LOADING.'" style="width:12px; display:none;" />',
|
541 |
-
'<input id="wfu_include_file_'.$file["index"].'_inpfail" type="hidden" value="File could not be included!" />'
|
542 |
-
)
|
543 |
-
);
|
544 |
-
|
545 |
-
return $actions;
|
546 |
-
}
|
547 |
-
|
548 |
-
/**
|
549 |
-
* Check if User Owns a File.
|
550 |
-
*
|
551 |
-
* This function checks if a user is the owner of a specific file. It will
|
552 |
-
* return true if the user in an administrator.
|
553 |
-
*
|
554 |
-
* @since 3.8.5
|
555 |
-
*
|
556 |
-
* @param integer $userid The ID of the user to check.
|
557 |
-
* @param object $filerec The database record of the file.
|
558 |
-
*
|
559 |
-
* @return bool True if the user owns the file, false otherwise.
|
560 |
-
*/
|
561 |
-
function wfu_user_owns_file($userid, $filerec) {
|
562 |
-
if ( 0 == $userid )
|
563 |
-
return false;
|
564 |
-
if ( current_user_can('manage_options') ) return true;
|
565 |
-
return false;
|
566 |
-
}
|
567 |
-
|
568 |
-
/**
|
569 |
-
* Check if Current User Owns a File.
|
570 |
-
*
|
571 |
-
* This function checks if the current user is the owner of a specific file. It
|
572 |
-
* will first check if the file extension is valid.
|
573 |
-
*
|
574 |
-
* @since 3.0.0
|
575 |
-
*
|
576 |
-
* @param string $filepath The full path of the file to check.
|
577 |
-
* @param object $filerec Optional. The db record of the file, if available.
|
578 |
-
*
|
579 |
-
* @return bool True if the user owns the file, false otherwise.
|
580 |
-
*/
|
581 |
-
function wfu_current_user_owes_file($filepath, $filerec = null) {
|
582 |
-
//first check if file has a restricted extension; for security reasons some
|
583 |
-
//file extensions cannot be owned
|
584 |
-
if ( wfu_file_extension_blacklisted($filepath) ) return false;
|
585 |
-
//then get file data from database, if exist
|
586 |
-
if ( $filerec == null ) $filerec = wfu_get_file_rec($filepath, false);
|
587 |
-
if ( $filerec == null ) return false;
|
588 |
-
|
589 |
-
$user = wp_get_current_user();
|
590 |
-
return wfu_user_owns_file($user->ID, $filerec);
|
591 |
-
}
|
592 |
-
|
593 |
-
/**
|
594 |
-
* Check if Current User is Allowed to Execute an Action on a File.
|
595 |
-
*
|
596 |
-
* This function checks if the current user is allowed to execute a specific
|
597 |
-
* action on a file.
|
598 |
-
*
|
599 |
-
* @since 2.4.1
|
600 |
-
*
|
601 |
-
* @param string $action A file action to check.
|
602 |
-
* @param string $filepath The full path of the file to check.
|
603 |
-
*
|
604 |
-
* @return object|null Returns the current WP_User object if current user is
|
605 |
-
* allowed to execute the action on the file or null otherwise.
|
606 |
-
*/
|
607 |
-
function wfu_current_user_allowed_action($action, $filepath) {
|
608 |
-
//first get file data from database, if exist
|
609 |
-
$filerec = wfu_get_file_rec($filepath, false);
|
610 |
-
|
611 |
-
$user = wp_get_current_user();
|
612 |
-
if ( 0 == $user->ID ) return null;
|
613 |
-
else $is_admin = current_user_can('manage_options');
|
614 |
-
if ( !$is_admin ) {
|
615 |
-
return null;
|
616 |
-
}
|
617 |
-
return $user;
|
618 |
-
}
|
619 |
-
|
620 |
-
/**
|
621 |
-
* Check if User is Allowed to Execute an Action on a File.
|
622 |
-
*
|
623 |
-
* This function checks if a user is allowed to execute a specific action on a
|
624 |
-
* file.
|
625 |
-
*
|
626 |
-
* @since 2.6.0
|
627 |
-
*
|
628 |
-
* @param string $action A file action to check.
|
629 |
-
* @param string $filepath The full path of the file to check.
|
630 |
-
* @param integer $userid The ID of the user to check.
|
631 |
-
*
|
632 |
-
* @return bool|null Returns true if current user is allowed to execute the
|
633 |
-
* action on the file or null otherwise.
|
634 |
-
*/
|
635 |
-
function wfu_current_user_allowed_action_remote($action, $filepath, $userid) {
|
636 |
-
//first get file data from database, if exist
|
637 |
-
$filerec = wfu_get_file_rec($filepath, false);
|
638 |
-
|
639 |
-
if ( 0 == $userid ) return null;
|
640 |
-
else $is_admin = user_can($userid, 'manage_options');
|
641 |
-
if ( !$is_admin ) {
|
642 |
-
return null;
|
643 |
-
}
|
644 |
-
return true;
|
645 |
-
}
|
646 |
-
|
647 |
-
/**
|
648 |
-
* Confirm Renaming of File.
|
649 |
-
*
|
650 |
-
* This function shows a page to confirm renaming of a file.
|
651 |
-
*
|
652 |
-
* @since 2.2.1
|
653 |
-
*
|
654 |
-
* @param string $file_code A code corresponding to the file/dir to be renamed.
|
655 |
-
* @param string $type Rename dir or file. Can take the values 'dir' or 'file'.
|
656 |
-
* @param string $error An error message to show on top of the page in case an
|
657 |
-
* error occured during renaming.
|
658 |
-
*
|
659 |
-
* @return string The HTML code of the confirmation page.
|
660 |
-
*/
|
661 |
-
function wfu_rename_file_prompt($file_code, $type, $error) {
|
662 |
-
if ( $type == 'dir' ) return;
|
663 |
-
|
664 |
-
$siteurl = site_url();
|
665 |
-
|
666 |
-
$is_admin = current_user_can( 'manage_options' );
|
667 |
-
//check if user is allowed to view file details
|
668 |
-
if ( !$is_admin ) {
|
669 |
-
return;
|
670 |
-
}
|
671 |
-
$file_code = wfu_sanitize_code($file_code);
|
672 |
-
$dec_file = wfu_get_filepath_from_safe($file_code);
|
673 |
-
if ( $dec_file === false ) return;
|
674 |
-
|
675 |
-
//first extract sort info from dec_file
|
676 |
-
$ret = wfu_extract_sortdata_from_path($dec_file);
|
677 |
-
$dec_file = wfu_path_rel2abs($ret['path']);
|
678 |
-
if ( $type == 'dir' && substr($dec_file, -1) == '/' ) $dec_file = substr($dec_file, 0, -1);
|
679 |
-
|
680 |
-
//check if user is allowed to perform this action
|
681 |
-
if ( !wfu_current_user_owes_file($dec_file) ) return;
|
682 |
-
|
683 |
-
$parts = pathinfo($dec_file);
|
684 |
-
$newname = $parts['basename'];
|
685 |
-
$dir_code = wfu_safe_store_filepath(wfu_path_abs2rel($parts['dirname']).'[['.$ret['sort'].']]');
|
686 |
-
|
687 |
-
$echo_str = "\n".'<div class="wrap">';
|
688 |
-
if ( $error ) {
|
689 |
-
$rename_file = WFU_USVAR('wfu_rename_file');
|
690 |
-
$newname = $rename_file['newname'];
|
691 |
-
$echo_str .= "\n\t".'<div class="error">';
|
692 |
-
$echo_str .= "\n\t\t".'<p>'.WFU_USVAR('wfu_rename_file_error').'</p>';
|
693 |
-
$echo_str .= "\n\t".'</div>';
|
694 |
-
}
|
695 |
-
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
696 |
-
if ( $is_admin ) $echo_str .= "\n\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$dir_code.'" class="button" title="go back">Go back</a>';
|
697 |
-
$echo_str .= "\n\t".'</div>';
|
698 |
-
$echo_str .= "\n\t".'<h2 style="margin-bottom: 10px;">Rename '.( $type == 'dir' ? 'Folder' : 'File' ).'</h2>';
|
699 |
-
if ( $is_admin ) $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">';
|
700 |
-
$echo_str .= "\n\t\t".'<input type="hidden" name="action" value="rename'.( $type == 'dir' ? 'dir' : 'file' ).'">';
|
701 |
-
$echo_str .= "\n\t\t".'<input type="hidden" name="dir" value="'.$dir_code.'">';
|
702 |
-
$echo_str .= "\n\t\t".'<input type="hidden" name="file" value="'.$file_code.'">';
|
703 |
-
if ( $type == 'dir' ) $echo_str .= "\n\t\t".'<label>Enter new name for folder <strong>'.$dec_file.'</strong></label><br/>';
|
704 |
-
elseif ( $is_admin ) $echo_str .= "\n\t\t".'<label>Enter new filename for file <strong>'.$dec_file.'</strong></label><br/>';
|
705 |
-
$echo_str .= "\n\t\t".'<input name="wfu_newname" id="wfu_newname" type="text" value="'.$newname.'" style="width:50%;" />';
|
706 |
-
$echo_str .= "\n\t\t".'<p class="submit">';
|
707 |
-
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Rename">';
|
708 |
-
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Cancel">';
|
709 |
-
$echo_str .= "\n\t\t".'</p>';
|
710 |
-
$echo_str .= "\n\t".'</form>';
|
711 |
-
$echo_str .= "\n".'</div>';
|
712 |
-
return $echo_str;
|
713 |
-
}
|
714 |
-
|
715 |
-
/**
|
716 |
-
* Confirm Moving of File.
|
717 |
-
*
|
718 |
-
* This function shows a page to confirm moving of a file to a new location.
|
719 |
-
*
|
720 |
-
* @since 4.10.3
|
721 |
-
*
|
722 |
-
* @param string $file_code A code corresponding to the file to be moved.
|
723 |
-
* @param string $error An error message to show on top of the page in case an
|
724 |
-
* error occured during move.
|
725 |
-
*
|
726 |
-
* @return string The HTML code of the confirmation page.
|
727 |
-
*/
|
728 |
-
function wfu_move_file_prompt($file_code, $error) {
|
729 |
-
$siteurl = site_url();
|
730 |
-
|
731 |
-
$is_admin = current_user_can( 'manage_options' );
|
732 |
-
//check if user is allowed to view file details
|
733 |
-
if ( !$is_admin ) return;
|
734 |
-
|
735 |
-
if ( !is_array($file_code) ) $file_code = array( $file_code );
|
736 |
-
$names = array();
|
737 |
-
foreach ( $file_code as $index => $code ) {
|
738 |
-
$file_code[$index] = wfu_sanitize_code($code);
|
739 |
-
$dec_file = wfu_get_filepath_from_safe($file_code[$index]);
|
740 |
-
if ( $dec_file === false ) unset($file_code[$index]);
|
741 |
-
else {
|
742 |
-
//first extract sort info from dec_file
|
743 |
-
$ret = wfu_extract_sortdata_from_path($dec_file);
|
744 |
-
$dec_file = $ret['path'];
|
745 |
-
$parts = pathinfo($dec_file);
|
746 |
-
array_push($names, $parts['basename']);
|
747 |
-
}
|
748 |
-
}
|
749 |
-
if ( count($file_code) == 0 ) return;
|
750 |
-
$file_code_list = "list:".implode(",", $file_code);
|
751 |
-
|
752 |
-
$newpath = $parts['dirname'];
|
753 |
-
$replacefiles = "";
|
754 |
-
$dir_code = wfu_safe_store_filepath($parts['dirname'].'[['.$ret['sort'].']]');
|
755 |
-
|
756 |
-
$echo_str = "\n".'<div class="wrap">';
|
757 |
-
if ( $error ) {
|
758 |
-
$move_file = WFU_USVAR('wfu_move_file');
|
759 |
-
$newpath = $move_file['newpath'];
|
760 |
-
$replacefiles = $move_file['replacefiles'];
|
761 |
-
$echo_str .= "\n\t".'<div class="error">';
|
762 |
-
$echo_str .= "\n\t\t".'<p>'.WFU_USVAR('wfu_move_file_error').'</p>';
|
763 |
-
$echo_str .= "\n\t".'</div>';
|
764 |
-
}
|
765 |
-
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
766 |
-
$echo_str .= "\n\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$dir_code.'" class="button" title="go back">Go back</a>';
|
767 |
-
$echo_str .= "\n\t".'</div>';
|
768 |
-
$echo_str .= "\n\t".'<h2 style="margin-bottom: 10px;">Move File</h2>';
|
769 |
-
$echo_str .= "\n\t".'<form enctype="multipart/form-data" name="movefile" id="movefile" method="post" action="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload" class="validate">';
|
770 |
-
$echo_str .= "\n\t\t".'<input type="hidden" name="action" value="movefile">';
|
771 |
-
$echo_str .= "\n\t\t".'<input type="hidden" name="dir" value="'.$dir_code.'">';
|
772 |
-
$echo_str .= "\n\t\t".'<input type="hidden" name="file" value="'.$file_code_list.'">';
|
773 |
-
if ( count($names) == 1 )
|
774 |
-
$echo_str .= "\n\t\t".'<label style="display:inline-block; margin-bottom:1em;">Enter destination folder for file <strong>'.$dec_file.'</strong></label><br/>';
|
775 |
-
else {
|
776 |
-
$echo_str .= "\n\t\t".'<label>Enter destination folder for files:</label><br/>';
|
777 |
-
$echo_str .= "\n\t\t".'<ul style="padding-left: 20px; list-style: initial;">';
|
778 |
-
foreach ( $names as $name )
|
779 |
-
$echo_str .= "\n\t\t\t".'<li><strong>'.$name.'</strong></li>';
|
780 |
-
$echo_str .= "\n\t\t".'</ul>';
|
781 |
-
}
|
782 |
-
$echo_str .= "\n\t\t".'<input name="wfu_newpath" id="wfu_newpath" type="text" value="'.$newpath.'" style="width:50%;" />';
|
783 |
-
$echo_str .= "\n\t\t".'<p>';
|
784 |
-
$echo_str .= "\n\t\t\t".'<label>Replace files with the same filename at destination:</label><br />';
|
785 |
-
$echo_str .= "\n\t\t\t".'<input name="wfu_replace" id="wfu_replace_yes" type="radio" value="yes"'.( $replacefiles == "yes" ? ' checked="checked"' : '' ).' /><label for="wfu_replace_yes">Yes</label>';
|
786 |
-
$echo_str .= "\n\t\t\t".'<input name="wfu_replace" id="wfu_replace_no" type="radio" value="no"'.( $replacefiles == "no" ? ' checked="checked"' : '' ).' style="margin-left:1em;" /><label for="wfu_replace_no">No</label>';
|
787 |
-
$echo_str .= "\n\t\t".'</p>';
|
788 |
-
$echo_str .= "\n\t\t".'<p class="submit">';
|
789 |
-
$echo_str .= "\n\t\t\t".'<input type="button" class="button-primary" name="submitBtn" value="Move" onclick="if (!document.getElementById(\'wfu_replace_yes\').checked && !document.getElementById(\'wfu_replace_no\').checked) alert(\'Please select if files in destination with the same filename will be replaced or not!\'); else this.form.submit();" />';
|
790 |
-
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submitBtn" value="Cancel" />';
|
791 |
-
$echo_str .= "\n\t\t".'</p>';
|
792 |
-
$echo_str .= "\n\t".'</form>';
|
793 |
-
$echo_str .= "\n".'</div>';
|
794 |
-
return $echo_str;
|
795 |
-
}
|
796 |
-
|
797 |
-
/**
|
798 |
-
* Execute Renaming of File.
|
799 |
-
*
|
800 |
-
* This function renames a file.
|
801 |
-
*
|
802 |
-
* @since 2.2.1
|
803 |
-
*
|
804 |
-
* @param string $file_code A code corresponding to the file/dir to be renamed.
|
805 |
-
* @param string $type Rename dir or file. Can take the values 'dir' or 'file'.
|
806 |
-
*
|
807 |
-
* @return bool True if renaming of file succeeded, false otherwise.
|
808 |
-
*/
|
809 |
-
function wfu_rename_file($file_code, $type) {
|
810 |
-
if ( $type == 'dir' ) return;
|
811 |
-
|
812 |
-
$user = wp_get_current_user();
|
813 |
-
$is_admin = current_user_can( 'manage_options' );
|
814 |
-
//check if user is allowed to view file details
|
815 |
-
if ( !$is_admin ) {
|
816 |
-
return;
|
817 |
-
}
|
818 |
-
$file_code = wfu_sanitize_code($file_code);
|
819 |
-
$dec_file = wfu_get_filepath_from_safe($file_code);
|
820 |
-
if ( $dec_file === false ) return;
|
821 |
-
|
822 |
-
$dec_file = wfu_path_rel2abs(wfu_flatten_path($dec_file));
|
823 |
-
if ( $type == 'dir' && substr($dec_file, -1) == '/' ) $dec_file = substr($dec_file, 0, -1);
|
824 |
-
if ( !
|
825 |
-
|
826 |
-
//check if user is allowed to perform this action
|
827 |
-
if ( !wfu_current_user_owes_file($dec_file) ) return;
|
828 |
-
|
829 |
-
$parts = pathinfo($dec_file);
|
830 |
-
$error = "";
|
831 |
-
if ( isset($_POST['wfu_newname']) && isset($_POST['submit']) ) {
|
832 |
-
if ( $_POST['submit'] == "Rename" && $_POST['wfu_newname'] != $parts['basename'] ) {
|
833 |
-
$new_file = $parts['dirname'].'/'.$_POST['wfu_newname'];
|
834 |
-
if ( $_POST['wfu_newname'] == "" ) $error = 'Error: New '.( $type == 'dir' ? 'folder ' : 'file' ).'name cannot be empty!';
|
835 |
-
elseif ( preg_match("/[^A-Za-z0-9_.#\-$]/", $_POST['wfu_newname']) ) $error = 'Error: name contained invalid characters that were stripped off! Please try again.';
|
836 |
-
elseif ( substr($_POST['wfu_newname'], -1 - strlen($parts['extension'])) != '.'.$parts['extension'] ) $error = 'Error: new and old file name extensions must be identical! Please correct.';
|
837 |
-
elseif ( wfu_file_extension_blacklisted($_POST['wfu_newname']) ) $error = 'Error: the new file name has an extension that is forbidden for security reasons. Please correct.';
|
838 |
-
elseif (
|
839 |
-
else {
|
840 |
-
//pre-log rename action
|
841 |
-
if ( $type == 'file' ) $retid = wfu_log_action('rename:'.$new_file, $dec_file, $user->ID, '', 0, 0, '', null);
|
842 |
-
//perform rename action
|
843 |
-
if ( rename($dec_file, $new_file) == false ) $error = 'Error: Rename of '.( $type == 'dir' ? 'folder' : 'file' ).' <strong>'.$parts['basename'].'</strong> failed!';
|
844 |
-
//revert log action if file was not renamed
|
845 |
-
if ( $type == 'file' && !
|
846 |
-
}
|
847 |
-
}
|
848 |
-
}
|
849 |
-
if ( $error != "" ) {
|
850 |
-
WFU_USVAR_store('wfu_rename_file_error', $error);
|
851 |
-
$rename_file = WFU_USVAR('wfu_rename_file');
|
852 |
-
$rename_file['newname'] = preg_replace("/[^A-Za-z0-9_.#\-$]/", "", $_POST['wfu_newname']);
|
853 |
-
WFU_USVAR_store('wfu_rename_file', $rename_file);
|
854 |
-
}
|
855 |
-
return ( $error == "" );
|
856 |
-
}
|
857 |
-
|
858 |
-
/**
|
859 |
-
* Execute Moving of File.
|
860 |
-
*
|
861 |
-
* This function moves a file to another location.
|
862 |
-
*
|
863 |
-
* @since 4.10.3
|
864 |
-
*
|
865 |
-
* @param string $file_code A code corresponding to the file to be moved.
|
866 |
-
*
|
867 |
-
* @return bool True if move of file succeeded, false otherwise.
|
868 |
-
*/
|
869 |
-
function wfu_move_file($file_code) {
|
870 |
-
$user = wp_get_current_user();
|
871 |
-
$is_admin = current_user_can( 'manage_options' );
|
872 |
-
//check if user is allowed to view file details
|
873 |
-
if ( !$is_admin ) return;
|
874 |
-
|
875 |
-
if ( !is_array($file_code) ) $file_code = array( $file_code );
|
876 |
-
$dec_files = array();
|
877 |
-
foreach ( $file_code as $index => $code ) {
|
878 |
-
$file_code[$index] = wfu_sanitize_code($code);
|
879 |
-
$dec_file = wfu_get_filepath_from_safe($file_code[$index]);
|
880 |
-
if ( $dec_file !== false ) {
|
881 |
-
$dec_file = wfu_path_rel2abs(wfu_flatten_path($dec_file));
|
882 |
-
array_push($dec_files, $dec_file);
|
883 |
-
}
|
884 |
-
}
|
885 |
-
if ( count($dec_files) == 0 ) return;
|
886 |
-
|
887 |
-
$parts = pathinfo($dec_files[0]);
|
888 |
-
$error = "";
|
889 |
-
$regex = "/([^A-Za-z0-9\-._~!$&'()*+,;=:@#\/\\\\%]|%[^A-Fa-f0-9][^A-Fa-f0-9]|%[A-Fa-f0-9][^A-Fa-f0-9]|%[^A-Fa-f0-9][A-Fa-f0-9]|%.?$)/";
|
890 |
-
if ( isset($_POST['wfu_newpath']) && isset($_POST['wfu_replace']) ) {
|
891 |
-
$oldpath = $parts['dirname'];
|
892 |
-
if ( substr($oldpath, -1) != '/' ) $oldpath = $oldpath.'/';
|
893 |
-
$newpath = preg_replace($regex, "", $_POST['wfu_newpath']);
|
894 |
-
if ( substr($newpath, 0, 1) != '/' ) $newpath = '/'.$newpath;
|
895 |
-
$newpath = realpath(wfu_path_rel2abs($newpath));
|
896 |
-
if ( substr($newpath, -1) != '/' ) $newpath = $newpath.'/';
|
897 |
-
$replacefiles = ( $_POST['wfu_replace'] == 'yes' ? 'yes' : ( $_POST['wfu_replace'] == 'no' ? 'no' : '' ) );
|
898 |
-
if ( trim($_POST['wfu_newpath']) == "" ) $error = 'Error: Destination path cannot be empty!';
|
899 |
-
elseif ( $newpath == $oldpath ) $error = 'Error: Destination path is the same as source path!';
|
900 |
-
elseif ( preg_match($regex, $_POST['wfu_newpath']) ) $error = 'Error: path contained invalid characters that were stripped off! Please try again.';
|
901 |
-
elseif ( !
|
902 |
-
elseif ( $replacefiles == "" ) $error = 'Error: Invalid selection about replacing files with same filename at destination!';
|
903 |
-
else {
|
904 |
-
foreach ( $dec_files as $dec_file ) {
|
905 |
-
if (
|
906 |
-
$new_file = $newpath.wfu_basename($dec_file);
|
907 |
-
if ( !
|
908 |
-
//pre-log move action
|
909 |
-
$retid = wfu_log_action('move:'.$new_file, $dec_file, $user->ID, '', 0, 0, '', null);
|
910 |
-
//perform move action
|
911 |
-
if ( @rename($dec_file, $new_file) === false || !
|
912 |
-
wfu_revert_log_action($retid);
|
913 |
-
}
|
914 |
-
}
|
915 |
-
}
|
916 |
-
}
|
917 |
-
}
|
918 |
-
}
|
919 |
-
if ( $error != "" ) {
|
920 |
-
WFU_USVAR_store('wfu_move_file_error', $error);
|
921 |
-
$move_file = WFU_USVAR('wfu_move_file');
|
922 |
-
$move_file['newpath'] = preg_replace($regex, "", $_POST['wfu_newpath']);
|
923 |
-
$move_file['replacefiles'] = $replacefiles;
|
924 |
-
WFU_USVAR_store('wfu_move_file', $move_file);
|
925 |
-
}
|
926 |
-
return ( $error == "" );
|
927 |
-
}
|
928 |
-
|
929 |
-
/**
|
930 |
-
* Confirm Deletion of File.
|
931 |
-
*
|
932 |
-
* This function shows a page to confirm deletion of a file.
|
933 |
-
*
|
934 |
-
* @since 2.2.1
|
935 |
-
*
|
936 |
-
* @param string $file_code A code corresponding to the file/dir to be deleted.
|
937 |
-
* @param string $type Delete dir or file. Can take the values 'dir' or 'file'.
|
938 |
-
* @param string $referer The page that initiated the deletion of the file.
|
939 |
-
*
|
940 |
-
* @return string The HTML code of the confirmation page.
|
941 |
-
*/
|
942 |
-
function wfu_delete_file_prompt($file_code, $type, $referer) {
|
943 |
-
if ( $type == 'dir' ) return;
|
944 |
-
|
945 |
-
$siteurl = site_url();
|
946 |
-
|
947 |
-
$is_admin = current_user_can( 'manage_options' );
|
948 |
-
//check if user is allowed to view file details
|
949 |
-
if ( !$is_admin ) {
|
950 |
-
return;
|
951 |
-
}
|
952 |
-
if ( !is_array($file_code) ) $file_code = array( $file_code );
|
953 |
-
$names = array();
|
954 |
-
foreach ( $file_code as $index => $code ) {
|
955 |
-
$file_code[$index] = wfu_sanitize_code($code);
|
956 |
-
$dec_file = wfu_get_filepath_from_safe($file_code[$index]);
|
957 |
-
if ( $dec_file === false ) unset($file_code[$index]);
|
958 |
-
else {
|
959 |
-
//first extract sort info from dec_file
|
960 |
-
$ret = wfu_extract_sortdata_from_path($dec_file);
|
961 |
-
$dec_file = wfu_path_rel2abs($ret['path']);
|
962 |
-
if ( $type == 'dir' && substr($dec_file, -1) == '/' ) $dec_file = substr($dec_file, 0, -1);
|
963 |
-
//check if user is allowed to perform this action
|
964 |
-
if ( !wfu_current_user_owes_file($dec_file) ) unset($file_code[$index]);
|
965 |
-
else {
|
966 |
-
$parts = pathinfo($dec_file);
|
967 |
-
array_push($names, $parts['basename']);
|
968 |
-
}
|
969 |
-
}
|
970 |
-
}
|
971 |
-
if ( count($file_code) == 0 ) return;
|
972 |
-
$file_code_list = "list:".implode(",", $file_code);
|
973 |
-
|
974 |
-
$referer_url = wfu_get_filepath_from_safe(wfu_sanitize_code($referer));
|
975 |
-
$ret = wfu_extract_sortdata_from_path($referer_url);
|
976 |
-
$referer_url = $ret['path'];
|
977 |
-
|
978 |
-
$echo_str = "\n".'<div class="wrap">';
|
979 |
-
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
980 |
-
if ( $is_admin ) $echo_str .= "\n\t\t".'<a href="'.$referer_url.'" class="button" title="go back">Go back</a>';
|
981 |
-
$echo_str .= "\n\t".'</div>';
|
982 |
-
$echo_str .= "\n\t".'<h2 style="margin-bottom: 10px;">Delete '.( $type == 'dir' ? 'Folder' : 'File'.( count($names) == 1 ? '' : 's' ) ).'</h2>';
|
983 |
-
if ( $is_admin ) $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">';
|
984 |
-
$echo_str .= "\n\t\t".'<input type="hidden" name="action" value="delete'.( $type == 'dir' ? 'dir' : 'file' ).'">';
|
985 |
-
$echo_str .= "\n\t\t".'<input type="hidden" name="referer" value="'.$referer.'">';
|
986 |
-
$echo_str .= "\n\t\t".'<input type="hidden" name="file" value="'.$file_code_list.'">';
|
987 |
-
if ( count($names) == 1 )
|
988 |
-
$echo_str .= "\n\t\t".'<label>Are you sure that you want to delete '.( $type == 'dir' ? 'folder' : 'file' ).' <strong>'.$names[0].'</strong>?</label><br/>';
|
989 |
-
else {
|
990 |
-
$echo_str .= "\n\t\t".'<label>Are you sure that you want to delete '.( $type == 'dir' ? 'folder' : 'files' ).':';
|
991 |
-
$echo_str .= "\n\t\t".'<ul style="padding-left: 20px; list-style: initial;">';
|
992 |
-
foreach ( $names as $name )
|
993 |
-
$echo_str .= "\n\t\t\t".'<li><strong>'.$name.'</strong></li>';
|
994 |
-
$echo_str .= "\n\t\t".'</ul>';
|
995 |
-
}
|
996 |
-
$echo_str .= "\n\t\t".'<p class="submit">';
|
997 |
-
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Delete">';
|
998 |
-
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Cancel">';
|
999 |
-
$echo_str .= "\n\t\t".'</p>';
|
1000 |
-
$echo_str .= "\n\t".'</form>';
|
1001 |
-
$echo_str .= "\n".'</div>';
|
1002 |
-
return $echo_str;
|
1003 |
-
}
|
1004 |
-
|
1005 |
-
/**
|
1006 |
-
* Execute Deletion of File.
|
1007 |
-
*
|
1008 |
-
* This function deletes a file.
|
1009 |
-
*
|
1010 |
-
* @since 2.2.1
|
1011 |
-
*
|
1012 |
-
* @param string $file_code A code corresponding to the file/dir to be deleted.
|
1013 |
-
* @param string $type Delete dir or file. Can take the values 'dir' or 'file'.
|
1014 |
-
*
|
1015 |
-
* @return bool True if deletion of file succeeded, false otherwise.
|
1016 |
-
*/
|
1017 |
-
function wfu_delete_file($file_code, $type) {
|
1018 |
-
if ( $type == 'dir' ) return;
|
1019 |
-
|
1020 |
-
$user = wp_get_current_user();
|
1021 |
-
$is_admin = current_user_can( 'manage_options' );
|
1022 |
-
//check if user is allowed to view file details
|
1023 |
-
if ( !$is_admin ) {
|
1024 |
-
return;
|
1025 |
-
}
|
1026 |
-
if ( !is_array($file_code) ) $file_code = array( $file_code );
|
1027 |
-
$dec_files = array();
|
1028 |
-
foreach ( $file_code as $index => $code ) {
|
1029 |
-
$file_code[$index] = wfu_sanitize_code($code);
|
1030 |
-
$dec_file = wfu_get_filepath_from_safe($file_code[$index]);
|
1031 |
-
if ( $dec_file !== false ) {
|
1032 |
-
$dec_file = wfu_path_rel2abs(wfu_flatten_path($dec_file));
|
1033 |
-
if ( $type == 'dir' && substr($dec_file, -1) == '/' ) $dec_file = substr($dec_file, 0, -1);
|
1034 |
-
//check if user is allowed to perform this action
|
1035 |
-
if ( wfu_current_user_owes_file($dec_file) ) array_push($dec_files, $dec_file);
|
1036 |
-
}
|
1037 |
-
}
|
1038 |
-
if ( count($dec_files) == 0 ) return;
|
1039 |
-
|
1040 |
-
if ( isset($_POST['submit']) ) {
|
1041 |
-
if ( $_POST['submit'] == "Delete" ) {
|
1042 |
-
foreach ( $dec_files as $dec_file ) {
|
1043 |
-
//pre-log delete action
|
1044 |
-
if ( $type == 'file' ) wfu_delete_file_execute($dec_file, $user->ID);
|
1045 |
-
elseif ( $type == 'dir' && $dec_file != "" ) wfu_delTree($dec_file);
|
1046 |
-
}
|
1047 |
-
}
|
1048 |
-
}
|
1049 |
-
return true;
|
1050 |
-
}
|
1051 |
-
|
1052 |
-
/**
|
1053 |
-
* Confirm Creation of a Directory.
|
1054 |
-
*
|
1055 |
-
* This function shows a page to confirm creation of a directory.
|
1056 |
-
*
|
1057 |
-
* @since 2.2.1
|
1058 |
-
*
|
1059 |
-
* @param string $dir_code A code corresponding to the dir to be created.
|
1060 |
-
* @param string $error An error message to show on top of the page in case an
|
1061 |
-
* error occured during creation.
|
1062 |
-
*
|
1063 |
-
* @return string The HTML code of the confirmation page.
|
1064 |
-
*/
|
1065 |
-
function wfu_create_dir_prompt($dir_code, $error) {
|
1066 |
-
return;
|
1067 |
-
|
1068 |
-
$siteurl = site_url();
|
1069 |
-
|
1070 |
-
if ( !current_user_can( 'manage_options' ) ) return;
|
1071 |
-
|
1072 |
-
$dir_code = wfu_sanitize_code($dir_code);
|
1073 |
-
$dec_dir = wfu_get_filepath_from_safe($dir_code);
|
1074 |
-
if ( $dec_dir === false ) return;
|
1075 |
-
|
1076 |
-
//first extract sort info from dec_dir
|
1077 |
-
$ret = wfu_extract_sortdata_from_path($dec_dir);
|
1078 |
-
$dec_dir = wfu_path_rel2abs($ret['path']);
|
1079 |
-
if ( substr($dec_dir, -1) != '/' ) $dec_dir .= '/';
|
1080 |
-
$newname = '';
|
1081 |
-
|
1082 |
-
$echo_str = "\n".'<div class="wrap">';
|
1083 |
-
if ( $error ) {
|
1084 |
-
$create_dir = WFU_USVAR('wfu_create_dir');
|
1085 |
-
$newname = $create_dir['newname'];
|
1086 |
-
$echo_str .= "\n\t".'<div class="error">';
|
1087 |
-
$echo_str .= "\n\t\t".'<p>'.WFU_USVAR('wfu_create_dir_error').'</p>';
|
1088 |
-
$echo_str .= "\n\t".'</div>';
|
1089 |
-
}
|
1090 |
-
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
1091 |
-
$echo_str .= "\n\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$dir_code.'" class="button" title="go back">Go back</a>';
|
1092 |
-
$echo_str .= "\n\t".'</div>';
|
1093 |
-
$echo_str .= "\n\t".'<h2 style="margin-bottom: 10px;">Create Folder</h2>';
|
1094 |
-
$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">';
|
1095 |
-
$echo_str .= "\n\t\t".'<input type="hidden" name="action" value="createdir">';
|
1096 |
-
$echo_str .= "\n\t\t".'<input type="hidden" name="dir" value="'.$dir_code.'">';
|
1097 |
-
$echo_str .= "\n\t\t".'<label>Enter the name of the new folder inside <strong>'.$dec_dir.'</strong></label><br/>';
|
1098 |
-
$echo_str .= "\n\t\t".'<input name="wfu_newname" id="wfu_newname" type="text" value="'.$newname.'" style="width:50%;" />';
|
1099 |
-
$echo_str .= "\n\t\t".'<p class="submit">';
|
1100 |
-
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Create">';
|
1101 |
-
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Cancel">';
|
1102 |
-
$echo_str .= "\n\t\t".'</p>';
|
1103 |
-
$echo_str .= "\n\t".'</form>';
|
1104 |
-
$echo_str .= "\n".'</div>';
|
1105 |
-
return $echo_str;
|
1106 |
-
}
|
1107 |
-
|
1108 |
-
/**
|
1109 |
-
* Execute Creation of Directory.
|
1110 |
-
*
|
1111 |
-
* This function creates a new directory.
|
1112 |
-
*
|
1113 |
-
* @since 2.2.1
|
1114 |
-
*
|
1115 |
-
* @param string $dir_code A code corresponding to the dir to be created.
|
1116 |
-
*
|
1117 |
-
* @return bool True if creation of dir succeeded, false otherwise.
|
1118 |
-
*/
|
1119 |
-
function wfu_create_dir($dir_code) {
|
1120 |
-
return;
|
1121 |
-
|
1122 |
-
if ( !current_user_can( 'manage_options' ) ) return;
|
1123 |
-
|
1124 |
-
$dir_code = wfu_sanitize_code($dir_code);
|
1125 |
-
$dec_dir = wfu_get_filepath_from_safe($dir_code);
|
1126 |
-
if ( $dec_dir === false ) return;
|
1127 |
-
|
1128 |
-
$dec_dir = wfu_path_rel2abs(wfu_flatten_path($dec_dir));
|
1129 |
-
if ( substr($dec_dir, -1) != '/' ) $dec_dir .= '/';
|
1130 |
-
if ( !
|
1131 |
-
$error = "";
|
1132 |
-
if ( isset($_POST['wfu_newname']) && isset($_POST['submit']) ) {
|
1133 |
-
if ( $_POST['submit'] == "Create" ) {
|
1134 |
-
$new_dir = $dec_dir.$_POST['wfu_newname'];
|
1135 |
-
if ( $_POST['wfu_newname'] == "" ) $error = 'Error: New folder name cannot be empty!';
|
1136 |
-
elseif ( preg_match("/[^A-Za-z0-9_.#\-$]/", $_POST['wfu_newname']) ) $error = 'Error: name contained invalid characters that were stripped off! Please try again.';
|
1137 |
-
elseif (
|
1138 |
-
elseif ( mkdir($new_dir) == false ) $error = 'Error: Creation of folder <strong>'.$_POST['wfu_newname'].'</strong> failed!';
|
1139 |
-
}
|
1140 |
-
}
|
1141 |
-
if ( $error != "" ) {
|
1142 |
-
WFU_USVAR_store('wfu_create_dir_error', $error);
|
1143 |
-
$create_dir = WFU_USVAR('wfu_create_dir');
|
1144 |
-
$create_dir['newname'] = preg_replace("/[^A-Za-z0-9_.#\-$]/", "", $_POST['wfu_newname']);
|
1145 |
-
WFU_USVAR_store('wfu_create_dir', $create_dir);
|
1146 |
-
}
|
1147 |
-
return ( $error == "" );
|
1148 |
-
}
|
1149 |
-
|
1150 |
-
/**
|
1151 |
-
* Confirm Inclusion of File in Plugin's Database.
|
1152 |
-
*
|
1153 |
-
* This function shows a page to confirm inclusion of a file in plugin's
|
1154 |
-
* database.
|
1155 |
-
*
|
1156 |
-
* @since 3.8.5
|
1157 |
-
*
|
1158 |
-
* @param string $file_code A code corresponding to the file to be included.
|
1159 |
-
* @param string $type Rename dir or file. Can take the values 'dir' or 'file'.
|
1160 |
-
* @param string $referer The page that initiated the inclusion of the file.
|
1161 |
-
*
|
1162 |
-
* @return string The HTML code of the confirmation page.
|
1163 |
-
*/
|
1164 |
-
function wfu_include_file_prompt($file_code, $referer) {
|
1165 |
-
if ( !current_user_can( 'manage_options' ) ) return;
|
1166 |
-
$plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
|
1167 |
-
if ( $plugin_options['includeotherfiles'] != "1" ) return;
|
1168 |
-
|
1169 |
-
$siteurl = site_url();
|
1170 |
-
if ( !is_array($file_code) ) $file_code = array( $file_code );
|
1171 |
-
$names = array();
|
1172 |
-
foreach ( $file_code as $index => $code ) {
|
1173 |
-
$file_code[$index] = wfu_sanitize_code($code);
|
1174 |
-
$dec_file = wfu_get_filepath_from_safe($file_code[$index]);
|
1175 |
-
if ( $dec_file === false ) unset($file_code[$index]);
|
1176 |
-
else {
|
1177 |
-
$dec_file = wfu_path_rel2abs(wfu_flatten_path($dec_file));
|
1178 |
-
//do not include file if it has a forbidden extention or it is already included
|
1179 |
-
if ( wfu_file_extension_blacklisted(wfu_basename($dec_file)) || wfu_get_file_rec($dec_file, false) != null )
|
1180 |
-
unset($file_code[$index]);
|
1181 |
-
else array_push($names, wfu_basename($dec_file));
|
1182 |
-
}
|
1183 |
-
}
|
1184 |
-
if ( count($file_code) == 0 ) return;
|
1185 |
-
$file_code_list = "list:".implode(",", $file_code);
|
1186 |
-
|
1187 |
-
$referer_url = wfu_get_filepath_from_safe(wfu_sanitize_code($referer));
|
1188 |
-
$ret = wfu_extract_sortdata_from_path($referer_url);
|
1189 |
-
$referer_url = $ret['path'];
|
1190 |
-
|
1191 |
-
$echo_str = "\n".'<div class="wrap">';
|
1192 |
-
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
1193 |
-
$echo_str .= "\n\t\t".'<a href="'.$referer_url.'" class="button" title="go back">Go back</a>';
|
1194 |
-
$echo_str .= "\n\t".'</div>';
|
1195 |
-
$echo_str .= "\n\t".'<h2 style="margin-bottom: 10px;">Include File'.( count($names) == 1 ? '' : 's' ).'</h2>';
|
1196 |
-
$echo_str .= "\n\t".'<form enctype="multipart/form-data" name="includefile" id="includefile" method="post" action="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload" class="validate">';
|
1197 |
-
$echo_str .= "\n\t\t".'<input type="hidden" name="action" value="includefile">';
|
1198 |
-
$echo_str .= "\n\t\t".'<input type="hidden" name="referer" value="'.$referer.'">';
|
1199 |
-
$echo_str .= "\n\t\t".'<input type="hidden" name="file" value="'.$file_code_list.'">';
|
1200 |
-
if ( count($names) == 1 )
|
1201 |
-
$echo_str .= "\n\t\t".'<label>Are you sure that you want to include file <strong>'.$names[0].'</strong>?</label><br/>';
|
1202 |
-
else {
|
1203 |
-
$echo_str .= "\n\t\t".'<label>Are you sure that you want to include files:';
|
1204 |
-
$echo_str .= "\n\t\t".'<ul style="padding-left: 20px; list-style: initial;">';
|
1205 |
-
foreach ( $names as $name )
|
1206 |
-
$echo_str .= "\n\t\t\t".'<li><strong>'.$name.'</strong></li>';
|
1207 |
-
$echo_str .= "\n\t\t".'</ul>';
|
1208 |
-
}
|
1209 |
-
$echo_str .= "\n\t\t".'<p class="submit">';
|
1210 |
-
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Include">';
|
1211 |
-
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Cancel">';
|
1212 |
-
$echo_str .= "\n\t\t".'</p>';
|
1213 |
-
$echo_str .= "\n\t".'</form>';
|
1214 |
-
$echo_str .= "\n".'</div>';
|
1215 |
-
return $echo_str;
|
1216 |
-
}
|
1217 |
-
|
1218 |
-
/**
|
1219 |
-
* Execute Inclusion of File in Plugin's Database.
|
1220 |
-
*
|
1221 |
-
* This function includes a file in plugin's database.
|
1222 |
-
*
|
1223 |
-
* @since 3.8.5
|
1224 |
-
*
|
1225 |
-
* @param string $file_code A code corresponding to the file to be included.
|
1226 |
-
*
|
1227 |
-
* @return bool True if inclusion of file succeeded, false otherwise.
|
1228 |
-
*/
|
1229 |
-
function wfu_include_file($file_code) {
|
1230 |
-
if ( !current_user_can( 'manage_options' ) ) return;
|
1231 |
-
$plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
|
1232 |
-
if ( $plugin_options['includeotherfiles'] != "1" ) return;
|
1233 |
-
|
1234 |
-
if ( !is_array($file_code) ) $file_code = array( $file_code );
|
1235 |
-
$dec_files = array();
|
1236 |
-
foreach ( $file_code as $index => $code ) {
|
1237 |
-
$file_code[$index] = wfu_sanitize_code($code);
|
1238 |
-
$dec_file = wfu_get_filepath_from_safe($file_code[$index]);
|
1239 |
-
if ( $dec_file !== false ) {
|
1240 |
-
$dec_file = wfu_path_rel2abs(wfu_flatten_path($dec_file));
|
1241 |
-
//include file if it does not have a forbidden extention and it not already included
|
1242 |
-
if ( !wfu_file_extension_blacklisted(wfu_basename($dec_file)) && wfu_get_file_rec($dec_file, false) == null )
|
1243 |
-
array_push($dec_files, $dec_file);
|
1244 |
-
}
|
1245 |
-
}
|
1246 |
-
if ( count($dec_files) == 0 ) return;
|
1247 |
-
|
1248 |
-
$user = wp_get_current_user();
|
1249 |
-
if ( isset($_POST['submit']) ) {
|
1250 |
-
if ( $_POST['submit'] == "Include" ) {
|
1251 |
-
foreach ( $dec_files as $dec_file )
|
1252 |
-
$fileid = wfu_log_action('include', $dec_file, $user->ID, '', '', get_current_blog_id(), '', null);
|
1253 |
-
}
|
1254 |
-
}
|
1255 |
-
return true;
|
1256 |
-
}
|
1257 |
-
|
1258 |
-
/**
|
1259 |
-
* Show File Details Page.
|
1260 |
-
*
|
1261 |
-
* This function shows a page displaying details of the uploaded file.
|
1262 |
-
*
|
1263 |
-
* @since 2.4.1
|
1264 |
-
*
|
1265 |
-
* @param string $file_code A code corresponding to the file to be included.
|
1266 |
-
* @param string $errorstatus Error status. If it has the value 'error' then an
|
1267 |
-
* error will be shown on top of the page.
|
1268 |
-
* @param string $invoker Optional. The page URL that initiated file details
|
1269 |
-
* page.
|
1270 |
-
*
|
1271 |
-
* @return string The HTML code of File Details page.
|
1272 |
-
*/
|
1273 |
-
function wfu_file_details($file_code, $errorstatus, $invoker = '') {
|
1274 |
-
$siteurl = site_url();
|
1275 |
-
$allow_obsolete = false;
|
1276 |
-
$file_exists = true;
|
1277 |
-
$file_belongs = true;
|
1278 |
-
$admin_can_edit = true;
|
1279 |
-
|
1280 |
-
//if $file_code starts with 'byID:', then it contains a db record ID and not
|
1281 |
-
//a file path; in this case we show the properties of the specific record
|
1282 |
-
//and all linked ones, even if it is obsolete; this is only allowed for
|
1283 |
-
//admins
|
1284 |
-
if ( substr($file_code, 0, 5) == "byID:" ) {
|
1285 |
-
$allow_obsolete = true;
|
1286 |
-
$file_code = substr($file_code, 5);
|
1287 |
-
}
|
1288 |
-
|
1289 |
-
$user = wp_get_current_user();
|
1290 |
-
$is_admin = current_user_can( 'manage_options' );
|
1291 |
-
//check if user is allowed to view file details
|
1292 |
-
if ( !$is_admin ) {
|
1293 |
-
if ( $allow_obsolete ) return;
|
1294 |
-
return;
|
1295 |
-
}
|
1296 |
-
if ( $allow_obsolete ) {
|
1297 |
-
$file_code = wfu_sanitize_int($file_code);
|
1298 |
-
$initialrec = wfu_get_file_rec_from_id($file_code, true);
|
1299 |
-
if ( $initialrec == null ) return;
|
1300 |
-
|
1301 |
-
//get all associated file records
|
1302 |
-
$filerecs = wfu_get_rec_new_history($initialrec->idlog);
|
1303 |
-
//get the latest record of this upload
|
1304 |
-
$filerec = $filerecs[count($filerecs) - 1];
|
1305 |
-
$filerec->userdata = $initialrec->userdata;
|
1306 |
-
|
1307 |
-
$filepath = wfu_path_rel2abs($filerec->filepath);
|
1308 |
-
//in the case of $allow_obsolete we need to check if the file exists and
|
1309 |
-
//if it belongs to the current record
|
1310 |
-
$latestrec = wfu_get_file_rec($filepath, true);
|
1311 |
-
$file_exists = ( $latestrec != null );
|
1312 |
-
$file_belongs = ( $file_exists && $latestrec->idlog == $filerec->idlog );
|
1313 |
-
$admin_can_edit = $file_exists;
|
1314 |
-
|
1315 |
-
//extract file parts and file properties
|
1316 |
-
$parts = pathinfo($filepath);
|
1317 |
-
if ( $file_exists ) $stat =
|
1318 |
-
else $stat['mtime'] = '';
|
1319 |
-
}
|
1320 |
-
else {
|
1321 |
-
$file_code = wfu_sanitize_code($file_code);
|
1322 |
-
$dec_file = wfu_get_filepath_from_safe($file_code);
|
1323 |
-
if ( $dec_file === false ) return;
|
1324 |
-
|
1325 |
-
//extract file browser data from $file variable
|
1326 |
-
$ret = wfu_extract_sortdata_from_path($dec_file);
|
1327 |
-
$filepath = wfu_path_rel2abs($ret['path']);
|
1328 |
-
|
1329 |
-
//check if user is allowed to perform this action
|
1330 |
-
if ( !wfu_current_user_owes_file($filepath) ) return;
|
1331 |
-
|
1332 |
-
//get file data from database with user data
|
1333 |
-
$filerec = wfu_get_file_rec($filepath, true);
|
1334 |
-
if ( $filerec == null ) return;
|
1335 |
-
|
1336 |
-
//extract sort info and construct contained dir
|
1337 |
-
$parts = pathinfo($filepath);
|
1338 |
-
$dir_code = wfu_safe_store_filepath(wfu_path_abs2rel($parts['dirname']).'[['.$ret['sort'].']]');
|
1339 |
-
|
1340 |
-
$stat =
|
1341 |
-
}
|
1342 |
-
|
1343 |
-
$echo_str = '<div class="regev_wrap">';
|
1344 |
-
if ( $errorstatus == 'error' ) {
|
1345 |
-
$echo_str .= "\n\t".'<div class="error">';
|
1346 |
-
$echo_str .= "\n\t\t".'<p>'.WFU_USVAR('wfu_filedetails_error').'</p>';
|
1347 |
-
$echo_str .= "\n\t".'</div>';
|
1348 |
-
}
|
1349 |
-
//show file
|
1350 |
-
$echo_str .= "\n\t".'<h2>
|
1351 |
-
if ( !$file_exists ) {
|
1352 |
-
$echo_str .= "\n\t\t".'<div class="notice notice-warning">';
|
1353 |
-
$echo_str .= "\n\t\t\t".'<p>File does not exist on the server anymore!</p>';
|
1354 |
-
$echo_str .= "\n\t\t".'</div>';
|
1355 |
-
}
|
1356 |
-
elseif ( !$file_belongs ) {
|
1357 |
-
$echo_str .= "\n\t\t".'<div class="notice notice-warning">';
|
1358 |
-
$echo_str .= "\n\t\t\t".'<p>This record is old. The file is associated with another record.</p>';
|
1359 |
-
$echo_str .= "\n\t\t".'</div>';
|
1360 |
-
}
|
1361 |
-
$echo_str .= "\n\t".'<div style="margin-top:10px;">';
|
1362 |
-
if ( $is_admin ) {
|
1363 |
-
$invoker_action = ( $invoker == '' ? false : wfu_get_browser_params_from_safe($invoker) );
|
1364 |
-
$goback_action = ( $invoker_action === false ? 'file_browser&dir='.$dir_code : $invoker_action );
|
1365 |
-
if ( substr($goback_action, 0, 18) == "wfu_uploaded_files" )
|
1366 |
-
$echo_str .= "\n\t\t".'<a href="'.$siteurl.'/wp-admin/admin.php?page='.$goback_action.'" class="button" title="go back">Go back</a>';
|
1367 |
-
elseif ( $goback_action != "no_referer" )
|
1368 |
-
$echo_str .= "\n\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action='.$goback_action.'" class="button" title="go back">Go back</a>';
|
1369 |
-
$echo_str .= "\n\t\t".'<form enctype="multipart/form-data" name="editfiledetails" id="editfiledetails" method="post" action="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=edit_filedetails" class="validate">';
|
1370 |
-
}
|
1371 |
-
$echo_str .= "\n\t\t\t".'<h3 style="margin-bottom: 10px; margin-top: 40px;">Upload Details</h3>';
|
1372 |
-
$echo_str .= "\n\t\t\t".'<input type="hidden" name="action" value="edit_filedetails" />';
|
1373 |
-
//$echo_str .= "\n\t\t\t".'<input type="hidden" name="dir" value="'.$dir_code.'">';
|
1374 |
-
$echo_str .= "\n\t\t\t".'<input type="hidden" name="invoker" value="'.$invoker.'">';
|
1375 |
-
$echo_str .= "\n\t\t\t".'<input type="hidden" name="file" value="'.( $allow_obsolete ? 'byID:'.$file_code : $file_code ).'">';
|
1376 |
-
$echo_str .= "\n\t\t\t".'<table class="form-table">';
|
1377 |
-
$echo_str .= "\n\t\t\t\t".'<tbody>';
|
1378 |
-
if ( $is_admin ) {
|
1379 |
-
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
1380 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
1381 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<label>Full Path</label>';
|
1382 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
1383 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
1384 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<input type="text" value="'.$filepath.'" readonly="readonly" style="width:50%;" />';
|
1385 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
1386 |
-
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
1387 |
-
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
1388 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
1389 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<label>Uploaded By User</label>';
|
1390 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
1391 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
1392 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<select id="wfu_filedetails_users" disabled="disabled">';
|
1393 |
-
//get all users
|
1394 |
-
$args = array();
|
1395 |
-
/**
|
1396 |
-
* Filter Arguments for Getting List of Users.
|
1397 |
-
*
|
1398 |
-
* This filter allows to customize the arguments passed to get_users()
|
1399 |
-
* function to get a list of users. By default the plugin will get a
|
1400 |
-
* list of all users. If the website contains too many users this
|
1401 |
-
* operation may take time and delay loading of the page. So this filter
|
1402 |
-
* can be used to optimize this operation.
|
1403 |
-
*
|
1404 |
-
* @since 4.11.0
|
1405 |
-
*
|
1406 |
-
* @param array $args Arguments to retrieve users.
|
1407 |
-
* @param string $operation A parameter designating in which operation
|
1408 |
-
* the filter is used.
|
1409 |
-
*/
|
1410 |
-
$args = apply_filters("_wfu_get_users", $args, "edit_file_details");
|
1411 |
-
$users = get_users($args);
|
1412 |
-
foreach ( $users as $userid => $user )
|
1413 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<option value="'.$user->ID.'"'.( $filerec->uploaduserid == $user->ID ? ' selected="selected"' : '' ).'>'.$user->display_name.' ('.$user->user_login.')</option>';
|
1414 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'</select>';
|
1415 |
-
if ( $admin_can_edit ) {
|
1416 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<a class="button" id="btn_change" href="" onclick="document.getElementById(\'wfu_filedetails_users\').disabled = false; this.style.display = \'none\'; document.getElementById(\'btn_ok\').style.display = \'inline-block\'; document.getElementById(\'btn_cancel\').style.display = \'inline-block\'; return false;"'.( $is_admin ? '' : ' style="display:none;"' ).'>Change User</a>';
|
1417 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<a class="button" id="btn_ok" href="" onclick="document.getElementById(\'wfu_filedetails_users\').disabled = true; document.getElementById(\'btn_change\').style.display = \'inline-block\'; this.style.display=\'none\'; document.getElementById(\'btn_cancel\').style.display = \'none\'; document.getElementById(\'wfu_filedetails_userid\').value = document.getElementById(\'wfu_filedetails_users\').value; wfu_filedetails_changed(); return false;" style="display:none;">Ok</a>';
|
1418 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<a class="button" id="btn_cancel" href="" onclick="document.getElementById(\'wfu_filedetails_users\').disabled = true; document.getElementById(\'btn_change\').style.display = \'inline-block\'; this.style.display=\'none\'; document.getElementById(\'btn_ok\').style.display = \'none\'; document.getElementById(\'wfu_filedetails_users\').value = document.getElementById(\'wfu_filedetails_userid\').value; return false;" style="display:none;">Cancel</a>';
|
1419 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<input type="hidden" id="wfu_filedetails_userid" name="wfu_filedetails_userid" value="'.$filerec->uploaduserid.'" />';
|
1420 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<input type="hidden" id="wfu_filedetails_userid_default" value="'.$filerec->uploaduserid.'" />';
|
1421 |
-
}
|
1422 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
1423 |
-
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
1424 |
-
}
|
1425 |
-
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
1426 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
1427 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<label>File Size</label>';
|
1428 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
1429 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
1430 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<input type="text" value="'.$filerec->filesize.'" readonly="readonly" style="width:auto;" />';
|
1431 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
1432 |
-
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
1433 |
-
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
1434 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
1435 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<label>File Date</label>';
|
1436 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
1437 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
1438 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<input type="text" value="'.( $file_exists ? get_date_from_gmt(date("Y-m-d H:i:s", $stat['mtime']), "d/m/Y H:i:s") : '' ).'" readonly="readonly" style="width:auto;" />';
|
1439 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
1440 |
-
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
1441 |
-
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
1442 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
1443 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<label>Uploaded From Page</label>';
|
1444 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
1445 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
1446 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<input type="text" value="'.get_the_title($filerec->pageid).' ('.$filerec->pageid.')'.'" readonly="readonly" style="width:50%;" />';
|
1447 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
1448 |
-
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
1449 |
-
if ( $is_admin ) {
|
1450 |
-
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
1451 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
1452 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<label>Upload Plugin ID</label>';
|
1453 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
1454 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
1455 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<input type="text" value="'.$filerec->sid.'" readonly="readonly" style="width:auto;" />';
|
1456 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
1457 |
-
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
1458 |
-
}
|
1459 |
-
$echo_str .= "\n\t\t\t\t".'</tbody>';
|
1460 |
-
$echo_str .= "\n\t\t\t".'</table>';
|
1461 |
-
if ( $is_admin ) {
|
1462 |
-
//show history details
|
1463 |
-
$echo_str .= "\n\t\t\t".'<h3 style="margin-bottom: 10px; margin-top: 40px;">File History</h3>';
|
1464 |
-
$echo_str .= "\n\t\t\t".'<table class="form-table">';
|
1465 |
-
$echo_str .= "\n\t\t\t\t".'<tbody>';
|
1466 |
-
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
1467 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
1468 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<label></label>';
|
1469 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
1470 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
1471 |
-
//read all linked older records
|
1472 |
-
$filerecs = wfu_get_rec_old_history($filerec->idlog);
|
1473 |
-
//construct report from db records
|
1474 |
-
$rep = '';
|
1475 |
-
foreach ( $filerecs as $rec ) {
|
1476 |
-
$username = wfu_get_username_by_id($rec->userid);
|
1477 |
-
$fileparts = pathinfo($rec->filepath);
|
1478 |
-
if ( $rep != '' ) $rep .= "<br />";
|
1479 |
-
$rep .= '<strong>['.get_date_from_gmt($rec->date_from).']</strong> ';
|
1480 |
-
if ( $rec->action == 'upload' )
|
1481 |
-
$rep .= 'File uploaded at <strong>'.$fileparts['dirname'].'</strong> with name <strong>'.$fileparts['basename'].'</strong> by user <strong>'.$username.'</strong>';
|
1482 |
-
elseif ( $rec->action == 'include' )
|
1483 |
-
$rep .= 'File included in database at <strong>'.$fileparts['dirname'].'</strong> with name <strong>'.$fileparts['basename'].'</strong> by user <strong>'.$username.'</strong>';
|
1484 |
-
elseif ( $rec->action == 'download' )
|
1485 |
-
$rep .= 'File downloaded by user <strong>'.$username.'</strong>';
|
1486 |
-
elseif ( $rec->action == 'rename' )
|
1487 |
-
$rep .= 'File renamed to <strong>'.$fileparts['basename'].'</strong> by user <strong>'.$username.'</strong>';
|
1488 |
-
elseif ( $rec->action == 'move' )
|
1489 |
-
$rep .= 'File moved to <strong>'.$fileparts['dirname'].'</strong> by user <strong>'.$username.'</strong>';
|
1490 |
-
elseif ( $rec->action == 'delete' )
|
1491 |
-
$rep .= 'File deleted by user <strong>'.$username.'</strong>';
|
1492 |
-
elseif ( $rec->action == 'modify' )
|
1493 |
-
$rep .= 'File userdata modified by user <strong>'.$username.'</strong>';
|
1494 |
-
elseif ( $rec->action == 'changeuser' )
|
1495 |
-
$rep .= 'File upload user modified by user <strong>'.$username.'</strong>';
|
1496 |
-
}
|
1497 |
-
$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;">';
|
1498 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<span style="white-space:nowrap;">'.$rep.'</span>';
|
1499 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'</div>';
|
1500 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
1501 |
-
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
1502 |
-
$echo_str .= "\n\t\t\t\t".'</tbody>';
|
1503 |
-
$echo_str .= "\n\t\t\t".'</table>';
|
1504 |
-
}
|
1505 |
-
|
1506 |
-
$echo_str .= "\n\t\t\t".'<h3 style="margin-bottom: 10px; margin-top: 40px;">User Data Details</h3>';
|
1507 |
-
$echo_str .= "\n\t\t\t".'<table class="form-table">';
|
1508 |
-
$echo_str .= "\n\t\t\t\t".'<tbody>';
|
1509 |
-
if ( is_array($filerec->userdata) && count($filerec->userdata) > 0 ) {
|
1510 |
-
foreach ( $filerec->userdata as $userdata ) {
|
1511 |
-
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
1512 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
1513 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<label>'.$userdata->property.'</label>';
|
1514 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
1515 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
1516 |
-
// $echo_str .= "\n\t\t\t\t\t\t\t".'<input id="wfu_filedetails_userdata_value_'.$userdata->propkey.'" name="wfu_filedetails_userdata" type="text"'.( $is_admin ? '' : ' readonly="readonly"' ).' value="'.$userdata->propvalue.'" />';
|
1517 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<textarea id="wfu_filedetails_userdata_value_'.$userdata->propkey.'" name="wfu_filedetails_userdata" '.( ($is_admin && $admin_can_edit) ? '' : ' readonly="readonly"' ).' value="'.$userdata->propvalue.'">'.$userdata->propvalue.'</textarea>';
|
1518 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<input id="wfu_filedetails_userdata_default_'.$userdata->propkey.'" type="hidden" value="'.$userdata->propvalue.'" />';
|
1519 |
-
$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.'" />';
|
1520 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
1521 |
-
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
1522 |
-
}
|
1523 |
-
}
|
1524 |
-
else {
|
1525 |
-
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
1526 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
1527 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<label>No user data</label>';
|
1528 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
1529 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<td></td>';
|
1530 |
-
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
1531 |
-
}
|
1532 |
-
$echo_str .= "\n\t\t\t\t".'</tbody>';
|
1533 |
-
$echo_str .= "\n\t\t\t".'</table>';
|
1534 |
-
if ( ($is_admin && $admin_can_edit) ) {
|
1535 |
-
$echo_str .= "\n\t\t\t".'<p class="submit">';
|
1536 |
-
$echo_str .= "\n\t\t\t\t".'<input id="dp_filedetails_submit_fields" type="submit" class="button-primary" name="submit" value="Update" disabled="disabled" />';
|
1537 |
-
$echo_str .= "\n\t\t\t".'</p>';
|
1538 |
-
}
|
1539 |
-
$echo_str .= "\n\t\t".'</form>';
|
1540 |
-
$echo_str .= "\n\t".'</div>';
|
1541 |
-
$handler = 'function() { wfu_Attach_FileDetails_Admin_Events(); }';
|
1542 |
-
$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>';
|
1543 |
-
$echo_str .= '</div>';
|
1544 |
-
|
1545 |
-
return $echo_str;
|
1546 |
-
}
|
1547 |
-
|
1548 |
-
/**
|
1549 |
-
* Change File Details.
|
1550 |
-
*
|
1551 |
-
* This function modifies the database record of an uploaded file, as well as
|
1552 |
-
* any associated user data field records.
|
1553 |
-
*
|
1554 |
-
* @since 2.4.1
|
1555 |
-
*
|
1556 |
-
* @param string $file_code A code corresponding to the file to be modified.
|
1557 |
-
*
|
1558 |
-
* @return bool True if modification of file succeeded, false otherwise.
|
1559 |
-
*/
|
1560 |
-
function wfu_edit_filedetails($file_code) {
|
1561 |
-
global $wpdb;
|
1562 |
-
$table_name2 = $wpdb->prefix . "wfu_userdata";
|
1563 |
-
$allow_obsolete = false;
|
1564 |
-
|
1565 |
-
if ( substr($file_code, 0, 5) == "byID:" ) {
|
1566 |
-
$allow_obsolete = true;
|
1567 |
-
$file_code = substr($file_code, 5);
|
1568 |
-
}
|
1569 |
-
|
1570 |
-
$user = wp_get_current_user();
|
1571 |
-
$is_admin = current_user_can( 'manage_options' );
|
1572 |
-
//check if user is allowed to view file details
|
1573 |
-
if ( !$is_admin ) {
|
1574 |
-
if ( $allow_obsolete ) return;
|
1575 |
-
return;
|
1576 |
-
}
|
1577 |
-
if ( $allow_obsolete ) {
|
1578 |
-
$file_code = wfu_sanitize_int($file_code);
|
1579 |
-
$initialrec = wfu_get_file_rec_from_id($file_code, true);
|
1580 |
-
if ( $initialrec == null ) return;
|
1581 |
-
|
1582 |
-
//get all associated file records
|
1583 |
-
$filerecs = wfu_get_rec_new_history($initialrec->idlog);
|
1584 |
-
//get the latest record of this upload
|
1585 |
-
$filerec = $filerecs[count($filerecs) - 1];
|
1586 |
-
$filerec->userdata = $initialrec->userdata;
|
1587 |
-
|
1588 |
-
$filepath = wfu_path_rel2abs($filerec->filepath);
|
1589 |
-
$latestrec = wfu_get_file_rec($filepath, true);
|
1590 |
-
//if $latestrec is null then this means that file does not exist
|
1591 |
-
if ( $latestrec == null ) return;
|
1592 |
-
//if the record is obsolete then do not proceed
|
1593 |
-
if ( $latestrec->idlog != $filerec->idlog ) return;
|
1594 |
-
}
|
1595 |
-
else {
|
1596 |
-
$file_code = wfu_sanitize_code($file_code);
|
1597 |
-
$dec_file = wfu_get_filepath_from_safe($file_code);
|
1598 |
-
if ( $dec_file === false ) return;
|
1599 |
-
|
1600 |
-
$filepath = wfu_path_rel2abs(wfu_flatten_path($dec_file));
|
1601 |
-
|
1602 |
-
//check if user is allowed to perform this action
|
1603 |
-
if ( !wfu_current_user_owes_file($filepath) ) return;
|
1604 |
-
|
1605 |
-
//get file data from database with user data
|
1606 |
-
$filerec = wfu_get_file_rec($filepath, true);
|
1607 |
-
if ( $filerec == null ) return;
|
1608 |
-
}
|
1609 |
-
|
1610 |
-
if ( isset($_POST['submit']) ) {
|
1611 |
-
if ( $_POST['submit'] == "Update" ) {
|
1612 |
-
if ( !is_array($filerec->userdata) ) $filerec->userdata = array();
|
1613 |
-
//check for errors
|
1614 |
-
$is_error = false;
|
1615 |
-
foreach ( $filerec->userdata as $userdata ) {
|
1616 |
-
if ( !isset($_POST['wfu_filedetails_userdata_'.$userdata->propkey]) ) {
|
1617 |
-
$is_error = true;
|
1618 |
-
break;
|
1619 |
-
}
|
1620 |
-
}
|
1621 |
-
if ( !$is_error ) {
|
1622 |
-
$now_date = date('Y-m-d H:i:s');
|
1623 |
-
$userdata_count = 0;
|
1624 |
-
foreach ( $filerec->userdata as $userdata ) {
|
1625 |
-
$userdata_count ++;
|
1626 |
-
//make existing userdata record obsolete
|
1627 |
-
$wpdb->update($table_name2,
|
1628 |
-
array( 'date_to' => $now_date ),
|
1629 |
-
array( 'uploadid' => $userdata->uploadid, 'propkey' => $userdata->propkey ),
|
1630 |
-
array( '%s' ),
|
1631 |
-
array( '%s', '%s' )
|
1632 |
-
);
|
1633 |
-
//insert new userdata record
|
1634 |
-
$wpdb->insert($table_name2,
|
1635 |
-
array(
|
1636 |
-
'uploadid' => $userdata->uploadid,
|
1637 |
-
'property' => $userdata->property,
|
1638 |
-
'propkey' => $userdata->propkey,
|
1639 |
-
'propvalue' => $_POST['wfu_filedetails_userdata_'.$userdata->propkey],
|
1640 |
-
'date_from' => $now_date,
|
1641 |
-
'date_to' => 0
|
1642 |
-
),
|
1643 |
-
array(
|
1644 |
-
'%s',
|
1645 |
-
'%s',
|
1646 |
-
'%d',
|
1647 |
-
'%s',
|
1648 |
-
'%s',
|
1649 |
-
'%s'
|
1650 |
-
)
|
1651 |
-
);
|
1652 |
-
}
|
1653 |
-
if ( $userdata_count > 0 ) wfu_log_action('modify:'.$now_date, $filepath, $user->ID, '', 0, 0, '', null);
|
1654 |
-
}
|
1655 |
-
if ( isset($_POST['wfu_filedetails_userid']) && $_POST['wfu_filedetails_userid'] != $filerec->uploaduserid ) {
|
1656 |
-
wfu_log_action('changeuser:'.$_POST['wfu_filedetails_userid'], $filepath, $user->ID, '', 0, 0, '', null);
|
1657 |
-
}
|
1658 |
-
}
|
1659 |
-
}
|
1660 |
-
return true;
|
1661 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* File Browser Page in Dashboard Area of Plugin
|
5 |
+
*
|
6 |
+
* This file contains functions related to File Browser page of plugin's
|
7 |
+
* Dashboard area.
|
8 |
+
*
|
9 |
+
* @link /lib/wfu_admin_browser.php
|
10 |
+
*
|
11 |
+
* @package WordPress File Upload Plugin
|
12 |
+
* @subpackage Core Components
|
13 |
+
* @since 3.7.1
|
14 |
+
*/
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Display the File Browser Page.
|
18 |
+
*
|
19 |
+
* This function displays the File Browser page of the plugin's Dashboard area.
|
20 |
+
*
|
21 |
+
* @since 2.2.1
|
22 |
+
*
|
23 |
+
* @param string $basedir_code A code string corresponding to the folder to be
|
24 |
+
* displayed.
|
25 |
+
* @param integer $page Optional. The page to display in case folder contents
|
26 |
+
* are paginated.
|
27 |
+
* @param bool $only_table_rows Optional. Return only the HTML code of the table
|
28 |
+
* rows.
|
29 |
+
*
|
30 |
+
* @return string The HTML output of the plugin's File Browser Dashboard page.
|
31 |
+
*/
|
32 |
+
function wfu_browse_files($basedir_code, $page = -1, $only_table_rows = false) {
|
33 |
+
$siteurl = site_url();
|
34 |
+
$plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
|
35 |
+
$user = wp_get_current_user();
|
36 |
+
//store session variables for use from the downloader
|
37 |
+
|
38 |
+
if ( !current_user_can( 'manage_options' ) ) return;
|
39 |
+
|
40 |
+
//first decode basedir_code
|
41 |
+
$basedir = wfu_get_filepath_from_safe($basedir_code);
|
42 |
+
//clean session array holding dir and file paths if it is too big
|
43 |
+
if ( WFU_USVAR_exists('wfu_filepath_safe_storage') && count(WFU_USVAR('wfu_filepath_safe_storage')) > WFU_VAR("WFU_PHP_ARRAY_MAXLEN") ) WFU_USVAR_store('wfu_filepath_safe_storage', array());
|
44 |
+
|
45 |
+
//basedir may also contain information about the sorting of the displayed
|
46 |
+
//elements, as well as a filename that needs to be located and get focus on
|
47 |
+
//the browser;
|
48 |
+
//sorting information is enclosed in double brackets: [[sort_info]]
|
49 |
+
//filename information is enclosed in double braces: {{filename}}
|
50 |
+
$sort = "";
|
51 |
+
$located_file = "";
|
52 |
+
$located_file_found = false;
|
53 |
+
$filter = "";
|
54 |
+
if ( $basedir !== false ) {
|
55 |
+
$ret = wfu_extract_sortdata_from_path($basedir);
|
56 |
+
$basedir = $ret['path'];
|
57 |
+
$sort = $ret['sort'];
|
58 |
+
$located_file = $ret['file'];
|
59 |
+
$filter = $ret['filter'];
|
60 |
+
}
|
61 |
+
if ( $sort == "" ) $sort = 'name';
|
62 |
+
if ( substr($sort, 0, 1) == '-' ) $order = SORT_DESC;
|
63 |
+
else $order = SORT_ASC;
|
64 |
+
//if page is not -1, then do not locate a file
|
65 |
+
if ( $located_file != "" && $page > -1 ) $located_file = "";
|
66 |
+
//adjust page to be larger than zero
|
67 |
+
if ( $page < 1 ) $page = 1;
|
68 |
+
|
69 |
+
//adjust basedir to have a standard format
|
70 |
+
if ( $basedir !== false ) {
|
71 |
+
if ( substr($basedir, -1) != '/' ) $basedir .= '/';
|
72 |
+
if ( substr($basedir, 0, 1) == '/' ) $basedir = substr($basedir, 1);
|
73 |
+
//calculate the absolute path of basedir knowing that basedir is relative to website root
|
74 |
+
$basedir = wfu_path_rel2abs($basedir);
|
75 |
+
if ( !wfu_file_exists($basedir, "wfu_browse_files") ) $basedir = false;
|
76 |
+
}
|
77 |
+
//set basedit to default value if empty
|
78 |
+
if ( $basedir === false ) {
|
79 |
+
$plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
|
80 |
+
$basedir = ( isset($plugin_options['basedir']) ? $plugin_options['basedir'] : "" );
|
81 |
+
$temp_params = array( 'uploadpath' => $basedir, 'accessmethod' => 'normal', 'ftpinfo' => '', 'useftpdomain' => 'false' );
|
82 |
+
$basedir = wfu_upload_plugin_full_path($temp_params);
|
83 |
+
}
|
84 |
+
//find relative dir
|
85 |
+
$reldir = str_replace(wfu_abspath(), "root/", $basedir);
|
86 |
+
//save dir route to an array
|
87 |
+
$parts = explode('/', $reldir);
|
88 |
+
$route = array();
|
89 |
+
$prev = "";
|
90 |
+
foreach ( $parts as $part ) {
|
91 |
+
$part = trim($part);
|
92 |
+
if ( $part != "" ) {
|
93 |
+
// if ( $part == 'root' && $prev == "" ) $prev = wfu_abspath();
|
94 |
+
if ( $part == 'root' && $prev == "" ) $prev = "";
|
95 |
+
else $prev .= $part.'/';
|
96 |
+
array_push($route, array( 'item' => $part, 'path' => $prev ));
|
97 |
+
}
|
98 |
+
}
|
99 |
+
//calculate upper directory
|
100 |
+
$updir = substr($basedir, 0, -1);
|
101 |
+
$delim_pos = strrpos($updir, '/');
|
102 |
+
if ( $delim_pos !== false ) $updir = substr($updir, 0, $delim_pos + 1);
|
103 |
+
|
104 |
+
//define referer (with sort data) to point to this url for use by the elements
|
105 |
+
$referer = $siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$basedir_code;
|
106 |
+
$referer_code = wfu_safe_store_filepath($referer.'[['.$sort.']]');
|
107 |
+
//define header parameters that can be later used when defining file actions
|
108 |
+
$header_params = array();
|
109 |
+
|
110 |
+
//find contents of current folder taking into account pagination, if it is
|
111 |
+
//activated; contents are found following an optimized procedure as follows:
|
112 |
+
// 1. all dirs and files are found and stored in separate arrays
|
113 |
+
// 2. if pagination is activated then it is checked if there are any dirs
|
114 |
+
// in the current page
|
115 |
+
// 3. if dir sorting is name then dirs are sorted
|
116 |
+
// 4. if dir sorting is date then stat is called for all dirs and then they
|
117 |
+
// are sorted
|
118 |
+
// 5. if pagination is activated then dirs array is sliced to keep only the
|
119 |
+
// ones belonging to the current page and then stat is called if it has
|
120 |
+
// not already been called
|
121 |
+
// 6. if there is room in the page for showing files, then files are also
|
122 |
+
// processed
|
123 |
+
// 7. if file sorting is name then files are sorted
|
124 |
+
// 8. if file sorting is date or size then stat is called for all files and
|
125 |
+
// then they are sorted
|
126 |
+
// 9. if file sorting is user then db record is retrieved for all files and
|
127 |
+
// then they are sorted
|
128 |
+
// 10. if pagination is activated then files array is sliced to keep only
|
129 |
+
// the ones fitting in the page; then stat is called and/or db record is
|
130 |
+
// retrieved
|
131 |
+
//first calculate dirs and files arrays
|
132 |
+
$dirlist = array();
|
133 |
+
$dirlist_include = true;
|
134 |
+
$dirlist_perpage = array();
|
135 |
+
$dirstat_ok = false;
|
136 |
+
$filelist = array();
|
137 |
+
$filestat_ok = false;
|
138 |
+
$filerec_ok = false;
|
139 |
+
if ( $handle = opendir($basedir) ) {
|
140 |
+
$blacklist = array('.', '..');
|
141 |
+
while ( false !== ($file = readdir($handle)) )
|
142 |
+
if ( !in_array($file, $blacklist) ) {
|
143 |
+
$filepath = $basedir.$file;
|
144 |
+
if ( is_dir($filepath) ) array_push($dirlist, array( 'name' => $file, 'fullpath' => $filepath ));
|
145 |
+
else array_push($filelist, array( 'name' => $file, 'fullpath' => $filepath ));
|
146 |
+
}
|
147 |
+
closedir($handle);
|
148 |
+
}
|
149 |
+
$dirlist_count = count($dirlist);
|
150 |
+
$filelist_count = count($filelist);
|
151 |
+
//get pagination details and determine if any dirs will be shown
|
152 |
+
$maxrows = (int)WFU_VAR("WFU_ADMINBROWSER_TABLE_MAXROWS");
|
153 |
+
$files_total = $dirlist_count + $filelist_count;
|
154 |
+
if ( $maxrows > 0 ) {
|
155 |
+
$pages = max(ceil($files_total / $maxrows), 1);
|
156 |
+
if ( $page > $pages ) $page = $pages;
|
157 |
+
//if first item index passes number of dirs then do not include dirs
|
158 |
+
if ( ($page - 1) * $maxrows >= $dirlist_count ) $dirlist_include = false;
|
159 |
+
//if a filename has been defined to get focus, then $dirlist_include
|
160 |
+
//needs to be true in order to calculate the dirs of every page
|
161 |
+
if ( $located_file != "" ) $dirlist_include = true;
|
162 |
+
}
|
163 |
+
//process dirs if they are included in page
|
164 |
+
if ( $dirlist_include ) {
|
165 |
+
//adjust sort details
|
166 |
+
$dirsort = ( substr($sort, -4) == 'date' ? 'mdate' : substr($sort, -4) );
|
167 |
+
$dirorder = $order;
|
168 |
+
if ( $dirsort == 'size' ) { $dirsort = 'name'; $dirorder = SORT_ASC; }
|
169 |
+
if ( $dirsort == 'user' ) { $dirsort = 'name'; $dirorder = SORT_ASC; }
|
170 |
+
switch ( $dirsort ) {
|
171 |
+
case "name": $dirsort .= ":s"; break;
|
172 |
+
case "mdate": $dirsort .= ":n"; break;
|
173 |
+
}
|
174 |
+
//if dir sort is mdate or if a file needs to be located then first
|
175 |
+
//calculate stat
|
176 |
+
if ( substr($dirsort, 0, 5) == 'mdate' || $located_file != "" ) {
|
177 |
+
foreach ( $dirlist as &$dir ) {
|
178 |
+
$stat = wfu_stat($dir['fullpath'], "wfu_browse_files:1");
|
179 |
+
$dir['mdate'] = $stat['mtime'];
|
180 |
+
}
|
181 |
+
unset($dir);
|
182 |
+
$dirstat_ok = true;
|
183 |
+
}
|
184 |
+
//sort dirs
|
185 |
+
$dirlist = wfu_array_sort($dirlist, $dirsort, $dirorder);
|
186 |
+
//if pagination is activated then slice dirs array to keep only the
|
187 |
+
//items belonging in the current page
|
188 |
+
if ( $maxrows > 0 ) {
|
189 |
+
//before slicing we store the items in $dirlist_perpage array
|
190 |
+
$i = $maxrows;
|
191 |
+
$ipage = 0;
|
192 |
+
foreach ( $dirlist as $dir ) {
|
193 |
+
if ( $i >= $maxrows ) {
|
194 |
+
$i = 0;
|
195 |
+
$ipage ++;
|
196 |
+
$dirlist_perpage[$ipage] = array();
|
197 |
+
}
|
198 |
+
array_push($dirlist_perpage[$ipage], $dir);
|
199 |
+
$i ++;
|
200 |
+
}
|
201 |
+
//now we slice $dirlist
|
202 |
+
$dirlist = array_slice($dirlist, ($page - 1) * $maxrows, $maxrows);
|
203 |
+
}
|
204 |
+
//calculate stat for the remaining dirs array, if it has not already
|
205 |
+
//been done
|
206 |
+
if ( !$dirstat_ok ) {
|
207 |
+
foreach ( $dirlist as &$dir ) {
|
208 |
+
$stat = wfu_stat($dir['fullpath'], "wfu_browse_files:2");
|
209 |
+
$dir['mdate'] = $stat['mtime'];
|
210 |
+
}
|
211 |
+
unset($dir);
|
212 |
+
}
|
213 |
+
}
|
214 |
+
else $dirlist = array();
|
215 |
+
//determine if any files will be included in page; in case pagination is
|
216 |
+
//activated then the remaining places need to be more than zero
|
217 |
+
$files_included = ( $maxrows > 0 ? ( $maxrows - count($dirlist) > 0 ) : true );
|
218 |
+
//if a filename has been defined to get focus, then $files_included
|
219 |
+
//needs to be true in order to re-calculate the page
|
220 |
+
if ( $located_file != "" ) $files_included = true;
|
221 |
+
if ( $files_included ) {
|
222 |
+
//adjust sort details
|
223 |
+
$filesort = ( substr($sort, -4) == 'date' ? 'mdate' : substr($sort, -4) );
|
224 |
+
switch ( $filesort ) {
|
225 |
+
case "name": $filesort .= ":s"; break;
|
226 |
+
case "size": $filesort .= ":n"; break;
|
227 |
+
case "mdate": $filesort .= ":n"; break;
|
228 |
+
case "user": $filesort .= ":s"; break;
|
229 |
+
}
|
230 |
+
//if file sort is size or mdate then first calculate stat
|
231 |
+
if ( substr($filesort, 0, 4) == 'size' || substr($filesort, 0, 5) == 'mdate' ) {
|
232 |
+
foreach ( $filelist as &$file ) {
|
233 |
+
$stat = wfu_stat($file['fullpath'], "wfu_browse_files:3");
|
234 |
+
$file['size'] = $stat['size'];
|
235 |
+
$file['mdate'] = $stat['mtime'];
|
236 |
+
}
|
237 |
+
unset($file);
|
238 |
+
$filestat_ok = true;
|
239 |
+
}
|
240 |
+
//if file sort is user then first calculate db records
|
241 |
+
elseif ( substr($filesort, 0, 4) == 'user' ) {
|
242 |
+
foreach ( $filelist as &$file ) {
|
243 |
+
//find relative file record in database together with user data;
|
244 |
+
//if the file is php, then file record is null meaning that the file
|
245 |
+
//can only be viewed; if file record is not found then the file can
|
246 |
+
//again only be viewed
|
247 |
+
if ( preg_match("/\.php$/", $file['fullpath']) ) $filerec = null;
|
248 |
+
else $filerec = wfu_get_file_rec($file['fullpath'], true);
|
249 |
+
//find user who uploaded the file
|
250 |
+
$username = ( $filerec != null ? wfu_get_username_by_id($filerec->uploaduserid) : '' );
|
251 |
+
$file['user'] = $username;
|
252 |
+
$file['filedata'] = $filerec;
|
253 |
+
}
|
254 |
+
unset($file);
|
255 |
+
$filerec_ok = true;
|
256 |
+
}
|
257 |
+
//sort files
|
258 |
+
$filelist = wfu_array_sort($filelist, $filesort, $order);
|
259 |
+
//if pagination is activated and a file needs to receive focus, then we
|
260 |
+
//need to calculate the page where the file is shown
|
261 |
+
if ( $maxrows > 0 && $located_file != "" ) {
|
262 |
+
$i = $dirlist_count;
|
263 |
+
foreach ( $filelist as $key => $file ) {
|
264 |
+
if ( $file['name'] == $located_file ) {
|
265 |
+
$located_file_found = true;
|
266 |
+
$filelist[$key]['highlighted'] = 1;
|
267 |
+
break;
|
268 |
+
}
|
269 |
+
$i ++;
|
270 |
+
}
|
271 |
+
if ( $located_file_found ) {
|
272 |
+
$page = floor( $i / $maxrows ) + 1;
|
273 |
+
if ( isset($dirlist_perpage[$page]) ) $dirlist = $dirlist_perpage[$page];
|
274 |
+
else $dirlist = array();
|
275 |
+
}
|
276 |
+
}
|
277 |
+
//if pagination is activated then slice files array to keep only the items
|
278 |
+
//belonging in the current page
|
279 |
+
if ( $maxrows > 0 )
|
280 |
+
$filelist = array_slice($filelist, max(($page - 1) * $maxrows - $dirlist_count, 0), $maxrows - count($dirlist));
|
281 |
+
if ( !$filestat_ok || !$filerec_ok ) {
|
282 |
+
foreach ( $filelist as &$file ) {
|
283 |
+
if ( !$filestat_ok ) {
|
284 |
+
$stat = wfu_stat($file['fullpath'], "wfu_browse_files:4");
|
285 |
+
$file['size'] = $stat['size'];
|
286 |
+
$file['mdate'] = $stat['mtime'];
|
287 |
+
}
|
288 |
+
if ( !$filerec_ok ) {
|
289 |
+
if ( preg_match("/\.php$/", $file['fullpath']) ) $filerec = null;
|
290 |
+
else $filerec = wfu_get_file_rec($file['fullpath'], true);
|
291 |
+
$username = ( $filerec != null ? wfu_get_username_by_id($filerec->uploaduserid) : '' );
|
292 |
+
$file['user'] = $username;
|
293 |
+
$file['filedata'] = $filerec;
|
294 |
+
}
|
295 |
+
}
|
296 |
+
unset($file);
|
297 |
+
}
|
298 |
+
}
|
299 |
+
else $filelist = array();
|
300 |
+
|
301 |
+
//start html output
|
302 |
+
$echo_str = "";
|
303 |
+
if ( !$only_table_rows ) {
|
304 |
+
$echo_str .= "\n".'<div class="wrap">';
|
305 |
+
$echo_str .= "\n\t".'<h2>Wordpress File Upload Control Panel</h2>';
|
306 |
+
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
307 |
+
$echo_str .= wfu_generate_dashboard_menu("\n\t\t", "File Browser");
|
308 |
+
$echo_str .= "\n\t".'<div>';
|
309 |
+
$echo_str .= "\n\t\t".'<span><strong>Location:</strong> </span>';
|
310 |
+
foreach ( $route as $item ) {
|
311 |
+
// store dir path that we need to pass to other functions in session, instead of exposing it in the url
|
312 |
+
$dir_code = wfu_safe_store_filepath($item['path']);
|
313 |
+
$echo_str .= '<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$dir_code.'">'.$item['item'].'</a>';
|
314 |
+
$echo_str .= '<span>/</span>';
|
315 |
+
}
|
316 |
+
//file browser header
|
317 |
+
$echo_str .= "\n\t".'</div>';
|
318 |
+
// $dir_code = wfu_safe_store_filepath(wfu_path_abs2rel($basedir).'[['.$sort.']]');
|
319 |
+
// $echo_str .= "\n\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=create_dir&dir='.$dir_code.'" class="button" title="create folder" style="margin-top:6px">Create folder</a>';
|
320 |
+
$echo_str .= "\n\t".'<div style="margin-top:10px; position:relative;">';
|
321 |
+
$echo_str .= wfu_add_loading_overlay("\n\t\t", "adminbrowser");
|
322 |
+
$adminbrowser_nonce = wp_create_nonce( 'wfu-adminbrowser-page' );
|
323 |
+
$echo_str .= "\n\t\t".'<div class="wfu_adminbrowser_header" style="width: 100%;">';
|
324 |
+
$bulkactions = array(
|
325 |
+
array( "name" => "move", "title" => "Move" ),
|
326 |
+
array( "name" => "delete", "title" => "Delete" ),
|
327 |
+
array( "name" => "include", "title" => "Include" )
|
328 |
+
);
|
329 |
+
$echo_str .= wfu_add_bulkactions_header("\n\t\t\t", "adminbrowser", $bulkactions);
|
330 |
+
if ( $maxrows > 0 ) {
|
331 |
+
$echo_str .= wfu_add_pagination_header("\n\t\t\t", "adminbrowser", $page, $pages, $adminbrowser_nonce);
|
332 |
+
}
|
333 |
+
$echo_str .= "\n\t\t\t".'<input id="wfu_adminbrowser_action_url" type="hidden" value="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload" />';
|
334 |
+
$echo_str .= "\n\t\t\t".'<input id="wfu_adminbrowser_code" type="hidden" value="'.$basedir_code.'" />';
|
335 |
+
$echo_str .= "\n\t\t\t".'<input id="wfu_adminbrowser_referer" type="hidden" value="'.$referer_code.'" />';
|
336 |
+
$echo_str .= "\n\t\t\t".'<input id="wfu_download_file_nonce" type="hidden" value="'.wp_create_nonce('wfu_download_file_invoker').'" />';
|
337 |
+
$echo_str .= "\n\t\t\t".'<input id="wfu_include_file_nonce" type="hidden" value="'.wp_create_nonce('wfu_include_file').'" />';
|
338 |
+
$echo_str .= "\n\t\t".'</div>';
|
339 |
+
$echo_str .= "\n\t\t".'<table id="wfu_adminbrowser_table" class="wfu-adminbrowser wp-list-table widefat fixed striped">';
|
340 |
+
$echo_str .= "\n\t\t\t".'<thead>';
|
341 |
+
$echo_str .= "\n\t\t\t\t".'<tr>';
|
342 |
+
$echo_str .= "\n\t\t\t\t\t".'<td scope="col" width="5%" class="manage-column check-column">';
|
343 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<input id="wfu_select_all_visible" type="checkbox" onchange="wfu_adminbrowser_select_all_visible_changed();" style="-webkit-appearance:checkbox;" />';
|
344 |
+
$echo_str .= "\n\t\t\t\t\t".'</td>';
|
345 |
+
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="25%" class="manage-column column-primary">';
|
346 |
+
$dir_code = wfu_safe_store_filepath(wfu_path_abs2rel($basedir).'[['.( substr($sort, -4) == 'name' ? ( $order == SORT_ASC ? '-name' : 'name' ) : 'name' ).']]');
|
347 |
+
$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='.$dir_code.'">Name'.( substr($sort, -4) == 'name' ? ( $order == SORT_ASC ? ' ↑' : ' ↓' ) : '' ).'</a>';
|
348 |
+
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
349 |
+
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="10%" class="manage-column">';
|
350 |
+
$dir_code = wfu_safe_store_filepath(wfu_path_abs2rel($basedir).'[['.( substr($sort, -4) == 'size' ? ( $order == SORT_ASC ? '-size' : 'size' ) : 'size' ).']]');
|
351 |
+
$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='.$dir_code.'">Size'.( substr($sort, -4) == 'size' ? ( $order == SORT_ASC ? ' ↑' : ' ↓' ) : '' ).'</a>';
|
352 |
+
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
353 |
+
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="20%" class="manage-column">';
|
354 |
+
$dir_code = wfu_safe_store_filepath(wfu_path_abs2rel($basedir).'[['.( substr($sort, -4) == 'date' ? ( $order == SORT_ASC ? '-date' : 'date' ) : 'date' ).']]');
|
355 |
+
$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='.$dir_code.'">Date'.( substr($sort, -4) == 'date' ? ( $order == SORT_ASC ? ' ↑' : ' ↓' ) : '' ).'</a>';
|
356 |
+
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
357 |
+
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="10%" class="manage-column">';
|
358 |
+
$dir_code = wfu_safe_store_filepath(wfu_path_abs2rel($basedir).'[['.( substr($sort, -4) == 'user' ? ( $order == SORT_ASC ? '-user' : 'user' ) : 'user' ).']]');
|
359 |
+
$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='.$dir_code.'">Uploaded By'.( substr($sort, -4) == 'user' ? ( $order == SORT_ASC ? ' ↑' : ' ↓' ) : '' ).'</a>';
|
360 |
+
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
361 |
+
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="30%" class="manage-column">';
|
362 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<label>User Data</label>';
|
363 |
+
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
364 |
+
$echo_str .= "\n\t\t\t\t".'</tr>';
|
365 |
+
$echo_str .= "\n\t\t\t".'</thead>';
|
366 |
+
$echo_str .= "\n\t\t\t".'<tbody>';
|
367 |
+
}
|
368 |
+
|
369 |
+
//show subfolders first
|
370 |
+
if ( $reldir != "root/" ) {
|
371 |
+
$dir_code = wfu_safe_store_filepath(wfu_path_abs2rel($updir));
|
372 |
+
$echo_str .= "\n\t\t\t\t".'<tr>';
|
373 |
+
$echo_str .= "\n\t\t\t\t\t".'<th class="check-column"><input type="checkbox" disabled="disabled" /></th>';
|
374 |
+
$echo_str .= "\n\t\t\t\t\t".'<td class="column-primary" data-colname="Name">';
|
375 |
+
$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='.$dir_code.'" title="go up">..</a>';
|
376 |
+
$echo_str .= "\n\t\t\t\t\t".'</td>';
|
377 |
+
$echo_str .= "\n\t\t\t\t\t".'<td data-colname="Size"> </td>';
|
378 |
+
$echo_str .= "\n\t\t\t\t\t".'<td data-colname="Date"> </td>';
|
379 |
+
$echo_str .= "\n\t\t\t\t\t".'<td data-colname="Uploaded By"> </td>';
|
380 |
+
$echo_str .= "\n\t\t\t\t\t".'<td data-colname="User Data"> </td>';
|
381 |
+
$echo_str .= "\n\t\t\t\t".'</tr>';
|
382 |
+
}
|
383 |
+
$ii = 1;
|
384 |
+
foreach ( $dirlist as $dir ) {
|
385 |
+
$dir_code = wfu_prepare_to_batch_safe_store_filepath(wfu_path_abs2rel($dir['fullpath']).'[['.$sort.']]');
|
386 |
+
$echo_str .= "\n\t\t\t\t".'<tr onmouseover="var actions=document.getElementsByName(\'wfu_dir_actions\'); for (var i=0; i<actions.length; i++) {actions[i].style.visibility=\'hidden\';} document.getElementById(\'wfu_dir_actions_'.$ii.'\').style.visibility=\'visible\'" onmouseout="var actions=document.getElementsByName(\'wfu_dir_actions\'); for (var i=0; i<actions.length; i++) {actions[i].style.visibility=\'hidden\';}">';
|
387 |
+
$echo_str .= "\n\t\t\t\t\t".'<th class="check-column"><input type="checkbox" disabled="disabled" /></th>';
|
388 |
+
$echo_str .= "\n\t\t\t\t\t".'<td class="column-primary" data-colname="Name">';
|
389 |
+
$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='.$dir_code.'" title="'.$dir['name'].'">'.$dir['name'].'</a>';
|
390 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<div id="wfu_dir_actions_'.$ii.'" name="wfu_dir_actions" style="visibility:hidden;">';
|
391 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<span style="visibility:hidden;">';
|
392 |
+
$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_browser&dir=">Noaction</a>';
|
393 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".' | ';
|
394 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'</span>';
|
395 |
+
// $echo_str .= "\n\t\t\t\t\t\t\t".'<span>';
|
396 |
+
// $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='.$dir_code.'" title="Rename this folder">Rename</a>';
|
397 |
+
// $echo_str .= "\n\t\t\t\t\t\t\t\t".' | ';
|
398 |
+
// $echo_str .= "\n\t\t\t\t\t\t\t".'</span>';
|
399 |
+
// $echo_str .= "\n\t\t\t\t\t\t\t".'<span>';
|
400 |
+
// $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='.$dir_code.'" title="Delete this folder">Delete</a>';
|
401 |
+
// $echo_str .= "\n\t\t\t\t\t\t\t".'</span>';
|
402 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</div>';
|
403 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<button type="button" class="toggle-row"><span class="screen-reader-text">Show more details</span></button>';
|
404 |
+
$echo_str .= "\n\t\t\t\t\t".'</td>';
|
405 |
+
$echo_str .= "\n\t\t\t\t\t".'<td data-colname="Size"> </td>';
|
406 |
+
$echo_str .= "\n\t\t\t\t\t".'<td data-colname="Date">'.get_date_from_gmt(date("Y-m-d H:i:s", $dir['mdate']), "d/m/Y H:i:s").'</td>';
|
407 |
+
$echo_str .= "\n\t\t\t\t\t".'<td data-colname="Uploaded By"> </td>';
|
408 |
+
$echo_str .= "\n\t\t\t\t\t".'<td data-colname="User Data"> </td>';
|
409 |
+
$echo_str .= "\n\t\t\t\t".'</tr>';
|
410 |
+
$ii ++;
|
411 |
+
}
|
412 |
+
//store dir paths to safe
|
413 |
+
wfu_batch_safe_store_filepaths();
|
414 |
+
//show contained files
|
415 |
+
foreach ( $filelist as $file ) {
|
416 |
+
$is_included = ( $file['filedata'] != null );
|
417 |
+
$can_be_included = ( $plugin_options['includeotherfiles'] == "1" ) && !wfu_file_extension_blacklisted($file['name']);
|
418 |
+
$highlighted = ( isset($file['highlighted']) && $file['highlighted'] == 1 );
|
419 |
+
$file_code = '';
|
420 |
+
if ( $is_included || $can_be_included ) $file_code = wfu_prepare_to_batch_safe_store_filepath(wfu_path_abs2rel($file['fullpath']).'[['.$sort.']]');
|
421 |
+
$echo_str .= "\n\t\t\t\t".'<tr '.( $highlighted ? 'class="wfu-highlighted" ' : '' ).'onmouseover="var actions=document.getElementsByName(\'wfu_file_actions\'); for (var i=0; i<actions.length; i++) {actions[i].style.visibility=\'hidden\';} document.getElementById(\'wfu_file_actions_'.$ii.'\').style.visibility=\'visible\'" onmouseout="var actions=document.getElementsByName(\'wfu_file_actions\'); for (var i=0; i<actions.length; i++) {actions[i].style.visibility=\'hidden\';}">';
|
422 |
+
$echo_str .= "\n\t\t\t\t\t".'<th class="check-column">';
|
423 |
+
if ( $is_included || $can_be_included ) $echo_str .= "\n\t\t\t\t\t\t".'<input class="wfu_selectors'.( $is_included ? ' wfu_included' : '' ).' wfu_selcode_'.$file_code.'" type="checkbox" onchange="wfu_adminbrowser_selector_changed(this);" />';
|
424 |
+
else $echo_str .= "\n\t\t\t\t\t\t".'<input type="checkbox" disabled="disabled" />';
|
425 |
+
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
426 |
+
$echo_str .= "\n\t\t\t\t\t".'<td class="column-primary" data-colname="Name">';
|
427 |
+
if ( $is_included || $can_be_included )
|
428 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<a id="wfu_file_link_'.$ii.'" class="row-title" href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_details&file='.$file_code.'" title="View and edit file details" style="font-weight:normal;'.( $is_included ? '' : ' display:none;' ).'">'.$file['name'].'</a>';
|
429 |
+
if ( !$is_included )
|
430 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<span id="wfu_file_flat_'.$ii.'">'.$file['name'].'</span>';
|
431 |
+
//set additional $file properties for generating file actions
|
432 |
+
$file["index"] = $ii;
|
433 |
+
$file["code"] = $file_code;
|
434 |
+
$file["referer_code"] = $referer_code;
|
435 |
+
$file_actions = wfu_adminbrowser_file_actions($file, $header_params);
|
436 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<div id="wfu_file_actions_'.$ii.'" name="wfu_file_actions" style="visibility:hidden;">';
|
437 |
+
if ( $is_included || $can_be_included ) {
|
438 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<div id="wfu_file_is_included_actions_'.$ii.'" style="display:'.( $is_included ? 'block' : 'none' ).';">';
|
439 |
+
//add file actions for files already included
|
440 |
+
$array_keys = array_keys($file_actions["is_included"]);
|
441 |
+
$lastkey = array_pop($array_keys);
|
442 |
+
foreach ( $file_actions["is_included"] as $key => $action ) {
|
443 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<span>';
|
444 |
+
foreach ( $action as $line )
|
445 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t\t".$line;
|
446 |
+
if ( $key != $lastkey ) $echo_str .= "\n\t\t\t\t\t\t\t\t\t".' | ';
|
447 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'</span>';
|
448 |
+
}
|
449 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'</div>';
|
450 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<div id="wfu_file_can_be_included_actions_'.$ii.'" style="display:'.( $is_included ? 'none' : 'block' ).';">';
|
451 |
+
//add file actions for files that can be included
|
452 |
+
$array_keys = array_keys($file_actions["can_be_included"]);
|
453 |
+
$lastkey = array_pop($array_keys);
|
454 |
+
foreach ( $file_actions["can_be_included"] as $key => $action ) {
|
455 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<span>';
|
456 |
+
foreach ( $action as $line )
|
457 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t\t".$line;
|
458 |
+
if ( $key != $lastkey ) $echo_str .= "\n\t\t\t\t\t\t\t\t\t".' | ';
|
459 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'</span>';
|
460 |
+
}
|
461 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'</div>';
|
462 |
+
}
|
463 |
+
else {
|
464 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<span style="visibility:hidden;">';
|
465 |
+
$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_browser&dir=">Noaction</a>';
|
466 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".' | ';
|
467 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'</span>';
|
468 |
+
}
|
469 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</div>';
|
470 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<div id="wfu_file_download_container_'.$ii.'" style="display: none;"></div>';
|
471 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<button type="button" class="toggle-row"><span class="screen-reader-text">Show more details</span></button>';
|
472 |
+
$echo_str .= "\n\t\t\t\t\t".'</td>';
|
473 |
+
$echo_str .= "\n\t\t\t\t\t".'<td data-colname="Size">'.$file['size'].'</td>';
|
474 |
+
$echo_str .= "\n\t\t\t\t\t".'<td data-colname="Date">'.get_date_from_gmt(date("Y-m-d H:i:s", $file['mdate']), "d/m/Y H:i:s").'</td>';
|
475 |
+
$echo_str .= "\n\t\t\t\t\t".'<td data-colname="Uploaded By">'.$file['user'].'</td>';
|
476 |
+
$echo_str .= "\n\t\t\t\t\t".'<td data-colname="User Data">';
|
477 |
+
if ( $is_included ) {
|
478 |
+
if ( is_array($file['filedata']->userdata) && count($file['filedata']->userdata) > 0 ) {
|
479 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<select multiple="multiple" style="width:100%; height:40px; background:none; font-size:small;">';
|
480 |
+
foreach ( $file['filedata']->userdata as $userdata )
|
481 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<option>'.$userdata->property.': '.$userdata->propvalue.'</option>';
|
482 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</select>';
|
483 |
+
}
|
484 |
+
}
|
485 |
+
$echo_str .= "\n\t\t\t\t\t".'</td>';
|
486 |
+
$echo_str .= "\n\t\t\t\t".'</tr>';
|
487 |
+
$ii ++;
|
488 |
+
}
|
489 |
+
//store file paths to safe
|
490 |
+
wfu_batch_safe_store_filepaths();
|
491 |
+
|
492 |
+
if ( !$only_table_rows ) {
|
493 |
+
$echo_str .= "\n\t\t\t".'</tbody>';
|
494 |
+
$echo_str .= "\n\t\t".'</table>';
|
495 |
+
$echo_str .= "\n\t\t".'<iframe id="wfu_download_frame" style="display: none;"></iframe>';
|
496 |
+
$echo_str .= "\n\t".'</div>';
|
497 |
+
$echo_str .= "\n\t".'</div>';
|
498 |
+
$echo_str .= "\n".'</div>';
|
499 |
+
}
|
500 |
+
if ( $located_file_found ) {
|
501 |
+
$handler = 'function() { wfu_focus_table_on_highlighted_file("wfu_adminbrowser_table"); }';
|
502 |
+
$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>';
|
503 |
+
}
|
504 |
+
|
505 |
+
return $echo_str;
|
506 |
+
}
|
507 |
+
|
508 |
+
/**
|
509 |
+
* Add Actions to Displayed Files.
|
510 |
+
*
|
511 |
+
* This function sets the actions that can be applied on the displayed files.
|
512 |
+
* Filters can customize these actions.
|
513 |
+
*
|
514 |
+
* @since 4.1.0
|
515 |
+
*
|
516 |
+
* @param array $file An array containing properties of the file.
|
517 |
+
* @param array $params An array of custom parameters to pass to file actions
|
518 |
+
* filter.
|
519 |
+
*
|
520 |
+
* @return array An array of actions that can be executed on the file.
|
521 |
+
*/
|
522 |
+
function wfu_adminbrowser_file_actions($file, $params) {
|
523 |
+
$siteurl = site_url();
|
524 |
+
$actions = array(
|
525 |
+
"is_included" => array(),
|
526 |
+
"can_be_included" => array()
|
527 |
+
);
|
528 |
+
//add file actions if file is already included
|
529 |
+
$actions["is_included"] += array(
|
530 |
+
array( '<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_details&file='.$file["code"].'" title="View and edit file details">Details</a>' ),
|
531 |
+
array( '<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=rename_file&file='.$file["code"].'" title="Rename this file">Rename</a>' ),
|
532 |
+
array( '<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=move_file&file='.$file["code"].'" title="Move this file">Move</a>' ),
|
533 |
+
array( '<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=delete_file&file='.$file["code"].'&referer='.$file["referer_code"].'" title="Delete this file">Delete</a>' ),
|
534 |
+
array( '<a href="javascript:wfu_download_file(\''.$file["code"].'\', '.$file["index"].');" title="Download this file">Download</a>' )
|
535 |
+
);
|
536 |
+
//add file actions if file can be included
|
537 |
+
$actions["can_be_included"] += array(
|
538 |
+
array(
|
539 |
+
'<a id="wfu_include_file_'.$file["index"].'_a" href="javascript:wfu_include_file(\''.$file["code"].'\', '.$file["index"].');" title="Include file in plugin\'s database">Include File</a>',
|
540 |
+
'<img id="wfu_include_file_'.$file["index"].'_img" src="'.WFU_IMAGE_ADMIN_SUBFOLDER_LOADING.'" style="width:12px; display:none;" />',
|
541 |
+
'<input id="wfu_include_file_'.$file["index"].'_inpfail" type="hidden" value="File could not be included!" />'
|
542 |
+
)
|
543 |
+
);
|
544 |
+
|
545 |
+
return $actions;
|
546 |
+
}
|
547 |
+
|
548 |
+
/**
|
549 |
+
* Check if User Owns a File.
|
550 |
+
*
|
551 |
+
* This function checks if a user is the owner of a specific file. It will
|
552 |
+
* return true if the user in an administrator.
|
553 |
+
*
|
554 |
+
* @since 3.8.5
|
555 |
+
*
|
556 |
+
* @param integer $userid The ID of the user to check.
|
557 |
+
* @param object $filerec The database record of the file.
|
558 |
+
*
|
559 |
+
* @return bool True if the user owns the file, false otherwise.
|
560 |
+
*/
|
561 |
+
function wfu_user_owns_file($userid, $filerec) {
|
562 |
+
if ( 0 == $userid )
|
563 |
+
return false;
|
564 |
+
if ( current_user_can('manage_options') ) return true;
|
565 |
+
return false;
|
566 |
+
}
|
567 |
+
|
568 |
+
/**
|
569 |
+
* Check if Current User Owns a File.
|
570 |
+
*
|
571 |
+
* This function checks if the current user is the owner of a specific file. It
|
572 |
+
* will first check if the file extension is valid.
|
573 |
+
*
|
574 |
+
* @since 3.0.0
|
575 |
+
*
|
576 |
+
* @param string $filepath The full path of the file to check.
|
577 |
+
* @param object $filerec Optional. The db record of the file, if available.
|
578 |
+
*
|
579 |
+
* @return bool True if the user owns the file, false otherwise.
|
580 |
+
*/
|
581 |
+
function wfu_current_user_owes_file($filepath, $filerec = null) {
|
582 |
+
//first check if file has a restricted extension; for security reasons some
|
583 |
+
//file extensions cannot be owned
|
584 |
+
if ( wfu_file_extension_blacklisted($filepath) ) return false;
|
585 |
+
//then get file data from database, if exist
|
586 |
+
if ( $filerec == null ) $filerec = wfu_get_file_rec($filepath, false);
|
587 |
+
if ( $filerec == null ) return false;
|
588 |
+
|
589 |
+
$user = wp_get_current_user();
|
590 |
+
return wfu_user_owns_file($user->ID, $filerec);
|
591 |
+
}
|
592 |
+
|
593 |
+
/**
|
594 |
+
* Check if Current User is Allowed to Execute an Action on a File.
|
595 |
+
*
|
596 |
+
* This function checks if the current user is allowed to execute a specific
|
597 |
+
* action on a file.
|
598 |
+
*
|
599 |
+
* @since 2.4.1
|
600 |
+
*
|
601 |
+
* @param string $action A file action to check.
|
602 |
+
* @param string $filepath The full path of the file to check.
|
603 |
+
*
|
604 |
+
* @return object|null Returns the current WP_User object if current user is
|
605 |
+
* allowed to execute the action on the file or null otherwise.
|
606 |
+
*/
|
607 |
+
function wfu_current_user_allowed_action($action, $filepath) {
|
608 |
+
//first get file data from database, if exist
|
609 |
+
$filerec = wfu_get_file_rec($filepath, false);
|
610 |
+
|
611 |
+
$user = wp_get_current_user();
|
612 |
+
if ( 0 == $user->ID ) return null;
|
613 |
+
else $is_admin = current_user_can('manage_options');
|
614 |
+
if ( !$is_admin ) {
|
615 |
+
return null;
|
616 |
+
}
|
617 |
+
return $user;
|
618 |
+
}
|
619 |
+
|
620 |
+
/**
|
621 |
+
* Check if User is Allowed to Execute an Action on a File.
|
622 |
+
*
|
623 |
+
* This function checks if a user is allowed to execute a specific action on a
|
624 |
+
* file.
|
625 |
+
*
|
626 |
+
* @since 2.6.0
|
627 |
+
*
|
628 |
+
* @param string $action A file action to check.
|
629 |
+
* @param string $filepath The full path of the file to check.
|
630 |
+
* @param integer $userid The ID of the user to check.
|
631 |
+
*
|
632 |
+
* @return bool|null Returns true if current user is allowed to execute the
|
633 |
+
* action on the file or null otherwise.
|
634 |
+
*/
|
635 |
+
function wfu_current_user_allowed_action_remote($action, $filepath, $userid) {
|
636 |
+
//first get file data from database, if exist
|
637 |
+
$filerec = wfu_get_file_rec($filepath, false);
|
638 |
+
|
639 |
+
if ( 0 == $userid ) return null;
|
640 |
+
else $is_admin = user_can($userid, 'manage_options');
|
641 |
+
if ( !$is_admin ) {
|
642 |
+
return null;
|
643 |
+
}
|
644 |
+
return true;
|
645 |
+
}
|
646 |
+
|
647 |
+
/**
|
648 |
+
* Confirm Renaming of File.
|
649 |
+
*
|
650 |
+
* This function shows a page to confirm renaming of a file.
|
651 |
+
*
|
652 |
+
* @since 2.2.1
|
653 |
+
*
|
654 |
+
* @param string $file_code A code corresponding to the file/dir to be renamed.
|
655 |
+
* @param string $type Rename dir or file. Can take the values 'dir' or 'file'.
|
656 |
+
* @param string $error An error message to show on top of the page in case an
|
657 |
+
* error occured during renaming.
|
658 |
+
*
|
659 |
+
* @return string The HTML code of the confirmation page.
|
660 |
+
*/
|
661 |
+
function wfu_rename_file_prompt($file_code, $type, $error) {
|
662 |
+
if ( $type == 'dir' ) return;
|
663 |
+
|
664 |
+
$siteurl = site_url();
|
665 |
+
|
666 |
+
$is_admin = current_user_can( 'manage_options' );
|
667 |
+
//check if user is allowed to view file details
|
668 |
+
if ( !$is_admin ) {
|
669 |
+
return;
|
670 |
+
}
|
671 |
+
$file_code = wfu_sanitize_code($file_code);
|
672 |
+
$dec_file = wfu_get_filepath_from_safe($file_code);
|
673 |
+
if ( $dec_file === false ) return;
|
674 |
+
|
675 |
+
//first extract sort info from dec_file
|
676 |
+
$ret = wfu_extract_sortdata_from_path($dec_file);
|
677 |
+
$dec_file = wfu_path_rel2abs($ret['path']);
|
678 |
+
if ( $type == 'dir' && substr($dec_file, -1) == '/' ) $dec_file = substr($dec_file, 0, -1);
|
679 |
+
|
680 |
+
//check if user is allowed to perform this action
|
681 |
+
if ( !wfu_current_user_owes_file($dec_file) ) return;
|
682 |
+
|
683 |
+
$parts = pathinfo($dec_file);
|
684 |
+
$newname = $parts['basename'];
|
685 |
+
$dir_code = wfu_safe_store_filepath(wfu_path_abs2rel($parts['dirname']).'[['.$ret['sort'].']]');
|
686 |
+
|
687 |
+
$echo_str = "\n".'<div class="wrap">';
|
688 |
+
if ( $error ) {
|
689 |
+
$rename_file = WFU_USVAR('wfu_rename_file');
|
690 |
+
$newname = $rename_file['newname'];
|
691 |
+
$echo_str .= "\n\t".'<div class="error">';
|
692 |
+
$echo_str .= "\n\t\t".'<p>'.WFU_USVAR('wfu_rename_file_error').'</p>';
|
693 |
+
$echo_str .= "\n\t".'</div>';
|
694 |
+
}
|
695 |
+
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
696 |
+
if ( $is_admin ) $echo_str .= "\n\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$dir_code.'" class="button" title="go back">Go back</a>';
|
697 |
+
$echo_str .= "\n\t".'</div>';
|
698 |
+
$echo_str .= "\n\t".'<h2 style="margin-bottom: 10px;">Rename '.( $type == 'dir' ? 'Folder' : 'File' ).'</h2>';
|
699 |
+
if ( $is_admin ) $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">';
|
700 |
+
$echo_str .= "\n\t\t".'<input type="hidden" name="action" value="rename'.( $type == 'dir' ? 'dir' : 'file' ).'">';
|
701 |
+
$echo_str .= "\n\t\t".'<input type="hidden" name="dir" value="'.$dir_code.'">';
|
702 |
+
$echo_str .= "\n\t\t".'<input type="hidden" name="file" value="'.$file_code.'">';
|
703 |
+
if ( $type == 'dir' ) $echo_str .= "\n\t\t".'<label>Enter new name for folder <strong>'.$dec_file.'</strong></label><br/>';
|
704 |
+
elseif ( $is_admin ) $echo_str .= "\n\t\t".'<label>Enter new filename for file <strong>'.$dec_file.'</strong></label><br/>';
|
705 |
+
$echo_str .= "\n\t\t".'<input name="wfu_newname" id="wfu_newname" type="text" value="'.$newname.'" style="width:50%;" />';
|
706 |
+
$echo_str .= "\n\t\t".'<p class="submit">';
|
707 |
+
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Rename">';
|
708 |
+
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Cancel">';
|
709 |
+
$echo_str .= "\n\t\t".'</p>';
|
710 |
+
$echo_str .= "\n\t".'</form>';
|
711 |
+
$echo_str .= "\n".'</div>';
|
712 |
+
return $echo_str;
|
713 |
+
}
|
714 |
+
|
715 |
+
/**
|
716 |
+
* Confirm Moving of File.
|
717 |
+
*
|
718 |
+
* This function shows a page to confirm moving of a file to a new location.
|
719 |
+
*
|
720 |
+
* @since 4.10.3
|
721 |
+
*
|
722 |
+
* @param string $file_code A code corresponding to the file to be moved.
|
723 |
+
* @param string $error An error message to show on top of the page in case an
|
724 |
+
* error occured during move.
|
725 |
+
*
|
726 |
+
* @return string The HTML code of the confirmation page.
|
727 |
+
*/
|
728 |
+
function wfu_move_file_prompt($file_code, $error) {
|
729 |
+
$siteurl = site_url();
|
730 |
+
|
731 |
+
$is_admin = current_user_can( 'manage_options' );
|
732 |
+
//check if user is allowed to view file details
|
733 |
+
if ( !$is_admin ) return;
|
734 |
+
|
735 |
+
if ( !is_array($file_code) ) $file_code = array( $file_code );
|
736 |
+
$names = array();
|
737 |
+
foreach ( $file_code as $index => $code ) {
|
738 |
+
$file_code[$index] = wfu_sanitize_code($code);
|
739 |
+
$dec_file = wfu_get_filepath_from_safe($file_code[$index]);
|
740 |
+
if ( $dec_file === false ) unset($file_code[$index]);
|
741 |
+
else {
|
742 |
+
//first extract sort info from dec_file
|
743 |
+
$ret = wfu_extract_sortdata_from_path($dec_file);
|
744 |
+
$dec_file = $ret['path'];
|
745 |
+
$parts = pathinfo($dec_file);
|
746 |
+
array_push($names, $parts['basename']);
|
747 |
+
}
|
748 |
+
}
|
749 |
+
if ( count($file_code) == 0 ) return;
|
750 |
+
$file_code_list = "list:".implode(",", $file_code);
|
751 |
+
|
752 |
+
$newpath = $parts['dirname'];
|
753 |
+
$replacefiles = "";
|
754 |
+
$dir_code = wfu_safe_store_filepath($parts['dirname'].'[['.$ret['sort'].']]');
|
755 |
+
|
756 |
+
$echo_str = "\n".'<div class="wrap">';
|
757 |
+
if ( $error ) {
|
758 |
+
$move_file = WFU_USVAR('wfu_move_file');
|
759 |
+
$newpath = $move_file['newpath'];
|
760 |
+
$replacefiles = $move_file['replacefiles'];
|
761 |
+
$echo_str .= "\n\t".'<div class="error">';
|
762 |
+
$echo_str .= "\n\t\t".'<p>'.WFU_USVAR('wfu_move_file_error').'</p>';
|
763 |
+
$echo_str .= "\n\t".'</div>';
|
764 |
+
}
|
765 |
+
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
766 |
+
$echo_str .= "\n\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$dir_code.'" class="button" title="go back">Go back</a>';
|
767 |
+
$echo_str .= "\n\t".'</div>';
|
768 |
+
$echo_str .= "\n\t".'<h2 style="margin-bottom: 10px;">Move File</h2>';
|
769 |
+
$echo_str .= "\n\t".'<form enctype="multipart/form-data" name="movefile" id="movefile" method="post" action="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload" class="validate">';
|
770 |
+
$echo_str .= "\n\t\t".'<input type="hidden" name="action" value="movefile">';
|
771 |
+
$echo_str .= "\n\t\t".'<input type="hidden" name="dir" value="'.$dir_code.'">';
|
772 |
+
$echo_str .= "\n\t\t".'<input type="hidden" name="file" value="'.$file_code_list.'">';
|
773 |
+
if ( count($names) == 1 )
|
774 |
+
$echo_str .= "\n\t\t".'<label style="display:inline-block; margin-bottom:1em;">Enter destination folder for file <strong>'.$dec_file.'</strong></label><br/>';
|
775 |
+
else {
|
776 |
+
$echo_str .= "\n\t\t".'<label>Enter destination folder for files:</label><br/>';
|
777 |
+
$echo_str .= "\n\t\t".'<ul style="padding-left: 20px; list-style: initial;">';
|
778 |
+
foreach ( $names as $name )
|
779 |
+
$echo_str .= "\n\t\t\t".'<li><strong>'.$name.'</strong></li>';
|
780 |
+
$echo_str .= "\n\t\t".'</ul>';
|
781 |
+
}
|
782 |
+
$echo_str .= "\n\t\t".'<input name="wfu_newpath" id="wfu_newpath" type="text" value="'.$newpath.'" style="width:50%;" />';
|
783 |
+
$echo_str .= "\n\t\t".'<p>';
|
784 |
+
$echo_str .= "\n\t\t\t".'<label>Replace files with the same filename at destination:</label><br />';
|
785 |
+
$echo_str .= "\n\t\t\t".'<input name="wfu_replace" id="wfu_replace_yes" type="radio" value="yes"'.( $replacefiles == "yes" ? ' checked="checked"' : '' ).' /><label for="wfu_replace_yes">Yes</label>';
|
786 |
+
$echo_str .= "\n\t\t\t".'<input name="wfu_replace" id="wfu_replace_no" type="radio" value="no"'.( $replacefiles == "no" ? ' checked="checked"' : '' ).' style="margin-left:1em;" /><label for="wfu_replace_no">No</label>';
|
787 |
+
$echo_str .= "\n\t\t".'</p>';
|
788 |
+
$echo_str .= "\n\t\t".'<p class="submit">';
|
789 |
+
$echo_str .= "\n\t\t\t".'<input type="button" class="button-primary" name="submitBtn" value="Move" onclick="if (!document.getElementById(\'wfu_replace_yes\').checked && !document.getElementById(\'wfu_replace_no\').checked) alert(\'Please select if files in destination with the same filename will be replaced or not!\'); else this.form.submit();" />';
|
790 |
+
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submitBtn" value="Cancel" />';
|
791 |
+
$echo_str .= "\n\t\t".'</p>';
|
792 |
+
$echo_str .= "\n\t".'</form>';
|
793 |
+
$echo_str .= "\n".'</div>';
|
794 |
+
return $echo_str;
|
795 |
+
}
|
796 |
+
|
797 |
+
/**
|
798 |
+
* Execute Renaming of File.
|
799 |
+
*
|
800 |
+
* This function renames a file.
|
801 |
+
*
|
802 |
+
* @since 2.2.1
|
803 |
+
*
|
804 |
+
* @param string $file_code A code corresponding to the file/dir to be renamed.
|
805 |
+
* @param string $type Rename dir or file. Can take the values 'dir' or 'file'.
|
806 |
+
*
|
807 |
+
* @return bool True if renaming of file succeeded, false otherwise.
|
808 |
+
*/
|
809 |
+
function wfu_rename_file($file_code, $type) {
|
810 |
+
if ( $type == 'dir' ) return;
|
811 |
+
|
812 |
+
$user = wp_get_current_user();
|
813 |
+
$is_admin = current_user_can( 'manage_options' );
|
814 |
+
//check if user is allowed to view file details
|
815 |
+
if ( !$is_admin ) {
|
816 |
+
return;
|
817 |
+
}
|
818 |
+
$file_code = wfu_sanitize_code($file_code);
|
819 |
+
$dec_file = wfu_get_filepath_from_safe($file_code);
|
820 |
+
if ( $dec_file === false ) return;
|
821 |
+
|
822 |
+
$dec_file = wfu_path_rel2abs(wfu_flatten_path($dec_file));
|
823 |
+
if ( $type == 'dir' && substr($dec_file, -1) == '/' ) $dec_file = substr($dec_file, 0, -1);
|
824 |
+
if ( !wfu_file_exists($dec_file, "wfu_rename_file:1") ) return;
|
825 |
+
|
826 |
+
//check if user is allowed to perform this action
|
827 |
+
if ( !wfu_current_user_owes_file($dec_file) ) return;
|
828 |
+
|
829 |
+
$parts = pathinfo($dec_file);
|
830 |
+
$error = "";
|
831 |
+
if ( isset($_POST['wfu_newname']) && isset($_POST['submit']) ) {
|
832 |
+
if ( $_POST['submit'] == "Rename" && $_POST['wfu_newname'] != $parts['basename'] ) {
|
833 |
+
$new_file = $parts['dirname'].'/'.$_POST['wfu_newname'];
|
834 |
+
if ( $_POST['wfu_newname'] == "" ) $error = 'Error: New '.( $type == 'dir' ? 'folder ' : 'file' ).'name cannot be empty!';
|
835 |
+
elseif ( preg_match("/[^A-Za-z0-9_.#\-$]/", $_POST['wfu_newname']) ) $error = 'Error: name contained invalid characters that were stripped off! Please try again.';
|
836 |
+
elseif ( substr($_POST['wfu_newname'], -1 - strlen($parts['extension'])) != '.'.$parts['extension'] ) $error = 'Error: new and old file name extensions must be identical! Please correct.';
|
837 |
+
elseif ( wfu_file_extension_blacklisted($_POST['wfu_newname']) ) $error = 'Error: the new file name has an extension that is forbidden for security reasons. Please correct.';
|
838 |
+
elseif ( wfu_file_exists($new_file, "wfu_rename_file:2") ) $error = 'Error: The '.( $type == 'dir' ? 'folder' : 'file' ).' <strong>'.$_POST['wfu_newname'].'</strong> already exists! Please choose another one.';
|
839 |
+
else {
|
840 |
+
//pre-log rename action
|
841 |
+
if ( $type == 'file' ) $retid = wfu_log_action('rename:'.$new_file, $dec_file, $user->ID, '', 0, 0, '', null);
|
842 |
+
//perform rename action
|
843 |
+
if ( rename($dec_file, $new_file) == false ) $error = 'Error: Rename of '.( $type == 'dir' ? 'folder' : 'file' ).' <strong>'.$parts['basename'].'</strong> failed!';
|
844 |
+
//revert log action if file was not renamed
|
845 |
+
if ( $type == 'file' && !wfu_file_exists($new_file, "wfu_rename_file:3") ) wfu_revert_log_action($retid);
|
846 |
+
}
|
847 |
+
}
|
848 |
+
}
|
849 |
+
if ( $error != "" ) {
|
850 |
+
WFU_USVAR_store('wfu_rename_file_error', $error);
|
851 |
+
$rename_file = WFU_USVAR('wfu_rename_file');
|
852 |
+
$rename_file['newname'] = preg_replace("/[^A-Za-z0-9_.#\-$]/", "", $_POST['wfu_newname']);
|
853 |
+
WFU_USVAR_store('wfu_rename_file', $rename_file);
|
854 |
+
}
|
855 |
+
return ( $error == "" );
|
856 |
+
}
|
857 |
+
|
858 |
+
/**
|
859 |
+
* Execute Moving of File.
|
860 |
+
*
|
861 |
+
* This function moves a file to another location.
|
862 |
+
*
|
863 |
+
* @since 4.10.3
|
864 |
+
*
|
865 |
+
* @param string $file_code A code corresponding to the file to be moved.
|
866 |
+
*
|
867 |
+
* @return bool True if move of file succeeded, false otherwise.
|
868 |
+
*/
|
869 |
+
function wfu_move_file($file_code) {
|
870 |
+
$user = wp_get_current_user();
|
871 |
+
$is_admin = current_user_can( 'manage_options' );
|
872 |
+
//check if user is allowed to view file details
|
873 |
+
if ( !$is_admin ) return;
|
874 |
+
|
875 |
+
if ( !is_array($file_code) ) $file_code = array( $file_code );
|
876 |
+
$dec_files = array();
|
877 |
+
foreach ( $file_code as $index => $code ) {
|
878 |
+
$file_code[$index] = wfu_sanitize_code($code);
|
879 |
+
$dec_file = wfu_get_filepath_from_safe($file_code[$index]);
|
880 |
+
if ( $dec_file !== false ) {
|
881 |
+
$dec_file = wfu_path_rel2abs(wfu_flatten_path($dec_file));
|
882 |
+
array_push($dec_files, $dec_file);
|
883 |
+
}
|
884 |
+
}
|
885 |
+
if ( count($dec_files) == 0 ) return;
|
886 |
+
|
887 |
+
$parts = pathinfo($dec_files[0]);
|
888 |
+
$error = "";
|
889 |
+
$regex = "/([^A-Za-z0-9\-._~!$&'()*+,;=:@#\/\\\\%]|%[^A-Fa-f0-9][^A-Fa-f0-9]|%[A-Fa-f0-9][^A-Fa-f0-9]|%[^A-Fa-f0-9][A-Fa-f0-9]|%.?$)/";
|
890 |
+
if ( isset($_POST['wfu_newpath']) && isset($_POST['wfu_replace']) ) {
|
891 |
+
$oldpath = $parts['dirname'];
|
892 |
+
if ( substr($oldpath, -1) != '/' ) $oldpath = $oldpath.'/';
|
893 |
+
$newpath = preg_replace($regex, "", $_POST['wfu_newpath']);
|
894 |
+
if ( substr($newpath, 0, 1) != '/' ) $newpath = '/'.$newpath;
|
895 |
+
$newpath = realpath(wfu_path_rel2abs($newpath));
|
896 |
+
if ( substr($newpath, -1) != '/' ) $newpath = $newpath.'/';
|
897 |
+
$replacefiles = ( $_POST['wfu_replace'] == 'yes' ? 'yes' : ( $_POST['wfu_replace'] == 'no' ? 'no' : '' ) );
|
898 |
+
if ( trim($_POST['wfu_newpath']) == "" ) $error = 'Error: Destination path cannot be empty!';
|
899 |
+
elseif ( $newpath == $oldpath ) $error = 'Error: Destination path is the same as source path!';
|
900 |
+
elseif ( preg_match($regex, $_POST['wfu_newpath']) ) $error = 'Error: path contained invalid characters that were stripped off! Please try again.';
|
901 |
+
elseif ( !wfu_file_exists($newpath, "wfu_move_file:1") ) $error = 'Error: Destination folder <strong>'.$_POST['wfu_newpath'].'</strong> does not exist!';
|
902 |
+
elseif ( $replacefiles == "" ) $error = 'Error: Invalid selection about replacing files with same filename at destination!';
|
903 |
+
else {
|
904 |
+
foreach ( $dec_files as $dec_file ) {
|
905 |
+
if ( wfu_file_exists($dec_file, "wfu_move_file:2") ) {
|
906 |
+
$new_file = $newpath.wfu_basename($dec_file);
|
907 |
+
if ( !wfu_file_exists($new_file, "wfu_move_file:3") || $replacefiles == "yes" ) {
|
908 |
+
//pre-log move action
|
909 |
+
$retid = wfu_log_action('move:'.$new_file, $dec_file, $user->ID, '', 0, 0, '', null);
|
910 |
+
//perform move action
|
911 |
+
if ( @rename($dec_file, $new_file) === false || !wfu_file_exists($new_file, "wfu_move_file:4") ) {
|
912 |
+
wfu_revert_log_action($retid);
|
913 |
+
}
|
914 |
+
}
|
915 |
+
}
|
916 |
+
}
|
917 |
+
}
|
918 |
+
}
|
919 |
+
if ( $error != "" ) {
|
920 |
+
WFU_USVAR_store('wfu_move_file_error', $error);
|
921 |
+
$move_file = WFU_USVAR('wfu_move_file');
|
922 |
+
$move_file['newpath'] = preg_replace($regex, "", $_POST['wfu_newpath']);
|
923 |
+
$move_file['replacefiles'] = $replacefiles;
|
924 |
+
WFU_USVAR_store('wfu_move_file', $move_file);
|
925 |
+
}
|
926 |
+
return ( $error == "" );
|
927 |
+
}
|
928 |
+
|
929 |
+
/**
|
930 |
+
* Confirm Deletion of File.
|
931 |
+
*
|
932 |
+
* This function shows a page to confirm deletion of a file.
|
933 |
+
*
|
934 |
+
* @since 2.2.1
|
935 |
+
*
|
936 |
+
* @param string $file_code A code corresponding to the file/dir to be deleted.
|
937 |
+
* @param string $type Delete dir or file. Can take the values 'dir' or 'file'.
|
938 |
+
* @param string $referer The page that initiated the deletion of the file.
|
939 |
+
*
|
940 |
+
* @return string The HTML code of the confirmation page.
|
941 |
+
*/
|
942 |
+
function wfu_delete_file_prompt($file_code, $type, $referer) {
|
943 |
+
if ( $type == 'dir' ) return;
|
944 |
+
|
945 |
+
$siteurl = site_url();
|
946 |
+
|
947 |
+
$is_admin = current_user_can( 'manage_options' );
|
948 |
+
//check if user is allowed to view file details
|
949 |
+
if ( !$is_admin ) {
|
950 |
+
return;
|
951 |
+
}
|
952 |
+
if ( !is_array($file_code) ) $file_code = array( $file_code );
|
953 |
+
$names = array();
|
954 |
+
foreach ( $file_code as $index => $code ) {
|
955 |
+
$file_code[$index] = wfu_sanitize_code($code);
|
956 |
+
$dec_file = wfu_get_filepath_from_safe($file_code[$index]);
|
957 |
+
if ( $dec_file === false ) unset($file_code[$index]);
|
958 |
+
else {
|
959 |
+
//first extract sort info from dec_file
|
960 |
+
$ret = wfu_extract_sortdata_from_path($dec_file);
|
961 |
+
$dec_file = wfu_path_rel2abs($ret['path']);
|
962 |
+
if ( $type == 'dir' && substr($dec_file, -1) == '/' ) $dec_file = substr($dec_file, 0, -1);
|
963 |
+
//check if user is allowed to perform this action
|
964 |
+
if ( !wfu_current_user_owes_file($dec_file) ) unset($file_code[$index]);
|
965 |
+
else {
|
966 |
+
$parts = pathinfo($dec_file);
|
967 |
+
array_push($names, $parts['basename']);
|
968 |
+
}
|
969 |
+
}
|
970 |
+
}
|
971 |
+
if ( count($file_code) == 0 ) return;
|
972 |
+
$file_code_list = "list:".implode(",", $file_code);
|
973 |
+
|
974 |
+
$referer_url = wfu_get_filepath_from_safe(wfu_sanitize_code($referer));
|
975 |
+
$ret = wfu_extract_sortdata_from_path($referer_url);
|
976 |
+
$referer_url = $ret['path'];
|
977 |
+
|
978 |
+
$echo_str = "\n".'<div class="wrap">';
|
979 |
+
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
980 |
+
if ( $is_admin ) $echo_str .= "\n\t\t".'<a href="'.$referer_url.'" class="button" title="go back">Go back</a>';
|
981 |
+
$echo_str .= "\n\t".'</div>';
|
982 |
+
$echo_str .= "\n\t".'<h2 style="margin-bottom: 10px;">Delete '.( $type == 'dir' ? 'Folder' : 'File'.( count($names) == 1 ? '' : 's' ) ).'</h2>';
|
983 |
+
if ( $is_admin ) $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">';
|
984 |
+
$echo_str .= "\n\t\t".'<input type="hidden" name="action" value="delete'.( $type == 'dir' ? 'dir' : 'file' ).'">';
|
985 |
+
$echo_str .= "\n\t\t".'<input type="hidden" name="referer" value="'.$referer.'">';
|
986 |
+
$echo_str .= "\n\t\t".'<input type="hidden" name="file" value="'.$file_code_list.'">';
|
987 |
+
if ( count($names) == 1 )
|
988 |
+
$echo_str .= "\n\t\t".'<label>Are you sure that you want to delete '.( $type == 'dir' ? 'folder' : 'file' ).' <strong>'.$names[0].'</strong>?</label><br/>';
|
989 |
+
else {
|
990 |
+
$echo_str .= "\n\t\t".'<label>Are you sure that you want to delete '.( $type == 'dir' ? 'folder' : 'files' ).':';
|
991 |
+
$echo_str .= "\n\t\t".'<ul style="padding-left: 20px; list-style: initial;">';
|
992 |
+
foreach ( $names as $name )
|
993 |
+
$echo_str .= "\n\t\t\t".'<li><strong>'.$name.'</strong></li>';
|
994 |
+
$echo_str .= "\n\t\t".'</ul>';
|
995 |
+
}
|
996 |
+
$echo_str .= "\n\t\t".'<p class="submit">';
|
997 |
+
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Delete">';
|
998 |
+
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Cancel">';
|
999 |
+
$echo_str .= "\n\t\t".'</p>';
|
1000 |
+
$echo_str .= "\n\t".'</form>';
|
1001 |
+
$echo_str .= "\n".'</div>';
|
1002 |
+
return $echo_str;
|
1003 |
+
}
|
1004 |
+
|
1005 |
+
/**
|
1006 |
+
* Execute Deletion of File.
|
1007 |
+
*
|
1008 |
+
* This function deletes a file.
|
1009 |
+
*
|
1010 |
+
* @since 2.2.1
|
1011 |
+
*
|
1012 |
+
* @param string $file_code A code corresponding to the file/dir to be deleted.
|
1013 |
+
* @param string $type Delete dir or file. Can take the values 'dir' or 'file'.
|
1014 |
+
*
|
1015 |
+
* @return bool True if deletion of file succeeded, false otherwise.
|
1016 |
+
*/
|
1017 |
+
function wfu_delete_file($file_code, $type) {
|
1018 |
+
if ( $type == 'dir' ) return;
|
1019 |
+
|
1020 |
+
$user = wp_get_current_user();
|
1021 |
+
$is_admin = current_user_can( 'manage_options' );
|
1022 |
+
//check if user is allowed to view file details
|
1023 |
+
if ( !$is_admin ) {
|
1024 |
+
return;
|
1025 |
+
}
|
1026 |
+
if ( !is_array($file_code) ) $file_code = array( $file_code );
|
1027 |
+
$dec_files = array();
|
1028 |
+
foreach ( $file_code as $index => $code ) {
|
1029 |
+
$file_code[$index] = wfu_sanitize_code($code);
|
1030 |
+
$dec_file = wfu_get_filepath_from_safe($file_code[$index]);
|
1031 |
+
if ( $dec_file !== false ) {
|
1032 |
+
$dec_file = wfu_path_rel2abs(wfu_flatten_path($dec_file));
|
1033 |
+
if ( $type == 'dir' && substr($dec_file, -1) == '/' ) $dec_file = substr($dec_file, 0, -1);
|
1034 |
+
//check if user is allowed to perform this action
|
1035 |
+
if ( wfu_current_user_owes_file($dec_file) ) array_push($dec_files, $dec_file);
|
1036 |
+
}
|
1037 |
+
}
|
1038 |
+
if ( count($dec_files) == 0 ) return;
|
1039 |
+
|
1040 |
+
if ( isset($_POST['submit']) ) {
|
1041 |
+
if ( $_POST['submit'] == "Delete" ) {
|
1042 |
+
foreach ( $dec_files as $dec_file ) {
|
1043 |
+
//pre-log delete action
|
1044 |
+
if ( $type == 'file' ) wfu_delete_file_execute($dec_file, $user->ID);
|
1045 |
+
elseif ( $type == 'dir' && $dec_file != "" ) wfu_delTree($dec_file);
|
1046 |
+
}
|
1047 |
+
}
|
1048 |
+
}
|
1049 |
+
return true;
|
1050 |
+
}
|
1051 |
+
|
1052 |
+
/**
|
1053 |
+
* Confirm Creation of a Directory.
|
1054 |
+
*
|
1055 |
+
* This function shows a page to confirm creation of a directory.
|
1056 |
+
*
|
1057 |
+
* @since 2.2.1
|
1058 |
+
*
|
1059 |
+
* @param string $dir_code A code corresponding to the dir to be created.
|
1060 |
+
* @param string $error An error message to show on top of the page in case an
|
1061 |
+
* error occured during creation.
|
1062 |
+
*
|
1063 |
+
* @return string The HTML code of the confirmation page.
|
1064 |
+
*/
|
1065 |
+
function wfu_create_dir_prompt($dir_code, $error) {
|
1066 |
+
return;
|
1067 |
+
|
1068 |
+
$siteurl = site_url();
|
1069 |
+
|
1070 |
+
if ( !current_user_can( 'manage_options' ) ) return;
|
1071 |
+
|
1072 |
+
$dir_code = wfu_sanitize_code($dir_code);
|
1073 |
+
$dec_dir = wfu_get_filepath_from_safe($dir_code);
|
1074 |
+
if ( $dec_dir === false ) return;
|
1075 |
+
|
1076 |
+
//first extract sort info from dec_dir
|
1077 |
+
$ret = wfu_extract_sortdata_from_path($dec_dir);
|
1078 |
+
$dec_dir = wfu_path_rel2abs($ret['path']);
|
1079 |
+
if ( substr($dec_dir, -1) != '/' ) $dec_dir .= '/';
|
1080 |
+
$newname = '';
|
1081 |
+
|
1082 |
+
$echo_str = "\n".'<div class="wrap">';
|
1083 |
+
if ( $error ) {
|
1084 |
+
$create_dir = WFU_USVAR('wfu_create_dir');
|
1085 |
+
$newname = $create_dir['newname'];
|
1086 |
+
$echo_str .= "\n\t".'<div class="error">';
|
1087 |
+
$echo_str .= "\n\t\t".'<p>'.WFU_USVAR('wfu_create_dir_error').'</p>';
|
1088 |
+
$echo_str .= "\n\t".'</div>';
|
1089 |
+
}
|
1090 |
+
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
1091 |
+
$echo_str .= "\n\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$dir_code.'" class="button" title="go back">Go back</a>';
|
1092 |
+
$echo_str .= "\n\t".'</div>';
|
1093 |
+
$echo_str .= "\n\t".'<h2 style="margin-bottom: 10px;">Create Folder</h2>';
|
1094 |
+
$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">';
|
1095 |
+
$echo_str .= "\n\t\t".'<input type="hidden" name="action" value="createdir">';
|
1096 |
+
$echo_str .= "\n\t\t".'<input type="hidden" name="dir" value="'.$dir_code.'">';
|
1097 |
+
$echo_str .= "\n\t\t".'<label>Enter the name of the new folder inside <strong>'.$dec_dir.'</strong></label><br/>';
|
1098 |
+
$echo_str .= "\n\t\t".'<input name="wfu_newname" id="wfu_newname" type="text" value="'.$newname.'" style="width:50%;" />';
|
1099 |
+
$echo_str .= "\n\t\t".'<p class="submit">';
|
1100 |
+
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Create">';
|
1101 |
+
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Cancel">';
|
1102 |
+
$echo_str .= "\n\t\t".'</p>';
|
1103 |
+
$echo_str .= "\n\t".'</form>';
|
1104 |
+
$echo_str .= "\n".'</div>';
|
1105 |
+
return $echo_str;
|
1106 |
+
}
|
1107 |
+
|
1108 |
+
/**
|
1109 |
+
* Execute Creation of Directory.
|
1110 |
+
*
|
1111 |
+
* This function creates a new directory.
|
1112 |
+
*
|
1113 |
+
* @since 2.2.1
|
1114 |
+
*
|
1115 |
+
* @param string $dir_code A code corresponding to the dir to be created.
|
1116 |
+
*
|
1117 |
+
* @return bool True if creation of dir succeeded, false otherwise.
|
1118 |
+
*/
|
1119 |
+
function wfu_create_dir($dir_code) {
|
1120 |
+
return;
|
1121 |
+
|
1122 |
+
if ( !current_user_can( 'manage_options' ) ) return;
|
1123 |
+
|
1124 |
+
$dir_code = wfu_sanitize_code($dir_code);
|
1125 |
+
$dec_dir = wfu_get_filepath_from_safe($dir_code);
|
1126 |
+
if ( $dec_dir === false ) return;
|
1127 |
+
|
1128 |
+
$dec_dir = wfu_path_rel2abs(wfu_flatten_path($dec_dir));
|
1129 |
+
if ( substr($dec_dir, -1) != '/' ) $dec_dir .= '/';
|
1130 |
+
if ( !wfu_file_exists($dec_dir, "wfu_create_dir:1") ) return;
|
1131 |
+
$error = "";
|
1132 |
+
if ( isset($_POST['wfu_newname']) && isset($_POST['submit']) ) {
|
1133 |
+
if ( $_POST['submit'] == "Create" ) {
|
1134 |
+
$new_dir = $dec_dir.$_POST['wfu_newname'];
|
1135 |
+
if ( $_POST['wfu_newname'] == "" ) $error = 'Error: New folder name cannot be empty!';
|
1136 |
+
elseif ( preg_match("/[^A-Za-z0-9_.#\-$]/", $_POST['wfu_newname']) ) $error = 'Error: name contained invalid characters that were stripped off! Please try again.';
|
1137 |
+
elseif ( wfu_file_exists($new_dir, "wfu_create_dir:2") ) $error = 'Error: The folder <strong>'.$_POST['wfu_newname'].'</strong> already exists! Please choose another one.';
|
1138 |
+
elseif ( mkdir($new_dir) == false ) $error = 'Error: Creation of folder <strong>'.$_POST['wfu_newname'].'</strong> failed!';
|
1139 |
+
}
|
1140 |
+
}
|
1141 |
+
if ( $error != "" ) {
|
1142 |
+
WFU_USVAR_store('wfu_create_dir_error', $error);
|
1143 |
+
$create_dir = WFU_USVAR('wfu_create_dir');
|
1144 |
+
$create_dir['newname'] = preg_replace("/[^A-Za-z0-9_.#\-$]/", "", $_POST['wfu_newname']);
|
1145 |
+
WFU_USVAR_store('wfu_create_dir', $create_dir);
|
1146 |
+
}
|
1147 |
+
return ( $error == "" );
|
1148 |
+
}
|
1149 |
+
|
1150 |
+
/**
|
1151 |
+
* Confirm Inclusion of File in Plugin's Database.
|
1152 |
+
*
|
1153 |
+
* This function shows a page to confirm inclusion of a file in plugin's
|
1154 |
+
* database.
|
1155 |
+
*
|
1156 |
+
* @since 3.8.5
|
1157 |
+
*
|
1158 |
+
* @param string $file_code A code corresponding to the file to be included.
|
1159 |
+
* @param string $type Rename dir or file. Can take the values 'dir' or 'file'.
|
1160 |
+
* @param string $referer The page that initiated the inclusion of the file.
|
1161 |
+
*
|
1162 |
+
* @return string The HTML code of the confirmation page.
|
1163 |
+
*/
|
1164 |
+
function wfu_include_file_prompt($file_code, $referer) {
|
1165 |
+
if ( !current_user_can( 'manage_options' ) ) return;
|
1166 |
+
$plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
|
1167 |
+
if ( $plugin_options['includeotherfiles'] != "1" ) return;
|
1168 |
+
|
1169 |
+
$siteurl = site_url();
|
1170 |
+
if ( !is_array($file_code) ) $file_code = array( $file_code );
|
1171 |
+
$names = array();
|
1172 |
+
foreach ( $file_code as $index => $code ) {
|
1173 |
+
$file_code[$index] = wfu_sanitize_code($code);
|
1174 |
+
$dec_file = wfu_get_filepath_from_safe($file_code[$index]);
|
1175 |
+
if ( $dec_file === false ) unset($file_code[$index]);
|
1176 |
+
else {
|
1177 |
+
$dec_file = wfu_path_rel2abs(wfu_flatten_path($dec_file));
|
1178 |
+
//do not include file if it has a forbidden extention or it is already included
|
1179 |
+
if ( wfu_file_extension_blacklisted(wfu_basename($dec_file)) || wfu_get_file_rec($dec_file, false) != null )
|
1180 |
+
unset($file_code[$index]);
|
1181 |
+
else array_push($names, wfu_basename($dec_file));
|
1182 |
+
}
|
1183 |
+
}
|
1184 |
+
if ( count($file_code) == 0 ) return;
|
1185 |
+
$file_code_list = "list:".implode(",", $file_code);
|
1186 |
+
|
1187 |
+
$referer_url = wfu_get_filepath_from_safe(wfu_sanitize_code($referer));
|
1188 |
+
$ret = wfu_extract_sortdata_from_path($referer_url);
|
1189 |
+
$referer_url = $ret['path'];
|
1190 |
+
|
1191 |
+
$echo_str = "\n".'<div class="wrap">';
|
1192 |
+
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
1193 |
+
$echo_str .= "\n\t\t".'<a href="'.$referer_url.'" class="button" title="go back">Go back</a>';
|
1194 |
+
$echo_str .= "\n\t".'</div>';
|
1195 |
+
$echo_str .= "\n\t".'<h2 style="margin-bottom: 10px;">Include File'.( count($names) == 1 ? '' : 's' ).'</h2>';
|
1196 |
+
$echo_str .= "\n\t".'<form enctype="multipart/form-data" name="includefile" id="includefile" method="post" action="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload" class="validate">';
|
1197 |
+
$echo_str .= "\n\t\t".'<input type="hidden" name="action" value="includefile">';
|
1198 |
+
$echo_str .= "\n\t\t".'<input type="hidden" name="referer" value="'.$referer.'">';
|
1199 |
+
$echo_str .= "\n\t\t".'<input type="hidden" name="file" value="'.$file_code_list.'">';
|
1200 |
+
if ( count($names) == 1 )
|
1201 |
+
$echo_str .= "\n\t\t".'<label>Are you sure that you want to include file <strong>'.$names[0].'</strong>?</label><br/>';
|
1202 |
+
else {
|
1203 |
+
$echo_str .= "\n\t\t".'<label>Are you sure that you want to include files:';
|
1204 |
+
$echo_str .= "\n\t\t".'<ul style="padding-left: 20px; list-style: initial;">';
|
1205 |
+
foreach ( $names as $name )
|
1206 |
+
$echo_str .= "\n\t\t\t".'<li><strong>'.$name.'</strong></li>';
|
1207 |
+
$echo_str .= "\n\t\t".'</ul>';
|
1208 |
+
}
|
1209 |
+
$echo_str .= "\n\t\t".'<p class="submit">';
|
1210 |
+
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Include">';
|
1211 |
+
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Cancel">';
|
1212 |
+
$echo_str .= "\n\t\t".'</p>';
|
1213 |
+
$echo_str .= "\n\t".'</form>';
|
1214 |
+
$echo_str .= "\n".'</div>';
|
1215 |
+
return $echo_str;
|
1216 |
+
}
|
1217 |
+
|
1218 |
+
/**
|
1219 |
+
* Execute Inclusion of File in Plugin's Database.
|
1220 |
+
*
|
1221 |
+
* This function includes a file in plugin's database.
|
1222 |
+
*
|
1223 |
+
* @since 3.8.5
|
1224 |
+
*
|
1225 |
+
* @param string $file_code A code corresponding to the file to be included.
|
1226 |
+
*
|
1227 |
+
* @return bool True if inclusion of file succeeded, false otherwise.
|
1228 |
+
*/
|
1229 |
+
function wfu_include_file($file_code) {
|
1230 |
+
if ( !current_user_can( 'manage_options' ) ) return;
|
1231 |
+
$plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
|
1232 |
+
if ( $plugin_options['includeotherfiles'] != "1" ) return;
|
1233 |
+
|
1234 |
+
if ( !is_array($file_code) ) $file_code = array( $file_code );
|
1235 |
+
$dec_files = array();
|
1236 |
+
foreach ( $file_code as $index => $code ) {
|
1237 |
+
$file_code[$index] = wfu_sanitize_code($code);
|
1238 |
+
$dec_file = wfu_get_filepath_from_safe($file_code[$index]);
|
1239 |
+
if ( $dec_file !== false ) {
|
1240 |
+
$dec_file = wfu_path_rel2abs(wfu_flatten_path($dec_file));
|
1241 |
+
//include file if it does not have a forbidden extention and it not already included
|
1242 |
+
if ( !wfu_file_extension_blacklisted(wfu_basename($dec_file)) && wfu_get_file_rec($dec_file, false) == null )
|
1243 |
+
array_push($dec_files, $dec_file);
|
1244 |
+
}
|
1245 |
+
}
|
1246 |
+
if ( count($dec_files) == 0 ) return;
|
1247 |
+
|
1248 |
+
$user = wp_get_current_user();
|
1249 |
+
if ( isset($_POST['submit']) ) {
|
1250 |
+
if ( $_POST['submit'] == "Include" ) {
|
1251 |
+
foreach ( $dec_files as $dec_file )
|
1252 |
+
$fileid = wfu_log_action('include', $dec_file, $user->ID, '', '', get_current_blog_id(), '', null);
|
1253 |
+
}
|
1254 |
+
}
|
1255 |
+
return true;
|
1256 |
+
}
|
1257 |
+
|
1258 |
+
/**
|
1259 |
+
* Show File Details Page.
|
1260 |
+
*
|
1261 |
+
* This function shows a page displaying details of the uploaded file.
|
1262 |
+
*
|
1263 |
+
* @since 2.4.1
|
1264 |
+
*
|
1265 |
+
* @param string $file_code A code corresponding to the file to be included.
|
1266 |
+
* @param string $errorstatus Error status. If it has the value 'error' then an
|
1267 |
+
* error will be shown on top of the page.
|
1268 |
+
* @param string $invoker Optional. The page URL that initiated file details
|
1269 |
+
* page.
|
1270 |
+
*
|
1271 |
+
* @return string The HTML code of File Details page.
|
1272 |
+
*/
|
1273 |
+
function wfu_file_details($file_code, $errorstatus, $invoker = '') {
|
1274 |
+
$siteurl = site_url();
|
1275 |
+
$allow_obsolete = false;
|
1276 |
+
$file_exists = true;
|
1277 |
+
$file_belongs = true;
|
1278 |
+
$admin_can_edit = true;
|
1279 |
+
|
1280 |
+
//if $file_code starts with 'byID:', then it contains a db record ID and not
|
1281 |
+
//a file path; in this case we show the properties of the specific record
|
1282 |
+
//and all linked ones, even if it is obsolete; this is only allowed for
|
1283 |
+
//admins
|
1284 |
+
if ( substr($file_code, 0, 5) == "byID:" ) {
|
1285 |
+
$allow_obsolete = true;
|
1286 |
+
$file_code = substr($file_code, 5);
|
1287 |
+
}
|
1288 |
+
|
1289 |
+
$user = wp_get_current_user();
|
1290 |
+
$is_admin = current_user_can( 'manage_options' );
|
1291 |
+
//check if user is allowed to view file details
|
1292 |
+
if ( !$is_admin ) {
|
1293 |
+
if ( $allow_obsolete ) return;
|
1294 |
+
return;
|
1295 |
+
}
|
1296 |
+
if ( $allow_obsolete ) {
|
1297 |
+
$file_code = wfu_sanitize_int($file_code);
|
1298 |
+
$initialrec = wfu_get_file_rec_from_id($file_code, true);
|
1299 |
+
if ( $initialrec == null ) return;
|
1300 |
+
|
1301 |
+
//get all associated file records
|
1302 |
+
$filerecs = wfu_get_rec_new_history($initialrec->idlog);
|
1303 |
+
//get the latest record of this upload
|
1304 |
+
$filerec = $filerecs[count($filerecs) - 1];
|
1305 |
+
$filerec->userdata = $initialrec->userdata;
|
1306 |
+
|
1307 |
+
$filepath = wfu_path_rel2abs($filerec->filepath);
|
1308 |
+
//in the case of $allow_obsolete we need to check if the file exists and
|
1309 |
+
//if it belongs to the current record
|
1310 |
+
$latestrec = wfu_get_file_rec($filepath, true);
|
1311 |
+
$file_exists = ( $latestrec != null );
|
1312 |
+
$file_belongs = ( $file_exists && $latestrec->idlog == $filerec->idlog );
|
1313 |
+
$admin_can_edit = $file_exists;
|
1314 |
+
|
1315 |
+
//extract file parts and file properties
|
1316 |
+
$parts = pathinfo($filepath);
|
1317 |
+
if ( $file_exists ) $stat = wfu_stat($filepath, "wfu_file_details:1");
|
1318 |
+
else $stat['mtime'] = '';
|
1319 |
+
}
|
1320 |
+
else {
|
1321 |
+
$file_code = wfu_sanitize_code($file_code);
|
1322 |
+
$dec_file = wfu_get_filepath_from_safe($file_code);
|
1323 |
+
if ( $dec_file === false ) return;
|
1324 |
+
|
1325 |
+
//extract file browser data from $file variable
|
1326 |
+
$ret = wfu_extract_sortdata_from_path($dec_file);
|
1327 |
+
$filepath = wfu_path_rel2abs($ret['path']);
|
1328 |
+
|
1329 |
+
//check if user is allowed to perform this action
|
1330 |
+
if ( !wfu_current_user_owes_file($filepath) ) return;
|
1331 |
+
|
1332 |
+
//get file data from database with user data
|
1333 |
+
$filerec = wfu_get_file_rec($filepath, true);
|
1334 |
+
if ( $filerec == null ) return;
|
1335 |
+
|
1336 |
+
//extract sort info and construct contained dir
|
1337 |
+
$parts = pathinfo($filepath);
|
1338 |
+
$dir_code = wfu_safe_store_filepath(wfu_path_abs2rel($parts['dirname']).'[['.$ret['sort'].']]');
|
1339 |
+
|
1340 |
+
$stat = wfu_stat($filepath, "wfu_file_details:2");
|
1341 |
+
}
|
1342 |
+
|
1343 |
+
$echo_str = '<div class="regev_wrap">';
|
1344 |
+
if ( $errorstatus == 'error' ) {
|
1345 |
+
$echo_str .= "\n\t".'<div class="error">';
|
1346 |
+
$echo_str .= "\n\t\t".'<p>'.WFU_USVAR('wfu_filedetails_error').'</p>';
|
1347 |
+
$echo_str .= "\n\t".'</div>';
|
1348 |
+
}
|
1349 |
+
//show file details
|
1350 |
+
$echo_str .= "\n\t".'<h2>Details of File: '.$parts['basename'].'</h2>';
|
1351 |
+
if ( !$file_exists ) {
|
1352 |
+
$echo_str .= "\n\t\t".'<div class="notice notice-warning">';
|
1353 |
+
$echo_str .= "\n\t\t\t".'<p>File does not exist on the server anymore!</p>';
|
1354 |
+
$echo_str .= "\n\t\t".'</div>';
|
1355 |
+
}
|
1356 |
+
elseif ( !$file_belongs ) {
|
1357 |
+
$echo_str .= "\n\t\t".'<div class="notice notice-warning">';
|
1358 |
+
$echo_str .= "\n\t\t\t".'<p>This record is old. The file is associated with another record.</p>';
|
1359 |
+
$echo_str .= "\n\t\t".'</div>';
|
1360 |
+
}
|
1361 |
+
$echo_str .= "\n\t".'<div style="margin-top:10px;">';
|
1362 |
+
if ( $is_admin ) {
|
1363 |
+
$invoker_action = ( $invoker == '' ? false : wfu_get_browser_params_from_safe($invoker) );
|
1364 |
+
$goback_action = ( $invoker_action === false ? 'file_browser&dir='.$dir_code : $invoker_action );
|
1365 |
+
if ( substr($goback_action, 0, 18) == "wfu_uploaded_files" )
|
1366 |
+
$echo_str .= "\n\t\t".'<a href="'.$siteurl.'/wp-admin/admin.php?page='.$goback_action.'" class="button" title="go back">Go back</a>';
|
1367 |
+
elseif ( $goback_action != "no_referer" )
|
1368 |
+
$echo_str .= "\n\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action='.$goback_action.'" class="button" title="go back">Go back</a>';
|
1369 |
+
$echo_str .= "\n\t\t".'<form enctype="multipart/form-data" name="editfiledetails" id="editfiledetails" method="post" action="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=edit_filedetails" class="validate">';
|
1370 |
+
}
|
1371 |
+
$echo_str .= "\n\t\t\t".'<h3 style="margin-bottom: 10px; margin-top: 40px;">Upload Details</h3>';
|
1372 |
+
$echo_str .= "\n\t\t\t".'<input type="hidden" name="action" value="edit_filedetails" />';
|
1373 |
+
//$echo_str .= "\n\t\t\t".'<input type="hidden" name="dir" value="'.$dir_code.'">';
|
1374 |
+
$echo_str .= "\n\t\t\t".'<input type="hidden" name="invoker" value="'.$invoker.'">';
|
1375 |
+
$echo_str .= "\n\t\t\t".'<input type="hidden" name="file" value="'.( $allow_obsolete ? 'byID:'.$file_code : $file_code ).'">';
|
1376 |
+
$echo_str .= "\n\t\t\t".'<table class="form-table">';
|
1377 |
+
$echo_str .= "\n\t\t\t\t".'<tbody>';
|
1378 |
+
if ( $is_admin ) {
|
1379 |
+
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
1380 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
1381 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<label>Full Path</label>';
|
1382 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
1383 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
1384 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<input type="text" value="'.$filepath.'" readonly="readonly" style="width:50%;" />';
|
1385 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
1386 |
+
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
1387 |
+
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
1388 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
1389 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<label>Uploaded By User</label>';
|
1390 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
1391 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
1392 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<select id="wfu_filedetails_users" disabled="disabled">';
|
1393 |
+
//get all users
|
1394 |
+
$args = array();
|
1395 |
+
/**
|
1396 |
+
* Filter Arguments for Getting List of Users.
|
1397 |
+
*
|
1398 |
+
* This filter allows to customize the arguments passed to get_users()
|
1399 |
+
* function to get a list of users. By default the plugin will get a
|
1400 |
+
* list of all users. If the website contains too many users this
|
1401 |
+
* operation may take time and delay loading of the page. So this filter
|
1402 |
+
* can be used to optimize this operation.
|
1403 |
+
*
|
1404 |
+
* @since 4.11.0
|
1405 |
+
*
|
1406 |
+
* @param array $args Arguments to retrieve users.
|
1407 |
+
* @param string $operation A parameter designating in which operation
|
1408 |
+
* the filter is used.
|
1409 |
+
*/
|
1410 |
+
$args = apply_filters("_wfu_get_users", $args, "edit_file_details");
|
1411 |
+
$users = get_users($args);
|
1412 |
+
foreach ( $users as $userid => $user )
|
1413 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<option value="'.$user->ID.'"'.( $filerec->uploaduserid == $user->ID ? ' selected="selected"' : '' ).'>'.$user->display_name.' ('.$user->user_login.')</option>';
|
1414 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'</select>';
|
1415 |
+
if ( $admin_can_edit ) {
|
1416 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<a class="button" id="btn_change" href="" onclick="document.getElementById(\'wfu_filedetails_users\').disabled = false; this.style.display = \'none\'; document.getElementById(\'btn_ok\').style.display = \'inline-block\'; document.getElementById(\'btn_cancel\').style.display = \'inline-block\'; return false;"'.( $is_admin ? '' : ' style="display:none;"' ).'>Change User</a>';
|
1417 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<a class="button" id="btn_ok" href="" onclick="document.getElementById(\'wfu_filedetails_users\').disabled = true; document.getElementById(\'btn_change\').style.display = \'inline-block\'; this.style.display=\'none\'; document.getElementById(\'btn_cancel\').style.display = \'none\'; document.getElementById(\'wfu_filedetails_userid\').value = document.getElementById(\'wfu_filedetails_users\').value; wfu_filedetails_changed(); return false;" style="display:none;">Ok</a>';
|
1418 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<a class="button" id="btn_cancel" href="" onclick="document.getElementById(\'wfu_filedetails_users\').disabled = true; document.getElementById(\'btn_change\').style.display = \'inline-block\'; this.style.display=\'none\'; document.getElementById(\'btn_ok\').style.display = \'none\'; document.getElementById(\'wfu_filedetails_users\').value = document.getElementById(\'wfu_filedetails_userid\').value; return false;" style="display:none;">Cancel</a>';
|
1419 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<input type="hidden" id="wfu_filedetails_userid" name="wfu_filedetails_userid" value="'.$filerec->uploaduserid.'" />';
|
1420 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<input type="hidden" id="wfu_filedetails_userid_default" value="'.$filerec->uploaduserid.'" />';
|
1421 |
+
}
|
1422 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
1423 |
+
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
1424 |
+
}
|
1425 |
+
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
1426 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
1427 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<label>File Size</label>';
|
1428 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
1429 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
1430 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<input type="text" value="'.$filerec->filesize.'" readonly="readonly" style="width:auto;" />';
|
1431 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
1432 |
+
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
1433 |
+
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
1434 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
1435 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<label>File Date</label>';
|
1436 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
1437 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
1438 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<input type="text" value="'.( $file_exists ? get_date_from_gmt(date("Y-m-d H:i:s", $stat['mtime']), "d/m/Y H:i:s") : '' ).'" readonly="readonly" style="width:auto;" />';
|
1439 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
1440 |
+
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
1441 |
+
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
1442 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
1443 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<label>Uploaded From Page</label>';
|
1444 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
1445 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
1446 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<input type="text" value="'.get_the_title($filerec->pageid).' ('.$filerec->pageid.')'.'" readonly="readonly" style="width:50%;" />';
|
1447 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
1448 |
+
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
1449 |
+
if ( $is_admin ) {
|
1450 |
+
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
1451 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
1452 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<label>Upload Plugin ID</label>';
|
1453 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
1454 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
1455 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<input type="text" value="'.$filerec->sid.'" readonly="readonly" style="width:auto;" />';
|
1456 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
1457 |
+
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
1458 |
+
}
|
1459 |
+
$echo_str .= "\n\t\t\t\t".'</tbody>';
|
1460 |
+
$echo_str .= "\n\t\t\t".'</table>';
|
1461 |
+
if ( $is_admin ) {
|
1462 |
+
//show history details
|
1463 |
+
$echo_str .= "\n\t\t\t".'<h3 style="margin-bottom: 10px; margin-top: 40px;">File History</h3>';
|
1464 |
+
$echo_str .= "\n\t\t\t".'<table class="form-table">';
|
1465 |
+
$echo_str .= "\n\t\t\t\t".'<tbody>';
|
1466 |
+
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
1467 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
1468 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<label></label>';
|
1469 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
1470 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
1471 |
+
//read all linked older records
|
1472 |
+
$filerecs = wfu_get_rec_old_history($filerec->idlog);
|
1473 |
+
//construct report from db records
|
1474 |
+
$rep = '';
|
1475 |
+
foreach ( $filerecs as $rec ) {
|
1476 |
+
$username = wfu_get_username_by_id($rec->userid);
|
1477 |
+
$fileparts = pathinfo($rec->filepath);
|
1478 |
+
if ( $rep != '' ) $rep .= "<br />";
|
1479 |
+
$rep .= '<strong>['.get_date_from_gmt($rec->date_from).']</strong> ';
|
1480 |
+
if ( $rec->action == 'upload' )
|
1481 |
+
$rep .= 'File uploaded at <strong>'.$fileparts['dirname'].'</strong> with name <strong>'.$fileparts['basename'].'</strong> by user <strong>'.$username.'</strong>';
|
1482 |
+
elseif ( $rec->action == 'include' )
|
1483 |
+
$rep .= 'File included in database at <strong>'.$fileparts['dirname'].'</strong> with name <strong>'.$fileparts['basename'].'</strong> by user <strong>'.$username.'</strong>';
|
1484 |
+
elseif ( $rec->action == 'download' )
|
1485 |
+
$rep .= 'File downloaded by user <strong>'.$username.'</strong>';
|
1486 |
+
elseif ( $rec->action == 'rename' )
|
1487 |
+
$rep .= 'File renamed to <strong>'.$fileparts['basename'].'</strong> by user <strong>'.$username.'</strong>';
|
1488 |
+
elseif ( $rec->action == 'move' )
|
1489 |
+
$rep .= 'File moved to <strong>'.$fileparts['dirname'].'</strong> by user <strong>'.$username.'</strong>';
|
1490 |
+
elseif ( $rec->action == 'delete' )
|
1491 |
+
$rep .= 'File deleted by user <strong>'.$username.'</strong>';
|
1492 |
+
elseif ( $rec->action == 'modify' )
|
1493 |
+
$rep .= 'File userdata modified by user <strong>'.$username.'</strong>';
|
1494 |
+
elseif ( $rec->action == 'changeuser' )
|
1495 |
+
$rep .= 'File upload user modified by user <strong>'.$username.'</strong>';
|
1496 |
+
}
|
1497 |
+
$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;">';
|
1498 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<span style="white-space:nowrap;">'.$rep.'</span>';
|
1499 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'</div>';
|
1500 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
1501 |
+
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
1502 |
+
$echo_str .= "\n\t\t\t\t".'</tbody>';
|
1503 |
+
$echo_str .= "\n\t\t\t".'</table>';
|
1504 |
+
}
|
1505 |
+
|
1506 |
+
$echo_str .= "\n\t\t\t".'<h3 style="margin-bottom: 10px; margin-top: 40px;">User Data Details</h3>';
|
1507 |
+
$echo_str .= "\n\t\t\t".'<table class="form-table">';
|
1508 |
+
$echo_str .= "\n\t\t\t\t".'<tbody>';
|
1509 |
+
if ( is_array($filerec->userdata) && count($filerec->userdata) > 0 ) {
|
1510 |
+
foreach ( $filerec->userdata as $userdata ) {
|
1511 |
+
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
1512 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
1513 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<label>'.$userdata->property.'</label>';
|
1514 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
1515 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
1516 |
+
// $echo_str .= "\n\t\t\t\t\t\t\t".'<input id="wfu_filedetails_userdata_value_'.$userdata->propkey.'" name="wfu_filedetails_userdata" type="text"'.( $is_admin ? '' : ' readonly="readonly"' ).' value="'.$userdata->propvalue.'" />';
|
1517 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<textarea id="wfu_filedetails_userdata_value_'.$userdata->propkey.'" name="wfu_filedetails_userdata" '.( ($is_admin && $admin_can_edit) ? '' : ' readonly="readonly"' ).' value="'.$userdata->propvalue.'">'.$userdata->propvalue.'</textarea>';
|
1518 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<input id="wfu_filedetails_userdata_default_'.$userdata->propkey.'" type="hidden" value="'.$userdata->propvalue.'" />';
|
1519 |
+
$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.'" />';
|
1520 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
1521 |
+
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
1522 |
+
}
|
1523 |
+
}
|
1524 |
+
else {
|
1525 |
+
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
1526 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
1527 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<label>No user data</label>';
|
1528 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
1529 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<td></td>';
|
1530 |
+
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
1531 |
+
}
|
1532 |
+
$echo_str .= "\n\t\t\t\t".'</tbody>';
|
1533 |
+
$echo_str .= "\n\t\t\t".'</table>';
|
1534 |
+
if ( ($is_admin && $admin_can_edit) ) {
|
1535 |
+
$echo_str .= "\n\t\t\t".'<p class="submit">';
|
1536 |
+
$echo_str .= "\n\t\t\t\t".'<input id="dp_filedetails_submit_fields" type="submit" class="button-primary" name="submit" value="Update" disabled="disabled" />';
|
1537 |
+
$echo_str .= "\n\t\t\t".'</p>';
|
1538 |
+
}
|
1539 |
+
$echo_str .= "\n\t\t".'</form>';
|
1540 |
+
$echo_str .= "\n\t".'</div>';
|
1541 |
+
$handler = 'function() { wfu_Attach_FileDetails_Admin_Events(); }';
|
1542 |
+
$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>';
|
1543 |
+
$echo_str .= '</div>';
|
1544 |
+
|
1545 |
+
return $echo_str;
|
1546 |
+
}
|
1547 |
+
|
1548 |
+
/**
|
1549 |
+
* Change File Details.
|
1550 |
+
*
|
1551 |
+
* This function modifies the database record of an uploaded file, as well as
|
1552 |
+
* any associated user data field records.
|
1553 |
+
*
|
1554 |
+
* @since 2.4.1
|
1555 |
+
*
|
1556 |
+
* @param string $file_code A code corresponding to the file to be modified.
|
1557 |
+
*
|
1558 |
+
* @return bool True if modification of file succeeded, false otherwise.
|
1559 |
+
*/
|
1560 |
+
function wfu_edit_filedetails($file_code) {
|
1561 |
+
global $wpdb;
|
1562 |
+
$table_name2 = $wpdb->prefix . "wfu_userdata";
|
1563 |
+
$allow_obsolete = false;
|
1564 |
+
|
1565 |
+
if ( substr($file_code, 0, 5) == "byID:" ) {
|
1566 |
+
$allow_obsolete = true;
|
1567 |
+
$file_code = substr($file_code, 5);
|
1568 |
+
}
|
1569 |
+
|
1570 |
+
$user = wp_get_current_user();
|
1571 |
+
$is_admin = current_user_can( 'manage_options' );
|
1572 |
+
//check if user is allowed to view file details
|
1573 |
+
if ( !$is_admin ) {
|
1574 |
+
if ( $allow_obsolete ) return;
|
1575 |
+
return;
|
1576 |
+
}
|
1577 |
+
if ( $allow_obsolete ) {
|
1578 |
+
$file_code = wfu_sanitize_int($file_code);
|
1579 |
+
$initialrec = wfu_get_file_rec_from_id($file_code, true);
|
1580 |
+
if ( $initialrec == null ) return;
|
1581 |
+
|
1582 |
+
//get all associated file records
|
1583 |
+
$filerecs = wfu_get_rec_new_history($initialrec->idlog);
|
1584 |
+
//get the latest record of this upload
|
1585 |
+
$filerec = $filerecs[count($filerecs) - 1];
|
1586 |
+
$filerec->userdata = $initialrec->userdata;
|
1587 |
+
|
1588 |
+
$filepath = wfu_path_rel2abs($filerec->filepath);
|
1589 |
+
$latestrec = wfu_get_file_rec($filepath, true);
|
1590 |
+
//if $latestrec is null then this means that file does not exist
|
1591 |
+
if ( $latestrec == null ) return;
|
1592 |
+
//if the record is obsolete then do not proceed
|
1593 |
+
if ( $latestrec->idlog != $filerec->idlog ) return;
|
1594 |
+
}
|
1595 |
+
else {
|
1596 |
+
$file_code = wfu_sanitize_code($file_code);
|
1597 |
+
$dec_file = wfu_get_filepath_from_safe($file_code);
|
1598 |
+
if ( $dec_file === false ) return;
|
1599 |
+
|
1600 |
+
$filepath = wfu_path_rel2abs(wfu_flatten_path($dec_file));
|
1601 |
+
|
1602 |
+
//check if user is allowed to perform this action
|
1603 |
+
if ( !wfu_current_user_owes_file($filepath) ) return;
|
1604 |
+
|
1605 |
+
//get file data from database with user data
|
1606 |
+
$filerec = wfu_get_file_rec($filepath, true);
|
1607 |
+
if ( $filerec == null ) return;
|
1608 |
+
}
|
1609 |
+
|
1610 |
+
if ( isset($_POST['submit']) ) {
|
1611 |
+
if ( $_POST['submit'] == "Update" ) {
|
1612 |
+
if ( !is_array($filerec->userdata) ) $filerec->userdata = array();
|
1613 |
+
//check for errors
|
1614 |
+
$is_error = false;
|
1615 |
+
foreach ( $filerec->userdata as $userdata ) {
|
1616 |
+
if ( !isset($_POST['wfu_filedetails_userdata_'.$userdata->propkey]) ) {
|
1617 |
+
$is_error = true;
|
1618 |
+
break;
|
1619 |
+
}
|
1620 |
+
}
|
1621 |
+
if ( !$is_error ) {
|
1622 |
+
$now_date = date('Y-m-d H:i:s');
|
1623 |
+
$userdata_count = 0;
|
1624 |
+
foreach ( $filerec->userdata as $userdata ) {
|
1625 |
+
$userdata_count ++;
|
1626 |
+
//make existing userdata record obsolete
|
1627 |
+
$wpdb->update($table_name2,
|
1628 |
+
array( 'date_to' => $now_date ),
|
1629 |
+
array( 'uploadid' => $userdata->uploadid, 'propkey' => $userdata->propkey ),
|
1630 |
+
array( '%s' ),
|
1631 |
+
array( '%s', '%s' )
|
1632 |
+
);
|
1633 |
+
//insert new userdata record
|
1634 |
+
$wpdb->insert($table_name2,
|
1635 |
+
array(
|
1636 |
+
'uploadid' => $userdata->uploadid,
|
1637 |
+
'property' => $userdata->property,
|
1638 |
+
'propkey' => $userdata->propkey,
|
1639 |
+
'propvalue' => $_POST['wfu_filedetails_userdata_'.$userdata->propkey],
|
1640 |
+
'date_from' => $now_date,
|
1641 |
+
'date_to' => 0
|
1642 |
+
),
|
1643 |
+
array(
|
1644 |
+
'%s',
|
1645 |
+
'%s',
|
1646 |
+
'%d',
|
1647 |
+
'%s',
|
1648 |
+
'%s',
|
1649 |
+
'%s'
|
1650 |
+
)
|
1651 |
+
);
|
1652 |
+
}
|
1653 |
+
if ( $userdata_count > 0 ) wfu_log_action('modify:'.$now_date, $filepath, $user->ID, '', 0, 0, '', null);
|
1654 |
+
}
|
1655 |
+
if ( isset($_POST['wfu_filedetails_userid']) && $_POST['wfu_filedetails_userid'] != $filerec->uploaduserid ) {
|
1656 |
+
wfu_log_action('changeuser:'.$_POST['wfu_filedetails_userid'], $filepath, $user->ID, '', 0, 0, '', null);
|
1657 |
+
}
|
1658 |
+
}
|
1659 |
+
}
|
1660 |
+
return true;
|
1661 |
}
|
lib/wfu_admin_composer.php
CHANGED
@@ -1,964 +1,964 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Shortcode Composer Page
|
5 |
-
*
|
6 |
-
* This file contains functions related to the shortcode composer page of the
|
7 |
-
* plugin. The shortcode composer is a visual editor of the plugin's shortcodes
|
8 |
-
* so that they can be configured easily by administrators.
|
9 |
-
*
|
10 |
-
* @link /lib/wfu_admin_composer.php
|
11 |
-
*
|
12 |
-
* @package WordPress File Upload Plugin
|
13 |
-
* @subpackage Core Components
|
14 |
-
* @since 2.4.1
|
15 |
-
*/
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Display the Shortcode Composer.
|
19 |
-
*
|
20 |
-
* This function displays the shortcode composer for a specific shortcode.
|
21 |
-
*
|
22 |
-
* @since 2.1.2
|
23 |
-
*
|
24 |
-
* @param string|array $data Optional. If this function was called for an
|
25 |
-
* existing shortcode, this param holds data of the shortcode. If it was
|
26 |
-
* called for a new shortcode, it contains an empty string.
|
27 |
-
* @param string $shortcode_tag Optional. The shortcode tag.
|
28 |
-
* @param string $referer Optional. The page that called this function.
|
29 |
-
*
|
30 |
-
* @return string The HTML output of the shortcode composer.
|
31 |
-
*/
|
32 |
-
function wfu_shortcode_composer($data = '', $shortcode_tag = 'wordpress_file_upload', $referer = 'page') {
|
33 |
-
global $wp_roles;
|
34 |
-
$siteurl = site_url();
|
35 |
-
|
36 |
-
$plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
|
37 |
-
$components = wfu_component_definitions();
|
38 |
-
if ( $shortcode_tag == 'wordpress_file_upload' ) {
|
39 |
-
$plugin_title = "Uploader";
|
40 |
-
$cats = wfu_category_definitions();
|
41 |
-
$defs = wfu_attribute_definitions();
|
42 |
-
//remove personaldata category if Personal Data are not activated in
|
43 |
-
//plugin's Settings
|
44 |
-
if ($plugin_options["personaldata"] != "1" && isset($cats["personaldata"])) unset($cats["personaldata"]);
|
45 |
-
}
|
46 |
-
else {
|
47 |
-
$plugin_title = "Browser";
|
48 |
-
$cats = wfu_browser_category_definitions();
|
49 |
-
$defs = wfu_browser_attribute_definitions();
|
50 |
-
}
|
51 |
-
|
52 |
-
if ( $data == "" ) {
|
53 |
-
$shortcode = $plugin_options['shortcode'];
|
54 |
-
$shortcode_full = '['.$shortcode_tag.' '.$shortcode.']';
|
55 |
-
$postid = "";
|
56 |
-
$postname = "";
|
57 |
-
$posttype = "";
|
58 |
-
$posthash = "";
|
59 |
-
$shortcode_position = -1;
|
60 |
-
$widgetid = "";
|
61 |
-
$sidebar = "";
|
62 |
-
$autosave = true;
|
63 |
-
}
|
64 |
-
else {
|
65 |
-
$shortcode = trim(substr($data['shortcode'], strlen('['.$shortcode_tag), -1));
|
66 |
-
$shortcode_full = $data['shortcode'];
|
67 |
-
$postid = $data['post_id'];
|
68 |
-
$postname = get_the_title($postid);
|
69 |
-
$posttype_obj = get_post_type_object(get_post_type($postid));
|
70 |
-
$posttype = ( $posttype_obj ? $posttype_obj->labels->singular_name : "" );
|
71 |
-
$posthash = $data['post_hash'];
|
72 |
-
$shortcode_position = $data['position'];
|
73 |
-
$widgetid = ( isset($data['widgetid']) ? $data['widgetid'] : "" );
|
74 |
-
$sidebar = ( isset($data['sidebar']) ? $data['sidebar'] : "" );
|
75 |
-
$autosave = false;
|
76 |
-
}
|
77 |
-
|
78 |
-
// index $components
|
79 |
-
$components_indexed = array();
|
80 |
-
foreach ( $components as $component ) $components_indexed[$component['id']] = $component;
|
81 |
-
// complete defs array and index dependencies
|
82 |
-
$governors = array();
|
83 |
-
$shortcode_attrs = wfu_shortcode_string_to_array($shortcode);
|
84 |
-
//replace old attribute definitions with new ones
|
85 |
-
$shortcode_attrs = wfu_old_to_new_attributes($shortcode_attrs);
|
86 |
-
$shortcode_id = '';
|
87 |
-
foreach ( $defs as $key => $def ) {
|
88 |
-
$attr = $def['attribute'];
|
89 |
-
$defs[$key]['default'] = $def['value'];
|
90 |
-
//'flat' property keeps the original attribute, because 'attribute'
|
91 |
-
//property will change for defs that their occurrence is higher than 1
|
92 |
-
$defs[$key]['flat'] = $attr;
|
93 |
-
if ( array_key_exists($attr, $shortcode_attrs) ) $defs[$key]['value'] = $shortcode_attrs[$attr];
|
94 |
-
$subblock_active = false;
|
95 |
-
//detect if the dependencies of this attribute will be disabled or not
|
96 |
-
if ( ( $def['type'] == "onoff" && $defs[$key]['value'] == "true" ) ||
|
97 |
-
( $def['type'] == "radio" && in_array("*".$defs[$key]['value'], $def['listitems']) ) )
|
98 |
-
$subblock_active = true;
|
99 |
-
// assign dependencies if exist
|
100 |
-
if ( $def['dependencies'] != null )
|
101 |
-
foreach ( $def['dependencies'] as $dependency ) {
|
102 |
-
if ( substr($dependency, 0, 1) == "!" ) //invert state for this dependency if an exclamation mark is defined
|
103 |
-
$governors[substr($dependency, 1)] = array( 'attribute' => $attr, 'active' => !$subblock_active, 'inv' => '_inv' );
|
104 |
-
else
|
105 |
-
$governors[$dependency] = array( 'attribute' => $attr, 'active' => $subblock_active, 'inv' => '' );
|
106 |
-
}
|
107 |
-
if ( $attr == 'uploadid' || $attr == 'browserid' ) $shortcode_id = $defs[$key]['value'];
|
108 |
-
}
|
109 |
-
|
110 |
-
//check if attributes need to be generated more than once because their governor is a component field that appears more than once in placements attribute
|
111 |
-
$key = 0;
|
112 |
-
while ( $key < count($defs) ) {
|
113 |
-
$defs[$key]['additional_values'] = array();
|
114 |
-
$def = $defs[$key];
|
115 |
-
$attr = $def['attribute'];
|
116 |
-
//check if this attribute needs to be generated more than once
|
117 |
-
if ( array_key_exists($attr, $governors) ) $governor = $governors[$attr]['attribute'];
|
118 |
-
else $governor = "";
|
119 |
-
if ( $governor != "" && isset($components_indexed[$governor]) && $components_indexed[$governor]['multiplacements'] && isset($shortcode_attrs['placements']) ) {
|
120 |
-
//count how many occurrences of the governor attribute appear inside placements attribute
|
121 |
-
$occurrences = 0;
|
122 |
-
$sections = explode("/", $shortcode_attrs['placements']);
|
123 |
-
foreach ( $sections as $section ) {
|
124 |
-
$items_in_section = explode("+", trim($section));
|
125 |
-
foreach ( $items_in_section as $item )
|
126 |
-
if ( trim($item) == $governor ) $occurrences++;
|
127 |
-
}
|
128 |
-
//add indexed attributes if there is more than one occurrence
|
129 |
-
for ( $ii = 2; $ii <= $occurrences; $ii++ ) {
|
130 |
-
$def2 = $def;
|
131 |
-
$def2['attribute'] .= $ii;
|
132 |
-
$def2['name'] .= ' ('.$ii.')';
|
133 |
-
if ( array_key_exists($def2['attribute'], $shortcode_attrs) )
|
134 |
-
$def2['value'] = $shortcode_attrs[$def2['attribute']];
|
135 |
-
else $def2['value'] = $def2['default'];
|
136 |
-
array_splice($defs, $key + 1, 0, array($def2));
|
137 |
-
$key++;
|
138 |
-
}
|
139 |
-
//check if the shortcode contains additional indexed definitions and store them in 'additional_values'
|
140 |
-
$ii = max(1, $occurrences) + 1;
|
141 |
-
while ( array_key_exists($attr.$ii, $shortcode_attrs) ) {
|
142 |
-
$defs[$key]['additional_values'][$ii] = $shortcode_attrs[$attr.$ii];
|
143 |
-
$ii++;
|
144 |
-
}
|
145 |
-
}
|
146 |
-
$key++;
|
147 |
-
}
|
148 |
-
|
149 |
-
$echo_str = '<div id="wfu_wrapper" class="wrap">';
|
150 |
-
$echo_str .= "\n\t".'<h2>Wordpress File Upload Control Panel</h2>';
|
151 |
-
$echo_str .= "\n\t".'<div id="wfu_page_obsolete_message" class="error" style="display:none;">';
|
152 |
-
$echo_str .= "\n\t\t".'<p>'.WFU_DASHBOARD_PAGE_OBSOLETE.'</p>';
|
153 |
-
$echo_str .= "\n\t".'</div>';
|
154 |
-
$echo_str .= "\n\t".'<div id="wfu_update_rejected_message" class="error" style="display:none;">';
|
155 |
-
$echo_str .= "\n\t\t".'<p>'.WFU_DASHBOARD_UPDATE_SHORTCODE_REJECTED.'</p>';
|
156 |
-
$echo_str .= "\n\t".'</div>';
|
157 |
-
$echo_str .= "\n\t".'<div id="wfu_update_failed_message" class="error" style="display:none;">';
|
158 |
-
$echo_str .= "\n\t\t".'<p>'.WFU_DASHBOARD_UPDATE_SHORTCODE_FAILED.'</p>';
|
159 |
-
$echo_str .= "\n\t".'</div>';
|
160 |
-
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
161 |
-
if ( $referer == "dashboard" ) $echo_str .= "\n\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=manage_mainmenu" class="button" title="go back">Go to Main Menu</a>';
|
162 |
-
$echo_str .= "\n\t".'</div>';
|
163 |
-
if ( $widgetid == "" ) $echo_str .= "\n\t".'<h2 style="margin-bottom: 10px; margin-top: 20px;">'.( $data == "" ? 'Test' : $posttype.' <strong>'.$postname.'</strong>' ).': Shortcode Composer for '.$plugin_title.' <strong>ID '.$shortcode_id.'</strong></h2>';
|
164 |
-
else $echo_str .= "\n\t".'<h2 style="margin-bottom: 10px; margin-top: 20px;">Sidebar <strong>'.$sidebar.'</strong>: Shortcode Composer for Uploader <strong>ID '.$shortcode_id.'</strong></h2>';
|
165 |
-
$echo_str .= "\n\t".'<div style="margin-top:10px; display:inline-block;">';
|
166 |
-
if ( $data != "") $echo_str .= "\n\t\t".'<input id="wfu_update_shortcode" type="button" value="Update" class="button-primary" disabled="disabled" onclick="wfu_save_shortcode()" /><span id="wfu_update_shortcode_wait" class="spinner" style="float:right; display:none;"></span>';
|
167 |
-
$echo_str .= "\n\t\t".'<input id="wfu_shortcode_original_enc" type="hidden" value="'.wfu_plugin_encode_string($shortcode_full).'" />';
|
168 |
-
$echo_str .= "\n\t\t".'<input id="wfu_shortcode_tag" type="hidden" value="'.$shortcode_tag.'" />';
|
169 |
-
$echo_str .= "\n\t\t".'<input id="wfu_shortcode_postid" type="hidden" value="'.$postid.'" />';
|
170 |
-
$echo_str .= "\n\t\t".'<input id="wfu_shortcode_posthash" type="hidden" value="'.$posthash.'" />';
|
171 |
-
$echo_str .= "\n\t\t".'<input id="wfu_shortcode_position" type="hidden" value="'.$shortcode_position.'" />';
|
172 |
-
$echo_str .= "\n\t\t".'<input id="wfu_shortcode_widgetid" type="hidden" value="'.$widgetid.'" />';
|
173 |
-
$echo_str .= "\n\t".'</div>';
|
174 |
-
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
175 |
-
$echo_str .= "\n\t\t".'<div class="wfu_shortcode_container">';
|
176 |
-
$echo_str .= "\n\t\t\t".'<span><strong>Generated Shortcode</strong></span>';
|
177 |
-
$echo_str .= "\n\t\t\t".'<span id="wfu_save_label" class="wfu_save_label">saved</span>';
|
178 |
-
$echo_str .= "\n\t\t\t".'<textarea id="wfu_shortcode" class="wfu_shortcode" rows="5">['.$shortcode_tag.']</textarea>';
|
179 |
-
$echo_str .= "\n\t\t\t".'<div id="wfu_attribute_defaults" style="display:none;">';
|
180 |
-
// remove hidden attributes from defs array
|
181 |
-
foreach ( $defs as $key => $def ) if ( $def['type'] == "hidden" ) unset($defs[$key]);
|
182 |
-
foreach ( $defs as $def )
|
183 |
-
$echo_str .= "\n\t\t\t\t".'<input id="wfu_attribute_default_'.$def['attribute'].'" type="hidden" value="'.$def['default'].'" />';
|
184 |
-
$echo_str .= "\n\t\t\t".'</div>';
|
185 |
-
$echo_str .= "\n\t\t\t".'<div id="wfu_attribute_values" style="display:none;">';
|
186 |
-
foreach ( $defs as $def ) {
|
187 |
-
$echo_str .= "\n\t\t\t\t".'<input id="wfu_attribute_value_'.$def['attribute'].'" type="hidden" value="'.$def['value'].'" />';
|
188 |
-
//add additional values, if exist
|
189 |
-
foreach( $def['additional_values'] as $key => $val )
|
190 |
-
$echo_str .= "\n\t\t\t\t".'<input id="wfu_attribute_value_'.$def['attribute'].$key.'" type="hidden" value="'.$val.'" />';
|
191 |
-
}
|
192 |
-
$echo_str .= "\n\t\t\t".'</div>';
|
193 |
-
$echo_str .= "\n\t\t".'</div>';
|
194 |
-
$echo_str .= "\n\t".'</div>';
|
195 |
-
$echo_str .= "\n\t".'<h3 id="wfu_tab_container" class="nav-tab-wrapper">';
|
196 |
-
$is_first = true;
|
197 |
-
foreach ( $cats as $key => $cat ) {
|
198 |
-
$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>';
|
199 |
-
$is_first = false;
|
200 |
-
}
|
201 |
-
$echo_str .= "\n\t".'</h3>';
|
202 |
-
|
203 |
-
$prevcat = "";
|
204 |
-
$prevsubcat = "";
|
205 |
-
$is_first = true;
|
206 |
-
$block_open = false;
|
207 |
-
$subblock_open = false;
|
208 |
-
foreach ( $defs as $def ) {
|
209 |
-
$attr = $def['attribute'];
|
210 |
-
//check if this attribute depends on other
|
211 |
-
if ( !array_key_exists($attr, $governors) ) $governors[$attr] = "";
|
212 |
-
if ( $governors[$attr] != "" ) $governor = $governors[$attr];
|
213 |
-
else $governor = array( 'attribute' => "independent", 'active' => true, 'inv' => '' );
|
214 |
-
|
215 |
-
//close previous blocks
|
216 |
-
if ( $def['parent'] == "" ) {
|
217 |
-
if ( $subblock_open ) {
|
218 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'</tbody>';
|
219 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</table>';
|
220 |
-
$subblock_open = false;
|
221 |
-
}
|
222 |
-
if ( $block_open ) {
|
223 |
-
$echo_str .= "\n\t\t\t\t\t".'</div></td>';
|
224 |
-
$echo_str .= "\n\t\t\t\t".'</tr>';
|
225 |
-
$block_open = false;
|
226 |
-
}
|
227 |
-
}
|
228 |
-
//check if new category must be generated
|
229 |
-
if ( $def['category'] != $prevcat ) {
|
230 |
-
if ( $prevcat != "" ) {
|
231 |
-
$echo_str .= "\n\t\t\t".'</tbody>';
|
232 |
-
$echo_str .= "\n\t\t".'</table>';
|
233 |
-
$echo_str .= "\n\t".'</div>';
|
234 |
-
}
|
235 |
-
$prevcat = $def['category'];
|
236 |
-
$prevsubcat = "";
|
237 |
-
$echo_str .= "\n\t".'<div id="wfu_container_'.$prevcat.'" class="wfu_container"'.( $is_first ? '' : ' style="display:none;"' ).'">';
|
238 |
-
$echo_str .= "\n\t\t".'<table class="form-table wfu_main_table">';
|
239 |
-
$echo_str .= "\n\t\t\t".'<thead><tr><th></th><td></td><td></td></tr></thead>';
|
240 |
-
$echo_str .= "\n\t\t\t".'<tbody>';
|
241 |
-
$is_first = false;
|
242 |
-
}
|
243 |
-
//check if new sub-category must be generated
|
244 |
-
if ( $def['subcategory'] != $prevsubcat ) {
|
245 |
-
$prevsubcat = $def['subcategory'];
|
246 |
-
$echo_str .= "\n\t\t\t\t".'<tr class="wfu_subcategory">';
|
247 |
-
$echo_str .= "\n\t\t\t\t\t".'<th scope="row" colspan="3">';
|
248 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<h3 style="margin-bottom: 10px; margin-top: 10px;">'.$prevsubcat.'</h3>';
|
249 |
-
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
250 |
-
$echo_str .= "\n\t\t\t\t".'</tr>';
|
251 |
-
}
|
252 |
-
//draw attribute element
|
253 |
-
if ( $def['parent'] == "" ) {
|
254 |
-
$dlp = "\n\t\t\t\t";
|
255 |
-
}
|
256 |
-
else {
|
257 |
-
if ( !$subblock_open ) {
|
258 |
-
$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>';
|
259 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<table class="form-table wfu_inner_table" style="margin:0;">';
|
260 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<tbody>';
|
261 |
-
}
|
262 |
-
$dlp = "\n\t\t\t\t\t\t\t\t";
|
263 |
-
}
|
264 |
-
$echo_str .= $dlp.'<tr>';
|
265 |
-
$echo_str .= $dlp."\t".'<th scope="row"><div class="wfu_td_div">';
|
266 |
-
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>';
|
267 |
-
$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>';
|
268 |
-
$echo_str .= $dlp."\t\t".'<label for="wfu_attribute_'.$attr.'">'.$def['name'].'</label>';
|
269 |
-
$echo_str .= $dlp."\t\t".'<input type="hidden" name="wfu_attribute_governor_'.$governor['attribute'].'" class="wfu_attribute_governor" value="'.$attr.'" />';
|
270 |
-
$echo_str .= $dlp."\t\t".'<div class="wfu_help_container" title="'.$def['help'].'"><img src="'.WFU_IMAGE_ADMIN_HELP.'" /></div>';
|
271 |
-
$echo_str .= $dlp."\t".'</div></th>';
|
272 |
-
$echo_str .= $dlp."\t".'<td style="vertical-align:top;"><div class="wfu_td_div">';
|
273 |
-
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>';
|
274 |
-
if ( $def['type'] == "onoff" ) {
|
275 |
-
$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.'\');">';
|
276 |
-
$echo_str .= $dlp."\t\t\t".'<div class="wfu_onoff_slider"></div>';
|
277 |
-
$echo_str .= $dlp."\t\t\t".'<span class="wfu_onoff_text">ON</span>';
|
278 |
-
$echo_str .= $dlp."\t\t\t".'<span class="wfu_onoff_text">OFF</span>';
|
279 |
-
$echo_str .= $dlp."\t\t".'</div>';
|
280 |
-
}
|
281 |
-
elseif ( $def['type'] == "text" ) {
|
282 |
-
$val = str_replace(array( "%n%", "%dq%", "%brl%", "%brr%" ), array( "\n", """, "[", "]" ), $def['value']);
|
283 |
-
$echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" value="'.$val.'" style="display:block;" />';
|
284 |
-
if ( $def['variables'] != null ) $echo_str .= $dlp.wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
|
285 |
-
}
|
286 |
-
elseif ( $def['type'] == "placements" ) {
|
287 |
-
$components_used = array();
|
288 |
-
foreach ( $components as $component ) $components_used[$component['id']] = 0;
|
289 |
-
$centered_content = '<div class="wfu_component_box_inner"><div class="wfu_component_box_label">XXX</div></div>';
|
290 |
-
$centered_content_multi = '<div class="wfu_component_box_inner"><div class="wfu_component_box_label">XXX</div><div class="wfu_component_box_index">YYY</div></div>';
|
291 |
-
$echo_str .= $dlp."\t\t".'<div class="wfu_placements_wrapper">';
|
292 |
-
$echo_str .= $dlp."\t\t\t".'<div id="wfu_placements_container" class="wfu_placements_container">';
|
293 |
-
$itemplaces = explode("/", $def['value']);
|
294 |
-
foreach ( $itemplaces as $section ) {
|
295 |
-
$echo_str .= $dlp."\t\t\t\t".'<div class="wfu_component_separator_hor"></div>';
|
296 |
-
$echo_str .= $dlp."\t\t\t\t".'<div class="wfu_component_separator_ver"></div>';
|
297 |
-
$items_in_section = explode("+", trim($section));
|
298 |
-
$section_array = array( );
|
299 |
-
foreach ( $items_in_section as $item_in_section ) {
|
300 |
-
if ( key_exists($item_in_section, $components_indexed) ) {
|
301 |
-
if ( $components_indexed[$item_in_section]['multiplacements'] || $components_used[$item_in_section] == 0 ) {
|
302 |
-
$components_used[$item_in_section] ++;
|
303 |
-
if ( $components_indexed[$item_in_section]['multiplacements'] ) {
|
304 |
-
$multi_index = $components_used[$item_in_section];
|
305 |
-
$echo_str .= $dlp."\t\t\t\t".'<div id="wfu_component_box_'.$item_in_section.'_'.$multi_index.'" class="wfu_component_box" draggable="true" title="'.$components_indexed[$item_in_section]['help'].'">'.str_replace(array("XXX", "YYY"), array($components_indexed[$item_in_section]['name'], $multi_index), $centered_content_multi).'</div>';
|
306 |
-
}
|
307 |
-
else
|
308 |
-
$echo_str .= $dlp."\t\t\t\t".'<div id="wfu_component_box_'.$item_in_section.'_0" class="wfu_component_box" draggable="true" title="'.$components_indexed[$item_in_section]['help'].'">'.str_replace("XXX", $components_indexed[$item_in_section]['name'], $centered_content).'</div>';
|
309 |
-
$echo_str .= $dlp."\t\t\t\t".'<div class="wfu_component_separator_ver"></div>';
|
310 |
-
}
|
311 |
-
}
|
312 |
-
}
|
313 |
-
}
|
314 |
-
$echo_str .= $dlp."\t\t\t\t".'<div class="wfu_component_separator_hor"></div>';
|
315 |
-
$echo_str .= $dlp."\t\t\t\t".'<div id="wfu_component_bar_hor" class="wfu_component_bar_hor"></div>';
|
316 |
-
$echo_str .= $dlp."\t\t\t\t".'<div id="wfu_component_bar_ver" class="wfu_component_bar_ver"></div>';
|
317 |
-
$echo_str .= $dlp."\t\t\t".'</div>';
|
318 |
-
$echo_str .= $dlp."\t\t\t".'<div id="wfu_componentlist_container" class="wfu_componentlist_container">';
|
319 |
-
$echo_str .= $dlp."\t\t\t\t".'<div id="wfu_componentlist_dragdrop" class="wfu_componentlist_dragdrop" style="display:none;"></div>';
|
320 |
-
$ii = 1;
|
321 |
-
foreach ( $components as $component ) {
|
322 |
-
$echo_str .= $dlp."\t\t\t\t".'<div id="wfu_component_box_container_'.$component['id'].'" class="wfu_component_box_container">';
|
323 |
-
$echo_str .= $dlp."\t\t\t\t\t".'<div class="wfu_component_box_base">'.str_replace("XXX", $component['name'], $centered_content).'</div>';
|
324 |
-
if ( $component['multiplacements'] ) {
|
325 |
-
$multi_index = $components_used[$component['id']] + 1;
|
326 |
-
$echo_str .= $dlp."\t\t\t\t\t".'<div id="wfu_component_box_'.$component['id'].'_'.$multi_index.'" class="wfu_component_box wfu_inbase" draggable="true" title="'.$component['help'].'">'.str_replace(array("XXX", "YYY"), array($component['name'], $multi_index), $centered_content_multi).'</div>';
|
327 |
-
}
|
328 |
-
elseif ( $components_used[$component['id']] == 0 )
|
329 |
-
$echo_str .= $dlp."\t\t\t\t\t".'<div id="wfu_component_box_'.$component['id'].'_0" class="wfu_component_box wfu_inbase" draggable="true" title="'.$component['help'].'">'.str_replace("XXX", $component['name'], $centered_content).'</div>';
|
330 |
-
$echo_str .= $dlp."\t\t\t\t".'</div>'.( ($ii++) % 3 == 0 ? '<br />' : '' );
|
331 |
-
}
|
332 |
-
$echo_str .= $dlp."\t\t\t".'</div>';
|
333 |
-
$echo_str .= $dlp."\t\t".'</div>';
|
334 |
-
}
|
335 |
-
elseif ( $def['type'] == "ltext" ) {
|
336 |
-
$val = str_replace(array( "%n%", "%dq%", "%brl%", "%brr%" ), array( "\n", """, "[", "]" ), $def['value']);
|
337 |
-
$echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" class="wfu_long_text" value="'.$val.'" />';
|
338 |
-
if ( $def['variables'] != null ) $echo_str .= $dlp.wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
|
339 |
-
}
|
340 |
-
elseif ( $def['type'] == "integer" ) {
|
341 |
-
$val = str_replace(array( "%n%", "%dq%", "%brl%", "%brr%" ), array( "\n", """, "[", "]" ), $def['value']);
|
342 |
-
$echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="number" name="wfu_text_elements" class="wfu_short_text" min="1" value="'.$val.'" />';
|
343 |
-
if ( isset($def['listitems']['unit']) ) $echo_str .= $dlp."\t\t".'<label> '.$def['listitems']['unit'].'</label>';
|
344 |
-
}
|
345 |
-
elseif ( $def['type'] == "float" ) {
|
346 |
-
$val = str_replace(array( "%n%", "%dq%", "%brl%", "%brr%" ), array( "\n", """, "[", "]" ), $def['value']);
|
347 |
-
$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.'" />';
|
348 |
-
if ( isset($def['listitems']['unit']) ) $echo_str .= $dlp."\t\t".'<label> '.$def['listitems']['unit'].'</label>';
|
349 |
-
}
|
350 |
-
elseif ( $def['type'] == "date" ) {
|
351 |
-
$val = $def['value'];
|
352 |
-
$echo_str .= $dlp."\t\t".'<div class="wfu_date_container"><input id="wfu_attribute_'.$attr.'" type="text" value="'.$val.'" readonly style="padding-right:16px; background-color:white; width:auto;" /><img class="wfu_datereset_button" src="'.WFU_IMAGE_ADMIN_SUBFOLDER_CANCEL.'" onclick="var f = document.getElementById(\'wfu_attribute_'.$attr.'\'); f.value = \'\'; wfu_update_date_value({target:f});" /></div><label style="font-size:smaller; margin-left:4px;">format: YYYY-MM-DD</label>';
|
353 |
-
$echo_str .= wfu_inject_js_code('jQuery(function() {jQuery("#wfu_attribute_'.$attr.'").datepicker({dateFormat: "yy-mm-dd", onClose: function(date, picker) {wfu_update_date_value({target:this});}});});');
|
354 |
-
}
|
355 |
-
elseif ( $def['type'] == "radio" ) {
|
356 |
-
$echo_str .= $dlp."\t\t";
|
357 |
-
$ii = 0;
|
358 |
-
foreach ( $def['listitems'] as $item )
|
359 |
-
$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 );
|
360 |
-
// $echo_str .= '<input type="button" class="button" value="empty" style="width:auto; margin:-2px 0px 0px 8px;" />';
|
361 |
-
}
|
362 |
-
elseif ( $def['type'] == "ptext" ) {
|
363 |
-
$val = str_replace(array( "%n%", "%dq%", "%brl%", "%brr%" ), array( "\n", """, "[", "]" ), $def['value']);
|
364 |
-
$parts = explode("/", $val);
|
365 |
-
$singular = $parts[0];
|
366 |
-
if ( count($parts) < 2 ) $plural = $singular;
|
367 |
-
else $plural = $parts[1];
|
368 |
-
$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.'" />';
|
369 |
-
if ( $def['variables'] != null ) if ( count($def['variables']) > 0 ) $echo_str .= $dlp."\t\t".'<br /><span class="wfu_ptext_span"> </span>';
|
370 |
-
if ( $def['variables'] != null ) $echo_str .= $dlp.wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_s_'.$attr);
|
371 |
-
$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.'" />';
|
372 |
-
if ( $def['variables'] != null ) if ( count($def['variables']) > 0 ) $echo_str .= $dlp."\t\t".'<br /><span class="wfu_ptext_span"> </span>';
|
373 |
-
if ( $def['variables'] != null ) $echo_str .= $dlp.wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_p_'.$attr, $dlp);
|
374 |
-
}
|
375 |
-
elseif ( $def['type'] == "mtext" ) {
|
376 |
-
$val = str_replace(array( "%n%", "%dq%", "%brl%", "%brr%" ), array( "\n", """, "[", "]" ), $def['value']);
|
377 |
-
$echo_str .= $dlp."\t\t".'<textarea id="wfu_attribute_'.$attr.'" name="wfu_text_elements" rows="5">'.$val.'</textarea>';
|
378 |
-
if ( $def['variables'] != null ) $echo_str .= $dlp.wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
|
379 |
-
}
|
380 |
-
elseif ( $def['type'] == "ftpinfo" ) {
|
381 |
-
$val = $def['value'];
|
382 |
-
$ftpinfo = wfu_decode_ftpinfo($val);
|
383 |
-
$error_class = ( $ftpinfo["error"] ? ' ftpinfo_error' : '' );
|
384 |
-
$echo_str .= $dlp."\t\t".'<div class="ftpinfo_header">';
|
385 |
-
$echo_str .= $dlp."\t\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_ftpinfobase_elements" class="ftpinfo_text'.$error_class.'" value="'.$val.'" />';
|
386 |
-
$echo_str .= $dlp."\t\t\t".'<button class="ftpinfo_btn" onclick="wfu_ftpinfotool_toggle();">Edit</button>';
|
387 |
-
$echo_str .= $dlp."\t\t".'</div>';
|
388 |
-
$echo_str .= $dlp."\t\t".'<div class="ftpinfo_tool hidden">';
|
389 |
-
$echo_str .= $dlp."\t\t\t".'<label class="ftpinfo_label">Username</label><input type="text" id="ftpinfo_username" name="wfu_ftpinfotool_elements" class="ftpinfo_value'.$error_class.'" value="'.$ftpinfo["data"]["username"].'" /><br />';
|
390 |
-
$echo_str .= $dlp."\t\t\t".'<label class="ftpinfo_label">Password</label><input type="text" id="ftpinfo_password" name="wfu_ftpinfotool_elements" class="ftpinfo_value'.$error_class.'" value="'.$ftpinfo["data"]["password"].'" /><br />';
|
391 |
-
$echo_str .= $dlp."\t\t\t".'<label class="ftpinfo_label">FTP Domain</label><input type="text" id="ftpinfo_domain" name="wfu_ftpinfotool_elements" class="ftpinfo_value'.$error_class.'" value="'.$ftpinfo["data"]["ftpdomain"].'" /><br />';
|
392 |
-
$echo_str .= $dlp."\t\t\t".'<label class="ftpinfo_label">Port</label><input type="text" id="ftpinfo_port" name="wfu_ftpinfotool_elements" class="ftpinfo_value'.$error_class.'" value="'.$ftpinfo["data"]["port"].'" /><br />';
|
393 |
-
$echo_str .= $dlp."\t\t\t".'<label class="ftpinfo_label">Use SFTP</label><input type="checkbox" id="ftpinfo_sftp" name="wfu_ftpinfotool_elements" class="ftpinfo_checkbox'.$error_class.'"'.( $ftpinfo["data"]["sftp"] ? " checked" : "" ).' />';
|
394 |
-
$echo_str .= $dlp."\t\t".'</div>';
|
395 |
-
if ( $def['variables'] != null ) $echo_str .= $dlp.wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
|
396 |
-
}
|
397 |
-
elseif ( $def['type'] == "folderlist" ) {
|
398 |
-
$echo_str .= $dlp."\t\t".'<div id="wfu_subfolders_inner_shadow_'.$attr.'" class="wfu_subfolders_inner_shadow" style="display:none;"></div>';
|
399 |
-
$subfolders = wfu_parse_folderlist($def['value']);
|
400 |
-
$poptitle = "Populate list automatically with the first-level subfolders of the path defined in uploadpath";
|
401 |
-
$edittitle = "Allow the user to type the subfolder and filter the list during typing";
|
402 |
-
$echo_str .= $dlp."\t\t".'<input type="checkbox" id="wfu_subfolders_auto_'.$attr.'"'.( substr($def['value'], 0, 4) == "auto" ? ' checked="checked"' : '' ).' onchange="wfu_subfolders_auto_changed(\''.$attr.'\');" title="'.$poptitle.'" /><label for="wfu_subfolders_auto_'.$attr.'" title="'.$poptitle.'"> Auto-populate list</label>';
|
403 |
-
$echo_str .= $dlp."\t\t".'<div style="display:'.( substr($def['value'], 0, 4) == "auto" ? 'inline' : 'none' ).'; padding:0; margin:0 0 0 30px; background:none; border:none;"><input type="checkbox" id="wfu_subfolders_editable_'.$attr.'"'.( substr($def['value'], 0, 5) == "auto+" ? ' checked="checked"' : '' ).' onchange="wfu_subfolders_auto_changed(\''.$attr.'\');" title="'.$edittitle.'" /><label for="wfu_subfolders_editable_'.$attr.'" title="'.$edittitle.'"> List is editable</label></div><br />';
|
404 |
-
$echo_str .= $dlp."\t\t".'<input type="hidden" id="wfu_subfolders_manualtext_'.$attr.'" value="'.( substr($def['value'], 0, 4) == "auto" ? "" : $def['value'] ).'" />';
|
405 |
-
$echo_str .= $dlp."\t\t".'<select id="wfu_attribute_'.$attr.'" class="wfu_select_folders'.( count($subfolders['path']) == 0 ? ' wfu_select_folders_empty' : '' ).'" size="7"'.( substr($def['value'], 0, 4) == "auto" ? ' disabled="disabled"' : '' ).' onchange="wfu_subfolders_changed(\''.$attr.'\');">';
|
406 |
-
foreach ($subfolders['path'] as $ind => $subfolder) {
|
407 |
-
if ( substr($subfolder, -1) == '/' ) $subfolder = substr($subfolder, 0, -1);
|
408 |
-
$subfolder_raw = explode('/', $subfolder);
|
409 |
-
$subfolder = $subfolder_raw[count($subfolder_raw) - 1];
|
410 |
-
$text = str_repeat(" ", intval($subfolders['level'][$ind])).$subfolders['label'][$ind];
|
411 |
-
$subvalue = str_repeat("*", intval($subfolders['level'][$ind])).( $subfolders['default'][$ind] ? '&' : '' ).( $subfolder == "" ? '{root}' : $subfolder ).'/'.$subfolders['label'][$ind];
|
412 |
-
$echo_str .= $dlp."\t\t\t".'<option class="'.( $subfolders['default'][$ind] ? 'wfu_select_folders_option_default' : '' ).'" value="'.wfu_plugin_encode_string($subvalue).'">'.$text.'</option>';
|
413 |
-
}
|
414 |
-
$echo_str .= $dlp."\t\t\t".'<option value="">'.( substr($def['value'], 0, 4) != "auto" && count($subfolders['path']) == 0 ? 'press here' : '' ).'</option>';
|
415 |
-
$echo_str .= $dlp."\t\t".'</select>';
|
416 |
-
$echo_str .= $dlp."\t\t".'<div id="wfu_subfolder_nav_'.$attr.'" class="wfu_subfolder_nav_container">';
|
417 |
-
$echo_str .= $dlp."\t\t\t".'<table class="wfu_subfolder_nav"><tbody>';
|
418 |
-
$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>';
|
419 |
-
$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>';
|
420 |
-
$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>';
|
421 |
-
$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>';
|
422 |
-
$echo_str .= $dlp."\t\t\t\t".'<tr><td style="line-height:0;"><button class="button" style="visibility:hidden; height:10px;"></button></tr></td>';
|
423 |
-
$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>';
|
424 |
-
$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>';
|
425 |
-
$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>';
|
426 |
-
$echo_str .= $dlp."\t\t\t".'</tbody></table>';
|
427 |
-
$echo_str .= $dlp."\t\t".'</div>';
|
428 |
-
$echo_str .= $dlp."\t\t".'<div id="wfu_subfolder_tools_'.$attr.'" class="wfu_subfolder_tools_container wfu_subfolder_tools_disabled">';
|
429 |
-
$echo_str .= $dlp."\t\t\t".'<table class="wfu_subfolder_tools"><tbody><tr>';
|
430 |
-
$echo_str .= $dlp."\t\t\t\t".'<td style="width:40%;">';
|
431 |
-
$echo_str .= $dlp."\t\t\t\t\t".'<label>Label</label>';
|
432 |
-
$echo_str .= $dlp."\t\t\t\t\t".'<input id="wfu_subfolders_label_'.$attr.'" name="wfu_subfolder_tools_input" type="text" disabled="disabled" />';
|
433 |
-
$echo_str .= $dlp."\t\t\t\t".'</td>';
|
434 |
-
$echo_str .= $dlp."\t\t\t\t".'<td style="width:60%;"><div style="padding-right:36px;">';
|
435 |
-
$echo_str .= $dlp."\t\t\t\t\t".'<label>Path</label>';
|
436 |
-
$echo_str .= $dlp."\t\t\t\t\t".'<input id="wfu_subfolders_path_'.$attr.'" name="wfu_subfolder_tools_input" type="text" disabled="disabled" />';
|
437 |
-
$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>';
|
438 |
-
$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>';
|
439 |
-
// file browser dialog
|
440 |
-
$echo_str .= $dlp."\t\t\t\t\t".'<div id="wfu_subfolders_browser_'.$attr.'" class="wfu_subfolders_browser_container" style="display:none;">';
|
441 |
-
$echo_str .= $dlp."\t\t\t\t\t\t".'<table><tbody>';
|
442 |
-
$echo_str .= $dlp."\t\t\t\t\t\t\t".'<tr><td style="height:15px;">';
|
443 |
-
$echo_str .= $dlp."\t\t\t\t\t\t\t\t".'<div>';
|
444 |
-
$echo_str .= $dlp."\t\t\t\t\t\t\t\t\t".'<label>Folder Browser</label>';
|
445 |
-
$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>';
|
446 |
-
$echo_str .= $dlp."\t\t\t\t\t\t\t\t".'</div>';
|
447 |
-
$echo_str .= $dlp."\t\t\t\t\t\t\t".'</td></tr>';
|
448 |
-
$echo_str .= $dlp."\t\t\t\t\t\t\t".'<tr><td style="height:106px;">';
|
449 |
-
$echo_str .= $dlp."\t\t\t\t\t\t\t\t".'<div>';
|
450 |
-
$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.'\');">';
|
451 |
-
$echo_str .= $dlp."\t\t\t\t\t\t\t\t\t\t".'<option>Value</option>';
|
452 |
-
$echo_str .= $dlp."\t\t\t\t\t\t\t\t\t\t".'<option>Value2</option>';
|
453 |
-
$echo_str .= $dlp."\t\t\t\t\t\t\t\t\t\t".'<option>Value3</option>';
|
454 |
-
$echo_str .= $dlp."\t\t\t\t\t\t\t\t\t".'</select>';
|
455 |
-
$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;">';
|
456 |
-
$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>';
|
457 |
-
$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>';
|
458 |
-
$echo_str .= $dlp."\t\t\t\t\t\t\t\t\t".'</div>';
|
459 |
-
$echo_str .= $dlp."\t\t\t\t\t\t\t\t".'</div>';
|
460 |
-
$echo_str .= $dlp."\t\t\t\t\t\t\t".'</td></tr>';
|
461 |
-
$echo_str .= $dlp."\t\t\t\t\t\t\t".'<tr><td align="right" style="height:15px;">';
|
462 |
-
$echo_str .= $dlp."\t\t\t\t\t\t\t\t".'<div>';
|
463 |
-
$echo_str .= $dlp."\t\t\t\t\t\t\t\t\t".'<button class="button" onclick="wfu_folder_browser_cancel_clicked(\''.$attr.'\');">Cancel</button>';
|
464 |
-
$echo_str .= $dlp."\t\t\t\t\t\t\t\t\t".'<button id="wfu_subfolders_browser_ok_'.$attr.'" class="button">Ok</button>';
|
465 |
-
$echo_str .= $dlp."\t\t\t\t\t\t\t\t".'</div>';
|
466 |
-
$echo_str .= $dlp."\t\t\t\t\t\t\t".'</td></tr>';
|
467 |
-
$echo_str .= $dlp."\t\t\t\t\t\t".'</tbody></table>';
|
468 |
-
$echo_str .= $dlp."\t\t\t\t\t".'</div>';
|
469 |
-
|
470 |
-
$echo_str .= $dlp."\t\t\t\t".'</div></td>';
|
471 |
-
$echo_str .= $dlp."\t\t\t".'</tr></tbody></table>';
|
472 |
-
$echo_str .= $dlp."\t\t\t".'<input id="wfu_subfolders_isnewitem_'.$attr.'" type="hidden" value="" />';
|
473 |
-
$echo_str .= $dlp."\t\t\t".'<input id="wfu_subfolders_newitemindex_'.$attr.'" type="hidden" value="" />';
|
474 |
-
$echo_str .= $dlp."\t\t\t".'<input id="wfu_subfolders_newitemlevel_'.$attr.'" type="hidden" value="" />';
|
475 |
-
$echo_str .= $dlp."\t\t\t".'<input id="wfu_subfolders_newitemlevel2_'.$attr.'" type="hidden" value="" />';
|
476 |
-
$echo_str .= $dlp."\t\t".'</div>';
|
477 |
-
}
|
478 |
-
elseif ( $def['type'] == "mchecklist" ) {
|
479 |
-
$help_count = 0;
|
480 |
-
foreach ( $def['listitems'] as $key => $item ) {
|
481 |
-
$parts = explode("/", $item);
|
482 |
-
if ( count($parts) == 1 ) {
|
483 |
-
$items[$key]['id'] = $item;
|
484 |
-
$items[$key]['help'] = '';
|
485 |
-
}
|
486 |
-
else {
|
487 |
-
$items[$key]['id'] = $parts[0];
|
488 |
-
$items[$key]['help'] = $parts[1];
|
489 |
-
$help_count ++;
|
490 |
-
}
|
491 |
-
}
|
492 |
-
$def['value'] = strtolower($def['value']);
|
493 |
-
if ( $def['value'] == "all" ) $selected = array();
|
494 |
-
else $selected = explode(",", $def['value']);
|
495 |
-
foreach ( $selected as $key => $item ) $selected[$key] = trim($item);
|
496 |
-
$echo_str .= $dlp."\t\t".'<div id="wfu_attribute_'.$attr.'" class="wfu_mchecklist_container">';
|
497 |
-
$is_first = true;
|
498 |
-
foreach ( $items as $key => $item ) {
|
499 |
-
if ( !$is_first ) $echo_str .= "<br />";
|
500 |
-
$is_first = false;
|
501 |
-
$echo_str .= $dlp."\t\t\t".'<div class="wfu_mchecklist_item"><input id="wfu_attribute_'.$attr.'_'.$key.'" type="checkbox"'.( $def['value'] == "all" || in_array($item['id'], $selected) ? ' checked="checked"' : '' ).( $def['value'] == "all" ? ' disabled="disabled"' : '' ).' onchange="wfu_update_mchecklist_value(\''.$attr.'\');" /><label for="wfu_attribute_'.$attr.'_'.$key.'">'.$item['id'].'</label>';
|
502 |
-
if ( $item['help'] != '' ) $echo_str .= '<div class="wfu_help_container" title="'.$item['help'].'"><img src="'.WFU_IMAGE_ADMIN_HELP.'" /></div>';
|
503 |
-
$echo_str .= '</div>';
|
504 |
-
}
|
505 |
-
$echo_str .= $dlp."\t\t".'</div>';
|
506 |
-
$echo_str .= $dlp."\t\t".'<div id="wfu_attribute_'.$attr.'_optionhelp" class="wfu_help_container" title="" style="display:none; position:absolute;"><img src="'.WFU_IMAGE_ADMIN_HELP.'" style="visibility:visible;" /></div>';
|
507 |
-
$echo_str .= $dlp."\t\t".'<div class="wfu_mchecklist_checkall"><input id="wfu_attribute_'.$attr.'_all" type="checkbox" onchange="wfu_update_mchecklist_value(\''.$attr.'\');"'.( $def['value'] == "all" ? ' checked="checked"' : '' ).' /> Select all</div>';
|
508 |
-
}
|
509 |
-
elseif ( $def['type'] == "rolelist" ) {
|
510 |
-
$roles = $wp_roles->get_names();
|
511 |
-
$selected = explode(",", $def['value']);
|
512 |
-
$default_administrator = ( is_array($def['listitems']) && in_array('default_administrator', $def['listitems']) );
|
513 |
-
if ( in_array('all', $selected) ) $rolesselected = ( $default_administrator ? array("administrator") : array( ) );
|
514 |
-
else $rolesselected = $selected;
|
515 |
-
foreach ( $selected as $key => $item ) $selected[$key] = trim($item);
|
516 |
-
$echo_str .= $dlp."\t\t".'<table class="wfu_rolelist_container"><tbody><tr><td>';
|
517 |
-
$echo_str .= $dlp."\t\t".'<select id="wfu_attribute_'.$attr.'" multiple="multiple" size="'.count($roles).'" onchange="wfu_update_rolelist_value(\''.$attr.'\');"'.( in_array('all', $selected) ? ' disabled="disabled"' : '' ).'>';
|
518 |
-
foreach ( $roles as $roleid => $rolename )
|
519 |
-
$echo_str .= $dlp."\t\t\t".'<option value="'.$roleid.'"'.( in_array($roleid, $rolesselected) ? ' selected="selected"' : '' ).'>'.$rolename.'</option>';
|
520 |
-
$echo_str .= $dlp."\t\t".'</select>';
|
521 |
-
$echo_str .= $dlp."\t\t".'</td><td>';
|
522 |
-
$echo_str .= $dlp."\t\t".'<div class="wfu_rolelist_checkbtn"><input class="'.( $default_administrator ? 'wfu_default_administrator' : '' ).'" id="wfu_attribute_'.$attr.'_all" type="checkbox" onchange="wfu_update_rolelist_value(\''.$attr.'\');"'.( in_array('all', $selected) ? ' checked="checked"' : '' ).' /><label for="wfu_attribute_'.$attr.'_all"> Select all</label></div><br />';
|
523 |
-
$echo_str .= $dlp."\t\t".'<div class="wfu_rolelist_checkbtn"><input id="wfu_attribute_'.$attr.'_guests" type="checkbox" onchange="wfu_update_rolelist_value(\''.$attr.'\');"'.( in_array("guests", $selected) ? ' checked="checked"' : '' ).' /><label for="wfu_attribute_'.$attr.'_guests"> Include guests</label></div>';
|
524 |
-
$echo_str .= $dlp."\t\t".'</td></tr></tbody></table>';
|
525 |
-
}
|
526 |
-
elseif ( $def['type'] == "userlist" ) {
|
527 |
-
$args = array();
|
528 |
-
/** This filter is documented in lib/wfu_admin_browser.php */
|
529 |
-
$args = apply_filters("_wfu_get_users", $args, "shortcode_composer");
|
530 |
-
$users = get_users($args);
|
531 |
-
$selected = explode(",", $def['value']);
|
532 |
-
$default_0 = ( is_array($def['listitems']) && in_array('default_0', $def['listitems']) );
|
533 |
-
if ( in_array('all', $selected) ) $usersselected = ( $default_0 ? array($users[0]->user_login) : array( ) );
|
534 |
-
else $usersselected = $selected;
|
535 |
-
$only_current = false;
|
536 |
-
$echo_str .= $dlp."\t\t".'<table class="wfu_userlist_container"><tbody><tr>';
|
537 |
-
if ( is_array($def['listitems']) && in_array('include_current', $def['listitems']) ) {
|
538 |
-
$only_current = ( $def['value'] == 'current' );
|
539 |
-
if ( $only_current ) $usersselected = ( $default_0 ? array($users[0]->user_login) : array( ) );
|
540 |
-
$echo_str .= $dlp."\t\t".'<td colspan="2"><div class="wfu_userlist_checkbtn"><input id="wfu_attribute_'.$attr.'_current" type="checkbox" onchange="wfu_update_userlist_value(\''.$attr.'\');"'.( $only_current ? ' checked="checked"' : '' ).' /><label for="wfu_attribute_'.$attr.'_current"> Only From Current User</label></div>';
|
541 |
-
$echo_str .= $dlp."\t\t".'</td></tr><tr>';
|
542 |
-
}
|
543 |
-
$echo_str .= $dlp."\t\t".'<td><select id="wfu_attribute_'.$attr.'" multiple="multiple" size="'.min(count($users), 10).'" onchange="wfu_update_userlist_value(\''.$attr.'\');"'.( $only_current || in_array('all', $selected) ? ' disabled="disabled"' : '' ).'>';
|
544 |
-
foreach ( $users as $userid => $user )
|
545 |
-
$echo_str .= $dlp."\t\t\t".'<option value="'.$user->user_login.'"'.( in_array($user->user_login, $usersselected) ? ' selected="selected"' : '' ).'>'.$user->display_name.' ('.$user->user_login.')</option>';
|
546 |
-
$echo_str .= $dlp."\t\t".'</select>';
|
547 |
-
$echo_str .= $dlp."\t\t".'</td><td>';
|
548 |
-
$echo_str .= $dlp."\t\t".'<div class="wfu_userlist_checkbtn"><input class="'.( $default_0 ? 'wfu_default_0' : '' ).'" id="wfu_attribute_'.$attr.'_all" type="checkbox" onchange="wfu_update_userlist_value(\''.$attr.'\');"'.( in_array('all', $selected) ? ' checked="checked"' : '' ).( $only_current ? ' disabled="disabled"' : '' ).' /><label for="wfu_attribute_'.$attr.'_all"> Select all</label></div><br />';
|
549 |
-
$echo_str .= $dlp."\t\t".'<div class="wfu_userlist_checkbtn"><input id="wfu_attribute_'.$attr.'_guests" type="checkbox" onchange="wfu_update_userlist_value(\''.$attr.'\');"'.( in_array("guests", $selected) ? ' checked="checked"' : '' ).( $only_current ? ' disabled="disabled"' : '' ).' /><label for="wfu_attribute_'.$attr.'_guests"> Include guests</label></div>';
|
550 |
-
$echo_str .= $dlp."\t\t".'</td></tr></tbody></table>';
|
551 |
-
}
|
552 |
-
elseif ( $def['type'] == "postlist" ) {
|
553 |
-
$processed = false;
|
554 |
-
if ( is_array($def['listitems']) ) {
|
555 |
-
$has_current = in_array('include_current', $def['listitems']);
|
556 |
-
if ( $has_current ) unset($def['listitems'][array_search('include_current', $def['listitems'])]);
|
557 |
-
foreach ( $def['listitems'] as $post_type ) {
|
558 |
-
// if a post type cannot be found then we reset the list so that it is not processed at all
|
559 |
-
if ( get_post_type_object( $post_type ) == null ) {
|
560 |
-
$def['listitems'] = array();
|
561 |
-
break;
|
562 |
-
}
|
563 |
-
}
|
564 |
-
if ( count($def['listitems']) > 0 ) {
|
565 |
-
$selected = explode(",", $def['value']);
|
566 |
-
$only_current = false;
|
567 |
-
$echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'_postlist" type="hidden" value="'.implode(",", $def['listitems']).'" />';
|
568 |
-
$echo_str .= $dlp."\t\t".'<table class="wfu_postlist_container"><tbody><tr>';
|
569 |
-
if ( $has_current ) {
|
570 |
-
$only_current = ( $def['value'] == 'current' );
|
571 |
-
if ( $only_current ) $sselected = array();
|
572 |
-
$echo_str .= $dlp."\t\t".'<td colspan="'.count($def['listitems']).'"><div class="wfu_postlist_checkbtn"><input id="wfu_attribute_'.$attr.'_current" type="checkbox" onchange="wfu_update_postlist_value(\''.$attr.'\');"'.( $only_current ? ' checked="checked"' : '' ).' /><label for="wfu_attribute_'.$attr.'_current"> Only From Current Post/Page</label></div>';
|
573 |
-
$echo_str .= $dlp."\t\t".'</td></tr><tr>';
|
574 |
-
}
|
575 |
-
$postargs = array( 'post_type' => $def['listitems'], 'post_status' => "publish,private,draft", 'posts_per_page' => -1 );
|
576 |
-
/** This filter is documented in lib/wfu_admin.php */
|
577 |
-
$postargs = apply_filters("_wfu_get_posts", $postargs, "visual_editor");
|
578 |
-
$posts = get_posts($postargs);
|
579 |
-
$list = wfu_construct_post_list($posts);
|
580 |
-
$td_width = (int)(100 / count($def['listitems']));
|
581 |
-
foreach ( $def['listitems'] as $post_type ) {
|
582 |
-
$flatlist = wfu_flatten_post_list($list[$post_type]);
|
583 |
-
$postobj = get_post_type_object( $post_type );
|
584 |
-
$echo_str .= $dlp."\t\t".'<td style="width:'.$td_width.'%;"><div class="wfu_postlist_header"><label>'.$postobj->label.'</label><div class="wfu_postlist_selectall"><input id="wfu_attribute_'.$attr.'_all_'.$post_type.'" type="checkbox" onchange="wfu_update_postlist_value(\''.$attr.'\');"'.( in_array('all', $selected) || in_array('all'.$post_type, $selected) ? ' checked="checked"' : '' ).( $only_current ? ' disabled="disabled"' : '' ).' /><label for="wfu_attribute_'.$attr.'_all_'.$post_type.'"> Select all</label></div></div>';
|
585 |
-
$echo_str .= $dlp."\t\t".'<select id="wfu_attribute_'.$attr.'_'.$post_type.'" multiple="multiple" size="'.min(count($flatlist), 10).'" onchange="wfu_update_postlist_value(\''.$attr.'\');"'.( $only_current || in_array('all', $selected) || in_array('all'.$post_type, $selected) ? ' disabled="disabled"' : '' ).' style="width:100%; overflow:auto;">';
|
586 |
-
foreach ( $flatlist as $item )
|
587 |
-
$echo_str .= $dlp."\t\t\t".'<option value="'.$item['id'].'"'.( in_array($item['id'], $selected) ? ' selected="selected"' : '' ).'>'.str_repeat(' ', 4 * $item['level']).( $item['status'] == 1 ? '[Private]' : ( $item['status'] == 2 ? '[Draft]' : '' ) ).$item['title'].'</option>';
|
588 |
-
$echo_str .= $dlp."\t\t".'</select></td>';
|
589 |
-
}
|
590 |
-
$echo_str .= $dlp."\t\t".'</tr></tbody></table>';
|
591 |
-
$processed = true;
|
592 |
-
}
|
593 |
-
}
|
594 |
-
if ( !$processed ) {
|
595 |
-
$val = str_replace(array( "%n%", "%dq%", "%brl%", "%brr%" ), array( "\n", """, "[", "]" ), $def['value']);
|
596 |
-
$echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" value="'.$val.'" />';
|
597 |
-
}
|
598 |
-
}
|
599 |
-
elseif ( $def['type'] == "bloglist" ) {
|
600 |
-
if ( function_exists('wp_get_sites') ) {
|
601 |
-
$blogs = wp_get_sites( );
|
602 |
-
$selected = explode(",", $def['value']);
|
603 |
-
if ( in_array('all', $selected) ) $blogsselected = array( );
|
604 |
-
else $blogsselected = $selected;
|
605 |
-
$only_current = false;
|
606 |
-
$echo_str .= $dlp."\t\t".'<table class="wfu_bloglist_container"><tbody><tr>';
|
607 |
-
if ( is_array($def['listitems']) && in_array('include_current', $def['listitems']) ) {
|
608 |
-
$only_current = ( $def['value'] == 'current' );
|
609 |
-
if ( $only_current ) $blogsselected = array( );
|
610 |
-
$echo_str .= $dlp."\t\t".'<td colspan="2"><div class="wfu_bloglist_checkbtn"><input id="wfu_attribute_'.$attr.'_current" type="checkbox" onchange="wfu_update_bloglist_value(\''.$attr.'\');"'.( $only_current ? ' checked="checked"' : '' ).' /><label for="wfu_attribute_'.$attr.'_current"> Only From Current Site</label></div>';
|
611 |
-
$echo_str .= $dlp."\t\t".'</td></tr><tr>';
|
612 |
-
}
|
613 |
-
$echo_str .= $dlp."\t\t".'<td><select id="wfu_attribute_'.$attr.'" multiple="multiple" size="'.min(count($blogs), 10).'" onchange="wfu_update_bloglist_value(\''.$attr.'\');"'.( $only_current || in_array('all', $selected) ? ' disabled="disabled"' : '' ).'>';
|
614 |
-
foreach ( $blogs as $blog )
|
615 |
-
$echo_str .= $dlp."\t\t\t".'<option value="'.$blog->blog_id.'"'.( in_array($blog->blog_id, $blogsselected) ? ' selected="selected"' : '' ).'>'.$blog->path.'</option>';
|
616 |
-
$echo_str .= $dlp."\t\t".'</select>';
|
617 |
-
$echo_str .= $dlp."\t\t".'</td><td>';
|
618 |
-
$echo_str .= $dlp."\t\t".'<div class="wfu_bloglist_checkbtn"><input id="wfu_attribute_'.$attr.'_all" type="checkbox" onchange="wfu_update_bloglist_value(\''.$attr.'\');"'.( in_array('all', $selected) ? ' checked="checked"' : '' ).( $only_current ? ' disabled="disabled"' : '' ).' /><label for="wfu_attribute_'.$attr.'_all"> Select all</label></div>';
|
619 |
-
$echo_str .= $dlp."\t\t".'</td></tr></tbody></table>';
|
620 |
-
}
|
621 |
-
else {
|
622 |
-
$val = str_replace(array( "%n%", "%dq%", "%brl%", "%brr%" ), array( "\n", """, "[", "]" ), $def['value']);
|
623 |
-
$echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" value="'.$val.'" />';
|
624 |
-
}
|
625 |
-
}
|
626 |
-
elseif ( $def['type'] == "stringmatch" ) {
|
627 |
-
$matchfield = "";
|
628 |
-
$matchcriterion = "equal to";
|
629 |
-
$matchvalue = "";
|
630 |
-
preg_match('/^field:(.*?);\s*criterion:(.*?)\s*;\s*value:(.*)$/', $def['value'], $matches);
|
631 |
-
if ( count($matches) == 4 ) {
|
632 |
-
$matchfield = $matches[1];
|
633 |
-
$matchcriterion = $matches[2];
|
634 |
-
$matchvalue = $matches[3];
|
635 |
-
}
|
636 |
-
// $echo_str .= $dlp."\t\t".'<div style="white-space:nowrap;">';
|
637 |
-
$echo_str .= $dlp."\t\t".'<table class="wfu_stringmatch_container"><tbody><tr>';
|
638 |
-
$echo_str .= $dlp."\t\t".'<td style="width:40%; white-space:nowrap;"><label>Field </label><input id="wfu_attribute_'.$attr.'_matchfield" type="text" name="wfu_stringmatch_elements" value="'.$matchfield.'" style="width:auto;" /></td>';
|
639 |
-
$echo_str .= $dlp."\t\t".'<td style="width:30%;"><select id="wfu_attribute_'.$attr.'_matchcriterion" value="'.$matchcriterion.'" onchange="wfu_update_stringmatch_value(\''.$attr.'\');">';
|
640 |
-
$echo_str .= $dlp."\t\t\t".'<option value="equal to"'.( $matchcriterion == "equal to" ? 'selected="selected"' : '' ).'>equal to</option>';
|
641 |
-
$echo_str .= $dlp."\t\t\t".'<option value="starts with"'.( $matchcriterion == "starts with" ? 'selected="selected"' : '' ).'>starts with</option>';
|
642 |
-
$echo_str .= $dlp."\t\t\t".'<option value="ends with"'.( $matchcriterion == "ends with" ? 'selected="selected"' : '' ).'>ends with</option>';
|
643 |
-
$echo_str .= $dlp."\t\t\t".'<option value="contains"'.( $matchcriterion == "contains" ? 'selected="selected"' : '' ).'>contains</option>';
|
644 |
-
$echo_str .= $dlp."\t\t\t".'<option value="not equal to"'.( $matchcriterion == "not equal to" ? 'selected="selected"' : '' ).'>not equal to</option>';
|
645 |
-
$echo_str .= $dlp."\t\t\t".'<option value="does not start with"'.( $matchcriterion == "does not start with" ? 'selected="selected"' : '' ).'>does not start with</option>';
|
646 |
-
$echo_str .= $dlp."\t\t\t".'<option value="does not end with"'.( $matchcriterion == "does not end with" ? 'selected="selected"' : '' ).'>does not end with</option>';
|
647 |
-
$echo_str .= $dlp."\t\t\t".'<option value="does not contain"'.( $matchcriterion == "does not contain" ? 'selected="selected"' : '' ).'>does not contain</option>';
|
648 |
-
$echo_str .= $dlp."\t\t".'</select></td>';
|
649 |
-
$echo_str .= $dlp."\t\t".'<td style="width:30%;"><input id="wfu_attribute_'.$attr.'_matchvalue" type="text" name="wfu_stringmatch_elements" value="'.$matchvalue.'" style="width:auto;" /></td>';
|
650 |
-
$echo_str .= $dlp."\t\t".'</tr></tbody></table>';
|
651 |
-
// $echo_str .= $dlp."\t\t".'</div>';
|
652 |
-
}
|
653 |
-
elseif ( $def['type'] == "columns" ) {
|
654 |
-
$selected = explode(",", $def['value']);
|
655 |
-
if ( count($selected) == 1 && $selected[0] == "" ) $selected = array();
|
656 |
-
$selected_flat = array();
|
657 |
-
foreach ( $selected as $ind => $item ) $selected_flat[$ind] = preg_replace("/(:|\/).*$/", "", $item);
|
658 |
-
$echo_str .= $dlp."\t".'<table class="wfu_columns_container"><tbody><tr>';
|
659 |
-
$echo_str .= $dlp."\t\t\t".'<td style="width:45%;"><label class="wfu_columns_listtitle">Available Columns</label></td>';
|
660 |
-
$echo_str .= $dlp."\t\t\t".'<td style="width:55%"><label class="wfu_columns_listtitle">Displayed Columns</label></td></tr><tr>';
|
661 |
-
$echo_str .= $dlp."\t\t".'<td style="width:45%;">';
|
662 |
-
$echo_str .= $dlp."\t\t\t".'<table class="wfu_columns_container" style="table-layout:fixed; width:100%;"><tbody><tr>';
|
663 |
-
$echo_str .= $dlp."\t\t\t\t".'<td><select id="wfu_attribute_'.$attr.'_sourcelist" multiple="multiple" size="'.min(count($def['listitems']), 10).'" style="width:100%; overflow:auto;">';
|
664 |
-
$itemprops = array();
|
665 |
-
foreach ( $def['listitems'] as $item ) {
|
666 |
-
$item_required = ( substr($item, 0, 1) == "*" );
|
667 |
-
if ( $item_required ) $item = substr($item, 1);
|
668 |
-
$item_parts = explode("/", $item, 3);
|
669 |
-
$item_name = $item_parts[0];
|
670 |
-
$item_label = "";
|
671 |
-
$item_title = "";
|
672 |
-
if ( count($item_parts) > 1 ) $item_label = $item_parts[1];
|
673 |
-
if ( count($item_parts) == 3 ) $item_title = $item_parts[2];
|
674 |
-
$item_parts = explode(":", $item_name, 2);
|
675 |
-
$item_name = $item_parts[0];
|
676 |
-
if ( count($item_parts) == 1 ) $item_sort = "";
|
677 |
-
else $item_sort = $item_parts[1];
|
678 |
-
if ( $item_label == "" ) $item_label = $item_name;
|
679 |
-
if ( $item_title == "" ) $item_title = $item_label;
|
680 |
-
$itemprops[$item_name] = array( 'label' => $item_label, 'title' => $item_title, 'required' => $item_required, 'sortable' => ( $item_name == "custom" || $item_sort != "" ), 'sorttype' => $item_sort );
|
681 |
-
$val = $item_name.":".$item_sort."/".$item_title;
|
682 |
-
$echo_str .= $dlp."\t\t\t\t\t".'<option value="'.$val.'"'.( $item_required ? ' class="wfu_columns_item_required"' : '' ).' onclick="wfu_columns_itemclicked(this, \''.$attr.'\');">'.$item_label.'</option>';
|
683 |
-
}
|
684 |
-
foreach ( $itemprops as $item_name => $prop )
|
685 |
-
if ( $prop['required'] && !in_array($item_name, $selected_flat) )
|
686 |
-
array_splice($selected, 0, 0, array( $item_name ));
|
687 |
-
$selprops = array();
|
688 |
-
foreach ( $selected as $item ) {
|
689 |
-
$item_parts = explode("/", $item, 2);
|
690 |
-
$item_name = $item_parts[0];
|
691 |
-
if ( count($item_parts) == 1 ) $item_title = "";
|
692 |
-
else $item_title = $item_parts[1];
|
693 |
-
$item_parts = explode(":", $item_name, 2);
|
694 |
-
$item_name = $item_parts[0];
|
695 |
-
$flat_name = preg_replace("/^custom[0-9]+$/", "custom", $item_name);
|
696 |
-
if ( $item_name != "custom" && isset($itemprops[$flat_name]) ) {
|
697 |
-
$prop = $itemprops[$flat_name];
|
698 |
-
if ( count($item_parts) == 1 ) $item_sort = ( $flat_name == "custom" ? "+-s" : ( $prop['sortable'] ? "-+".$prop['sorttype'] : "" ) );
|
699 |
-
elseif ( $flat_name == "custom" ) $item_sort = "+".($item_parts[1] == "" ? "-s" : "+".$item_parts[1]);
|
700 |
-
else $item_sort = ( $prop['sortable'] ? "-".($item_parts[1] == "" ? "-" : "+").$prop['sorttype'].substr($item_parts[1], 1, 1) : "" );
|
701 |
-
if ( $item_title == "" ) $item_title = $prop['title'];
|
702 |
-
array_push($selprops, array( 'name' => $item_name, 'label' => $prop['label'], 'title' => $item_title, 'required' => $prop['required'], 'sorttype' => $item_sort ));
|
703 |
-
}
|
704 |
-
}
|
705 |
-
$echo_str .= $dlp."\t\t\t\t".'</select></td>';
|
706 |
-
$echo_str .= $dlp."\t\t\t\t".'<td style="width:30px; padding:0 6px;"><button class="wfu_columns_addbutton" title="add column" onclick="wfu_columns_buttonaction(\''.$attr.'\', \'add\');" style="width:100%;">>></button></td>';
|
707 |
-
$echo_str .= $dlp."\t\t\t".'</tr></tbody></table>';
|
708 |
-
$echo_str .= $dlp."\t\t".'</td>';
|
709 |
-
$echo_str .= $dlp."\t\t".'<td style="width:55%">';
|
710 |
-
$echo_str .= $dlp."\t\t\t".'<table class="wfu_columns_container" style="table-layout:fixed; width:100%;"><tbody><tr>';
|
711 |
-
$echo_str .= $dlp."\t\t\t\t".'<td><select id="wfu_attribute_'.$attr.'" multiple="multiple" size="'.min(count($def['listitems']), 10).'" onchange="wfu_update_columns(\''.$attr.'\');" style="width:100%; overflow:auto;">';
|
712 |
-
foreach ( $selprops as $prop ) {
|
713 |
-
$val = $prop['name'].":".$prop['sorttype']."/".$prop['label']."/".$prop['title'];
|
714 |
-
$echo_str .= $dlp."\t\t\t\t\t".'<option value="'.$val.'"'.( $prop['required'] ? ' class="wfu_columns_item_required"' : '' ).' onclick="wfu_columns_itemclicked(this, \''.$attr.'\');">'.$prop['label'].( $prop['title'] != "" && $prop['title'] != $prop['label'] ? " (".$prop['title'].")" : "" ).'</option>';
|
715 |
-
}
|
716 |
-
$echo_str .= $dlp."\t\t\t\t".'</select></td>';
|
717 |
-
$echo_str .= $dlp."\t\t\t\t".'<td style="width:30px; padding:0 6px;">';
|
718 |
-
$echo_str .= $dlp."\t\t\t\t\t".'<button class="wfu_columns_addbutton" title="move up" onclick="wfu_columns_buttonaction(\''.$attr.'\', \'up\');" style="width:100%;">↑</button>';
|
719 |
-
$echo_str .= $dlp."\t\t\t\t\t".'<button class="wfu_columns_addbutton" title="remove" onclick="wfu_columns_buttonaction(\''.$attr.'\', \'del\');" style="width:100%;">-</button>';
|
720 |
-
$echo_str .= $dlp."\t\t\t\t\t".'<button class="wfu_columns_addbutton" title="move down" onclick="wfu_columns_buttonaction(\''.$attr.'\', \'down\');" style="width:100%;">↓</button>';
|
721 |
-
$echo_str .= $dlp."\t\t\t\t".'</td>';
|
722 |
-
$echo_str .= $dlp."\t\t\t".'</tr></tbody></table>';
|
723 |
-
$echo_str .= $dlp."\t\t\t".'<label class="wfu_columns_listtitle" style="margin-top:6px; display:block;">Column Properties</label>';
|
724 |
-
$echo_str .= $dlp."\t\t\t".'<table id="wfu_attribute_'.$attr.'_columnprops_container" class="wfu_columnprops_container wfu_columnprops_container_disabled"><tbody>';
|
725 |
-
$echo_str .= $dlp."\t\t\t\t".'<tr><td style="width:1%; padding-right:10px;"><label id="wfu_attribute_'.$attr.'_columnprops_title_label">Title</label></td>';
|
726 |
-
$echo_str .= $dlp."\t\t\t\t".'<td><input type="text" id="wfu_attribute_'.$attr.'_columnprops_title" name="wfu_columnprops_elements" value="" style="width:100%;" disabled="disabled" /></td></tr>';
|
727 |
-
$echo_str .= $dlp."\t\t\t\t".'<tr><td style="width:1%; padding-right:10px; white-space:nowrap;"><label id="wfu_attribute_'.$attr.'_columnprops_id_label">Field ID</label></td>';
|
728 |
-
$echo_str .= $dlp."\t\t\t\t".'<td><input type="number" id="wfu_attribute_'.$attr.'_columnprops_id" name="wfu_columnprops_elements" min="1" value="" style="width:100%;" disabled="disabled" /></td></tr>';
|
729 |
-
$echo_str .= $dlp."\t\t\t\t".'<tr><td colspan="2"><input type="checkbox" id="wfu_attribute_'.$attr.'_columnprops_sort" value="" onchange="wfu_columnprops_element_changed({target:this});" disabled="disabled" /><label id="wfu_attribute_'.$attr.'_columnprops_sort_label" for="wfu_attribute_'.$attr.'_columnprops_sort">Sortable</label></td></tr>';
|
730 |
-
$echo_str .= $dlp."\t\t\t\t".'<tr><td style="width:1%; padding-right:10px;"><label id="wfu_attribute_'.$attr.'_columnprops_sorttype_label" style="white-space:nowrap;">Sort As</label></td>';
|
731 |
-
$echo_str .= $dlp."\t\t\t\t".'<td><select id="wfu_attribute_'.$attr.'_columnprops_sorttype" value="" onchange="wfu_columnprops_element_changed({target:this});" disabled="disabled"><option value=""></option><option value="s">String</option><option value="n">Integer</option></select></td></tr>';
|
732 |
-
$echo_str .= $dlp."\t\t\t\t".'<tr><td style="width:1%; padding-right:10px;"><label id="wfu_attribute_'.$attr.'_columnprops_defaultsort_label" style="white-space:nowrap;">Default Sort</label></td>';
|
733 |
-
$echo_str .= $dlp."\t\t\t\t".'<td><select id="wfu_attribute_'.$attr.'_columnprops_defaultsort" value="" onchange="wfu_columnprops_element_changed({target:this});" disabled="disabled"><option value=" "></option><option value="+">Ascending</option><option value="-">Descending</option></select></td></tr>';
|
734 |
-
$echo_str .= $dlp."\t\t\t".'</tbody></table>';
|
735 |
-
$echo_str .= $dlp."\t\t".'</td>';
|
736 |
-
$echo_str .= $dlp."\t".'</tr></tbody></table>';
|
737 |
-
|
738 |
-
}
|
739 |
-
elseif ( $def['type'] == "dimensions" ) {
|
740 |
-
$vals_arr = explode(",", $def['value']);
|
741 |
-
$vals = array();
|
742 |
-
foreach ( $vals_arr as $val_raw ) {
|
743 |
-
if ( trim($val_raw) != "" ) {
|
744 |
-
list($val_id, $val) = explode(":", $val_raw);
|
745 |
-
$vals[trim($val_id)] = trim($val);
|
746 |
-
}
|
747 |
-
}
|
748 |
-
$dims = array();
|
749 |
-
foreach ( $components as $comp ) {
|
750 |
-
if ( $comp['dimensions'] == null ) $dims[$comp['id']] = $comp['name'];
|
751 |
-
else foreach ( $comp['dimensions'] as $dimraw ) {
|
752 |
-
list($dim_id, $dim_name) = explode("/", $dimraw);
|
753 |
-
$dims[$dim_id] = $dim_name;
|
754 |
-
}
|
755 |
-
}
|
756 |
-
foreach ( $dims as $dim_id => $dim_name ) {
|
757 |
-
if ( !array_key_exists($dim_id, $vals) ) $vals[$dim_id] = "";
|
758 |
-
$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 />';
|
759 |
-
}
|
760 |
-
}
|
761 |
-
elseif ( $def['type'] == "userfields" ) {
|
762 |
-
$fields_arr = explode("/", $def['value']);
|
763 |
-
$fields = array();
|
764 |
-
foreach ( $fields_arr as $field_raw ) {
|
765 |
-
$is_req = ( substr($field_raw, 0, 1) == "*" );
|
766 |
-
if ( $is_req ) $field_raw = substr($field_raw, 1);
|
767 |
-
if ( $field_raw != "" ) array_push($fields, array( "name" => $field_raw, "required" => $is_req ));
|
768 |
-
}
|
769 |
-
if ( count($fields) == 0 ) array_push($fields, array( "name" => "", "required" => false ));
|
770 |
-
$echo_str .= $dlp."\t\t".'<div id="wfu_attribute_'.$attr.'" class="wfu_userdata_container">';
|
771 |
-
foreach ( $fields as $field ) {
|
772 |
-
$echo_str .= $dlp."\t\t\t".'<div class="wfu_userdata_line">';
|
773 |
-
$echo_str .= $dlp."\t\t\t\t".'<input type="text" name="wfu_userfield_elements" value="'.$field['name'].'" />';
|
774 |
-
$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>';
|
775 |
-
$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>';
|
776 |
-
$echo_str .= $dlp."\t\t\t\t".'<input type="checkbox"'.( $field['required'] ? 'checked="checked"' : '' ).' onchange="wfu_update_userfield_value({target:this});" />';
|
777 |
-
$echo_str .= $dlp."\t\t\t\t".'<span>Required</span>';
|
778 |
-
$echo_str .= $dlp."\t\t\t".'</div>';
|
779 |
-
}
|
780 |
-
$echo_str .= $dlp."\t\t".'</div>';
|
781 |
-
}
|
782 |
-
elseif ( $def['type'] == "formfields" ) {
|
783 |
-
//find occurrence index of this attribute and total occrrence length
|
784 |
-
$flat = $def['flat'];
|
785 |
-
$attr_occur_index = 0;
|
786 |
-
$attr_occur_length = 0;
|
787 |
-
$all_attributes = array();
|
788 |
-
foreach ( $defs as $def2 ) {
|
789 |
-
if ( $def2['flat'] == $flat ) {
|
790 |
-
$attr_occur_length ++;
|
791 |
-
array_push($all_attributes, $def2['attribute']);
|
792 |
-
if ( $def2['attribute'] == $attr ) $attr_occur_index = $attr_occur_length;
|
793 |
-
}
|
794 |
-
}
|
795 |
-
//get field type definitions
|
796 |
-
$fielddefs_array = $def['listitems'];
|
797 |
-
foreach ( $fielddefs_array as $fielddef ) $fielddefs[$fielddef['type']] = $fielddef;
|
798 |
-
//initialize editable field properties
|
799 |
-
$fieldprops_basic = array('label', 'required', 'donotautocomplete', 'validate', 'typehook', 'labelposition', 'hintposition', 'default', 'data', 'group', 'format');
|
800 |
-
$fieldprops_default = array ( "type" => "text", "label" => "", "labelposition" => "left", "required" => false, "donotautocomplete" => false, "validate" => false, "default" => "", "data" => "", "group" => "", "format" => "", "hintposition" => "right", "typehook" => false );
|
801 |
-
//parse shortcode attribute to $fields
|
802 |
-
$fields = wfu_parse_userdata_attribute($def['value']);
|
803 |
-
$labelpositions = array("none", "top", "right", "bottom", "left", "placeholder");
|
804 |
-
$hintpositions = array("none", "inline", "top", "right", "bottom", "left");
|
805 |
-
if ( count($fields) == 0 ) array_push($fields, $fieldprops_default);
|
806 |
-
//set html template variable
|
807 |
-
$template = $dlp."\t\t\t\t".'<table class="wfu_formdata_props_table"><tbody>';
|
808 |
-
$template .= $dlp."\t\t\t\t".'<tr><td colspan="2"><label class="wfu_formdata_label">Type</label><select id="wfu_formfield_[[key]]_type" value="[[t]]" onchange="wfu_formdata_type_changed(\'[[key]]\');">';
|
809 |
-
foreach( $fielddefs as $item ) $template .= $dlp."\t\t\t\t\t".'<option value="'.$item['type'].'"[[type_'.$item['type'].'_selected]]>'.$item['type_description'].'</option>';
|
810 |
-
$template .= $dlp."\t\t\t\t".'</select></td><td>';
|
811 |
-
$template .= $dlp."\t\t\t\t".'<div class="wfu_formdata_action wfu_formdata_action_add" onclick="wfu_formdata_add_field(\'[[key]]\');"><img src="'.WFU_IMAGE_ADMIN_USERDATA_ADD.'" ></div>';
|
812 |
-
$template .= $dlp."\t\t\t\t".'<div class="wfu_formdata_action wfu_formdata_action_remove[[remove_disabled]]" onclick="wfu_formdata_remove_field(\'[[key]]\');"><img src="'.WFU_IMAGE_ADMIN_USERDATA_REMOVE.'" ></div>';
|
813 |
-
$template .= $dlp."\t\t\t\t".'<div class="wfu_formdata_action wfu_formdata_action_up[[up_disabled]]" onclick="wfu_formdata_move_field(\'[[key]]\', \'up\');"><img src="'.WFU_IMAGE_ADMIN_USERDATA_UP.'" ></div>';
|
814 |
-
$template .= $dlp."\t\t\t\t".'<div class="wfu_formdata_action wfu_formdata_action_down[[down_disabled]]" onclick="wfu_formdata_move_field(\'[[key]]\', \'down\');"><img src="'.WFU_IMAGE_ADMIN_USERDATA_DOWN.'" ></div></td></tr>';
|
815 |
-
$template .= $dlp."\t\t\t\t".'<tr><td class="wfu_formdata_props"><label class="wfu_formdata_label" title="[[label_hint]]">[[label_label]]</label></td><td><input type="text" id="wfu_formfield_[[key]]_label" name="wfu_formfield_elements" value="[[label]]" /></td><td></td></tr>';
|
816 |
-
$labelpos_options = "";
|
817 |
-
foreach ( $labelpositions as $pos ) $labelpos_options .= '<option value="'.$pos.'"[[labelposition_'.$pos.'_selected]]>'.$pos.'</option>';
|
818 |
-
$template .= '[[S->]]'.$dlp."\t\t\t\t".'<tr><td class="wfu_formdata_props"><label class="wfu_formdata_labelposition" title="[[labelposition_hint]]">Label Position</label></td><td><select id="wfu_formfield_[[key]]_labelposition" value="[[s]]" title="[[labelposition_hint]]" onchange="wfu_update_formfield_value({target:this});">'.$labelpos_options.'</select></td><td></td></tr>[[<-S]]';
|
819 |
-
$template .= '[[R->]]'.$dlp."\t\t\t\t".'<tr><td colspan="2" class="wfu_formdata_props"><input id="wfu_formfield_[[key]]_required" type="checkbox"[[r->]] checked="checked"[[<-r]] title="[[required_hint]]" onchange="wfu_update_formfield_value({target:this});" /><label for="wfu_formfield_[[key]]_required" title="[[required_hint]]"> Required</label></td><td></td></tr>[[<-R]]';
|
820 |
-
$template .= '[[A->]]'.$dlp."\t\t\t\t".'<tr><td colspan="2" class="wfu_formdata_props"><input id="wfu_formfield_[[key]]_donotautocomplete" type="checkbox"[[a->]] checked="checked"[[<-a]] title="[[donotautocomplete_hint]]" onchange="wfu_update_formfield_value({target:this});" /><label for="wfu_formfield_[[key]]_donotautocomplete" title="[[donotautocomplete_hint]]"> Do not autocomplete</label></td><td></td></tr>[[<-A]]';
|
821 |
-
$template .= '[[V->]]'.$dlp."\t\t\t\t".'<tr><td colspan="2" class="wfu_formdata_props"><input id="wfu_formfield_[[key]]_validate" type="checkbox"[[v->]] checked="checked"[[<-v]] title="[[validate_hint]]" onchange="wfu_update_formfield_value({target:this});" /><label for="wfu_formfield_[[key]]_validate" title="[[validate_hint]]"> Validate</label></td><td></td></tr>[[<-V]]';
|
822 |
-
$hint_options = "";
|
823 |
-
foreach ( $hintpositions as $pos ) $hint_options .= '<option value="'.$pos.'"[[hintposition_'.$pos.'_selected]]>'.$pos.'</option>';
|
824 |
-
$template .= '[[P->]]'.$dlp."\t\t\t\t".'<tr><td class="wfu_formdata_props"><label class="wfu_formdata_label" title="[[hintposition_hint]]">Hint Position</label></td><td><select id="wfu_formfield_[[key]]_hintposition" value="[[p]]" title="[[hintposition_hint]]" onchange="wfu_update_formfield_value({target:this});">'.$hint_options.'</select></td><td></td></tr>[[<-P]]';
|
825 |
-
$template .= '[[H->]]'.$dlp."\t\t\t\t".'<tr><td colspan="2" class="wfu_formdata_props"><input id="wfu_formfield_[[key]]_typehook" type="checkbox"[[h->]] checked="checked"[[<-h]] title="[[typehook_hint]]" onchange="wfu_update_formfield_value({target:this});" /><label for="wfu_formfield_[[key]]_typehook" title="[[typehook_hint]]"> Type hook</label></td><td></td></tr>[[<-H]]';
|
826 |
-
$template .= '[[D->]]'.$dlp."\t\t\t\t".'<tr><td class="wfu_formdata_props"><label class="wfu_formdata_label" title="[[default_hint]]">Default</label></td><td><input id="wfu_formfield_[[key]]_default" type="text" name="wfu_formfield_elements" value="[[d]]" title="[[default_hint]]" /></td><td></td></tr>[[<-D]]';
|
827 |
-
$template .= '[[L->]]'.$dlp."\t\t\t\t".'<tr><td class="wfu_formdata_props"><label class="wfu_formdata_label" title="[[data_hint]]">[[data_label]]</label></td><td><input id="wfu_formfield_[[key]]_data" type="text" name="wfu_formfield_elements" value="[[l]]" title="[[data_hint]]" /></td><td></td></tr>[[<-L]]';
|
828 |
-
$template .= '[[G->]]'.$dlp."\t\t\t\t".'<tr><td class="wfu_formdata_props"><label class="wfu_formdata_label" title="[[group_hint]]">Group ID</label></td><td><input id="wfu_formfield_[[key]]_group" type="text" name="wfu_formfield_elements" value="[[g]]" title="[[group_hint]]" /></td><td></td></tr>[[<-G]]';
|
829 |
-
$template .= '[[F->]]'.$dlp."\t\t\t\t".'<tr><td class="wfu_formdata_props"><label class="wfu_formdata_label" title="[[format_hint]]">Format</label></td><td><input id="wfu_formfield_[[key]]_format" type="text" name="wfu_formfield_elements" value="[[f]]" title="[[format_hint]]" /></td><td></td></tr>[[<-F]]';
|
830 |
-
$template .= $dlp."\t\t\t\t".'</tbody></table>';
|
831 |
-
//draw html elements
|
832 |
-
$echo_str .= $dlp."\t\t".'<div id="wfu_attribute_'.$attr.'" class="wfu_formdata_container">';
|
833 |
-
$echo_str .= $dlp."\t\t\t".'<input type="hidden" class="wfu_formdata_all_attributes" value="'.implode(",", $all_attributes).'" />';
|
834 |
-
$echo_str .= $dlp."\t\t\t".'<div id="wfu_attribute_'.$attr.'_codeadd" style="display:none;">';
|
835 |
-
//pass template and type props to client javascript variable and then erase the code
|
836 |
-
$echo_str .= $dlp."\t\t\t\t".'<script type="text/javascript">';
|
837 |
-
$echo_str .= $dlp."\t\t\t\t\t".'var wfu_attribute_'.$attr.'_formtemplate = "'.wfu_plugin_encode_string($template).'";';
|
838 |
-
$echo_str .= $dlp."\t\t\t\t\t".'var wfu_attribute_'.$attr.'_typeprops = {};';
|
839 |
-
$fielddef_array = array();
|
840 |
-
foreach( $fielddefs as $item ) array_push($fielddef_array, $item['type']);
|
841 |
-
//prepare storage of field definitions to browser context
|
842 |
-
$echo_str .= $dlp."\t\t\t\t\t".'wfu_attribute_'.$attr.'_typeprops[0] = \''.implode(",", $fielddef_array).'\'';
|
843 |
-
foreach( $fielddefs as $item ) {
|
844 |
-
$typeprops = array();
|
845 |
-
foreach ( $fieldprops_basic as $prop ) {
|
846 |
-
array_push($typeprops, $prop.': \''.$item[$prop].'\'');
|
847 |
-
array_push($typeprops, $prop.'_hint: \''.$item[$prop.'_hint'].'\'');
|
848 |
-
}
|
849 |
-
array_push($typeprops, 'label_label: \''.$item['label_label'].'\'');
|
850 |
-
array_push($typeprops, 'data_label: \''.$item['data_label'].'\'');
|
851 |
-
$echo_str .= $dlp."\t\t\t\t\t".'wfu_attribute_'.$attr.'_typeprops["'.$item['type'].'"] = {'.implode(", ", $typeprops).'};';
|
852 |
-
}
|
853 |
-
$echo_str .= $dlp."\t\t\t\t\t".'var self = document.getElementById("wfu_attribute_'.$attr.'_codeadd"); self.parentNode.removeChild(self);';
|
854 |
-
$echo_str .= $dlp."\t\t\t\t".'</script>';
|
855 |
-
$echo_str .= $dlp."\t\t\t".'</div>';
|
856 |
-
$i = 1;
|
857 |
-
foreach ( $fields as $field ) {
|
858 |
-
$ind = wfu_create_random_string(4);
|
859 |
-
$key = $attr."_".$ind;
|
860 |
-
$fielddef = $fielddefs[$field["type"]];
|
861 |
-
$echo_str .= $dlp."\t\t\t".'<div id="wfu_formfield_'.$key.'_container" class="wfu_formdata_line_container">';
|
862 |
-
//generate html elements from template, replacing variables where applicable
|
863 |
-
$from_template = str_replace(array('[[key]]', '[[t]]', '[[label]]', '[[s]]', '[[d]]', '[[l]]', '[[label_label]]', '[[data_label]]', '[[g]]', '[[f]]', '[[p]]'), array($key, $field['type'], $field['label'], $field['labelposition'], $field['default'], $field['data'], $fielddef['label_label'], $fielddef['data_label'], $field['group'], $field['format'], $field['hintposition']), $template);
|
864 |
-
foreach ( $fieldprops_basic as $prop ) $from_template = str_replace('[['.$prop.'_hint]]', str_replace('\r\n', "\r\n", $fielddef[$prop.'_hint']), $from_template);
|
865 |
-
foreach( $fielddefs as $item ) $from_template = str_replace('[[type_'.$item['type'].'_selected]]', ( $item['type'] == $field['type'] ? ' selected = "selected"' : '' ), $from_template);
|
866 |
-
foreach( $labelpositions as $pos ) $from_template = str_replace('[[labelposition_'.$pos.'_selected]]', ( $pos == $field['labelposition'] ? ' selected = "selected"' : '' ), $from_template);
|
867 |
-
foreach( $hintpositions as $pos ) $from_template = str_replace('[[hintposition_'.$pos.'_selected]]', ( $pos == $field['hintposition'] ? ' selected = "selected"' : '' ), $from_template);
|
868 |
-
$from_template = str_replace('[[remove_disabled]]', ( count($fields) <= 1 ? ' wfu_formdata_action_disabled' : '' ), $from_template);
|
869 |
-
$from_template = str_replace('[[up_disabled]]', ( ( $attr_occur_index == 1 && $i == 1 ) ? ' wfu_formdata_action_disabled' : '' ), $from_template);
|
870 |
-
$from_template = str_replace('[[down_disabled]]', ( ( $attr_occur_index == $attr_occur_length && $i == count($fields) ) ? ' wfu_formdata_action_disabled' : '' ), $from_template);
|
871 |
-
//adjust checkbox field values
|
872 |
-
$from_template = preg_replace('/\[\[r\-\>\]\]'.( $field['required'] ? '|' : '.*' ).'\[\[\<\-r\]\]/', '', $from_template);
|
873 |
-
$from_template = preg_replace('/\[\[a\-\>\]\]'.( $field['donotautocomplete'] ? '|' : '.*' ).'\[\[\<\-a\]\]/', '', $from_template);
|
874 |
-
$from_template = preg_replace('/\[\[v\-\>\]\]'.( $field['validate'] ? '|' : '.*' ).'\[\[\<\-v\]\]/', '', $from_template);
|
875 |
-
$from_template = preg_replace('/\[\[h\-\>\]\]'.( $field['typehook'] ? '|' : '.*' ).'\[\[\<\-h\]\]/', '', $from_template);
|
876 |
-
//adjust visibility of properties
|
877 |
-
$from_template = preg_replace('/\[\[S\-\>\]\]'.( substr($fielddef["labelposition"], 0, 4) == "show" ? '|' : '.*' ).'\[\[\<\-S\]\]/s', '', $from_template);
|
878 |
-
$from_template = preg_replace('/\[\[R\-\>\]\]'.( substr($fielddef["required"], 0, 4) == "show" ? '|' : '.*' ).'\[\[\<\-R\]\]/s', '', $from_template);
|
879 |
-
$from_template = preg_replace('/\[\[A\-\>\]\]'.( substr($fielddef["donotautocomplete"], 0, 4) == "show" ? '|' : '.*' ).'\[\[\<\-A\]\]/s', '', $from_template);
|
880 |
-
$from_template = preg_replace('/\[\[V\-\>\]\]'.( substr($fielddef["validate"], 0, 4) == "show" ? '|' : '.*' ).'\[\[\<\-V\]\]/s', '', $from_template);
|
881 |
-
$from_template = preg_replace('/\[\[P\-\>\]\]'.( substr($fielddef["hintposition"], 0, 4) == "show" ? '|' : '.*' ).'\[\[\<\-P\]\]/s', '', $from_template);
|
882 |
-
$from_template = preg_replace('/\[\[H\-\>\]\]'.( substr($fielddef["typehook"], 0, 4) == "show" ? '|' : '.*' ).'\[\[\<\-H\]\]/s', '', $from_template);
|
883 |
-
$from_template = preg_replace('/\[\[D\-\>\]\]'.( substr($fielddef["default"], 0, 4) == "show" ? '|' : '.*' ).'\[\[\<\-D\]\]/s', '', $from_template);
|
884 |
-
$from_template = preg_replace('/\[\[L\-\>\]\]'.( substr($fielddef["data"], 0, 4) == "show" ? '|' : '.*' ).'\[\[\<\-L\]\]/s', '', $from_template);
|
885 |
-
$from_template = preg_replace('/\[\[G\-\>\]\]'.( substr($fielddef["group"], 0, 4) == "show" ? '|' : '.*' ).'\[\[\<\-G\]\]/s', '', $from_template);
|
886 |
-
$from_template = preg_replace('/\[\[F\-\>\]\]'.( substr($fielddef["format"], 0, 4) == "show" ? '|' : '.*' ).'\[\[\<\-F\]\]/s', '', $from_template);
|
887 |
-
$echo_str .= $from_template;
|
888 |
-
$echo_str .= $dlp."\t\t\t".'</div>';
|
889 |
-
$i++;
|
890 |
-
}
|
891 |
-
$echo_str .= $dlp."\t\t".'</div>';
|
892 |
-
}
|
893 |
-
elseif ( $def['type'] == "color" ) {
|
894 |
-
$val = str_replace(array( "%n%", "%dq%", "%brl%", "%brr%" ), array( "\n", """, "[", "]" ), $def['value']);
|
895 |
-
$echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" class="wfu_color_field" value="'.$val.'" />';
|
896 |
-
}
|
897 |
-
elseif ( $def['type'] == "color-triplet" ) {
|
898 |
-
$triplet = explode(",", $def['value']);
|
899 |
-
foreach ( $triplet as $key => $item ) $triplet[$key] = trim($item);
|
900 |
-
if ( count($triplet) == 2 ) $triplet = array( $triplet[0], $triplet[1], "#000000");
|
901 |
-
elseif ( count($triplet) == 1 ) $triplet = array( $triplet[0], "#FFFFFF", "#000000");
|
902 |
-
elseif ( count($triplet) < 3 ) $triplet = array( "#000000", "#FFFFFF", "#000000");
|
903 |
-
$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>';
|
904 |
-
$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>';
|
905 |
-
$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>';
|
906 |
-
}
|
907 |
-
else {
|
908 |
-
$echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" value="'.$def['value'].'" />';
|
909 |
-
if ( $def['variables'] != null ) $echo_str .= $dlp.wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
|
910 |
-
}
|
911 |
-
$echo_str .= $dlp."\t".'</div></td>';
|
912 |
-
if ( $def['parent'] == "" ) {
|
913 |
-
$echo_str .= $dlp."\t".'<td style="position:relative; vertical-align:top; padding:0;"><div class="wfu_td_div">';
|
914 |
-
$block_open = false;
|
915 |
-
}
|
916 |
-
else {
|
917 |
-
$echo_str .= $dlp.'</tr>';
|
918 |
-
$subblock_open = true;
|
919 |
-
}
|
920 |
-
}
|
921 |
-
if ( $subblock_open ) {
|
922 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</div>';
|
923 |
-
}
|
924 |
-
if ( $block_open ) {
|
925 |
-
$echo_str .= "\n\t\t\t\t\t".'</div></td>';
|
926 |
-
$echo_str .= "\n\t\t\t\t".'</tr>';
|
927 |
-
}
|
928 |
-
$echo_str .= "\n\t\t\t".'</tbody>';
|
929 |
-
$echo_str .= "\n\t\t".'</table>';
|
930 |
-
$echo_str .= "\n\t".'</div>';
|
931 |
-
$echo_str .= "\n\t".'<div id="wfu_global_dialog_container" class="wfu_global_dialog_container">';
|
932 |
-
$echo_str .= "\n\t".'</div>';
|
933 |
-
$handler = 'function() { wfu_Attach_Admin_Events('.( $data == "" ? 'true' : 'false' ).'); }';
|
934 |
-
$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>';
|
935 |
-
$echo_str .= "\n".'</div>';
|
936 |
-
// $echo_str .= "\n\t".'<div style="margin-top:10px;">';
|
937 |
-
// $echo_str .= "\n\t\t".'<label>Final shortcode text</label>';
|
938 |
-
// $echo_str .= "\n\t".'</div>';
|
939 |
-
|
940 |
-
echo $echo_str;
|
941 |
-
}
|
942 |
-
|
943 |
-
/**
|
944 |
-
* Insert Variables in an Attribute.
|
945 |
-
*
|
946 |
-
* This function generates the HTML code of the variables that are shown below
|
947 |
-
* the attribute which they refer to.
|
948 |
-
*
|
949 |
-
* @since 2.1.3
|
950 |
-
*
|
951 |
-
* @param array $variables. The array of variables to display below the
|
952 |
-
* attribute.
|
953 |
-
* @param string $class A class name to set in the elements of the generated
|
954 |
-
* HTML code.
|
955 |
-
*
|
956 |
-
* @return string The HTML output of the variables.
|
957 |
-
*/
|
958 |
-
function wfu_insert_variables($variables, $class) {
|
959 |
-
$ret = "";
|
960 |
-
foreach ( $variables as $variable )
|
961 |
-
if ( $variable == "%userdataXXX%" ) $ret .= "\t\t".'<select class="'.$class.'" name="wfu_formfield_select" title="'.constant("WFU_VARIABLE_TITLE_".strtoupper(str_replace("%", "", $variable))).'" onchange="wfu_insert_userfield_variable(this);"><option style="display:none;">%userdataXXX%</option></select>';
|
962 |
-
elseif ( $variable != "%n%" && $variable != "%dq%" && $variable != "%brl%" && $variable != "%brr%" ) $ret .= "\t\t".'<span class="'.$class.'" title="'.constant("WFU_VARIABLE_TITLE_".strtoupper(str_replace("%", "", $variable))).'" ondblclick="wfu_insert_variable(this);">'.$variable.'</span>';
|
963 |
-
return $ret;
|
964 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Shortcode Composer Page
|
5 |
+
*
|
6 |
+
* This file contains functions related to the shortcode composer page of the
|
7 |
+
* plugin. The shortcode composer is a visual editor of the plugin's shortcodes
|
8 |
+
* so that they can be configured easily by administrators.
|
9 |
+
*
|
10 |
+
* @link /lib/wfu_admin_composer.php
|
11 |
+
*
|
12 |
+
* @package WordPress File Upload Plugin
|
13 |
+
* @subpackage Core Components
|
14 |
+
* @since 2.4.1
|
15 |
+
*/
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Display the Shortcode Composer.
|
19 |
+
*
|
20 |
+
* This function displays the shortcode composer for a specific shortcode.
|
21 |
+
*
|
22 |
+
* @since 2.1.2
|
23 |
+
*
|
24 |
+
* @param string|array $data Optional. If this function was called for an
|
25 |
+
* existing shortcode, this param holds data of the shortcode. If it was
|
26 |
+
* called for a new shortcode, it contains an empty string.
|
27 |
+
* @param string $shortcode_tag Optional. The shortcode tag.
|
28 |
+
* @param string $referer Optional. The page that called this function.
|
29 |
+
*
|
30 |
+
* @return string The HTML output of the shortcode composer.
|
31 |
+
*/
|
32 |
+
function wfu_shortcode_composer($data = '', $shortcode_tag = 'wordpress_file_upload', $referer = 'page') {
|
33 |
+
global $wp_roles;
|
34 |
+
$siteurl = site_url();
|
35 |
+
|
36 |
+
$plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
|
37 |
+
$components = wfu_component_definitions();
|
38 |
+
if ( $shortcode_tag == 'wordpress_file_upload' ) {
|
39 |
+
$plugin_title = "Uploader";
|
40 |
+
$cats = wfu_category_definitions();
|
41 |
+
$defs = wfu_attribute_definitions();
|
42 |
+
//remove personaldata category if Personal Data are not activated in
|
43 |
+
//plugin's Settings
|
44 |
+
if ($plugin_options["personaldata"] != "1" && isset($cats["personaldata"])) unset($cats["personaldata"]);
|
45 |
+
}
|
46 |
+
else {
|
47 |
+
$plugin_title = "Browser";
|
48 |
+
$cats = wfu_browser_category_definitions();
|
49 |
+
$defs = wfu_browser_attribute_definitions();
|
50 |
+
}
|
51 |
+
|
52 |
+
if ( $data == "" ) {
|
53 |
+
$shortcode = $plugin_options['shortcode'];
|
54 |
+
$shortcode_full = '['.$shortcode_tag.' '.$shortcode.']';
|
55 |
+
$postid = "";
|
56 |
+
$postname = "";
|
57 |
+
$posttype = "";
|
58 |
+
$posthash = "";
|
59 |
+
$shortcode_position = -1;
|
60 |
+
$widgetid = "";
|
61 |
+
$sidebar = "";
|
62 |
+
$autosave = true;
|
63 |
+
}
|
64 |
+
else {
|
65 |
+
$shortcode = trim(substr($data['shortcode'], strlen('['.$shortcode_tag), -1));
|
66 |
+
$shortcode_full = $data['shortcode'];
|
67 |
+
$postid = $data['post_id'];
|
68 |
+
$postname = get_the_title($postid);
|
69 |
+
$posttype_obj = get_post_type_object(get_post_type($postid));
|
70 |
+
$posttype = ( $posttype_obj ? $posttype_obj->labels->singular_name : "" );
|
71 |
+
$posthash = $data['post_hash'];
|
72 |
+
$shortcode_position = $data['position'];
|
73 |
+
$widgetid = ( isset($data['widgetid']) ? $data['widgetid'] : "" );
|
74 |
+
$sidebar = ( isset($data['sidebar']) ? $data['sidebar'] : "" );
|
75 |
+
$autosave = false;
|
76 |
+
}
|
77 |
+
|
78 |
+
// index $components
|
79 |
+
$components_indexed = array();
|
80 |
+
foreach ( $components as $component ) $components_indexed[$component['id']] = $component;
|
81 |
+
// complete defs array and index dependencies
|
82 |
+
$governors = array();
|
83 |
+
$shortcode_attrs = wfu_shortcode_string_to_array($shortcode);
|
84 |
+
//replace old attribute definitions with new ones
|
85 |
+
$shortcode_attrs = wfu_old_to_new_attributes($shortcode_attrs);
|
86 |
+
$shortcode_id = '';
|
87 |
+
foreach ( $defs as $key => $def ) {
|
88 |
+
$attr = $def['attribute'];
|
89 |
+
$defs[$key]['default'] = $def['value'];
|
90 |
+
//'flat' property keeps the original attribute, because 'attribute'
|
91 |
+
//property will change for defs that their occurrence is higher than 1
|
92 |
+
$defs[$key]['flat'] = $attr;
|
93 |
+
if ( array_key_exists($attr, $shortcode_attrs) ) $defs[$key]['value'] = $shortcode_attrs[$attr];
|
94 |
+
$subblock_active = false;
|
95 |
+
//detect if the dependencies of this attribute will be disabled or not
|
96 |
+
if ( ( $def['type'] == "onoff" && $defs[$key]['value'] == "true" ) ||
|
97 |
+
( $def['type'] == "radio" && in_array("*".$defs[$key]['value'], $def['listitems']) ) )
|
98 |
+
$subblock_active = true;
|
99 |
+
// assign dependencies if exist
|
100 |
+
if ( $def['dependencies'] != null )
|
101 |
+
foreach ( $def['dependencies'] as $dependency ) {
|
102 |
+
if ( substr($dependency, 0, 1) == "!" ) //invert state for this dependency if an exclamation mark is defined
|
103 |
+
$governors[substr($dependency, 1)] = array( 'attribute' => $attr, 'active' => !$subblock_active, 'inv' => '_inv' );
|
104 |
+
else
|
105 |
+
$governors[$dependency] = array( 'attribute' => $attr, 'active' => $subblock_active, 'inv' => '' );
|
106 |
+
}
|
107 |
+
if ( $attr == 'uploadid' || $attr == 'browserid' ) $shortcode_id = $defs[$key]['value'];
|
108 |
+
}
|
109 |
+
|
110 |
+
//check if attributes need to be generated more than once because their governor is a component field that appears more than once in placements attribute
|
111 |
+
$key = 0;
|
112 |
+
while ( $key < count($defs) ) {
|
113 |
+
$defs[$key]['additional_values'] = array();
|
114 |
+
$def = $defs[$key];
|
115 |
+
$attr = $def['attribute'];
|
116 |
+
//check if this attribute needs to be generated more than once
|
117 |
+
if ( array_key_exists($attr, $governors) ) $governor = $governors[$attr]['attribute'];
|
118 |
+
else $governor = "";
|
119 |
+
if ( $governor != "" && isset($components_indexed[$governor]) && $components_indexed[$governor]['multiplacements'] && isset($shortcode_attrs['placements']) ) {
|
120 |
+
//count how many occurrences of the governor attribute appear inside placements attribute
|
121 |
+
$occurrences = 0;
|
122 |
+
$sections = explode("/", $shortcode_attrs['placements']);
|
123 |
+
foreach ( $sections as $section ) {
|
124 |
+
$items_in_section = explode("+", trim($section));
|
125 |
+
foreach ( $items_in_section as $item )
|
126 |
+
if ( trim($item) == $governor ) $occurrences++;
|
127 |
+
}
|
128 |
+
//add indexed attributes if there is more than one occurrence
|
129 |
+
for ( $ii = 2; $ii <= $occurrences; $ii++ ) {
|
130 |
+
$def2 = $def;
|
131 |
+
$def2['attribute'] .= $ii;
|
132 |
+
$def2['name'] .= ' ('.$ii.')';
|
133 |
+
if ( array_key_exists($def2['attribute'], $shortcode_attrs) )
|
134 |
+
$def2['value'] = $shortcode_attrs[$def2['attribute']];
|
135 |
+
else $def2['value'] = $def2['default'];
|
136 |
+
array_splice($defs, $key + 1, 0, array($def2));
|
137 |
+
$key++;
|
138 |
+
}
|
139 |
+
//check if the shortcode contains additional indexed definitions and store them in 'additional_values'
|
140 |
+
$ii = max(1, $occurrences) + 1;
|
141 |
+
while ( array_key_exists($attr.$ii, $shortcode_attrs) ) {
|
142 |
+
$defs[$key]['additional_values'][$ii] = $shortcode_attrs[$attr.$ii];
|
143 |
+
$ii++;
|
144 |
+
}
|
145 |
+
}
|
146 |
+
$key++;
|
147 |
+
}
|
148 |
+
|
149 |
+
$echo_str = '<div id="wfu_wrapper" class="wrap">';
|
150 |
+
$echo_str .= "\n\t".'<h2>Wordpress File Upload Control Panel</h2>';
|
151 |
+
$echo_str .= "\n\t".'<div id="wfu_page_obsolete_message" class="error" style="display:none;">';
|
152 |
+
$echo_str .= "\n\t\t".'<p>'.WFU_DASHBOARD_PAGE_OBSOLETE.'</p>';
|
153 |
+
$echo_str .= "\n\t".'</div>';
|
154 |
+
$echo_str .= "\n\t".'<div id="wfu_update_rejected_message" class="error" style="display:none;">';
|
155 |
+
$echo_str .= "\n\t\t".'<p>'.WFU_DASHBOARD_UPDATE_SHORTCODE_REJECTED.'</p>';
|
156 |
+
$echo_str .= "\n\t".'</div>';
|
157 |
+
$echo_str .= "\n\t".'<div id="wfu_update_failed_message" class="error" style="display:none;">';
|
158 |
+
$echo_str .= "\n\t\t".'<p>'.WFU_DASHBOARD_UPDATE_SHORTCODE_FAILED.'</p>';
|
159 |
+
$echo_str .= "\n\t".'</div>';
|
160 |
+
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
161 |
+
if ( $referer == "dashboard" ) $echo_str .= "\n\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=manage_mainmenu" class="button" title="go back">Go to Main Menu</a>';
|
162 |
+
$echo_str .= "\n\t".'</div>';
|
163 |
+
if ( $widgetid == "" ) $echo_str .= "\n\t".'<h2 style="margin-bottom: 10px; margin-top: 20px;">'.( $data == "" ? 'Test' : $posttype.' <strong>'.$postname.'</strong>' ).': Shortcode Composer for '.$plugin_title.' <strong>ID '.$shortcode_id.'</strong></h2>';
|
164 |
+
else $echo_str .= "\n\t".'<h2 style="margin-bottom: 10px; margin-top: 20px;">Sidebar <strong>'.$sidebar.'</strong>: Shortcode Composer for Uploader <strong>ID '.$shortcode_id.'</strong></h2>';
|
165 |
+
$echo_str .= "\n\t".'<div style="margin-top:10px; display:inline-block;">';
|
166 |
+
if ( $data != "") $echo_str .= "\n\t\t".'<input id="wfu_update_shortcode" type="button" value="Update" class="button-primary" disabled="disabled" onclick="wfu_save_shortcode()" /><span id="wfu_update_shortcode_wait" class="spinner" style="float:right; display:none;"></span>';
|
167 |
+
$echo_str .= "\n\t\t".'<input id="wfu_shortcode_original_enc" type="hidden" value="'.wfu_plugin_encode_string($shortcode_full).'" />';
|
168 |
+
$echo_str .= "\n\t\t".'<input id="wfu_shortcode_tag" type="hidden" value="'.$shortcode_tag.'" />';
|
169 |
+
$echo_str .= "\n\t\t".'<input id="wfu_shortcode_postid" type="hidden" value="'.$postid.'" />';
|
170 |
+
$echo_str .= "\n\t\t".'<input id="wfu_shortcode_posthash" type="hidden" value="'.$posthash.'" />';
|
171 |
+
$echo_str .= "\n\t\t".'<input id="wfu_shortcode_position" type="hidden" value="'.$shortcode_position.'" />';
|
172 |
+
$echo_str .= "\n\t\t".'<input id="wfu_shortcode_widgetid" type="hidden" value="'.$widgetid.'" />';
|
173 |
+
$echo_str .= "\n\t".'</div>';
|
174 |
+
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
175 |
+
$echo_str .= "\n\t\t".'<div class="wfu_shortcode_container">';
|
176 |
+
$echo_str .= "\n\t\t\t".'<span><strong>Generated Shortcode</strong></span>';
|
177 |
+
$echo_str .= "\n\t\t\t".'<span id="wfu_save_label" class="wfu_save_label">saved</span>';
|
178 |
+
$echo_str .= "\n\t\t\t".'<textarea id="wfu_shortcode" class="wfu_shortcode" rows="5">['.$shortcode_tag.']</textarea>';
|
179 |
+
$echo_str .= "\n\t\t\t".'<div id="wfu_attribute_defaults" style="display:none;">';
|
180 |
+
// remove hidden attributes from defs array
|
181 |
+
foreach ( $defs as $key => $def ) if ( $def['type'] == "hidden" ) unset($defs[$key]);
|
182 |
+
foreach ( $defs as $def )
|
183 |
+
$echo_str .= "\n\t\t\t\t".'<input id="wfu_attribute_default_'.$def['attribute'].'" type="hidden" value="'.$def['default'].'" />';
|
184 |
+
$echo_str .= "\n\t\t\t".'</div>';
|
185 |
+
$echo_str .= "\n\t\t\t".'<div id="wfu_attribute_values" style="display:none;">';
|
186 |
+
foreach ( $defs as $def ) {
|
187 |
+
$echo_str .= "\n\t\t\t\t".'<input id="wfu_attribute_value_'.$def['attribute'].'" type="hidden" value="'.$def['value'].'" />';
|
188 |
+
//add additional values, if exist
|
189 |
+
foreach( $def['additional_values'] as $key => $val )
|
190 |
+
$echo_str .= "\n\t\t\t\t".'<input id="wfu_attribute_value_'.$def['attribute'].$key.'" type="hidden" value="'.$val.'" />';
|
191 |
+
}
|
192 |
+
$echo_str .= "\n\t\t\t".'</div>';
|
193 |
+
$echo_str .= "\n\t\t".'</div>';
|
194 |
+
$echo_str .= "\n\t".'</div>';
|
195 |
+
$echo_str .= "\n\t".'<h3 id="wfu_tab_container" class="nav-tab-wrapper">';
|
196 |
+
$is_first = true;
|
197 |
+
foreach ( $cats as $key => $cat ) {
|
198 |
+
$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>';
|
199 |
+
$is_first = false;
|
200 |
+
}
|
201 |
+
$echo_str .= "\n\t".'</h3>';
|
202 |
+
|
203 |
+
$prevcat = "";
|
204 |
+
$prevsubcat = "";
|
205 |
+
$is_first = true;
|
206 |
+
$block_open = false;
|
207 |
+
$subblock_open = false;
|
208 |
+
foreach ( $defs as $def ) {
|
209 |
+
$attr = $def['attribute'];
|
210 |
+
//check if this attribute depends on other
|
211 |
+
if ( !array_key_exists($attr, $governors) ) $governors[$attr] = "";
|
212 |
+
if ( $governors[$attr] != "" ) $governor = $governors[$attr];
|
213 |
+
else $governor = array( 'attribute' => "independent", 'active' => true, 'inv' => '' );
|
214 |
+
|
215 |
+
//close previous blocks
|
216 |
+
if ( $def['parent'] == "" ) {
|
217 |
+
if ( $subblock_open ) {
|
218 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'</tbody>';
|
219 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</table>';
|
220 |
+
$subblock_open = false;
|
221 |
+
}
|
222 |
+
if ( $block_open ) {
|
223 |
+
$echo_str .= "\n\t\t\t\t\t".'</div></td>';
|
224 |
+
$echo_str .= "\n\t\t\t\t".'</tr>';
|
225 |
+
$block_open = false;
|
226 |
+
}
|
227 |
+
}
|
228 |
+
//check if new category must be generated
|
229 |
+
if ( $def['category'] != $prevcat ) {
|
230 |
+
if ( $prevcat != "" ) {
|
231 |
+
$echo_str .= "\n\t\t\t".'</tbody>';
|
232 |
+
$echo_str .= "\n\t\t".'</table>';
|
233 |
+
$echo_str .= "\n\t".'</div>';
|
234 |
+
}
|
235 |
+
$prevcat = $def['category'];
|
236 |
+
$prevsubcat = "";
|
237 |
+
$echo_str .= "\n\t".'<div id="wfu_container_'.$prevcat.'" class="wfu_container"'.( $is_first ? '' : ' style="display:none;"' ).'">';
|
238 |
+
$echo_str .= "\n\t\t".'<table class="form-table wfu_main_table">';
|
239 |
+
$echo_str .= "\n\t\t\t".'<thead><tr><th></th><td></td><td></td></tr></thead>';
|
240 |
+
$echo_str .= "\n\t\t\t".'<tbody>';
|
241 |
+
$is_first = false;
|
242 |
+
}
|
243 |
+
//check if new sub-category must be generated
|
244 |
+
if ( $def['subcategory'] != $prevsubcat ) {
|
245 |
+
$prevsubcat = $def['subcategory'];
|
246 |
+
$echo_str .= "\n\t\t\t\t".'<tr class="wfu_subcategory">';
|
247 |
+
$echo_str .= "\n\t\t\t\t\t".'<th scope="row" colspan="3">';
|
248 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<h3 style="margin-bottom: 10px; margin-top: 10px;">'.$prevsubcat.'</h3>';
|
249 |
+
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
250 |
+
$echo_str .= "\n\t\t\t\t".'</tr>';
|
251 |
+
}
|
252 |
+
//draw attribute element
|
253 |
+
if ( $def['parent'] == "" ) {
|
254 |
+
$dlp = "\n\t\t\t\t";
|
255 |
+
}
|
256 |
+
else {
|
257 |
+
if ( !$subblock_open ) {
|
258 |
+
$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>';
|
259 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<table class="form-table wfu_inner_table" style="margin:0;">';
|
260 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<tbody>';
|
261 |
+
}
|
262 |
+
$dlp = "\n\t\t\t\t\t\t\t\t";
|
263 |
+
}
|
264 |
+
$echo_str .= $dlp.'<tr>';
|
265 |
+
$echo_str .= $dlp."\t".'<th scope="row"><div class="wfu_td_div">';
|
266 |
+
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>';
|
267 |
+
$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>';
|
268 |
+
$echo_str .= $dlp."\t\t".'<label for="wfu_attribute_'.$attr.'">'.$def['name'].'</label>';
|
269 |
+
$echo_str .= $dlp."\t\t".'<input type="hidden" name="wfu_attribute_governor_'.$governor['attribute'].'" class="wfu_attribute_governor" value="'.$attr.'" />';
|
270 |
+
$echo_str .= $dlp."\t\t".'<div class="wfu_help_container" title="'.$def['help'].'"><img src="'.WFU_IMAGE_ADMIN_HELP.'" /></div>';
|
271 |
+
$echo_str .= $dlp."\t".'</div></th>';
|
272 |
+
$echo_str .= $dlp."\t".'<td style="vertical-align:top;"><div class="wfu_td_div">';
|
273 |
+
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>';
|
274 |
+
if ( $def['type'] == "onoff" ) {
|
275 |
+
$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.'\');">';
|
276 |
+
$echo_str .= $dlp."\t\t\t".'<div class="wfu_onoff_slider"></div>';
|
277 |
+
$echo_str .= $dlp."\t\t\t".'<span class="wfu_onoff_text">ON</span>';
|
278 |
+
$echo_str .= $dlp."\t\t\t".'<span class="wfu_onoff_text">OFF</span>';
|
279 |
+
$echo_str .= $dlp."\t\t".'</div>';
|
280 |
+
}
|
281 |
+
elseif ( $def['type'] == "text" ) {
|
282 |
+
$val = str_replace(array( "%n%", "%dq%", "%brl%", "%brr%" ), array( "\n", """, "[", "]" ), $def['value']);
|
283 |
+
$echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" value="'.$val.'" style="display:block;" />';
|
284 |
+
if ( $def['variables'] != null ) $echo_str .= $dlp.wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
|
285 |
+
}
|
286 |
+
elseif ( $def['type'] == "placements" ) {
|
287 |
+
$components_used = array();
|
288 |
+
foreach ( $components as $component ) $components_used[$component['id']] = 0;
|
289 |
+
$centered_content = '<div class="wfu_component_box_inner"><div class="wfu_component_box_label">XXX</div></div>';
|
290 |
+
$centered_content_multi = '<div class="wfu_component_box_inner"><div class="wfu_component_box_label">XXX</div><div class="wfu_component_box_index">YYY</div></div>';
|
291 |
+
$echo_str .= $dlp."\t\t".'<div class="wfu_placements_wrapper">';
|
292 |
+
$echo_str .= $dlp."\t\t\t".'<div id="wfu_placements_container" class="wfu_placements_container">';
|
293 |
+
$itemplaces = explode("/", $def['value']);
|
294 |
+
foreach ( $itemplaces as $section ) {
|
295 |
+
$echo_str .= $dlp."\t\t\t\t".'<div class="wfu_component_separator_hor"></div>';
|
296 |
+
$echo_str .= $dlp."\t\t\t\t".'<div class="wfu_component_separator_ver"></div>';
|
297 |
+
$items_in_section = explode("+", trim($section));
|
298 |
+
$section_array = array( );
|
299 |
+
foreach ( $items_in_section as $item_in_section ) {
|
300 |
+
if ( key_exists($item_in_section, $components_indexed) ) {
|
301 |
+
if ( $components_indexed[$item_in_section]['multiplacements'] || $components_used[$item_in_section] == 0 ) {
|
302 |
+
$components_used[$item_in_section] ++;
|
303 |
+
if ( $components_indexed[$item_in_section]['multiplacements'] ) {
|
304 |
+
$multi_index = $components_used[$item_in_section];
|
305 |
+
$echo_str .= $dlp."\t\t\t\t".'<div id="wfu_component_box_'.$item_in_section.'_'.$multi_index.'" class="wfu_component_box" draggable="true" title="'.$components_indexed[$item_in_section]['help'].'">'.str_replace(array("XXX", "YYY"), array($components_indexed[$item_in_section]['name'], $multi_index), $centered_content_multi).'</div>';
|
306 |
+
}
|
307 |
+
else
|
308 |
+
$echo_str .= $dlp."\t\t\t\t".'<div id="wfu_component_box_'.$item_in_section.'_0" class="wfu_component_box" draggable="true" title="'.$components_indexed[$item_in_section]['help'].'">'.str_replace("XXX", $components_indexed[$item_in_section]['name'], $centered_content).'</div>';
|
309 |
+
$echo_str .= $dlp."\t\t\t\t".'<div class="wfu_component_separator_ver"></div>';
|
310 |
+
}
|
311 |
+
}
|
312 |
+
}
|
313 |
+
}
|
314 |
+
$echo_str .= $dlp."\t\t\t\t".'<div class="wfu_component_separator_hor"></div>';
|
315 |
+
$echo_str .= $dlp."\t\t\t\t".'<div id="wfu_component_bar_hor" class="wfu_component_bar_hor"></div>';
|
316 |
+
$echo_str .= $dlp."\t\t\t\t".'<div id="wfu_component_bar_ver" class="wfu_component_bar_ver"></div>';
|
317 |
+
$echo_str .= $dlp."\t\t\t".'</div>';
|
318 |
+
$echo_str .= $dlp."\t\t\t".'<div id="wfu_componentlist_container" class="wfu_componentlist_container">';
|
319 |
+
$echo_str .= $dlp."\t\t\t\t".'<div id="wfu_componentlist_dragdrop" class="wfu_componentlist_dragdrop" style="display:none;"></div>';
|
320 |
+
$ii = 1;
|
321 |
+
foreach ( $components as $component ) {
|
322 |
+
$echo_str .= $dlp."\t\t\t\t".'<div id="wfu_component_box_container_'.$component['id'].'" class="wfu_component_box_container">';
|
323 |
+
$echo_str .= $dlp."\t\t\t\t\t".'<div class="wfu_component_box_base">'.str_replace("XXX", $component['name'], $centered_content).'</div>';
|
324 |
+
if ( $component['multiplacements'] ) {
|
325 |
+
$multi_index = $components_used[$component['id']] + 1;
|
326 |
+
$echo_str .= $dlp."\t\t\t\t\t".'<div id="wfu_component_box_'.$component['id'].'_'.$multi_index.'" class="wfu_component_box wfu_inbase" draggable="true" title="'.$component['help'].'">'.str_replace(array("XXX", "YYY"), array($component['name'], $multi_index), $centered_content_multi).'</div>';
|
327 |
+
}
|
328 |
+
elseif ( $components_used[$component['id']] == 0 )
|
329 |
+
$echo_str .= $dlp."\t\t\t\t\t".'<div id="wfu_component_box_'.$component['id'].'_0" class="wfu_component_box wfu_inbase" draggable="true" title="'.$component['help'].'">'.str_replace("XXX", $component['name'], $centered_content).'</div>';
|
330 |
+
$echo_str .= $dlp."\t\t\t\t".'</div>'.( ($ii++) % 3 == 0 ? '<br />' : '' );
|
331 |
+
}
|
332 |
+
$echo_str .= $dlp."\t\t\t".'</div>';
|
333 |
+
$echo_str .= $dlp."\t\t".'</div>';
|
334 |
+
}
|
335 |
+
elseif ( $def['type'] == "ltext" ) {
|
336 |
+
$val = str_replace(array( "%n%", "%dq%", "%brl%", "%brr%" ), array( "\n", """, "[", "]" ), $def['value']);
|
337 |
+
$echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" class="wfu_long_text" value="'.$val.'" />';
|
338 |
+
if ( $def['variables'] != null ) $echo_str .= $dlp.wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
|
339 |
+
}
|
340 |
+
elseif ( $def['type'] == "integer" ) {
|
341 |
+
$val = str_replace(array( "%n%", "%dq%", "%brl%", "%brr%" ), array( "\n", """, "[", "]" ), $def['value']);
|
342 |
+
$echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="number" name="wfu_text_elements" class="wfu_short_text" min="1" value="'.$val.'" />';
|
343 |
+
if ( isset($def['listitems']['unit']) ) $echo_str .= $dlp."\t\t".'<label> '.$def['listitems']['unit'].'</label>';
|
344 |
+
}
|
345 |
+
elseif ( $def['type'] == "float" ) {
|
346 |
+
$val = str_replace(array( "%n%", "%dq%", "%brl%", "%brr%" ), array( "\n", """, "[", "]" ), $def['value']);
|
347 |
+
$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.'" />';
|
348 |
+
if ( isset($def['listitems']['unit']) ) $echo_str .= $dlp."\t\t".'<label> '.$def['listitems']['unit'].'</label>';
|
349 |
+
}
|
350 |
+
elseif ( $def['type'] == "date" ) {
|
351 |
+
$val = $def['value'];
|
352 |
+
$echo_str .= $dlp."\t\t".'<div class="wfu_date_container"><input id="wfu_attribute_'.$attr.'" type="text" value="'.$val.'" readonly style="padding-right:16px; background-color:white; width:auto;" /><img class="wfu_datereset_button" src="'.WFU_IMAGE_ADMIN_SUBFOLDER_CANCEL.'" onclick="var f = document.getElementById(\'wfu_attribute_'.$attr.'\'); f.value = \'\'; wfu_update_date_value({target:f});" /></div><label style="font-size:smaller; margin-left:4px;">format: YYYY-MM-DD</label>';
|
353 |
+
$echo_str .= wfu_inject_js_code('jQuery(function() {jQuery("#wfu_attribute_'.$attr.'").datepicker({dateFormat: "yy-mm-dd", onClose: function(date, picker) {wfu_update_date_value({target:this});}});});');
|
354 |
+
}
|
355 |
+
elseif ( $def['type'] == "radio" ) {
|
356 |
+
$echo_str .= $dlp."\t\t";
|
357 |
+
$ii = 0;
|
358 |
+
foreach ( $def['listitems'] as $item )
|
359 |
+
$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 );
|
360 |
+
// $echo_str .= '<input type="button" class="button" value="empty" style="width:auto; margin:-2px 0px 0px 8px;" />';
|
361 |
+
}
|
362 |
+
elseif ( $def['type'] == "ptext" ) {
|
363 |
+
$val = str_replace(array( "%n%", "%dq%", "%brl%", "%brr%" ), array( "\n", """, "[", "]" ), $def['value']);
|
364 |
+
$parts = explode("/", $val);
|
365 |
+
$singular = $parts[0];
|
366 |
+
if ( count($parts) < 2 ) $plural = $singular;
|
367 |
+
else $plural = $parts[1];
|
368 |
+
$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.'" />';
|
369 |
+
if ( $def['variables'] != null ) if ( count($def['variables']) > 0 ) $echo_str .= $dlp."\t\t".'<br /><span class="wfu_ptext_span"> </span>';
|
370 |
+
if ( $def['variables'] != null ) $echo_str .= $dlp.wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_s_'.$attr);
|
371 |
+
$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.'" />';
|
372 |
+
if ( $def['variables'] != null ) if ( count($def['variables']) > 0 ) $echo_str .= $dlp."\t\t".'<br /><span class="wfu_ptext_span"> </span>';
|
373 |
+
if ( $def['variables'] != null ) $echo_str .= $dlp.wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_p_'.$attr, $dlp);
|
374 |
+
}
|
375 |
+
elseif ( $def['type'] == "mtext" ) {
|
376 |
+
$val = str_replace(array( "%n%", "%dq%", "%brl%", "%brr%" ), array( "\n", """, "[", "]" ), $def['value']);
|
377 |
+
$echo_str .= $dlp."\t\t".'<textarea id="wfu_attribute_'.$attr.'" name="wfu_text_elements" rows="5">'.$val.'</textarea>';
|
378 |
+
if ( $def['variables'] != null ) $echo_str .= $dlp.wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
|
379 |
+
}
|
380 |
+
elseif ( $def['type'] == "ftpinfo" ) {
|
381 |
+
$val = $def['value'];
|
382 |
+
$ftpinfo = wfu_decode_ftpinfo($val);
|
383 |
+
$error_class = ( $ftpinfo["error"] ? ' ftpinfo_error' : '' );
|
384 |
+
$echo_str .= $dlp."\t\t".'<div class="ftpinfo_header">';
|
385 |
+
$echo_str .= $dlp."\t\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_ftpinfobase_elements" class="ftpinfo_text'.$error_class.'" value="'.$val.'" />';
|
386 |
+
$echo_str .= $dlp."\t\t\t".'<button class="ftpinfo_btn" onclick="wfu_ftpinfotool_toggle();">Edit</button>';
|
387 |
+
$echo_str .= $dlp."\t\t".'</div>';
|
388 |
+
$echo_str .= $dlp."\t\t".'<div class="ftpinfo_tool hidden">';
|
389 |
+
$echo_str .= $dlp."\t\t\t".'<label class="ftpinfo_label">Username</label><input type="text" id="ftpinfo_username" name="wfu_ftpinfotool_elements" class="ftpinfo_value'.$error_class.'" value="'.$ftpinfo["data"]["username"].'" /><br />';
|
390 |
+
$echo_str .= $dlp."\t\t\t".'<label class="ftpinfo_label">Password</label><input type="text" id="ftpinfo_password" name="wfu_ftpinfotool_elements" class="ftpinfo_value'.$error_class.'" value="'.$ftpinfo["data"]["password"].'" /><br />';
|
391 |
+
$echo_str .= $dlp."\t\t\t".'<label class="ftpinfo_label">FTP Domain</label><input type="text" id="ftpinfo_domain" name="wfu_ftpinfotool_elements" class="ftpinfo_value'.$error_class.'" value="'.$ftpinfo["data"]["ftpdomain"].'" /><br />';
|
392 |
+
$echo_str .= $dlp."\t\t\t".'<label class="ftpinfo_label">Port</label><input type="text" id="ftpinfo_port" name="wfu_ftpinfotool_elements" class="ftpinfo_value'.$error_class.'" value="'.$ftpinfo["data"]["port"].'" /><br />';
|
393 |
+
$echo_str .= $dlp."\t\t\t".'<label class="ftpinfo_label">Use SFTP</label><input type="checkbox" id="ftpinfo_sftp" name="wfu_ftpinfotool_elements" class="ftpinfo_checkbox'.$error_class.'"'.( $ftpinfo["data"]["sftp"] ? " checked" : "" ).' />';
|
394 |
+
$echo_str .= $dlp."\t\t".'</div>';
|
395 |
+
if ( $def['variables'] != null ) $echo_str .= $dlp.wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
|
396 |
+
}
|
397 |
+
elseif ( $def['type'] == "folderlist" ) {
|
398 |
+
$echo_str .= $dlp."\t\t".'<div id="wfu_subfolders_inner_shadow_'.$attr.'" class="wfu_subfolders_inner_shadow" style="display:none;"></div>';
|
399 |
+
$subfolders = wfu_parse_folderlist($def['value']);
|
400 |
+
$poptitle = "Populate list automatically with the first-level subfolders of the path defined in uploadpath";
|
401 |
+
$edittitle = "Allow the user to type the subfolder and filter the list during typing";
|
402 |
+
$echo_str .= $dlp."\t\t".'<input type="checkbox" id="wfu_subfolders_auto_'.$attr.'"'.( substr($def['value'], 0, 4) == "auto" ? ' checked="checked"' : '' ).' onchange="wfu_subfolders_auto_changed(\''.$attr.'\');" title="'.$poptitle.'" /><label for="wfu_subfolders_auto_'.$attr.'" title="'.$poptitle.'"> Auto-populate list</label>';
|
403 |
+
$echo_str .= $dlp."\t\t".'<div style="display:'.( substr($def['value'], 0, 4) == "auto" ? 'inline' : 'none' ).'; padding:0; margin:0 0 0 30px; background:none; border:none;"><input type="checkbox" id="wfu_subfolders_editable_'.$attr.'"'.( substr($def['value'], 0, 5) == "auto+" ? ' checked="checked"' : '' ).' onchange="wfu_subfolders_auto_changed(\''.$attr.'\');" title="'.$edittitle.'" /><label for="wfu_subfolders_editable_'.$attr.'" title="'.$edittitle.'"> List is editable</label></div><br />';
|
404 |
+
$echo_str .= $dlp."\t\t".'<input type="hidden" id="wfu_subfolders_manualtext_'.$attr.'" value="'.( substr($def['value'], 0, 4) == "auto" ? "" : $def['value'] ).'" />';
|
405 |
+
$echo_str .= $dlp."\t\t".'<select id="wfu_attribute_'.$attr.'" class="wfu_select_folders'.( count($subfolders['path']) == 0 ? ' wfu_select_folders_empty' : '' ).'" size="7"'.( substr($def['value'], 0, 4) == "auto" ? ' disabled="disabled"' : '' ).' onchange="wfu_subfolders_changed(\''.$attr.'\');">';
|
406 |
+
foreach ($subfolders['path'] as $ind => $subfolder) {
|
407 |
+
if ( substr($subfolder, -1) == '/' ) $subfolder = substr($subfolder, 0, -1);
|
408 |
+
$subfolder_raw = explode('/', $subfolder);
|
409 |
+
$subfolder = $subfolder_raw[count($subfolder_raw) - 1];
|
410 |
+
$text = str_repeat(" ", intval($subfolders['level'][$ind])).$subfolders['label'][$ind];
|
411 |
+
$subvalue = str_repeat("*", intval($subfolders['level'][$ind])).( $subfolders['default'][$ind] ? '&' : '' ).( $subfolder == "" ? '{root}' : $subfolder ).'/'.$subfolders['label'][$ind];
|
412 |
+
$echo_str .= $dlp."\t\t\t".'<option class="'.( $subfolders['default'][$ind] ? 'wfu_select_folders_option_default' : '' ).'" value="'.wfu_plugin_encode_string($subvalue).'">'.$text.'</option>';
|
413 |
+
}
|
414 |
+
$echo_str .= $dlp."\t\t\t".'<option value="">'.( substr($def['value'], 0, 4) != "auto" && count($subfolders['path']) == 0 ? 'press here' : '' ).'</option>';
|
415 |
+
$echo_str .= $dlp."\t\t".'</select>';
|
416 |
+
$echo_str .= $dlp."\t\t".'<div id="wfu_subfolder_nav_'.$attr.'" class="wfu_subfolder_nav_container">';
|
417 |
+
$echo_str .= $dlp."\t\t\t".'<table class="wfu_subfolder_nav"><tbody>';
|
418 |
+
$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>';
|
419 |
+
$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>';
|
420 |
+
$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>';
|
421 |
+
$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>';
|
422 |
+
$echo_str .= $dlp."\t\t\t\t".'<tr><td style="line-height:0;"><button class="button" style="visibility:hidden; height:10px;"></button></tr></td>';
|
423 |
+
$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>';
|
424 |
+
$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>';
|
425 |
+
$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>';
|
426 |
+
$echo_str .= $dlp."\t\t\t".'</tbody></table>';
|
427 |
+
$echo_str .= $dlp."\t\t".'</div>';
|
428 |
+
$echo_str .= $dlp."\t\t".'<div id="wfu_subfolder_tools_'.$attr.'" class="wfu_subfolder_tools_container wfu_subfolder_tools_disabled">';
|
429 |
+
$echo_str .= $dlp."\t\t\t".'<table class="wfu_subfolder_tools"><tbody><tr>';
|
430 |
+
$echo_str .= $dlp."\t\t\t\t".'<td style="width:40%;">';
|
431 |
+
$echo_str .= $dlp."\t\t\t\t\t".'<label>Label</label>';
|
432 |
+
$echo_str .= $dlp."\t\t\t\t\t".'<input id="wfu_subfolders_label_'.$attr.'" name="wfu_subfolder_tools_input" type="text" disabled="disabled" />';
|
433 |
+
$echo_str .= $dlp."\t\t\t\t".'</td>';
|
434 |
+
$echo_str .= $dlp."\t\t\t\t".'<td style="width:60%;"><div style="padding-right:36px;">';
|
435 |
+
$echo_str .= $dlp."\t\t\t\t\t".'<label>Path</label>';
|
436 |
+
$echo_str .= $dlp."\t\t\t\t\t".'<input id="wfu_subfolders_path_'.$attr.'" name="wfu_subfolder_tools_input" type="text" disabled="disabled" />';
|
437 |
+
$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>';
|
438 |
+
$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>';
|
439 |
+
// file browser dialog
|
440 |
+
$echo_str .= $dlp."\t\t\t\t\t".'<div id="wfu_subfolders_browser_'.$attr.'" class="wfu_subfolders_browser_container" style="display:none;">';
|
441 |
+
$echo_str .= $dlp."\t\t\t\t\t\t".'<table><tbody>';
|
442 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t".'<tr><td style="height:15px;">';
|
443 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t\t".'<div>';
|
444 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t\t\t".'<label>Folder Browser</label>';
|
445 |
+
$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>';
|
446 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t\t".'</div>';
|
447 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t".'</td></tr>';
|
448 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t".'<tr><td style="height:106px;">';
|
449 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t\t".'<div>';
|
450 |
+
$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.'\');">';
|
451 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t\t\t\t".'<option>Value</option>';
|
452 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t\t\t\t".'<option>Value2</option>';
|
453 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t\t\t\t".'<option>Value3</option>';
|
454 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t\t\t".'</select>';
|
455 |
+
$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;">';
|
456 |
+
$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>';
|
457 |
+
$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>';
|
458 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t\t\t".'</div>';
|
459 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t\t".'</div>';
|
460 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t".'</td></tr>';
|
461 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t".'<tr><td align="right" style="height:15px;">';
|
462 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t\t".'<div>';
|
463 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t\t\t".'<button class="button" onclick="wfu_folder_browser_cancel_clicked(\''.$attr.'\');">Cancel</button>';
|
464 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t\t\t".'<button id="wfu_subfolders_browser_ok_'.$attr.'" class="button">Ok</button>';
|
465 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t\t".'</div>';
|
466 |
+
$echo_str .= $dlp."\t\t\t\t\t\t\t".'</td></tr>';
|
467 |
+
$echo_str .= $dlp."\t\t\t\t\t\t".'</tbody></table>';
|
468 |
+
$echo_str .= $dlp."\t\t\t\t\t".'</div>';
|
469 |
+
|
470 |
+
$echo_str .= $dlp."\t\t\t\t".'</div></td>';
|
471 |
+
$echo_str .= $dlp."\t\t\t".'</tr></tbody></table>';
|
472 |
+
$echo_str .= $dlp."\t\t\t".'<input id="wfu_subfolders_isnewitem_'.$attr.'" type="hidden" value="" />';
|
473 |
+
$echo_str .= $dlp."\t\t\t".'<input id="wfu_subfolders_newitemindex_'.$attr.'" type="hidden" value="" />';
|
474 |
+
$echo_str .= $dlp."\t\t\t".'<input id="wfu_subfolders_newitemlevel_'.$attr.'" type="hidden" value="" />';
|
475 |
+
$echo_str .= $dlp."\t\t\t".'<input id="wfu_subfolders_newitemlevel2_'.$attr.'" type="hidden" value="" />';
|
476 |
+
$echo_str .= $dlp."\t\t".'</div>';
|
477 |
+
}
|
478 |
+
elseif ( $def['type'] == "mchecklist" ) {
|
479 |
+
$help_count = 0;
|
480 |
+
foreach ( $def['listitems'] as $key => $item ) {
|
481 |
+
$parts = explode("/", $item);
|
482 |
+
if ( count($parts) == 1 ) {
|
483 |
+
$items[$key]['id'] = $item;
|
484 |
+
$items[$key]['help'] = '';
|
485 |
+
}
|
486 |
+
else {
|
487 |
+
$items[$key]['id'] = $parts[0];
|
488 |
+
$items[$key]['help'] = $parts[1];
|
489 |
+
$help_count ++;
|
490 |
+
}
|
491 |
+
}
|
492 |
+
$def['value'] = strtolower($def['value']);
|
493 |
+
if ( $def['value'] == "all" ) $selected = array();
|
494 |
+
else $selected = explode(",", $def['value']);
|
495 |
+
foreach ( $selected as $key => $item ) $selected[$key] = trim($item);
|
496 |
+
$echo_str .= $dlp."\t\t".'<div id="wfu_attribute_'.$attr.'" class="wfu_mchecklist_container">';
|
497 |
+
$is_first = true;
|
498 |
+
foreach ( $items as $key => $item ) {
|
499 |
+
if ( !$is_first ) $echo_str .= "<br />";
|
500 |
+
$is_first = false;
|
501 |
+
$echo_str .= $dlp."\t\t\t".'<div class="wfu_mchecklist_item"><input id="wfu_attribute_'.$attr.'_'.$key.'" type="checkbox"'.( $def['value'] == "all" || in_array($item['id'], $selected) ? ' checked="checked"' : '' ).( $def['value'] == "all" ? ' disabled="disabled"' : '' ).' onchange="wfu_update_mchecklist_value(\''.$attr.'\');" /><label for="wfu_attribute_'.$attr.'_'.$key.'">'.$item['id'].'</label>';
|
502 |
+
if ( $item['help'] != '' ) $echo_str .= '<div class="wfu_help_container" title="'.$item['help'].'"><img src="'.WFU_IMAGE_ADMIN_HELP.'" /></div>';
|
503 |
+
$echo_str .= '</div>';
|
504 |
+
}
|
505 |
+
$echo_str .= $dlp."\t\t".'</div>';
|
506 |
+
$echo_str .= $dlp."\t\t".'<div id="wfu_attribute_'.$attr.'_optionhelp" class="wfu_help_container" title="" style="display:none; position:absolute;"><img src="'.WFU_IMAGE_ADMIN_HELP.'" style="visibility:visible;" /></div>';
|
507 |
+
$echo_str .= $dlp."\t\t".'<div class="wfu_mchecklist_checkall"><input id="wfu_attribute_'.$attr.'_all" type="checkbox" onchange="wfu_update_mchecklist_value(\''.$attr.'\');"'.( $def['value'] == "all" ? ' checked="checked"' : '' ).' /> Select all</div>';
|
508 |
+
}
|
509 |
+
elseif ( $def['type'] == "rolelist" ) {
|
510 |
+
$roles = $wp_roles->get_names();
|
511 |
+
$selected = explode(",", $def['value']);
|
512 |
+
$default_administrator = ( is_array($def['listitems']) && in_array('default_administrator', $def['listitems']) );
|
513 |
+
if ( in_array('all', $selected) ) $rolesselected = ( $default_administrator ? array("administrator") : array( ) );
|
514 |
+
else $rolesselected = $selected;
|
515 |
+
foreach ( $selected as $key => $item ) $selected[$key] = trim($item);
|
516 |
+
$echo_str .= $dlp."\t\t".'<table class="wfu_rolelist_container"><tbody><tr><td>';
|
517 |
+
$echo_str .= $dlp."\t\t".'<select id="wfu_attribute_'.$attr.'" multiple="multiple" size="'.count($roles).'" onchange="wfu_update_rolelist_value(\''.$attr.'\');"'.( in_array('all', $selected) ? ' disabled="disabled"' : '' ).'>';
|
518 |
+
foreach ( $roles as $roleid => $rolename )
|
519 |
+
$echo_str .= $dlp."\t\t\t".'<option value="'.$roleid.'"'.( in_array($roleid, $rolesselected) ? ' selected="selected"' : '' ).'>'.$rolename.'</option>';
|
520 |
+
$echo_str .= $dlp."\t\t".'</select>';
|
521 |
+
$echo_str .= $dlp."\t\t".'</td><td>';
|
522 |
+
$echo_str .= $dlp."\t\t".'<div class="wfu_rolelist_checkbtn"><input class="'.( $default_administrator ? 'wfu_default_administrator' : '' ).'" id="wfu_attribute_'.$attr.'_all" type="checkbox" onchange="wfu_update_rolelist_value(\''.$attr.'\');"'.( in_array('all', $selected) ? ' checked="checked"' : '' ).' /><label for="wfu_attribute_'.$attr.'_all"> Select all</label></div><br />';
|
523 |
+
$echo_str .= $dlp."\t\t".'<div class="wfu_rolelist_checkbtn"><input id="wfu_attribute_'.$attr.'_guests" type="checkbox" onchange="wfu_update_rolelist_value(\''.$attr.'\');"'.( in_array("guests", $selected) ? ' checked="checked"' : '' ).' /><label for="wfu_attribute_'.$attr.'_guests"> Include guests</label></div>';
|
524 |
+
$echo_str .= $dlp."\t\t".'</td></tr></tbody></table>';
|
525 |
+
}
|
526 |
+
elseif ( $def['type'] == "userlist" ) {
|
527 |
+
$args = array();
|
528 |
+
/** This filter is documented in lib/wfu_admin_browser.php */
|
529 |
+
$args = apply_filters("_wfu_get_users", $args, "shortcode_composer");
|
530 |
+
$users = get_users($args);
|
531 |
+
$selected = explode(",", $def['value']);
|
532 |
+
$default_0 = ( is_array($def['listitems']) && in_array('default_0', $def['listitems']) );
|
533 |
+
if ( in_array('all', $selected) ) $usersselected = ( $default_0 ? array($users[0]->user_login) : array( ) );
|
534 |
+
else $usersselected = $selected;
|
535 |
+
$only_current = false;
|
536 |
+
$echo_str .= $dlp."\t\t".'<table class="wfu_userlist_container"><tbody><tr>';
|
537 |
+
if ( is_array($def['listitems']) && in_array('include_current', $def['listitems']) ) {
|
538 |
+
$only_current = ( $def['value'] == 'current' );
|
539 |
+
if ( $only_current ) $usersselected = ( $default_0 ? array($users[0]->user_login) : array( ) );
|
540 |
+
$echo_str .= $dlp."\t\t".'<td colspan="2"><div class="wfu_userlist_checkbtn"><input id="wfu_attribute_'.$attr.'_current" type="checkbox" onchange="wfu_update_userlist_value(\''.$attr.'\');"'.( $only_current ? ' checked="checked"' : '' ).' /><label for="wfu_attribute_'.$attr.'_current"> Only From Current User</label></div>';
|
541 |
+
$echo_str .= $dlp."\t\t".'</td></tr><tr>';
|
542 |
+
}
|
543 |
+
$echo_str .= $dlp."\t\t".'<td><select id="wfu_attribute_'.$attr.'" multiple="multiple" size="'.min(count($users), 10).'" onchange="wfu_update_userlist_value(\''.$attr.'\');"'.( $only_current || in_array('all', $selected) ? ' disabled="disabled"' : '' ).'>';
|
544 |
+
foreach ( $users as $userid => $user )
|
545 |
+
$echo_str .= $dlp."\t\t\t".'<option value="'.$user->user_login.'"'.( in_array($user->user_login, $usersselected) ? ' selected="selected"' : '' ).'>'.$user->display_name.' ('.$user->user_login.')</option>';
|
546 |
+
$echo_str .= $dlp."\t\t".'</select>';
|
547 |
+
$echo_str .= $dlp."\t\t".'</td><td>';
|
548 |
+
$echo_str .= $dlp."\t\t".'<div class="wfu_userlist_checkbtn"><input class="'.( $default_0 ? 'wfu_default_0' : '' ).'" id="wfu_attribute_'.$attr.'_all" type="checkbox" onchange="wfu_update_userlist_value(\''.$attr.'\');"'.( in_array('all', $selected) ? ' checked="checked"' : '' ).( $only_current ? ' disabled="disabled"' : '' ).' /><label for="wfu_attribute_'.$attr.'_all"> Select all</label></div><br />';
|
549 |
+
$echo_str .= $dlp."\t\t".'<div class="wfu_userlist_checkbtn"><input id="wfu_attribute_'.$attr.'_guests" type="checkbox" onchange="wfu_update_userlist_value(\''.$attr.'\');"'.( in_array("guests", $selected) ? ' checked="checked"' : '' ).( $only_current ? ' disabled="disabled"' : '' ).' /><label for="wfu_attribute_'.$attr.'_guests"> Include guests</label></div>';
|
550 |
+
$echo_str .= $dlp."\t\t".'</td></tr></tbody></table>';
|
551 |
+
}
|
552 |
+
elseif ( $def['type'] == "postlist" ) {
|
553 |
+
$processed = false;
|
554 |
+
if ( is_array($def['listitems']) ) {
|
555 |
+
$has_current = in_array('include_current', $def['listitems']);
|
556 |
+
if ( $has_current ) unset($def['listitems'][array_search('include_current', $def['listitems'])]);
|
557 |
+
foreach ( $def['listitems'] as $post_type ) {
|
558 |
+
// if a post type cannot be found then we reset the list so that it is not processed at all
|
559 |
+
if ( get_post_type_object( $post_type ) == null ) {
|
560 |
+
$def['listitems'] = array();
|
561 |
+
break;
|
562 |
+
}
|
563 |
+
}
|
564 |
+
if ( count($def['listitems']) > 0 ) {
|
565 |
+
$selected = explode(",", $def['value']);
|
566 |
+
$only_current = false;
|
567 |
+
$echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'_postlist" type="hidden" value="'.implode(",", $def['listitems']).'" />';
|
568 |
+
$echo_str .= $dlp."\t\t".'<table class="wfu_postlist_container"><tbody><tr>';
|
569 |
+
if ( $has_current ) {
|
570 |
+
$only_current = ( $def['value'] == 'current' );
|
571 |
+
if ( $only_current ) $sselected = array();
|
572 |
+
$echo_str .= $dlp."\t\t".'<td colspan="'.count($def['listitems']).'"><div class="wfu_postlist_checkbtn"><input id="wfu_attribute_'.$attr.'_current" type="checkbox" onchange="wfu_update_postlist_value(\''.$attr.'\');"'.( $only_current ? ' checked="checked"' : '' ).' /><label for="wfu_attribute_'.$attr.'_current"> Only From Current Post/Page</label></div>';
|
573 |
+
$echo_str .= $dlp."\t\t".'</td></tr><tr>';
|
574 |
+
}
|
575 |
+
$postargs = array( 'post_type' => $def['listitems'], 'post_status' => "publish,private,draft", 'posts_per_page' => -1 );
|
576 |
+
/** This filter is documented in lib/wfu_admin.php */
|
577 |
+
$postargs = apply_filters("_wfu_get_posts", $postargs, "visual_editor");
|
578 |
+
$posts = get_posts($postargs);
|
579 |
+
$list = wfu_construct_post_list($posts);
|
580 |
+
$td_width = (int)(100 / count($def['listitems']));
|
581 |
+
foreach ( $def['listitems'] as $post_type ) {
|
582 |
+
$flatlist = wfu_flatten_post_list($list[$post_type]);
|
583 |
+
$postobj = get_post_type_object( $post_type );
|
584 |
+
$echo_str .= $dlp."\t\t".'<td style="width:'.$td_width.'%;"><div class="wfu_postlist_header"><label>'.$postobj->label.'</label><div class="wfu_postlist_selectall"><input id="wfu_attribute_'.$attr.'_all_'.$post_type.'" type="checkbox" onchange="wfu_update_postlist_value(\''.$attr.'\');"'.( in_array('all', $selected) || in_array('all'.$post_type, $selected) ? ' checked="checked"' : '' ).( $only_current ? ' disabled="disabled"' : '' ).' /><label for="wfu_attribute_'.$attr.'_all_'.$post_type.'"> Select all</label></div></div>';
|
585 |
+
$echo_str .= $dlp."\t\t".'<select id="wfu_attribute_'.$attr.'_'.$post_type.'" multiple="multiple" size="'.min(count($flatlist), 10).'" onchange="wfu_update_postlist_value(\''.$attr.'\');"'.( $only_current || in_array('all', $selected) || in_array('all'.$post_type, $selected) ? ' disabled="disabled"' : '' ).' style="width:100%; overflow:auto;">';
|
586 |
+
foreach ( $flatlist as $item )
|
587 |
+
$echo_str .= $dlp."\t\t\t".'<option value="'.$item['id'].'"'.( in_array($item['id'], $selected) ? ' selected="selected"' : '' ).'>'.str_repeat(' ', 4 * $item['level']).( $item['status'] == 1 ? '[Private]' : ( $item['status'] == 2 ? '[Draft]' : '' ) ).$item['title'].'</option>';
|
588 |
+
$echo_str .= $dlp."\t\t".'</select></td>';
|
589 |
+
}
|
590 |
+
$echo_str .= $dlp."\t\t".'</tr></tbody></table>';
|
591 |
+
$processed = true;
|
592 |
+
}
|
593 |
+
}
|
594 |
+
if ( !$processed ) {
|
595 |
+
$val = str_replace(array( "%n%", "%dq%", "%brl%", "%brr%" ), array( "\n", """, "[", "]" ), $def['value']);
|
596 |
+
$echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" value="'.$val.'" />';
|
597 |
+
}
|
598 |
+
}
|
599 |
+
elseif ( $def['type'] == "bloglist" ) {
|
600 |
+
if ( function_exists('wp_get_sites') ) {
|
601 |
+
$blogs = wp_get_sites( );
|
602 |
+
$selected = explode(",", $def['value']);
|
603 |
+
if ( in_array('all', $selected) ) $blogsselected = array( );
|
604 |
+
else $blogsselected = $selected;
|
605 |
+
$only_current = false;
|
606 |
+
$echo_str .= $dlp."\t\t".'<table class="wfu_bloglist_container"><tbody><tr>';
|
607 |
+
if ( is_array($def['listitems']) && in_array('include_current', $def['listitems']) ) {
|
608 |
+
$only_current = ( $def['value'] == 'current' );
|
609 |
+
if ( $only_current ) $blogsselected = array( );
|
610 |
+
$echo_str .= $dlp."\t\t".'<td colspan="2"><div class="wfu_bloglist_checkbtn"><input id="wfu_attribute_'.$attr.'_current" type="checkbox" onchange="wfu_update_bloglist_value(\''.$attr.'\');"'.( $only_current ? ' checked="checked"' : '' ).' /><label for="wfu_attribute_'.$attr.'_current"> Only From Current Site</label></div>';
|
611 |
+
$echo_str .= $dlp."\t\t".'</td></tr><tr>';
|
612 |
+
}
|
613 |
+
$echo_str .= $dlp."\t\t".'<td><select id="wfu_attribute_'.$attr.'" multiple="multiple" size="'.min(count($blogs), 10).'" onchange="wfu_update_bloglist_value(\''.$attr.'\');"'.( $only_current || in_array('all', $selected) ? ' disabled="disabled"' : '' ).'>';
|
614 |
+
foreach ( $blogs as $blog )
|
615 |
+
$echo_str .= $dlp."\t\t\t".'<option value="'.$blog->blog_id.'"'.( in_array($blog->blog_id, $blogsselected) ? ' selected="selected"' : '' ).'>'.$blog->path.'</option>';
|
616 |
+
$echo_str .= $dlp."\t\t".'</select>';
|
617 |
+
$echo_str .= $dlp."\t\t".'</td><td>';
|
618 |
+
$echo_str .= $dlp."\t\t".'<div class="wfu_bloglist_checkbtn"><input id="wfu_attribute_'.$attr.'_all" type="checkbox" onchange="wfu_update_bloglist_value(\''.$attr.'\');"'.( in_array('all', $selected) ? ' checked="checked"' : '' ).( $only_current ? ' disabled="disabled"' : '' ).' /><label for="wfu_attribute_'.$attr.'_all"> Select all</label></div>';
|
619 |
+
$echo_str .= $dlp."\t\t".'</td></tr></tbody></table>';
|
620 |
+
}
|
621 |
+
else {
|
622 |
+
$val = str_replace(array( "%n%", "%dq%", "%brl%", "%brr%" ), array( "\n", """, "[", "]" ), $def['value']);
|
623 |
+
$echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" value="'.$val.'" />';
|
624 |
+
}
|
625 |
+
}
|
626 |
+
elseif ( $def['type'] == "stringmatch" ) {
|
627 |
+
$matchfield = "";
|
628 |
+
$matchcriterion = "equal to";
|
629 |
+
$matchvalue = "";
|
630 |
+
preg_match('/^field:(.*?);\s*criterion:(.*?)\s*;\s*value:(.*)$/', $def['value'], $matches);
|
631 |
+
if ( count($matches) == 4 ) {
|
632 |
+
$matchfield = $matches[1];
|
633 |
+
$matchcriterion = $matches[2];
|
634 |
+
$matchvalue = $matches[3];
|
635 |
+
}
|
636 |
+
// $echo_str .= $dlp."\t\t".'<div style="white-space:nowrap;">';
|
637 |
+
$echo_str .= $dlp."\t\t".'<table class="wfu_stringmatch_container"><tbody><tr>';
|
638 |
+
$echo_str .= $dlp."\t\t".'<td style="width:40%; white-space:nowrap;"><label>Field </label><input id="wfu_attribute_'.$attr.'_matchfield" type="text" name="wfu_stringmatch_elements" value="'.$matchfield.'" style="width:auto;" /></td>';
|
639 |
+
$echo_str .= $dlp."\t\t".'<td style="width:30%;"><select id="wfu_attribute_'.$attr.'_matchcriterion" value="'.$matchcriterion.'" onchange="wfu_update_stringmatch_value(\''.$attr.'\');">';
|
640 |
+
$echo_str .= $dlp."\t\t\t".'<option value="equal to"'.( $matchcriterion == "equal to" ? 'selected="selected"' : '' ).'>equal to</option>';
|
641 |
+
$echo_str .= $dlp."\t\t\t".'<option value="starts with"'.( $matchcriterion == "starts with" ? 'selected="selected"' : '' ).'>starts with</option>';
|
642 |
+
$echo_str .= $dlp."\t\t\t".'<option value="ends with"'.( $matchcriterion == "ends with" ? 'selected="selected"' : '' ).'>ends with</option>';
|
643 |
+
$echo_str .= $dlp."\t\t\t".'<option value="contains"'.( $matchcriterion == "contains" ? 'selected="selected"' : '' ).'>contains</option>';
|
644 |
+
$echo_str .= $dlp."\t\t\t".'<option value="not equal to"'.( $matchcriterion == "not equal to" ? 'selected="selected"' : '' ).'>not equal to</option>';
|
645 |
+
$echo_str .= $dlp."\t\t\t".'<option value="does not start with"'.( $matchcriterion == "does not start with" ? 'selected="selected"' : '' ).'>does not start with</option>';
|
646 |
+
$echo_str .= $dlp."\t\t\t".'<option value="does not end with"'.( $matchcriterion == "does not end with" ? 'selected="selected"' : '' ).'>does not end with</option>';
|
647 |
+
$echo_str .= $dlp."\t\t\t".'<option value="does not contain"'.( $matchcriterion == "does not contain" ? 'selected="selected"' : '' ).'>does not contain</option>';
|
648 |
+
$echo_str .= $dlp."\t\t".'</select></td>';
|
649 |
+
$echo_str .= $dlp."\t\t".'<td style="width:30%;"><input id="wfu_attribute_'.$attr.'_matchvalue" type="text" name="wfu_stringmatch_elements" value="'.$matchvalue.'" style="width:auto;" /></td>';
|
650 |
+
$echo_str .= $dlp."\t\t".'</tr></tbody></table>';
|
651 |
+
// $echo_str .= $dlp."\t\t".'</div>';
|
652 |
+
}
|
653 |
+
elseif ( $def['type'] == "columns" ) {
|
654 |
+
$selected = explode(",", $def['value']);
|
655 |
+
if ( count($selected) == 1 && $selected[0] == "" ) $selected = array();
|
656 |
+
$selected_flat = array();
|
657 |
+
foreach ( $selected as $ind => $item ) $selected_flat[$ind] = preg_replace("/(:|\/).*$/", "", $item);
|
658 |
+
$echo_str .= $dlp."\t".'<table class="wfu_columns_container"><tbody><tr>';
|
659 |
+
$echo_str .= $dlp."\t\t\t".'<td style="width:45%;"><label class="wfu_columns_listtitle">Available Columns</label></td>';
|
660 |
+
$echo_str .= $dlp."\t\t\t".'<td style="width:55%"><label class="wfu_columns_listtitle">Displayed Columns</label></td></tr><tr>';
|
661 |
+
$echo_str .= $dlp."\t\t".'<td style="width:45%;">';
|
662 |
+
$echo_str .= $dlp."\t\t\t".'<table class="wfu_columns_container" style="table-layout:fixed; width:100%;"><tbody><tr>';
|
663 |
+
$echo_str .= $dlp."\t\t\t\t".'<td><select id="wfu_attribute_'.$attr.'_sourcelist" multiple="multiple" size="'.min(count($def['listitems']), 10).'" style="width:100%; overflow:auto;">';
|
664 |
+
$itemprops = array();
|
665 |
+
foreach ( $def['listitems'] as $item ) {
|
666 |
+
$item_required = ( substr($item, 0, 1) == "*" );
|
667 |
+
if ( $item_required ) $item = substr($item, 1);
|
668 |
+
$item_parts = explode("/", $item, 3);
|
669 |
+
$item_name = $item_parts[0];
|
670 |
+
$item_label = "";
|
671 |
+
$item_title = "";
|
672 |
+
if ( count($item_parts) > 1 ) $item_label = $item_parts[1];
|
673 |
+
if ( count($item_parts) == 3 ) $item_title = $item_parts[2];
|
674 |
+
$item_parts = explode(":", $item_name, 2);
|
675 |
+
$item_name = $item_parts[0];
|
676 |
+
if ( count($item_parts) == 1 ) $item_sort = "";
|
677 |
+
else $item_sort = $item_parts[1];
|
678 |
+
if ( $item_label == "" ) $item_label = $item_name;
|
679 |
+
if ( $item_title == "" ) $item_title = $item_label;
|
680 |
+
$itemprops[$item_name] = array( 'label' => $item_label, 'title' => $item_title, 'required' => $item_required, 'sortable' => ( $item_name == "custom" || $item_sort != "" ), 'sorttype' => $item_sort );
|
681 |
+
$val = $item_name.":".$item_sort."/".$item_title;
|
682 |
+
$echo_str .= $dlp."\t\t\t\t\t".'<option value="'.$val.'"'.( $item_required ? ' class="wfu_columns_item_required"' : '' ).' onclick="wfu_columns_itemclicked(this, \''.$attr.'\');">'.$item_label.'</option>';
|
683 |
+
}
|
684 |
+
foreach ( $itemprops as $item_name => $prop )
|
685 |
+
if ( $prop['required'] && !in_array($item_name, $selected_flat) )
|
686 |
+
array_splice($selected, 0, 0, array( $item_name ));
|
687 |
+
$selprops = array();
|
688 |
+
foreach ( $selected as $item ) {
|
689 |
+
$item_parts = explode("/", $item, 2);
|
690 |
+
$item_name = $item_parts[0];
|
691 |
+
if ( count($item_parts) == 1 ) $item_title = "";
|
692 |
+
else $item_title = $item_parts[1];
|
693 |
+
$item_parts = explode(":", $item_name, 2);
|
694 |
+
$item_name = $item_parts[0];
|
695 |
+
$flat_name = preg_replace("/^custom[0-9]+$/", "custom", $item_name);
|
696 |
+
if ( $item_name != "custom" && isset($itemprops[$flat_name]) ) {
|
697 |
+
$prop = $itemprops[$flat_name];
|
698 |
+
if ( count($item_parts) == 1 ) $item_sort = ( $flat_name == "custom" ? "+-s" : ( $prop['sortable'] ? "-+".$prop['sorttype'] : "" ) );
|
699 |
+
elseif ( $flat_name == "custom" ) $item_sort = "+".($item_parts[1] == "" ? "-s" : "+".$item_parts[1]);
|
700 |
+
else $item_sort = ( $prop['sortable'] ? "-".($item_parts[1] == "" ? "-" : "+").$prop['sorttype'].substr($item_parts[1], 1, 1) : "" );
|
701 |
+
if ( $item_title == "" ) $item_title = $prop['title'];
|
702 |
+
array_push($selprops, array( 'name' => $item_name, 'label' => $prop['label'], 'title' => $item_title, 'required' => $prop['required'], 'sorttype' => $item_sort ));
|
703 |
+
}
|
704 |
+
}
|
705 |
+
$echo_str .= $dlp."\t\t\t\t".'</select></td>';
|
706 |
+
$echo_str .= $dlp."\t\t\t\t".'<td style="width:30px; padding:0 6px;"><button class="wfu_columns_addbutton" title="add column" onclick="wfu_columns_buttonaction(\''.$attr.'\', \'add\');" style="width:100%;">>></button></td>';
|
707 |
+
$echo_str .= $dlp."\t\t\t".'</tr></tbody></table>';
|
708 |
+
$echo_str .= $dlp."\t\t".'</td>';
|
709 |
+
$echo_str .= $dlp."\t\t".'<td style="width:55%">';
|
710 |
+
$echo_str .= $dlp."\t\t\t".'<table class="wfu_columns_container" style="table-layout:fixed; width:100%;"><tbody><tr>';
|
711 |
+
$echo_str .= $dlp."\t\t\t\t".'<td><select id="wfu_attribute_'.$attr.'" multiple="multiple" size="'.min(count($def['listitems']), 10).'" onchange="wfu_update_columns(\''.$attr.'\');" style="width:100%; overflow:auto;">';
|
712 |
+
foreach ( $selprops as $prop ) {
|
713 |
+
$val = $prop['name'].":".$prop['sorttype']."/".$prop['label']."/".$prop['title'];
|
714 |
+
$echo_str .= $dlp."\t\t\t\t\t".'<option value="'.$val.'"'.( $prop['required'] ? ' class="wfu_columns_item_required"' : '' ).' onclick="wfu_columns_itemclicked(this, \''.$attr.'\');">'.$prop['label'].( $prop['title'] != "" && $prop['title'] != $prop['label'] ? " (".$prop['title'].")" : "" ).'</option>';
|
715 |
+
}
|
716 |
+
$echo_str .= $dlp."\t\t\t\t".'</select></td>';
|
717 |
+
$echo_str .= $dlp."\t\t\t\t".'<td style="width:30px; padding:0 6px;">';
|
718 |
+
$echo_str .= $dlp."\t\t\t\t\t".'<button class="wfu_columns_addbutton" title="move up" onclick="wfu_columns_buttonaction(\''.$attr.'\', \'up\');" style="width:100%;">↑</button>';
|
719 |
+
$echo_str .= $dlp."\t\t\t\t\t".'<button class="wfu_columns_addbutton" title="remove" onclick="wfu_columns_buttonaction(\''.$attr.'\', \'del\');" style="width:100%;">-</button>';
|
720 |
+
$echo_str .= $dlp."\t\t\t\t\t".'<button class="wfu_columns_addbutton" title="move down" onclick="wfu_columns_buttonaction(\''.$attr.'\', \'down\');" style="width:100%;">↓</button>';
|
721 |
+
$echo_str .= $dlp."\t\t\t\t".'</td>';
|
722 |
+
$echo_str .= $dlp."\t\t\t".'</tr></tbody></table>';
|
723 |
+
$echo_str .= $dlp."\t\t\t".'<label class="wfu_columns_listtitle" style="margin-top:6px; display:block;">Column Properties</label>';
|
724 |
+
$echo_str .= $dlp."\t\t\t".'<table id="wfu_attribute_'.$attr.'_columnprops_container" class="wfu_columnprops_container wfu_columnprops_container_disabled"><tbody>';
|
725 |
+
$echo_str .= $dlp."\t\t\t\t".'<tr><td style="width:1%; padding-right:10px;"><label id="wfu_attribute_'.$attr.'_columnprops_title_label">Title</label></td>';
|
726 |
+
$echo_str .= $dlp."\t\t\t\t".'<td><input type="text" id="wfu_attribute_'.$attr.'_columnprops_title" name="wfu_columnprops_elements" value="" style="width:100%;" disabled="disabled" /></td></tr>';
|
727 |
+
$echo_str .= $dlp."\t\t\t\t".'<tr><td style="width:1%; padding-right:10px; white-space:nowrap;"><label id="wfu_attribute_'.$attr.'_columnprops_id_label">Field ID</label></td>';
|
728 |
+
$echo_str .= $dlp."\t\t\t\t".'<td><input type="number" id="wfu_attribute_'.$attr.'_columnprops_id" name="wfu_columnprops_elements" min="1" value="" style="width:100%;" disabled="disabled" /></td></tr>';
|
729 |
+
$echo_str .= $dlp."\t\t\t\t".'<tr><td colspan="2"><input type="checkbox" id="wfu_attribute_'.$attr.'_columnprops_sort" value="" onchange="wfu_columnprops_element_changed({target:this});" disabled="disabled" /><label id="wfu_attribute_'.$attr.'_columnprops_sort_label" for="wfu_attribute_'.$attr.'_columnprops_sort">Sortable</label></td></tr>';
|
730 |
+
$echo_str .= $dlp."\t\t\t\t".'<tr><td style="width:1%; padding-right:10px;"><label id="wfu_attribute_'.$attr.'_columnprops_sorttype_label" style="white-space:nowrap;">Sort As</label></td>';
|
731 |
+
$echo_str .= $dlp."\t\t\t\t".'<td><select id="wfu_attribute_'.$attr.'_columnprops_sorttype" value="" onchange="wfu_columnprops_element_changed({target:this});" disabled="disabled"><option value=""></option><option value="s">String</option><option value="n">Integer</option></select></td></tr>';
|
732 |
+
$echo_str .= $dlp."\t\t\t\t".'<tr><td style="width:1%; padding-right:10px;"><label id="wfu_attribute_'.$attr.'_columnprops_defaultsort_label" style="white-space:nowrap;">Default Sort</label></td>';
|
733 |
+
$echo_str .= $dlp."\t\t\t\t".'<td><select id="wfu_attribute_'.$attr.'_columnprops_defaultsort" value="" onchange="wfu_columnprops_element_changed({target:this});" disabled="disabled"><option value=" "></option><option value="+">Ascending</option><option value="-">Descending</option></select></td></tr>';
|
734 |
+
$echo_str .= $dlp."\t\t\t".'</tbody></table>';
|
735 |
+
$echo_str .= $dlp."\t\t".'</td>';
|
736 |
+
$echo_str .= $dlp."\t".'</tr></tbody></table>';
|
737 |
+
|
738 |
+
}
|
739 |
+
elseif ( $def['type'] == "dimensions" ) {
|
740 |
+
$vals_arr = explode(",", $def['value']);
|
741 |
+
$vals = array();
|
742 |
+
foreach ( $vals_arr as $val_raw ) {
|
743 |
+
if ( trim($val_raw) != "" ) {
|
744 |
+
list($val_id, $val) = explode(":", $val_raw);
|
745 |
+
$vals[trim($val_id)] = trim($val);
|
746 |
+
}
|
747 |
+
}
|
748 |
+
$dims = array();
|
749 |
+
foreach ( $components as $comp ) {
|
750 |
+
if ( $comp['dimensions'] == null ) $dims[$comp['id']] = $comp['name'];
|
751 |
+
else foreach ( $comp['dimensions'] as $dimraw ) {
|
752 |
+
list($dim_id, $dim_name) = explode("/", $dimraw);
|
753 |
+
$dims[$dim_id] = $dim_name;
|
754 |
+
}
|
755 |
+
}
|
756 |
+
foreach ( $dims as $dim_id => $dim_name ) {
|
757 |
+
if ( !array_key_exists($dim_id, $vals) ) $vals[$dim_id] = "";
|
758 |
+
$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 />';
|
759 |
+
}
|
760 |
+
}
|
761 |
+
elseif ( $def['type'] == "userfields" ) {
|
762 |
+
$fields_arr = explode("/", $def['value']);
|
763 |
+
$fields = array();
|
764 |
+
foreach ( $fields_arr as $field_raw ) {
|
765 |
+
$is_req = ( substr($field_raw, 0, 1) == "*" );
|
766 |
+
if ( $is_req ) $field_raw = substr($field_raw, 1);
|
767 |
+
if ( $field_raw != "" ) array_push($fields, array( "name" => $field_raw, "required" => $is_req ));
|
768 |
+
}
|
769 |
+
if ( count($fields) == 0 ) array_push($fields, array( "name" => "", "required" => false ));
|
770 |
+
$echo_str .= $dlp."\t\t".'<div id="wfu_attribute_'.$attr.'" class="wfu_userdata_container">';
|
771 |
+
foreach ( $fields as $field ) {
|
772 |
+
$echo_str .= $dlp."\t\t\t".'<div class="wfu_userdata_line">';
|
773 |
+
$echo_str .= $dlp."\t\t\t\t".'<input type="text" name="wfu_userfield_elements" value="'.$field['name'].'" />';
|
774 |
+
$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>';
|
775 |
+
$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>';
|
776 |
+
$echo_str .= $dlp."\t\t\t\t".'<input type="checkbox"'.( $field['required'] ? 'checked="checked"' : '' ).' onchange="wfu_update_userfield_value({target:this});" />';
|
777 |
+
$echo_str .= $dlp."\t\t\t\t".'<span>Required</span>';
|
778 |
+
$echo_str .= $dlp."\t\t\t".'</div>';
|
779 |
+
}
|
780 |
+
$echo_str .= $dlp."\t\t".'</div>';
|
781 |
+
}
|
782 |
+
elseif ( $def['type'] == "formfields" ) {
|
783 |
+
//find occurrence index of this attribute and total occrrence length
|
784 |
+
$flat = $def['flat'];
|
785 |
+
$attr_occur_index = 0;
|
786 |
+
$attr_occur_length = 0;
|
787 |
+
$all_attributes = array();
|
788 |
+
foreach ( $defs as $def2 ) {
|
789 |
+
if ( $def2['flat'] == $flat ) {
|
790 |
+
$attr_occur_length ++;
|
791 |
+
array_push($all_attributes, $def2['attribute']);
|
792 |
+
if ( $def2['attribute'] == $attr ) $attr_occur_index = $attr_occur_length;
|
793 |
+
}
|
794 |
+
}
|
795 |
+
//get field type definitions
|
796 |
+
$fielddefs_array = $def['listitems'];
|
797 |
+
foreach ( $fielddefs_array as $fielddef ) $fielddefs[$fielddef['type']] = $fielddef;
|
798 |
+
//initialize editable field properties
|
799 |
+
$fieldprops_basic = array('label', 'required', 'donotautocomplete', 'validate', 'typehook', 'labelposition', 'hintposition', 'default', 'data', 'group', 'format');
|
800 |
+
$fieldprops_default = array ( "type" => "text", "label" => "", "labelposition" => "left", "required" => false, "donotautocomplete" => false, "validate" => false, "default" => "", "data" => "", "group" => "", "format" => "", "hintposition" => "right", "typehook" => false );
|
801 |
+
//parse shortcode attribute to $fields
|
802 |
+
$fields = wfu_parse_userdata_attribute($def['value']);
|
803 |
+
$labelpositions = array("none", "top", "right", "bottom", "left", "placeholder");
|
804 |
+
$hintpositions = array("none", "inline", "top", "right", "bottom", "left");
|
805 |
+
if ( count($fields) == 0 ) array_push($fields, $fieldprops_default);
|
806 |
+
//set html template variable
|
807 |
+
$template = $dlp."\t\t\t\t".'<table class="wfu_formdata_props_table"><tbody>';
|
808 |
+
$template .= $dlp."\t\t\t\t".'<tr><td colspan="2"><label class="wfu_formdata_label">Type</label><select id="wfu_formfield_[[key]]_type" value="[[t]]" onchange="wfu_formdata_type_changed(\'[[key]]\');">';
|
809 |
+
foreach( $fielddefs as $item ) $template .= $dlp."\t\t\t\t\t".'<option value="'.$item['type'].'"[[type_'.$item['type'].'_selected]]>'.$item['type_description'].'</option>';
|
810 |
+
$template .= $dlp."\t\t\t\t".'</select></td><td>';
|
811 |
+
$template .= $dlp."\t\t\t\t".'<div class="wfu_formdata_action wfu_formdata_action_add" onclick="wfu_formdata_add_field(\'[[key]]\');"><img src="'.WFU_IMAGE_ADMIN_USERDATA_ADD.'" ></div>';
|
812 |
+
$template .= $dlp."\t\t\t\t".'<div class="wfu_formdata_action wfu_formdata_action_remove[[remove_disabled]]" onclick="wfu_formdata_remove_field(\'[[key]]\');"><img src="'.WFU_IMAGE_ADMIN_USERDATA_REMOVE.'" ></div>';
|
813 |
+
$template .= $dlp."\t\t\t\t".'<div class="wfu_formdata_action wfu_formdata_action_up[[up_disabled]]" onclick="wfu_formdata_move_field(\'[[key]]\', \'up\');"><img src="'.WFU_IMAGE_ADMIN_USERDATA_UP.'" ></div>';
|
814 |
+
$template .= $dlp."\t\t\t\t".'<div class="wfu_formdata_action wfu_formdata_action_down[[down_disabled]]" onclick="wfu_formdata_move_field(\'[[key]]\', \'down\');"><img src="'.WFU_IMAGE_ADMIN_USERDATA_DOWN.'" ></div></td></tr>';
|
815 |
+
$template .= $dlp."\t\t\t\t".'<tr><td class="wfu_formdata_props"><label class="wfu_formdata_label" title="[[label_hint]]">[[label_label]]</label></td><td><input type="text" id="wfu_formfield_[[key]]_label" name="wfu_formfield_elements" value="[[label]]" /></td><td></td></tr>';
|
816 |
+
$labelpos_options = "";
|
817 |
+
foreach ( $labelpositions as $pos ) $labelpos_options .= '<option value="'.$pos.'"[[labelposition_'.$pos.'_selected]]>'.$pos.'</option>';
|
818 |
+
$template .= '[[S->]]'.$dlp."\t\t\t\t".'<tr><td class="wfu_formdata_props"><label class="wfu_formdata_labelposition" title="[[labelposition_hint]]">Label Position</label></td><td><select id="wfu_formfield_[[key]]_labelposition" value="[[s]]" title="[[labelposition_hint]]" onchange="wfu_update_formfield_value({target:this});">'.$labelpos_options.'</select></td><td></td></tr>[[<-S]]';
|
819 |
+
$template .= '[[R->]]'.$dlp."\t\t\t\t".'<tr><td colspan="2" class="wfu_formdata_props"><input id="wfu_formfield_[[key]]_required" type="checkbox"[[r->]] checked="checked"[[<-r]] title="[[required_hint]]" onchange="wfu_update_formfield_value({target:this});" /><label for="wfu_formfield_[[key]]_required" title="[[required_hint]]"> Required</label></td><td></td></tr>[[<-R]]';
|
820 |
+
$template .= '[[A->]]'.$dlp."\t\t\t\t".'<tr><td colspan="2" class="wfu_formdata_props"><input id="wfu_formfield_[[key]]_donotautocomplete" type="checkbox"[[a->]] checked="checked"[[<-a]] title="[[donotautocomplete_hint]]" onchange="wfu_update_formfield_value({target:this});" /><label for="wfu_formfield_[[key]]_donotautocomplete" title="[[donotautocomplete_hint]]"> Do not autocomplete</label></td><td></td></tr>[[<-A]]';
|
821 |
+
$template .= '[[V->]]'.$dlp."\t\t\t\t".'<tr><td colspan="2" class="wfu_formdata_props"><input id="wfu_formfield_[[key]]_validate" type="checkbox"[[v->]] checked="checked"[[<-v]] title="[[validate_hint]]" onchange="wfu_update_formfield_value({target:this});" /><label for="wfu_formfield_[[key]]_validate" title="[[validate_hint]]"> Validate</label></td><td></td></tr>[[<-V]]';
|
822 |
+
$hint_options = "";
|
823 |
+
foreach ( $hintpositions as $pos ) $hint_options .= '<option value="'.$pos.'"[[hintposition_'.$pos.'_selected]]>'.$pos.'</option>';
|
824 |
+
$template .= '[[P->]]'.$dlp."\t\t\t\t".'<tr><td class="wfu_formdata_props"><label class="wfu_formdata_label" title="[[hintposition_hint]]">Hint Position</label></td><td><select id="wfu_formfield_[[key]]_hintposition" value="[[p]]" title="[[hintposition_hint]]" onchange="wfu_update_formfield_value({target:this});">'.$hint_options.'</select></td><td></td></tr>[[<-P]]';
|
825 |
+
$template .= '[[H->]]'.$dlp."\t\t\t\t".'<tr><td colspan="2" class="wfu_formdata_props"><input id="wfu_formfield_[[key]]_typehook" type="checkbox"[[h->]] checked="checked"[[<-h]] title="[[typehook_hint]]" onchange="wfu_update_formfield_value({target:this});" /><label for="wfu_formfield_[[key]]_typehook" title="[[typehook_hint]]"> Type hook</label></td><td></td></tr>[[<-H]]';
|
826 |
+
$template .= '[[D->]]'.$dlp."\t\t\t\t".'<tr><td class="wfu_formdata_props"><label class="wfu_formdata_label" title="[[default_hint]]">Default</label></td><td><input id="wfu_formfield_[[key]]_default" type="text" name="wfu_formfield_elements" value="[[d]]" title="[[default_hint]]" /></td><td></td></tr>[[<-D]]';
|
827 |
+
$template .= '[[L->]]'.$dlp."\t\t\t\t".'<tr><td class="wfu_formdata_props"><label class="wfu_formdata_label" title="[[data_hint]]">[[data_label]]</label></td><td><input id="wfu_formfield_[[key]]_data" type="text" name="wfu_formfield_elements" value="[[l]]" title="[[data_hint]]" /></td><td></td></tr>[[<-L]]';
|
828 |
+
$template .= '[[G->]]'.$dlp."\t\t\t\t".'<tr><td class="wfu_formdata_props"><label class="wfu_formdata_label" title="[[group_hint]]">Group ID</label></td><td><input id="wfu_formfield_[[key]]_group" type="text" name="wfu_formfield_elements" value="[[g]]" title="[[group_hint]]" /></td><td></td></tr>[[<-G]]';
|
829 |
+
$template .= '[[F->]]'.$dlp."\t\t\t\t".'<tr><td class="wfu_formdata_props"><label class="wfu_formdata_label" title="[[format_hint]]">Format</label></td><td><input id="wfu_formfield_[[key]]_format" type="text" name="wfu_formfield_elements" value="[[f]]" title="[[format_hint]]" /></td><td></td></tr>[[<-F]]';
|
830 |
+
$template .= $dlp."\t\t\t\t".'</tbody></table>';
|
831 |
+
//draw html elements
|
832 |
+
$echo_str .= $dlp."\t\t".'<div id="wfu_attribute_'.$attr.'" class="wfu_formdata_container">';
|
833 |
+
$echo_str .= $dlp."\t\t\t".'<input type="hidden" class="wfu_formdata_all_attributes" value="'.implode(",", $all_attributes).'" />';
|
834 |
+
$echo_str .= $dlp."\t\t\t".'<div id="wfu_attribute_'.$attr.'_codeadd" style="display:none;">';
|
835 |
+
//pass template and type props to client javascript variable and then erase the code
|
836 |
+
$echo_str .= $dlp."\t\t\t\t".'<script type="text/javascript">';
|
837 |
+
$echo_str .= $dlp."\t\t\t\t\t".'var wfu_attribute_'.$attr.'_formtemplate = "'.wfu_plugin_encode_string($template).'";';
|
838 |
+
$echo_str .= $dlp."\t\t\t\t\t".'var wfu_attribute_'.$attr.'_typeprops = {};';
|
839 |
+
$fielddef_array = array();
|
840 |
+
foreach( $fielddefs as $item ) array_push($fielddef_array, $item['type']);
|
841 |
+
//prepare storage of field definitions to browser context
|
842 |
+
$echo_str .= $dlp."\t\t\t\t\t".'wfu_attribute_'.$attr.'_typeprops[0] = \''.implode(",", $fielddef_array).'\'';
|
843 |
+
foreach( $fielddefs as $item ) {
|
844 |
+
$typeprops = array();
|
845 |
+
foreach ( $fieldprops_basic as $prop ) {
|
846 |
+
array_push($typeprops, $prop.': \''.$item[$prop].'\'');
|
847 |
+
array_push($typeprops, $prop.'_hint: \''.$item[$prop.'_hint'].'\'');
|
848 |
+
}
|
849 |
+
array_push($typeprops, 'label_label: \''.$item['label_label'].'\'');
|
850 |
+
array_push($typeprops, 'data_label: \''.$item['data_label'].'\'');
|
851 |
+
$echo_str .= $dlp."\t\t\t\t\t".'wfu_attribute_'.$attr.'_typeprops["'.$item['type'].'"] = {'.implode(", ", $typeprops).'};';
|
852 |
+
}
|
853 |
+
$echo_str .= $dlp."\t\t\t\t\t".'var self = document.getElementById("wfu_attribute_'.$attr.'_codeadd"); self.parentNode.removeChild(self);';
|
854 |
+
$echo_str .= $dlp."\t\t\t\t".'</script>';
|
855 |
+
$echo_str .= $dlp."\t\t\t".'</div>';
|
856 |
+
$i = 1;
|
857 |
+
foreach ( $fields as $field ) {
|
858 |
+
$ind = wfu_create_random_string(4);
|
859 |
+
$key = $attr."_".$ind;
|
860 |
+
$fielddef = $fielddefs[$field["type"]];
|
861 |
+
$echo_str .= $dlp."\t\t\t".'<div id="wfu_formfield_'.$key.'_container" class="wfu_formdata_line_container">';
|
862 |
+
//generate html elements from template, replacing variables where applicable
|
863 |
+
$from_template = str_replace(array('[[key]]', '[[t]]', '[[label]]', '[[s]]', '[[d]]', '[[l]]', '[[label_label]]', '[[data_label]]', '[[g]]', '[[f]]', '[[p]]'), array($key, $field['type'], $field['label'], $field['labelposition'], $field['default'], $field['data'], $fielddef['label_label'], $fielddef['data_label'], $field['group'], $field['format'], $field['hintposition']), $template);
|
864 |
+
foreach ( $fieldprops_basic as $prop ) $from_template = str_replace('[['.$prop.'_hint]]', str_replace('\r\n', "\r\n", $fielddef[$prop.'_hint']), $from_template);
|
865 |
+
foreach( $fielddefs as $item ) $from_template = str_replace('[[type_'.$item['type'].'_selected]]', ( $item['type'] == $field['type'] ? ' selected = "selected"' : '' ), $from_template);
|
866 |
+
foreach( $labelpositions as $pos ) $from_template = str_replace('[[labelposition_'.$pos.'_selected]]', ( $pos == $field['labelposition'] ? ' selected = "selected"' : '' ), $from_template);
|
867 |
+
foreach( $hintpositions as $pos ) $from_template = str_replace('[[hintposition_'.$pos.'_selected]]', ( $pos == $field['hintposition'] ? ' selected = "selected"' : '' ), $from_template);
|
868 |
+
$from_template = str_replace('[[remove_disabled]]', ( count($fields) <= 1 ? ' wfu_formdata_action_disabled' : '' ), $from_template);
|
869 |
+
$from_template = str_replace('[[up_disabled]]', ( ( $attr_occur_index == 1 && $i == 1 ) ? ' wfu_formdata_action_disabled' : '' ), $from_template);
|
870 |
+
$from_template = str_replace('[[down_disabled]]', ( ( $attr_occur_index == $attr_occur_length && $i == count($fields) ) ? ' wfu_formdata_action_disabled' : '' ), $from_template);
|
871 |
+
//adjust checkbox field values
|
872 |
+
$from_template = preg_replace('/\[\[r\-\>\]\]'.( $field['required'] ? '|' : '.*' ).'\[\[\<\-r\]\]/', '', $from_template);
|
873 |
+
$from_template = preg_replace('/\[\[a\-\>\]\]'.( $field['donotautocomplete'] ? '|' : '.*' ).'\[\[\<\-a\]\]/', '', $from_template);
|
874 |
+
$from_template = preg_replace('/\[\[v\-\>\]\]'.( $field['validate'] ? '|' : '.*' ).'\[\[\<\-v\]\]/', '', $from_template);
|
875 |
+
$from_template = preg_replace('/\[\[h\-\>\]\]'.( $field['typehook'] ? '|' : '.*' ).'\[\[\<\-h\]\]/', '', $from_template);
|
876 |
+
//adjust visibility of properties
|
877 |
+
$from_template = preg_replace('/\[\[S\-\>\]\]'.( substr($fielddef["labelposition"], 0, 4) == "show" ? '|' : '.*' ).'\[\[\<\-S\]\]/s', '', $from_template);
|
878 |
+
$from_template = preg_replace('/\[\[R\-\>\]\]'.( substr($fielddef["required"], 0, 4) == "show" ? '|' : '.*' ).'\[\[\<\-R\]\]/s', '', $from_template);
|
879 |
+
$from_template = preg_replace('/\[\[A\-\>\]\]'.( substr($fielddef["donotautocomplete"], 0, 4) == "show" ? '|' : '.*' ).'\[\[\<\-A\]\]/s', '', $from_template);
|
880 |
+
$from_template = preg_replace('/\[\[V\-\>\]\]'.( substr($fielddef["validate"], 0, 4) == "show" ? '|' : '.*' ).'\[\[\<\-V\]\]/s', '', $from_template);
|
881 |
+
$from_template = preg_replace('/\[\[P\-\>\]\]'.( substr($fielddef["hintposition"], 0, 4) == "show" ? '|' : '.*' ).'\[\[\<\-P\]\]/s', '', $from_template);
|
882 |
+
$from_template = preg_replace('/\[\[H\-\>\]\]'.( substr($fielddef["typehook"], 0, 4) == "show" ? '|' : '.*' ).'\[\[\<\-H\]\]/s', '', $from_template);
|
883 |
+
$from_template = preg_replace('/\[\[D\-\>\]\]'.( substr($fielddef["default"], 0, 4) == "show" ? '|' : '.*' ).'\[\[\<\-D\]\]/s', '', $from_template);
|
884 |
+
$from_template = preg_replace('/\[\[L\-\>\]\]'.( substr($fielddef["data"], 0, 4) == "show" ? '|' : '.*' ).'\[\[\<\-L\]\]/s', '', $from_template);
|
885 |
+
$from_template = preg_replace('/\[\[G\-\>\]\]'.( substr($fielddef["group"], 0, 4) == "show" ? '|' : '.*' ).'\[\[\<\-G\]\]/s', '', $from_template);
|
886 |
+
$from_template = preg_replace('/\[\[F\-\>\]\]'.( substr($fielddef["format"], 0, 4) == "show" ? '|' : '.*' ).'\[\[\<\-F\]\]/s', '', $from_template);
|
887 |
+
$echo_str .= $from_template;
|
888 |
+
$echo_str .= $dlp."\t\t\t".'</div>';
|
889 |
+
$i++;
|
890 |
+
}
|
891 |
+
$echo_str .= $dlp."\t\t".'</div>';
|
892 |
+
}
|
893 |
+
elseif ( $def['type'] == "color" ) {
|
894 |
+
$val = str_replace(array( "%n%", "%dq%", "%brl%", "%brr%" ), array( "\n", """, "[", "]" ), $def['value']);
|
895 |
+
$echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" class="wfu_color_field" value="'.$val.'" />';
|
896 |
+
}
|
897 |
+
elseif ( $def['type'] == "color-triplet" ) {
|
898 |
+
$triplet = explode(",", $def['value']);
|
899 |
+
foreach ( $triplet as $key => $item ) $triplet[$key] = trim($item);
|
900 |
+
if ( count($triplet) == 2 ) $triplet = array( $triplet[0], $triplet[1], "#000000");
|
901 |
+
elseif ( count($triplet) == 1 ) $triplet = array( $triplet[0], "#FFFFFF", "#000000");
|
902 |
+
elseif ( count($triplet) < 3 ) $triplet = array( "#000000", "#FFFFFF", "#000000");
|
903 |
+
$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>';
|
904 |
+
$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>';
|
905 |
+
$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>';
|
906 |
+
}
|
907 |
+
else {
|
908 |
+
$echo_str .= $dlp."\t\t".'<input id="wfu_attribute_'.$attr.'" type="text" name="wfu_text_elements" value="'.$def['value'].'" />';
|
909 |
+
if ( $def['variables'] != null ) $echo_str .= $dlp.wfu_insert_variables($def['variables'], 'wfu_variable wfu_variable_'.$attr);
|
910 |
+
}
|
911 |
+
$echo_str .= $dlp."\t".'</div></td>';
|
912 |
+
if ( $def['parent'] == "" ) {
|
913 |
+
$echo_str .= $dlp."\t".'<td style="position:relative; vertical-align:top; padding:0;"><div class="wfu_td_div">';
|
914 |
+
$block_open = false;
|
915 |
+
}
|
916 |
+
else {
|
917 |
+
$echo_str .= $dlp.'</tr>';
|
918 |
+
$subblock_open = true;
|
919 |
+
}
|
920 |
+
}
|
921 |
+
if ( $subblock_open ) {
|
922 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</div>';
|
923 |
+
}
|
924 |
+
if ( $block_open ) {
|
925 |
+
$echo_str .= "\n\t\t\t\t\t".'</div></td>';
|
926 |
+
$echo_str .= "\n\t\t\t\t".'</tr>';
|
927 |
+
}
|
928 |
+
$echo_str .= "\n\t\t\t".'</tbody>';
|
929 |
+
$echo_str .= "\n\t\t".'</table>';
|
930 |
+
$echo_str .= "\n\t".'</div>';
|
931 |
+
$echo_str .= "\n\t".'<div id="wfu_global_dialog_container" class="wfu_global_dialog_container">';
|
932 |
+
$echo_str .= "\n\t".'</div>';
|
933 |
+
$handler = 'function() { wfu_Attach_Admin_Events('.( $data == "" ? 'true' : 'false' ).'); }';
|
934 |
+
$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>';
|
935 |
+
$echo_str .= "\n".'</div>';
|
936 |
+
// $echo_str .= "\n\t".'<div style="margin-top:10px;">';
|
937 |
+
// $echo_str .= "\n\t\t".'<label>Final shortcode text</label>';
|
938 |
+
// $echo_str .= "\n\t".'</div>';
|
939 |
+
|
940 |
+
echo $echo_str;
|
941 |
+
}
|
942 |
+
|
943 |
+
/**
|
944 |
+
* Insert Variables in an Attribute.
|
945 |
+
*
|
946 |
+
* This function generates the HTML code of the variables that are shown below
|
947 |
+
* the attribute which they refer to.
|
948 |
+
*
|
949 |
+
* @since 2.1.3
|
950 |
+
*
|
951 |
+
* @param array $variables. The array of variables to display below the
|
952 |
+
* attribute.
|
953 |
+
* @param string $class A class name to set in the elements of the generated
|
954 |
+
* HTML code.
|
955 |
+
*
|
956 |
+
* @return string The HTML output of the variables.
|
957 |
+
*/
|
958 |
+
function wfu_insert_variables($variables, $class) {
|
959 |
+
$ret = "";
|
960 |
+
foreach ( $variables as $variable )
|
961 |
+
if ( $variable == "%userdataXXX%" ) $ret .= "\t\t".'<select class="'.$class.'" name="wfu_formfield_select" title="'.constant("WFU_VARIABLE_TITLE_".strtoupper(str_replace("%", "", $variable))).'" onchange="wfu_insert_userfield_variable(this);"><option style="display:none;">%userdataXXX%</option></select>';
|
962 |
+
elseif ( $variable != "%n%" && $variable != "%dq%" && $variable != "%brl%" && $variable != "%brr%" ) $ret .= "\t\t".'<span class="'.$class.'" title="'.constant("WFU_VARIABLE_TITLE_".strtoupper(str_replace("%", "", $variable))).'" ondblclick="wfu_insert_variable(this);">'.$variable.'</span>';
|
963 |
+
return $ret;
|
964 |
}
|
lib/wfu_admin_log.php
CHANGED
@@ -1,203 +1,204 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* View Log Page in Dashboard Area of Plugin
|
5 |
-
*
|
6 |
-
* This file contains functions related to View Log page of plugin's Dashboard
|
7 |
-
* area.
|
8 |
-
*
|
9 |
-
* @link /lib/wfu_admin_log.php
|
10 |
-
*
|
11 |
-
* @package WordPress File Upload Plugin
|
12 |
-
* @subpackage Core Components
|
13 |
-
* @since 2.4.1
|
14 |
-
*/
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Display the View Log Page.
|
18 |
-
*
|
19 |
-
* This function displays the View Log page of the plugin's Dashboard area.
|
20 |
-
*
|
21 |
-
* @since 2.4.1
|
22 |
-
*
|
23 |
-
* @param integer $page Optional. The page to display in case log contents are
|
24 |
-
* paginated.
|
25 |
-
* @param bool $only_table_rows Optional. Return only the HTML code of the table
|
26 |
-
* rows.
|
27 |
-
* @param bool $located_rec Optional. The unique ID of a log record to focus and
|
28 |
-
* highlight.
|
29 |
-
*
|
30 |
-
* @return string The HTML output of the plugin's View Log Dashboard page.
|
31 |
-
*/
|
32 |
-
function wfu_view_log($page = 1, $only_table_rows = false, $located_rec = -1) {
|
33 |
-
$a = func_get_args(); $a = WFU_FUNCTION_HOOK(__FUNCTION__, $a, $out); if (isset($out['vars'])) foreach($out['vars'] as $p => $v) $$p = $v; switch($a) { case 'R': return $out['output']; break; case 'D': die($out['output']); }
|
34 |
-
global $wpdb;
|
35 |
-
$siteurl = site_url();
|
36 |
-
$table_name1 = $wpdb->prefix . "wfu_log";
|
37 |
-
$table_name2 = $wpdb->prefix . "wfu_userdata";
|
38 |
-
$plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
|
39 |
-
|
40 |
-
if ( !current_user_can( 'manage_options' ) ) return;
|
41 |
-
|
42 |
-
$maxrows = (int)WFU_VAR("WFU_HISTORYLOG_TABLE_MAXROWS");
|
43 |
-
//get log data from database
|
44 |
-
$files_total = $wpdb->get_var('SELECT COUNT(idlog) FROM '.$table_name1);
|
45 |
-
//if we need to locate and focus on a specific record, then we need to
|
46 |
-
//recalculate and define the right page
|
47 |
-
if ( $located_rec > 0 && $maxrows > 0 ) {
|
48 |
-
$files_before = $wpdb->get_var('SELECT COUNT(idlog) FROM '.$table_name1.' WHERE idlog > '.(int)$located_rec);
|
49 |
-
$page = floor( $files_before / $maxrows ) + 1;
|
50 |
-
}
|
51 |
-
$filerecs = $wpdb->get_results('SELECT * FROM '.$table_name1.' ORDER BY date_from DESC'.( $maxrows > 0 ? ' LIMIT '.$maxrows.' OFFSET '.(($page - 1) * $maxrows) : '' ));
|
52 |
-
|
53 |
-
$echo_str = "";
|
54 |
-
if ( !$only_table_rows ) {
|
55 |
-
$echo_str .= "\n".'<div class="wrap">';
|
56 |
-
$echo_str .= "\n\t".'<h2>Wordpress File Upload Control Panel</h2>';
|
57 |
-
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
58 |
-
$echo_str .= wfu_generate_dashboard_menu("\n\t\t", "View Log");
|
59 |
-
$echo_str .= "\n\t".'<div style="position:relative;">';
|
60 |
-
$echo_str .= wfu_add_loading_overlay("\n\t\t", "historylog");
|
61 |
-
$echo_str .= "\n\t\t".'<div class="wfu_historylog_header" style="width: 100%;">';
|
62 |
-
if ( $maxrows > 0 ) {
|
63 |
-
$pages = max(ceil($files_total / $maxrows), 1);
|
64 |
-
if ( $page > $pages ) $page = $pages;
|
65 |
-
$echo_str .= wfu_add_pagination_header("\n\t\t\t", "historylog", $page, $pages);
|
66 |
-
}
|
67 |
-
$echo_str .= "\n\t\t".'</div>';
|
68 |
-
$echo_str .= "\n\t\t".'<table id="wfu_historylog_table" class="wfu-historylog wp-list-table widefat fixed striped">';
|
69 |
-
$echo_str .= "\n\t\t\t".'<thead>';
|
70 |
-
$echo_str .= "\n\t\t\t\t".'<tr>';
|
71 |
-
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="5%" class="manage-column">';
|
72 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<label>#</label>';
|
73 |
-
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
74 |
-
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="30%" class="manage-column column-primary">';
|
75 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<label>File</label>';
|
76 |
-
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
77 |
-
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="10%" class="manage-column">';
|
78 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<label>Action</label>';
|
79 |
-
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
80 |
-
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="15%" class="manage-column">';
|
81 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<label>Date</label>';
|
82 |
-
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
83 |
-
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="15%" class="manage-column">';
|
84 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<label>User</label>';
|
85 |
-
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
86 |
-
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="25%" class="manage-column">';
|
87 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<label>Remarks</label>';
|
88 |
-
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
89 |
-
$echo_str .= "\n\t\t\t\t".'</tr>';
|
90 |
-
$echo_str .= "\n\t\t\t".'</thead>';
|
91 |
-
$echo_str .= "\n\t\t\t".'<tbody>';
|
92 |
-
}
|
93 |
-
|
94 |
-
$userdatarecs = $wpdb->get_results('SELECT * FROM '.$table_name2);
|
95 |
-
$deletedfiles = array();
|
96 |
-
$filecodes = array();
|
97 |
-
$logpagecode = wfu_safe_store_browser_params('view_log&tag='.$page);
|
98 |
-
$time0 = strtotime("0000-00-00 00:00:00");
|
99 |
-
$i = ($page - 1) * $maxrows;
|
100 |
-
$filerecs_count = count($filerecs);
|
101 |
-
foreach ( $filerecs as $ind => $filerec ) {
|
102 |
-
$remarks = '';
|
103 |
-
if ( $filerec->action == 'delete' ) array_push($deletedfiles, $filerec->linkedto);
|
104 |
-
elseif ( $filerec->action == 'rename' || $filerec->action == 'move' ) {
|
105 |
-
$prevfilepath = '';
|
106 |
-
$prevfilerec = wfu_get_file_rec_from_id($filerec->linkedto);
|
107 |
-
if ( $prevfilerec != null ) $prevfilepath = $prevfilerec->filepath;
|
108 |
-
if ( $prevfilepath != '' )
|
109 |
-
$remarks = "\n\t\t\t\t\t\t".'<label>Previous filepath: '.$prevfilepath.'</label>';
|
110 |
-
}
|
111 |
-
elseif ( $filerec->action == 'upload' || $filerec->action == 'modify' || $filerec->action == 'datasubmit' ) {
|
112 |
-
foreach ( $userdatarecs as $userdata ) {
|
113 |
-
if ( $userdata->uploadid == $filerec->uploadid ) {
|
114 |
-
$userdata_datefrom = strtotime($userdata->date_from);
|
115 |
-
$userdata_dateto = strtotime($userdata->date_to);
|
116 |
-
$filerec_datefrom = strtotime($filerec->date_from);
|
117 |
-
if ( $filerec_datefrom >= $userdata_datefrom && ( $userdata_dateto == $time0 || $filerec_datefrom < $userdata_dateto ) )
|
118 |
-
$remarks .= "\n\t\t\t\t\t\t\t".'<option>'.$userdata->property.': '.$userdata->propvalue.'</option>';
|
119 |
-
}
|
120 |
-
}
|
121 |
-
if ( $remarks != '' ) {
|
122 |
-
$remarks = "\n\t\t\t\t\t\t".'<select multiple="multiple" style="width:100%; height:40px; background:none; font-size:small; overflow:scroll; resize:vertical;">'.$remarks;
|
123 |
-
$remarks .= "\n\t\t\t\t\t\t".'</select>';
|
124 |
-
}
|
125 |
-
}
|
126 |
-
elseif ( $filerec->action == 'changeuser' ) {
|
127 |
-
$prevuploaduserid = '';
|
128 |
-
$prevfilerec = wfu_get_file_rec_from_id($filerec->linkedto);
|
129 |
-
if ( $prevfilerec != null ) $prevuploaduserid = $prevfilerec->uploaduserid;
|
130 |
-
if ( $prevuploaduserid != '' ) {
|
131 |
-
$prevuploaduser = wfu_get_username_by_id($prevuploaduserid);
|
132 |
-
$remarks = "\n\t\t\t\t\t\t".'<label>Previous upload user: '.$prevuploaduser.'</label>';
|
133 |
-
}
|
134 |
-
}
|
135 |
-
elseif ( $filerec->action == 'other' ) {
|
136 |
-
$info = $filerec->filepath;
|
137 |
-
$filerec->filepath = '';
|
138 |
-
$remarks = "\n\t\t\t\t\t\t".'<textarea style="width:100%; resize:vertical; background:none;" readonly="readonly">'.$info.'</textarea>';
|
139 |
-
}
|
140 |
-
$
|
141 |
-
$
|
142 |
-
$echo_str .= "\n\t\t\t\t
|
143 |
-
$echo_str .= "\n\t\t\t\t\t".'<
|
144 |
-
|
145 |
-
|
146 |
-
elseif (
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
$
|
151 |
-
$
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
$
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
$
|
162 |
-
$
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
$
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
//
|
173 |
-
//
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
$echo_str .= "\n\t\t\t\t\t".'</
|
182 |
-
$echo_str .= "\n\t\t\t\t\t".'
|
183 |
-
$echo_str .= "\n\t\t\t\t\t".'<td data-colname="
|
184 |
-
$echo_str .= "\n\t\t\t\t\t".'<td data-colname="
|
185 |
-
$echo_str .= "\n\t\t\t\t\t".'<td data-colname="
|
186 |
-
$echo_str .=
|
187 |
-
$echo_str .=
|
188 |
-
$echo_str .= "\n\t\t\t\t".'</
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
$echo_str .= "\n\t\t".'</
|
193 |
-
$echo_str .= "\n\t".'</
|
194 |
-
$echo_str .= "\n\t".'</div>';
|
195 |
-
$echo_str .= "\n".'</div>';
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
$
|
200 |
-
|
201 |
-
|
202 |
-
|
|
|
203 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* View Log Page in Dashboard Area of Plugin
|
5 |
+
*
|
6 |
+
* This file contains functions related to View Log page of plugin's Dashboard
|
7 |
+
* area.
|
8 |
+
*
|
9 |
+
* @link /lib/wfu_admin_log.php
|
10 |
+
*
|
11 |
+
* @package WordPress File Upload Plugin
|
12 |
+
* @subpackage Core Components
|
13 |
+
* @since 2.4.1
|
14 |
+
*/
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Display the View Log Page.
|
18 |
+
*
|
19 |
+
* This function displays the View Log page of the plugin's Dashboard area.
|
20 |
+
*
|
21 |
+
* @since 2.4.1
|
22 |
+
*
|
23 |
+
* @param integer $page Optional. The page to display in case log contents are
|
24 |
+
* paginated.
|
25 |
+
* @param bool $only_table_rows Optional. Return only the HTML code of the table
|
26 |
+
* rows.
|
27 |
+
* @param bool $located_rec Optional. The unique ID of a log record to focus and
|
28 |
+
* highlight.
|
29 |
+
*
|
30 |
+
* @return string The HTML output of the plugin's View Log Dashboard page.
|
31 |
+
*/
|
32 |
+
function wfu_view_log($page = 1, $only_table_rows = false, $located_rec = -1) {
|
33 |
+
$a = func_get_args(); $a = WFU_FUNCTION_HOOK(__FUNCTION__, $a, $out); if (isset($out['vars'])) foreach($out['vars'] as $p => $v) $$p = $v; switch($a) { case 'R': return $out['output']; break; case 'D': die($out['output']); }
|
34 |
+
global $wpdb;
|
35 |
+
$siteurl = site_url();
|
36 |
+
$table_name1 = $wpdb->prefix . "wfu_log";
|
37 |
+
$table_name2 = $wpdb->prefix . "wfu_userdata";
|
38 |
+
$plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
|
39 |
+
|
40 |
+
if ( !current_user_can( 'manage_options' ) ) return;
|
41 |
+
|
42 |
+
$maxrows = (int)WFU_VAR("WFU_HISTORYLOG_TABLE_MAXROWS");
|
43 |
+
//get log data from database
|
44 |
+
$files_total = $wpdb->get_var('SELECT COUNT(idlog) FROM '.$table_name1);
|
45 |
+
//if we need to locate and focus on a specific record, then we need to
|
46 |
+
//recalculate and define the right page
|
47 |
+
if ( $located_rec > 0 && $maxrows > 0 ) {
|
48 |
+
$files_before = $wpdb->get_var('SELECT COUNT(idlog) FROM '.$table_name1.' WHERE idlog > '.(int)$located_rec);
|
49 |
+
$page = floor( $files_before / $maxrows ) + 1;
|
50 |
+
}
|
51 |
+
$filerecs = $wpdb->get_results('SELECT * FROM '.$table_name1.' ORDER BY date_from DESC'.( $maxrows > 0 ? ' LIMIT '.$maxrows.' OFFSET '.(($page - 1) * $maxrows) : '' ));
|
52 |
+
|
53 |
+
$echo_str = "";
|
54 |
+
if ( !$only_table_rows ) {
|
55 |
+
$echo_str .= "\n".'<div class="wrap">';
|
56 |
+
$echo_str .= "\n\t".'<h2>Wordpress File Upload Control Panel</h2>';
|
57 |
+
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
58 |
+
$echo_str .= wfu_generate_dashboard_menu("\n\t\t", "View Log");
|
59 |
+
$echo_str .= "\n\t".'<div style="position:relative;">';
|
60 |
+
$echo_str .= wfu_add_loading_overlay("\n\t\t", "historylog");
|
61 |
+
$echo_str .= "\n\t\t".'<div class="wfu_historylog_header" style="width: 100%;">';
|
62 |
+
if ( $maxrows > 0 ) {
|
63 |
+
$pages = max(ceil($files_total / $maxrows), 1);
|
64 |
+
if ( $page > $pages ) $page = $pages;
|
65 |
+
$echo_str .= wfu_add_pagination_header("\n\t\t\t", "historylog", $page, $pages);
|
66 |
+
}
|
67 |
+
$echo_str .= "\n\t\t".'</div>';
|
68 |
+
$echo_str .= "\n\t\t".'<table id="wfu_historylog_table" class="wfu-historylog wp-list-table widefat fixed striped">';
|
69 |
+
$echo_str .= "\n\t\t\t".'<thead>';
|
70 |
+
$echo_str .= "\n\t\t\t\t".'<tr>';
|
71 |
+
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="5%" class="manage-column">';
|
72 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<label>#</label>';
|
73 |
+
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
74 |
+
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="30%" class="manage-column column-primary">';
|
75 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<label>File</label>';
|
76 |
+
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
77 |
+
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="10%" class="manage-column">';
|
78 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<label>Action</label>';
|
79 |
+
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
80 |
+
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="15%" class="manage-column">';
|
81 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<label>Date</label>';
|
82 |
+
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
83 |
+
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="15%" class="manage-column">';
|
84 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<label>User</label>';
|
85 |
+
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
86 |
+
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="25%" class="manage-column">';
|
87 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<label>Remarks</label>';
|
88 |
+
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
89 |
+
$echo_str .= "\n\t\t\t\t".'</tr>';
|
90 |
+
$echo_str .= "\n\t\t\t".'</thead>';
|
91 |
+
$echo_str .= "\n\t\t\t".'<tbody>';
|
92 |
+
}
|
93 |
+
|
94 |
+
$userdatarecs = $wpdb->get_results('SELECT * FROM '.$table_name2);
|
95 |
+
$deletedfiles = array();
|
96 |
+
$filecodes = array();
|
97 |
+
$logpagecode = wfu_safe_store_browser_params('view_log&tag='.$page);
|
98 |
+
$time0 = strtotime("0000-00-00 00:00:00");
|
99 |
+
$i = ($page - 1) * $maxrows;
|
100 |
+
$filerecs_count = count($filerecs);
|
101 |
+
foreach ( $filerecs as $ind => $filerec ) {
|
102 |
+
$remarks = '';
|
103 |
+
if ( $filerec->action == 'delete' ) array_push($deletedfiles, $filerec->linkedto);
|
104 |
+
elseif ( $filerec->action == 'rename' || $filerec->action == 'move' ) {
|
105 |
+
$prevfilepath = '';
|
106 |
+
$prevfilerec = wfu_get_file_rec_from_id($filerec->linkedto);
|
107 |
+
if ( $prevfilerec != null ) $prevfilepath = $prevfilerec->filepath;
|
108 |
+
if ( $prevfilepath != '' )
|
109 |
+
$remarks = "\n\t\t\t\t\t\t".'<label>Previous filepath: '.$prevfilepath.'</label>';
|
110 |
+
}
|
111 |
+
elseif ( $filerec->action == 'upload' || $filerec->action == 'modify' || $filerec->action == 'datasubmit' ) {
|
112 |
+
foreach ( $userdatarecs as $userdata ) {
|
113 |
+
if ( $userdata->uploadid == $filerec->uploadid ) {
|
114 |
+
$userdata_datefrom = strtotime($userdata->date_from);
|
115 |
+
$userdata_dateto = strtotime($userdata->date_to);
|
116 |
+
$filerec_datefrom = strtotime($filerec->date_from);
|
117 |
+
if ( $filerec_datefrom >= $userdata_datefrom && ( $userdata_dateto == $time0 || $filerec_datefrom < $userdata_dateto ) )
|
118 |
+
$remarks .= "\n\t\t\t\t\t\t\t".'<option>'.$userdata->property.': '.$userdata->propvalue.'</option>';
|
119 |
+
}
|
120 |
+
}
|
121 |
+
if ( $remarks != '' ) {
|
122 |
+
$remarks = "\n\t\t\t\t\t\t".'<select multiple="multiple" style="width:100%; height:40px; background:none; font-size:small; overflow:scroll; resize:vertical;">'.$remarks;
|
123 |
+
$remarks .= "\n\t\t\t\t\t\t".'</select>';
|
124 |
+
}
|
125 |
+
}
|
126 |
+
elseif ( $filerec->action == 'changeuser' ) {
|
127 |
+
$prevuploaduserid = '';
|
128 |
+
$prevfilerec = wfu_get_file_rec_from_id($filerec->linkedto);
|
129 |
+
if ( $prevfilerec != null ) $prevuploaduserid = $prevfilerec->uploaduserid;
|
130 |
+
if ( $prevuploaduserid != '' ) {
|
131 |
+
$prevuploaduser = wfu_get_username_by_id($prevuploaduserid);
|
132 |
+
$remarks = "\n\t\t\t\t\t\t".'<label>Previous upload user: '.$prevuploaduser.'</label>';
|
133 |
+
}
|
134 |
+
}
|
135 |
+
elseif ( $filerec->action == 'other' ) {
|
136 |
+
$info = $filerec->filepath;
|
137 |
+
$filerec->filepath = '';
|
138 |
+
$remarks = "\n\t\t\t\t\t\t".'<textarea style="width:100%; resize:vertical; background:none;" readonly="readonly">'.$info.'</textarea>';
|
139 |
+
}
|
140 |
+
$displayed_path = wfu_hide_credentials_from_ftpurl($filerec->filepath);
|
141 |
+
$i ++;
|
142 |
+
$echo_str .= "\n\t\t\t\t".'<tr'.( $located_rec > 0 && $filerec->idlog == $located_rec ? ' class="wfu-highlighted"' : '' ).'>';
|
143 |
+
$echo_str .= "\n\t\t\t\t\t".'<th style="word-wrap: break-word;">'.$i.'</th>';
|
144 |
+
$echo_str .= "\n\t\t\t\t\t".'<td class="column-primary" data-colname="File">';
|
145 |
+
if ( $filerec->action == 'other' ) $echo_str .= "\n\t\t\t\t\t\t".'<span>Other action not related to file</span>';
|
146 |
+
elseif ( $filerec->action == 'datasubmit' ) $echo_str .= "\n\t\t\t\t\t\t".'<span>Submission of data without file</span>';
|
147 |
+
elseif ( in_array($filerec->linkedto, $deletedfiles) || in_array($filerec->idlog, $deletedfiles) ) $echo_str .= "\n\t\t\t\t\t\t".'<span>'.$displayed_path.'</span>';
|
148 |
+
else {
|
149 |
+
//find newest linked record
|
150 |
+
$newestidlog = $filerec->idlog;
|
151 |
+
$newestind = $ind;
|
152 |
+
$parind = $ind;
|
153 |
+
while ( $parind >= 0 && $filerecs[$newestind]->date_to != "0000-00-00 00:00:00" ) {
|
154 |
+
if ( isset($filerecs[$parind]->linkedto) && $filerecs[$parind]->linkedto == $newestidlog ) {
|
155 |
+
$newestind = $parind;
|
156 |
+
$newestidlog = $filerecs[$parind]->idlog;
|
157 |
+
}
|
158 |
+
$parind --;
|
159 |
+
}
|
160 |
+
//find oldest linked record
|
161 |
+
$oldestidlog = $filerec->idlog;
|
162 |
+
$oldestind = $ind;
|
163 |
+
$parind = $ind;
|
164 |
+
while ( $parind < $filerecs_count && isset($filerecs[$oldestind]->linkedto) ) {
|
165 |
+
if ( $filerecs[$parind]->idlog == $filerecs[$oldestind]->linkedto ) {
|
166 |
+
$oldestind = $parind;
|
167 |
+
$oldestidlog = $filerecs[$parind]->idlog;
|
168 |
+
}
|
169 |
+
$parind ++;
|
170 |
+
}
|
171 |
+
$lid = $oldestidlog;
|
172 |
+
//make the file linkable only if the record is still valid, the
|
173 |
+
//filename has not changed (due to a rename action) and the file
|
174 |
+
//exists
|
175 |
+
if ( $filerecs[$newestind]->date_to == "0000-00-00 00:00:00" && $filerec->filepath == $filerecs[$newestind]->filepath && wfu_file_exists(wfu_path_rel2abs($filerec->filepath), "wfu_view_log") ) {
|
176 |
+
if ( !isset($filecodes[$lid]) ) $filecodes[$lid] = wfu_safe_store_filepath($filerec->filepath);
|
177 |
+
$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='.$filecodes[$lid].'&invoker='.$logpagecode.'" title="View and edit file details" style="font-weight:normal;">'.$displayed_path.'</a>';
|
178 |
+
}
|
179 |
+
else $echo_str .= "\n\t\t\t\t\t\t".'<span>'.$displayed_path.'</span>';
|
180 |
+
}
|
181 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<button type="button" class="toggle-row"><span class="screen-reader-text">Show more details</span></button>';
|
182 |
+
$echo_str .= "\n\t\t\t\t\t".'</td>';
|
183 |
+
$echo_str .= "\n\t\t\t\t\t".'<td data-colname="Action">'.( $filerec->action != 'other' && $filerec->action != 'datasubmit' ? $filerec->action : '' ).'</td>';
|
184 |
+
$echo_str .= "\n\t\t\t\t\t".'<td data-colname="Date">'.get_date_from_gmt($filerec->date_from).'</td>';
|
185 |
+
$echo_str .= "\n\t\t\t\t\t".'<td data-colname="User">'.wfu_get_username_by_id($filerec->userid).'</td>';
|
186 |
+
$echo_str .= "\n\t\t\t\t\t".'<td data-colname="Remarks">';
|
187 |
+
$echo_str .= $remarks;
|
188 |
+
$echo_str .= "\n\t\t\t\t\t".'</td>';
|
189 |
+
$echo_str .= "\n\t\t\t\t".'</tr>';
|
190 |
+
}
|
191 |
+
if ( !$only_table_rows ) {
|
192 |
+
$echo_str .= "\n\t\t\t".'</tbody>';
|
193 |
+
$echo_str .= "\n\t\t".'</table>';
|
194 |
+
$echo_str .= "\n\t".'</div>';
|
195 |
+
$echo_str .= "\n\t".'</div>';
|
196 |
+
$echo_str .= "\n".'</div>';
|
197 |
+
}
|
198 |
+
if ( $located_rec > 0 ) {
|
199 |
+
$handler = 'function() { wfu_focus_table_on_highlighted_file("wfu_historylog_table"); }';
|
200 |
+
$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>';
|
201 |
+
}
|
202 |
+
|
203 |
+
return $echo_str;
|
204 |
}
|
lib/wfu_admin_maintenance.php
CHANGED
@@ -1,562 +1,562 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Maintenance Actions Page in Dashboard Area of Plugin
|
5 |
-
*
|
6 |
-
* This file contains functions related to Maintenance Actions page of plugin's
|
7 |
-
* Dashboard area.
|
8 |
-
*
|
9 |
-
* @link /lib/wfu_admin_maintenance.php
|
10 |
-
*
|
11 |
-
* @package WordPress File Upload Plugin
|
12 |
-
* @subpackage Core Components
|
13 |
-
* @since 3.7.1
|
14 |
-
*/
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Display the Maintenance Actions Page.
|
18 |
-
*
|
19 |
-
* This function displays the Maintenance Actions page of the plugin's Dashboard
|
20 |
-
* area.
|
21 |
-
*
|
22 |
-
* @since 3.3.1
|
23 |
-
*
|
24 |
-
* @param string $message Optional. A message to display on top of the page.
|
25 |
-
*
|
26 |
-
* @return string The HTML output of the plugin's Maintenance Actions Dashboard
|
27 |
-
* page.
|
28 |
-
*/
|
29 |
-
function wfu_maintenance_actions($message = '') {
|
30 |
-
if ( !current_user_can( 'manage_options' ) ) return wfu_manage_mainmenu();
|
31 |
-
|
32 |
-
$siteurl = site_url();
|
33 |
-
|
34 |
-
$echo_str = '<div class="wrap">';
|
35 |
-
$echo_str .= "\n\t".'<h2>Wordpress File Upload Control Panel</h2>';
|
36 |
-
if ( $message != '' ) {
|
37 |
-
$echo_str .= "\n\t".'<div class="updated">';
|
38 |
-
$echo_str .= "\n\t\t".'<p>'.$message.'</p>';
|
39 |
-
$echo_str .= "\n\t".'</div>';
|
40 |
-
}
|
41 |
-
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
42 |
-
$echo_str .= wfu_generate_dashboard_menu("\n\t\t", "Maintenance Actions");
|
43 |
-
//maintenance actions
|
44 |
-
$echo_str .= "\n\t\t".'<h3 style="margin-bottom: 10px;">Maintenance Actions</h3>';
|
45 |
-
$echo_str .= "\n\t\t".'<table class="form-table">';
|
46 |
-
$echo_str .= "\n\t\t\t".'<tbody>';
|
47 |
-
$echo_str .= "\n\t\t\t\t".'<tr>';
|
48 |
-
$echo_str .= "\n\t\t\t\t\t".'<th scope="row">';
|
49 |
-
$wfu_maintenance_nonce = wp_create_nonce("wfu_maintenance_actions");
|
50 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=sync_db&nonce='.$wfu_maintenance_nonce.'" class="button" title="Update database to reflect current status of files">Sync Database</a>';
|
51 |
-
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
52 |
-
$echo_str .= "\n\t\t\t\t\t".'<td>';
|
53 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<label>Update database to reflect current status of files.</label>';
|
54 |
-
$echo_str .= "\n\t\t\t\t\t".'</td>';
|
55 |
-
$echo_str .= "\n\t\t\t\t".'</tr>';
|
56 |
-
$echo_str .= "\n\t\t\t\t".'<tr>';
|
57 |
-
$echo_str .= "\n\t\t\t\t\t".'<th scope="row">';
|
58 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<a href="" class="button" title="Clean database log" onclick="wfu_cleanlog_selector_toggle(true); return false;">Clean Log</a>';
|
59 |
-
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
60 |
-
$echo_str .= "\n\t\t\t\t\t".'<td>';
|
61 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<label>Clean-up database log, either all or of specific period, including file information, user data and optionally the files.</label>';
|
62 |
-
$echo_str .= "\n\t\t\t\t\t".'</td>';
|
63 |
-
$echo_str .= "\n\t\t\t\t".'</tr>';
|
64 |
-
$echo_str .= "\n\t\t\t\t".'<tr class="wfu_cleanlog_tr">';
|
65 |
-
$echo_str .= "\n\t\t\t\t\t".'<th scope="row"></th>';
|
66 |
-
$echo_str .= "\n\t\t\t\t\t".'<td>';
|
67 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<div>';
|
68 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<label>Select Clean-Up Period</label>';
|
69 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<select id="wfu_cleanlog_period" onchange="wfu_cleanlog_period_changed();">';
|
70 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<option value="older_than_date">Clean-up log older than date</option>';
|
71 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<option value="older_than_period">Clean-up log older than period</option>';
|
72 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<option value="between_dates">Clean-up log between dates</option>';
|
73 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<option value="all">Clean-up all log</option>';
|
74 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'</select>';
|
75 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<div class="wfu_selectdate_container">';
|
76 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<label>Select date</label>';
|
77 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<input id="wfu_cleanlog_dateold" type="text" />';
|
78 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'</div>';
|
79 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<div class="wfu_selectperiod_container">';
|
80 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<label>Select period</label>';
|
81 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<input id="wfu_cleanlog_periodold" type="number" min="1" />';
|
82 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<select id="wfu_cleanlog_periodtype">';
|
83 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t\t".'<option value="days">days</option>';
|
84 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t\t".'<option value="months">months</option>';
|
85 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t\t".'<option value="years">years</option>';
|
86 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'</select>';
|
87 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'</div>';
|
88 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<div class="wfu_selectdates_container">';
|
89 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<label>Select period from</label>';
|
90 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<input id="wfu_cleanlog_datefrom" type="text" />';
|
91 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<label>back to</label>';
|
92 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<input id="wfu_cleanlog_dateto" type="text" />';
|
93 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'</div>';
|
94 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<div class="wfu_includefiles_container">';
|
95 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<label for="wfu_includefiles">Clean-up also affected files</label>';
|
96 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<input id="wfu_includefiles" type="checkbox" />';
|
97 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'</div>';
|
98 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<div class="wfu_buttons_container">';
|
99 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<a href="" class="button" title="Close" onclick="wfu_cleanlog_selector_toggle(false); return false;">Close</a>';
|
100 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<a href="" class="button wfu_cleanlog_proceed" title="Proceed to log clean-up" onclick="if (wfu_cleanlog_selector_checkproceed()) return true; else return false; ">Proceed</a>';
|
101 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<span class="wfu_cleanlog_error hidden">Error</span>';
|
102 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<input id="wfu_cleanlog_href" type="hidden" value="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=clean_log_ask&nonce='.$wfu_maintenance_nonce.'" />';
|
103 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'</div>';
|
104 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</div>';
|
105 |
-
$echo_str .= "\n\t\t\t\t\t".'</td>';
|
106 |
-
$echo_str .= "\n\t\t\t\t".'</tr>';
|
107 |
-
$echo_str .= "\n\t\t\t\t".'<tr>';
|
108 |
-
$echo_str .= "\n\t\t\t\t\t".'<th scope="row">';
|
109 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=purge_data_ask&nonce='.$wfu_maintenance_nonce.'" class="button" title="Remove all plugin data from website" style="color:red;">Purge All Data</a>';
|
110 |
-
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
111 |
-
$echo_str .= "\n\t\t\t\t\t".'<td>';
|
112 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<label>Purge all plugin options and tables from database, as well as any session data. The plugin will be deactivated after this action.</label>';
|
113 |
-
$echo_str .= "\n\t\t\t\t\t".'</td>';
|
114 |
-
$echo_str .= "\n\t\t\t\t".'</tr>';
|
115 |
-
$echo_str .= "\n\t\t\t".'</tbody>';
|
116 |
-
$echo_str .= "\n\t\t".'</table>';
|
117 |
-
$echo_str .= "\n\t".'</div>';
|
118 |
-
//export actions
|
119 |
-
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
120 |
-
$echo_str .= "\n\t\t".'<h3 style="margin-bottom: 10px;">Export Actions</h3>';
|
121 |
-
$echo_str .= "\n\t\t".'<table class="form-table">';
|
122 |
-
$echo_str .= "\n\t\t\t".'<tbody>';
|
123 |
-
$echo_str .= "\n\t\t\t\t".'<tr>';
|
124 |
-
$echo_str .= "\n\t\t\t\t\t".'<th scope="row">';
|
125 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<a href="javascript:wfu_download_file(\'exportdata\', 1);" class="button" title="Export uploaded file data">Export Uploaded File Data</a>';
|
126 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<input id="wfu_download_file_nonce" type="hidden" value="'.wp_create_nonce('wfu_download_file_invoker').'" />';
|
127 |
-
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
128 |
-
$echo_str .= "\n\t\t\t\t\t".'<td>';
|
129 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<label>Export uploaded valid file data, together with any userdata fields, to a comma-separated text file.</label>';
|
130 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<div id="wfu_file_download_container_1" style="display: none;"></div>';
|
131 |
-
$echo_str .= "\n\t\t\t\t\t".'</td>';
|
132 |
-
$echo_str .= "\n\t\t\t\t".'</tr>';
|
133 |
-
$echo_str .= "\n\t\t\t".'</tbody>';
|
134 |
-
$echo_str .= "\n\t\t".'</table>';
|
135 |
-
$echo_str .= "\n\t".'</div>';
|
136 |
-
$handler = 'function() { wfu_cleanlog_initialize_elements(); }';
|
137 |
-
$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>';
|
138 |
-
$echo_str .= "\n".'</div>';
|
139 |
-
|
140 |
-
echo $echo_str;
|
141 |
-
}
|
142 |
-
|
143 |
-
/**
|
144 |
-
* Check and Execute Database Synchronization.
|
145 |
-
*
|
146 |
-
* This function performs security checks whether database synchronization can
|
147 |
-
* be executed and then executes this operation.
|
148 |
-
*
|
149 |
-
* @since 4.6.0
|
150 |
-
*
|
151 |
-
* @param string $nonce A string that verifies that the request came from
|
152 |
-
* Maintenance Actions page.
|
153 |
-
*
|
154 |
-
* @return int The number of records affected by synchronization.
|
155 |
-
*/
|
156 |
-
function wfu_sync_database_controller($nonce) {
|
157 |
-
if ( !current_user_can( 'manage_options' ) ) return -1;
|
158 |
-
if ( !wp_verify_nonce($nonce, 'wfu_maintenance_actions') ) return -1;
|
159 |
-
|
160 |
-
return wfu_sync_database();
|
161 |
-
}
|
162 |
-
|
163 |
-
/**
|
164 |
-
* Prepare Data for Log Cleaning.
|
165 |
-
*
|
166 |
-
* This function prepares data for executing log cleaning operation.
|
167 |
-
*
|
168 |
-
* @since 4.6.0
|
169 |
-
*
|
170 |
-
* @param string $data An encoded string containing information about what
|
171 |
-
* records to clean.
|
172 |
-
*
|
173 |
-
* @return array An array containing log cleaning data.
|
174 |
-
*/
|
175 |
-
function wfu_clean_log_parse_data($data) {
|
176 |
-
$ret = array( "result" => true );
|
177 |
-
$data = sanitize_text_field($data);
|
178 |
-
$data_array = explode(":", $data);
|
179 |
-
if ( count($data_array) == 0 ) $ret["result"] = false;
|
180 |
-
elseif ( $data_array[0] == "00" || $data_array[0] == "01" ) {
|
181 |
-
$ret["code"] = "0";
|
182 |
-
$ret["include_files"] = ( substr($data_array[0], 1, 1) == "1" );
|
183 |
-
if ( count($data_array) != 2 || strlen($data_array[1]) != 8 ) $ret["result"] = false;
|
184 |
-
else {
|
185 |
-
$ret["dateold"] = strtotime(substr($data_array[1], 0, 4)."-".substr($data_array[1], 4, 2)."-".substr($data_array[1], 6, 2)." 00:00");
|
186 |
-
if ( $ret["dateold"] > time() ) $ret["result"] = false;
|
187 |
-
}
|
188 |
-
}
|
189 |
-
elseif ( $data_array[0] == "10" || $data_array[0] == "11" ) {
|
190 |
-
$ret["code"] = "1";
|
191 |
-
$ret["include_files"] = ( substr($data_array[0], 1, 1) == "1" );
|
192 |
-
if ( count($data_array) != 3 ) $ret["result"] = false;
|
193 |
-
else {
|
194 |
-
$ret["periodold"] = (int)$data_array[1];
|
195 |
-
if ( $ret["periodold"] <= 0 ) $ret["result"] = false;
|
196 |
-
elseif ( $data_array[2] == 'd' ) $ret["periodtype"] = 'days';
|
197 |
-
elseif ( $data_array[2] == 'm' ) $ret["periodtype"] = 'months';
|
198 |
-
elseif ( $data_array[2] == 'y' ) $ret["periodtype"] = 'years';
|
199 |
-
else $ret["result"] = false;
|
200 |
-
}
|
201 |
-
}
|
202 |
-
elseif ( $data_array[0] == "20" || $data_array[0] == "21" ) {
|
203 |
-
$ret["code"] = "2";
|
204 |
-
$ret["include_files"] = ( substr($data_array[0], 1, 1) == "1" );
|
205 |
-
if ( count($data_array) != 3 || strlen($data_array[1]) != 8 || strlen($data_array[2]) != 8 ) $ret["result"] = false;
|
206 |
-
$ret["datefrom"] = strtotime(substr($data_array[1], 0, 4)."-".substr($data_array[1], 4, 2)."-".substr($data_array[1], 6, 2)." 00:00");
|
207 |
-
if ( $ret["datefrom"] > time() ) $ret["result"] = false;
|
208 |
-
else {
|
209 |
-
$ret["dateto"] = strtotime(substr($data_array[2], 0, 4)."-".substr($data_array[2], 4, 2)."-".substr($data_array[2], 6, 2)." 00:00");
|
210 |
-
if ( $ret["dateto"] > $ret["datefrom"] ) $ret["result"] = false;
|
211 |
-
}
|
212 |
-
}
|
213 |
-
elseif ( $data_array[0] == "30" || $data_array[0] == "31" ) {
|
214 |
-
$ret["code"] = "3";
|
215 |
-
$ret["include_files"] = ( substr($data_array[0], 1, 1) == "1" );
|
216 |
-
if ( count($data_array) != 1 ) $ret["result"] = false;
|
217 |
-
}
|
218 |
-
else $ret["result"] = false;
|
219 |
-
|
220 |
-
return $ret;
|
221 |
-
}
|
222 |
-
|
223 |
-
/**
|
224 |
-
* Prepare Query for Log Cleaning.
|
225 |
-
*
|
226 |
-
* This function prepares the SQL WHERE clause of the query for log cleaning.
|
227 |
-
*
|
228 |
-
* @since 4.9.1
|
229 |
-
*
|
230 |
-
* @param array $data An array containing log cleaning data.
|
231 |
-
*
|
232 |
-
* @return string An SQL WHERE clause that defines which database records will
|
233 |
-
* be affected by log cleaning operation.
|
234 |
-
*/
|
235 |
-
function wfu_clean_log_where_query($data) {
|
236 |
-
$query = "";
|
237 |
-
if ( $data["code"] == "0" ) $query = " WHERE date_from < '".date('Y-m-d H:i:s', $data["dateold"])."'";
|
238 |
-
elseif ( $data["code"] == "1" ) {
|
239 |
-
$date = strtotime(date('Y-m-d', strtotime('-'.$data["periodold"].' '.$data["periodtype"]))." 00:00");
|
240 |
-
$query = " WHERE date_from < '".date('Y-m-d H:i:s', $date)."'";
|
241 |
-
}
|
242 |
-
elseif ( $data["code"] == "2" ) $query = " WHERE date_from < '".date('Y-m-d H:i:s', $data["datefrom"] + 86400)."' AND date_from >= '".date('Y-m-d H:i:s', $data["dateto"])."'";
|
243 |
-
|
244 |
-
return $query;
|
245 |
-
}
|
246 |
-
|
247 |
-
/**
|
248 |
-
* Confirm Log Cleaning Operation.
|
249 |
-
*
|
250 |
-
* This function shows a page to confirm log cleaning operation.
|
251 |
-
*
|
252 |
-
* @since 3.3.1
|
253 |
-
*
|
254 |
-
* @param string $nonce A string that verifies that the request came from
|
255 |
-
* Maintenance Actions page.
|
256 |
-
* @param string $data_enc An encoded string containing information about what
|
257 |
-
* records to clean.
|
258 |
-
*
|
259 |
-
* @return string The HTML code of the confirmation page.
|
260 |
-
*/
|
261 |
-
function wfu_clean_log_prompt($nonce, $data_enc) {
|
262 |
-
global $wpdb;
|
263 |
-
$table_name1 = $wpdb->prefix . "wfu_log";
|
264 |
-
$siteurl = site_url();
|
265 |
-
|
266 |
-
if ( !current_user_can( 'manage_options' ) || !wp_verify_nonce($nonce, 'wfu_maintenance_actions') ) return wfu_maintenance_actions();
|
267 |
-
//parse data
|
268 |
-
$data = wfu_clean_log_parse_data($data_enc);
|
269 |
-
if ( $data["result"] == false ) return wfu_maintenance_actions();
|
270 |
-
|
271 |
-
$echo_str = "\n".'<div class="wrap">';
|
272 |
-
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
273 |
-
$echo_str .= "\n\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=maintenance_actions" class="button" title="go back">Go back</a>';
|
274 |
-
$echo_str .= "\n\t".'</div>';
|
275 |
-
$echo_str .= "\n\t".'<h2 style="margin-bottom: 10px;">Clean Database Log</h2>';
|
276 |
-
$echo_str .= "\n\t".'<form enctype="multipart/form-data" name="clean_log" id="clean_log" method="post" action="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload" class="validate">';
|
277 |
-
$nonce = wp_nonce_field('wfu_clean_log', '_wpnonce', false, false);
|
278 |
-
$nonce_ref = wp_referer_field(false);
|
279 |
-
$echo_str .= "\n\t\t".$nonce;
|
280 |
-
$echo_str .= "\n\t\t".$nonce_ref;
|
281 |
-
$echo_str .= "\n\t\t".'<input type="hidden" name="action" value="clean_log">';
|
282 |
-
$echo_str .= "\n\t\t".'<input type="hidden" name="data" value="'.$data_enc.'">';
|
283 |
-
if ( $data["include_files"] ) {
|
284 |
-
if ( $data["code"] == "0" )
|
285 |
-
$echo_str .= "\n\t\t".'<label>This will erase all files uploaded <strong>before '.date("Y-m-d", $data["dateold"]).'</strong> together with associated records kept by the plugin in the database (like file metadata and userdata).</label><br/>';
|
286 |
-
elseif ( $data["code"] == "1" )
|
287 |
-
$echo_str .= "\n\t\t".'<label>This will erase all files uploaded <strong>'.$data["periodold"].' '.$data["periodtype"].' ago or older</strong> together with associated records kept by the plugin in the database (like file metadata and userdata).</label><br/>';
|
288 |
-
elseif ( $data["code"] == "2" )
|
289 |
-
$echo_str .= "\n\t\t".'<label>This will erase all files uploaded <strong>between '.date("Y-m-d", $data["datefrom"]).' and '.date("Y-m-d", $data["dateto"]).'</strong> together with associated records kept by the plugin in the database (like file metadata and userdata).</label><br/>';
|
290 |
-
else
|
291 |
-
$echo_str .= "\n\t\t".'<label>This will erase <strong>ALL</strong> files and associated records kept by the plugin in the database (like file metadata and userdata).</label><br/>';
|
292 |
-
$affected_recs = $wpdb->get_results("SELECT * FROM $table_name1".wfu_clean_log_where_query($data));
|
293 |
-
$affected_files = wfu_get_valid_affected_files($affected_recs);
|
294 |
-
$echo_str .= "\n\t\t".'<br/><div class="wfu_cleanlog_files">';
|
295 |
-
$echo_str .= "\n\t\t\t".'<div>';
|
296 |
-
$echo_str .= "\n\t\t\t\t".'<label style="vertical-align: middle;"><strong>'.count($affected_files).'</strong> files will be deleted</label>';
|
297 |
-
$echo_str .= "\n\t\t\t\t".'<button id="wfu_cleanlog_prompt_button" onclick="document.querySelector(\'.wfu_cleanlog_files\').classList.toggle(\'visible\');return false;" style="vertical-align: middle;"></button>';
|
298 |
-
$echo_str .= "\n\t\t\t".'</div>';
|
299 |
-
$echo_str .= "\n\t\t\t".'<div id="wfu_cleanlog_prompt_list" style="margin-top:10px;">';
|
300 |
-
$echo_str .= "\n\t\t\t\t".'<textarea readonly="readonly" style="width:250px; height:150px; overflow:scroll; white-space:pre; resize:both;">';
|
301 |
-
foreach ( $affected_files as $file ) {
|
302 |
-
$echo_str .= $file."\n";
|
303 |
-
}
|
304 |
-
$echo_str .= "\n\t\t\t\t".'</textarea>';
|
305 |
-
$echo_str .= "\n\t\t\t".'</div>';
|
306 |
-
$echo_str .= "\n\t\t".'</div>';
|
307 |
-
$echo_str .= "\n\t\t".'<br/><label>Are you sure that you want to continue?</label><br/>';
|
308 |
-
$echo_str .= "\n\t\t".'<style>';
|
309 |
-
$echo_str .= "\n\t\t".'.wfu_cleanlog_files button:before { content: "Click to see affected files"; } ';
|
310 |
-
$echo_str .= "\n\t\t".'.wfu_cleanlog_files.visible button:before { content: "Close list"; } ';
|
311 |
-
$echo_str .= "\n\t\t".'.wfu_cleanlog_files #wfu_cleanlog_prompt_list { display: none; } ';
|
312 |
-
$echo_str .= "\n\t\t".'.wfu_cleanlog_files.visible #wfu_cleanlog_prompt_list { display: block; } ';
|
313 |
-
$echo_str .= "\n\t\t".'</style>';
|
314 |
-
}
|
315 |
-
else {
|
316 |
-
if ( $data["code"] == "0" )
|
317 |
-
$echo_str .= "\n\t\t".'<label>This will erase all records <strong>before '.date("Y-m-d", $data["dateold"]).'</strong> kept by the plugin in the database (like file metadata and userdata, however files uploaded by the plugin will be maintained). Are you sure that you want to continue?</label><br/>';
|
318 |
-
elseif ( $data["code"] == "1" )
|
319 |
-
$echo_str .= "\n\t\t".'<label>This will erase all records <strong>older than '.$data["periodold"].' '.$data["periodtype"].'</strong> kept by the plugin in the database (like file metadata and userdata, however files uploaded by the plugin will be maintained). Are you sure that you want to continue?</label><br/>';
|
320 |
-
elseif ( $data["code"] == "2" )
|
321 |
-
$echo_str .= "\n\t\t".'<label>This will erase all records <strong>between '.date("Y-m-d", $data["datefrom"]).' and '.date("Y-m-d", $data["dateto"]).'</strong> kept by the plugin in the database (like file metadata and userdata, however files uploaded by the plugin will be maintained). Are you sure that you want to continue?</label><br/>';
|
322 |
-
else
|
323 |
-
$echo_str .= "\n\t\t".'<label>This will erase <strong>ALL</strong> records kept by the plugin in the database (like file metadata and userdata, however files uploaded by the plugin will be maintained). Are you sure that you want to continue?</label><br/>';
|
324 |
-
}
|
325 |
-
$echo_str .= "\n\t\t".'<p class="submit">';
|
326 |
-
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Yes">';
|
327 |
-
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Cancel">';
|
328 |
-
$echo_str .= "\n\t\t".'</p>';
|
329 |
-
$echo_str .= "\n\t".'</form>';
|
330 |
-
$echo_str .= "\n".'</div>';
|
331 |
-
return $echo_str;
|
332 |
-
}
|
333 |
-
|
334 |
-
/**
|
335 |
-
* Execute Log Cleaning.
|
336 |
-
*
|
337 |
-
* This function cleans the database log based on criteria selected by the
|
338 |
-
* admin.
|
339 |
-
*
|
340 |
-
* @since 3.3.1
|
341 |
-
*
|
342 |
-
* @redeclarable
|
343 |
-
*
|
344 |
-
* @return array An array containing the number of records and files affected by
|
345 |
-
* cleaning operation.
|
346 |
-
*/
|
347 |
-
function wfu_clean_log() {
|
348 |
-
$a = func_get_args(); $a = WFU_FUNCTION_HOOK(__FUNCTION__, $a, $out); if (isset($out['vars'])) foreach($out['vars'] as $p => $v) $$p = $v; switch($a) { case 'R': return $out['output']; break; case 'D': die($out['output']); }
|
349 |
-
global $wpdb;
|
350 |
-
|
351 |
-
if ( !current_user_can( 'manage_options' ) ) return array( "recs_count" => -1, "files_count" => -1 );
|
352 |
-
if ( !check_admin_referer('wfu_clean_log') ) return array( "recs_count" => -1, "files_count" => -1 );
|
353 |
-
|
354 |
-
$recs_count = 0;
|
355 |
-
if ( isset($_POST['data']) && isset($_POST['submit']) && $_POST['submit'] == "Yes" ) {
|
356 |
-
$data = wfu_clean_log_parse_data($_POST['data']);
|
357 |
-
if ( $data["result"] ) {
|
358 |
-
$table_name1 = $wpdb->prefix . "wfu_log";
|
359 |
-
$table_name2 = $wpdb->prefix . "wfu_userdata";
|
360 |
-
//$table_name3 = $wpdb->prefix . "wfu_dbxqueue";
|
361 |
-
|
362 |
-
$affected_files = array();
|
363 |
-
if ( $data["include_files"] ) {
|
364 |
-
$affected_recs = $wpdb->get_results("SELECT * FROM $table_name1".wfu_clean_log_where_query($data));
|
365 |
-
$affected_files = wfu_get_valid_affected_files($affected_recs);
|
366 |
-
}
|
367 |
-
$query1 = "DELETE FROM $table_name1";
|
368 |
-
$query2 = "DELETE FROM $table_name2";
|
369 |
-
//$query3 = "DELETE FROM $table_name3";
|
370 |
-
if ( $data["code"] == "0" ) {
|
371 |
-
$query1 .= " WHERE date_from < '".date('Y-m-d H:i:s', $data["dateold"])."'";
|
372 |
-
$query2 .= " WHERE date_from < '".date('Y-m-d H:i:s', $data["dateold"])."'";
|
373 |
-
}
|
374 |
-
elseif ( $data["code"] == "1" ) {
|
375 |
-
$date = strtotime(date('Y-m-d', strtotime('-'.$data["periodold"].' '.$data["periodtype"]))." 00:00");
|
376 |
-
$query1 .= " WHERE date_from < '".date('Y-m-d H:i:s', $date)."'";
|
377 |
-
$query2 .= " WHERE date_from < '".date('Y-m-d H:i:s', $date)."'";
|
378 |
-
}
|
379 |
-
elseif ( $data["code"] == "2" ) {
|
380 |
-
$query1 .= " WHERE date_from < '".date('Y-m-d H:i:s', $data["datefrom"] + 86400)."' AND date_from >= '".date('Y-m-d H:i:s', $data["dateto"])."'";
|
381 |
-
$query2 .= " WHERE date_from < '".date('Y-m-d H:i:s', $data["datefrom"] + 86400)."' AND date_from >= '".date('Y-m-d H:i:s', $data["dateto"])."'";
|
382 |
-
}
|
383 |
-
$recs_count = $wpdb->query($query1);
|
384 |
-
$recs_count += $wpdb->query($query2);
|
385 |
-
//$recs_count += $wpdb->query($query3);
|
386 |
-
|
387 |
-
//delete affected files
|
388 |
-
$files_count = 0;
|
389 |
-
foreach( $affected_files as $file ) {
|
390 |
-
|
391 |
-
if ( !
|
392 |
-
}
|
393 |
-
}
|
394 |
-
}
|
395 |
-
|
396 |
-
return array( "recs_count" => $recs_count, "files_count" => $files_count );
|
397 |
-
}
|
398 |
-
|
399 |
-
/**
|
400 |
-
* Confirm Purge of Data Operation.
|
401 |
-
*
|
402 |
-
* This function shows a page to confirm purge of data operation. Purge
|
403 |
-
* operation deletes all plugin data from the website.
|
404 |
-
*
|
405 |
-
* @since 4.9.1
|
406 |
-
*
|
407 |
-
* @param string $nonce A string that verifies that the request came from
|
408 |
-
* Maintenance Actions page.
|
409 |
-
*
|
410 |
-
* @return string The HTML code of the confirmation page.
|
411 |
-
*/
|
412 |
-
function wfu_purge_data_prompt($nonce) {
|
413 |
-
$siteurl = site_url();
|
414 |
-
|
415 |
-
if ( !current_user_can( 'manage_options' ) || !wp_verify_nonce($nonce, 'wfu_maintenance_actions') ) return wfu_maintenance_actions();
|
416 |
-
|
417 |
-
$echo_str = "\n".'<div class="wrap">';
|
418 |
-
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
419 |
-
$echo_str .= "\n\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=maintenance_actions" class="button" title="go back">Go back</a>';
|
420 |
-
$echo_str .= "\n\t".'</div>';
|
421 |
-
$echo_str .= "\n\t".'<h2 style="margin-bottom: 10px;">Purge All Data</h2>';
|
422 |
-
$echo_str .= "\n\t".'<form enctype="multipart/form-data" name="purge_data" id="purge_data" method="post" action="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload" class="validate">';
|
423 |
-
$nonce = wp_nonce_field('wfu_purge_data', '_wpnonce', false, false);
|
424 |
-
$nonce_ref = wp_referer_field(false);
|
425 |
-
$echo_str .= "\n\t\t".$nonce;
|
426 |
-
$echo_str .= "\n\t\t".$nonce_ref;
|
427 |
-
$echo_str .= "\n\t\t".'<input type="hidden" name="action" value="purge_data">';
|
428 |
-
$echo_str .= "\n\t\t".'<label>This action will remove all plugin options and records from database, data stored in session and will dectivate the plugin. Use it only if you want to entirely remove the plugin from the website.</label><br/>';
|
429 |
-
$echo_str .= "\n\t\t".'<br/><label>Are you sure you want to continue?</label><br/>';
|
430 |
-
$echo_str .= "\n\t\t".'<p class="submit">';
|
431 |
-
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Yes">';
|
432 |
-
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Cancel">';
|
433 |
-
$echo_str .= "\n\t\t".'</p>';
|
434 |
-
$echo_str .= "\n\t".'</form>';
|
435 |
-
$echo_str .= "\n".'</div>';
|
436 |
-
return $echo_str;
|
437 |
-
}
|
438 |
-
|
439 |
-
/**
|
440 |
-
* Purge Plugin Data.
|
441 |
-
*
|
442 |
-
* This function deletes all plugin data from the website. It drops the tables
|
443 |
-
* of the plugin from the database, it deletes all plugin options and all plugin
|
444 |
-
* data stored in session.
|
445 |
-
*
|
446 |
-
* @since 4.9.1
|
447 |
-
*
|
448 |
-
* @redeclarable
|
449 |
-
*
|
450 |
-
* @return bool Always true.
|
451 |
-
*/
|
452 |
-
function wfu_purge_data() {
|
453 |
-
$a = func_get_args(); $a = WFU_FUNCTION_HOOK(__FUNCTION__, $a, $out); if (isset($out['vars'])) foreach($out['vars'] as $p => $v) $$p = $v; switch($a) { case 'R': return $out['output']; break; case 'D': die($out['output']); }
|
454 |
-
global $wpdb;
|
455 |
-
|
456 |
-
if ( !current_user_can( 'manage_options' ) ) return;
|
457 |
-
if ( !check_admin_referer('wfu_purge_data') ) return;
|
458 |
-
|
459 |
-
if ( isset($_POST['submit']) && $_POST['submit'] == "Yes" ) {
|
460 |
-
$all_options = array_keys(wp_load_alloptions());
|
461 |
-
$all_session = array_keys($_SESSION);
|
462 |
-
$wfu_options = wfu_get_all_plugin_options();
|
463 |
-
//first delete relevant db options
|
464 |
-
foreach ( $all_options as $opt1 )
|
465 |
-
foreach ( $wfu_options as $opt2 )
|
466 |
-
if ( $opt2[2] && $opt2[1] == "db" ) {
|
467 |
-
if (( substr($opt2[0], 0, 1) != "*" && substr($opt2[0], -1) != "*" && $opt1 == $opt2[0] ) ||
|
468 |
-
( substr($opt2[0], 0, 1) != "*" && substr($opt2[0], -1) == "*" && substr($opt1, 0, strlen($opt2[0])) == substr($opt2[0], 0, -1) ) ||
|
469 |
-
( substr($opt2[0], 0, 1) == "*" && substr($opt2[0], -1) != "*" && substr($opt1, -strlen($opt2[0])) == substr($opt2[0], 1) ) ||
|
470 |
-
( substr($opt2[0], 0, 1) == "*" && substr($opt2[0], -1) == "*" && strpos($opt1, substr($opt2[0], 1, -1)) !== false ))
|
471 |
-
delete_option($opt1);
|
472 |
-
}
|
473 |
-
//then delete relevant session data
|
474 |
-
foreach ( $all_session as $opt1 )
|
475 |
-
foreach ( $wfu_options as $opt2 )
|
476 |
-
if ( $opt2[2] && $opt2[1] == "session" ) {
|
477 |
-
if (( substr($opt2[0], 0, 1) != "*" && substr($opt2[0], -1) != "*" && $opt1 == $opt2[0] ) ||
|
478 |
-
( substr($opt2[0], 0, 1) != "*" && substr($opt2[0], -1) == "*" && substr($opt1, 0, strlen($opt2[0])) == substr($opt2[0], 0, -1) ) ||
|
479 |
-
( substr($opt2[0], 0, 1) == "*" && substr($opt2[0], -1) != "*" && substr($opt1, -strlen($opt2[0])) == substr($opt2[0], 1) ) ||
|
480 |
-
( substr($opt2[0], 0, 1) == "*" && substr($opt2[0], -1) == "*" && strpos($opt1, substr($opt2[0], 1, -1)) !== false ))
|
481 |
-
unset($_SESSION[$opt1]);
|
482 |
-
}
|
483 |
-
//then delete relevant tables
|
484 |
-
$wpdb->query( "DROP TABLE IF EXISTS ".$wpdb->prefix."wfu_log" );
|
485 |
-
$wpdb->query( "DROP TABLE IF EXISTS ".$wpdb->prefix."wfu_userdata" );
|
486 |
-
$wpdb->query( "DROP TABLE IF EXISTS ".$wpdb->prefix."wfu_dbxqueue" );
|
487 |
-
//then deactivate the plugin
|
488 |
-
deactivate_plugins( plugin_basename( WPFILEUPLOAD_PLUGINFILE ) );
|
489 |
-
}
|
490 |
-
else return;
|
491 |
-
|
492 |
-
return true;
|
493 |
-
}
|
494 |
-
|
495 |
-
|
496 |
-
/**
|
497 |
-
* Update File Transfers.
|
498 |
-
*
|
499 |
-
* This function causes the file transfers manager to re-check the pending file
|
500 |
-
* tranfers immediately.
|
501 |
-
*
|
502 |
-
* @since 4.6.0
|
503 |
-
*
|
504 |
-
* @redeclarable
|
505 |
-
*
|
506 |
-
* @param bool $clearfiles Optional. If it is true then all pending file
|
507 |
-
* transfers will be cleared.
|
508 |
-
*/
|
509 |
-
function wfu_process_all_transfers($clearfiles = false) {
|
510 |
-
$a = func_get_args(); $a = WFU_FUNCTION_HOOK(__FUNCTION__, $a, $out); if (isset($out['vars'])) foreach($out['vars'] as $p => $v) $$p = $v; switch($a) { case 'R': return $out['output']; break; case 'D': die($out['output']); }
|
511 |
-
global $wpdb;
|
512 |
-
if ( $clearfiles ) {
|
513 |
-
$table_name1 = $wpdb->prefix . "wfu_log";
|
514 |
-
$table_name3 = $wpdb->prefix . "wfu_dbxqueue";
|
515 |
-
$wpdb->query('DELETE FROM '.$table_name3);
|
516 |
-
}
|
517 |
-
wfu_schedule_transfermanager(true);
|
518 |
-
}
|
519 |
-
|
520 |
-
/**
|
521 |
-
* Check and Execute Reset of File Transfers.
|
522 |
-
*
|
523 |
-
* This function performs security checks whether reset of file transfers can be
|
524 |
-
* executed and then executes this operation.
|
525 |
-
*
|
526 |
-
* @since 4.6.0
|
527 |
-
*
|
528 |
-
* @param string $nonce A string that verifies that the request came from
|
529 |
-
* Maintenance Actions page.
|
530 |
-
*
|
531 |
-
* @return bool Always true.
|
532 |
-
*/
|
533 |
-
function wfu_reset_all_transfers_controller($nonce) {
|
534 |
-
if ( !current_user_can( 'manage_options' ) ) return false;
|
535 |
-
if ( !wp_verify_nonce($nonce, 'wfu_maintenance_actions') ) return false;
|
536 |
-
|
537 |
-
wfu_process_all_transfers();
|
538 |
-
|
539 |
-
return true;
|
540 |
-
}
|
541 |
-
|
542 |
-
/**
|
543 |
-
* Check and Execute Clear of File Transfers.
|
544 |
-
*
|
545 |
-
* This function performs security checks whether clear of file transfers can be
|
546 |
-
* executed and then executes this operation.
|
547 |
-
*
|
548 |
-
* @since 4.6.0
|
549 |
-
*
|
550 |
-
* @param string $nonce A string that verifies that the request came from
|
551 |
-
* Maintenance Actions page.
|
552 |
-
*
|
553 |
-
* @return bool Always true.
|
554 |
-
*/
|
555 |
-
function wfu_clear_all_transfers_controller($nonce) {
|
556 |
-
if ( !current_user_can( 'manage_options' ) ) return false;
|
557 |
-
if ( !wp_verify_nonce($nonce, 'wfu_maintenance_actions') ) return false;
|
558 |
-
|
559 |
-
wfu_process_all_transfers(true);
|
560 |
-
|
561 |
-
return true;
|
562 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Maintenance Actions Page in Dashboard Area of Plugin
|
5 |
+
*
|
6 |
+
* This file contains functions related to Maintenance Actions page of plugin's
|
7 |
+
* Dashboard area.
|
8 |
+
*
|
9 |
+
* @link /lib/wfu_admin_maintenance.php
|
10 |
+
*
|
11 |
+
* @package WordPress File Upload Plugin
|
12 |
+
* @subpackage Core Components
|
13 |
+
* @since 3.7.1
|
14 |
+
*/
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Display the Maintenance Actions Page.
|
18 |
+
*
|
19 |
+
* This function displays the Maintenance Actions page of the plugin's Dashboard
|
20 |
+
* area.
|
21 |
+
*
|
22 |
+
* @since 3.3.1
|
23 |
+
*
|
24 |
+
* @param string $message Optional. A message to display on top of the page.
|
25 |
+
*
|
26 |
+
* @return string The HTML output of the plugin's Maintenance Actions Dashboard
|
27 |
+
* page.
|
28 |
+
*/
|
29 |
+
function wfu_maintenance_actions($message = '') {
|
30 |
+
if ( !current_user_can( 'manage_options' ) ) return wfu_manage_mainmenu();
|
31 |
+
|
32 |
+
$siteurl = site_url();
|
33 |
+
|
34 |
+
$echo_str = '<div class="wrap">';
|
35 |
+
$echo_str .= "\n\t".'<h2>Wordpress File Upload Control Panel</h2>';
|
36 |
+
if ( $message != '' ) {
|
37 |
+
$echo_str .= "\n\t".'<div class="updated">';
|
38 |
+
$echo_str .= "\n\t\t".'<p>'.$message.'</p>';
|
39 |
+
$echo_str .= "\n\t".'</div>';
|
40 |
+
}
|
41 |
+
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
42 |
+
$echo_str .= wfu_generate_dashboard_menu("\n\t\t", "Maintenance Actions");
|
43 |
+
//maintenance actions
|
44 |
+
$echo_str .= "\n\t\t".'<h3 style="margin-bottom: 10px;">Maintenance Actions</h3>';
|
45 |
+
$echo_str .= "\n\t\t".'<table class="form-table">';
|
46 |
+
$echo_str .= "\n\t\t\t".'<tbody>';
|
47 |
+
$echo_str .= "\n\t\t\t\t".'<tr>';
|
48 |
+
$echo_str .= "\n\t\t\t\t\t".'<th scope="row">';
|
49 |
+
$wfu_maintenance_nonce = wp_create_nonce("wfu_maintenance_actions");
|
50 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=sync_db&nonce='.$wfu_maintenance_nonce.'" class="button" title="Update database to reflect current status of files">Sync Database</a>';
|
51 |
+
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
52 |
+
$echo_str .= "\n\t\t\t\t\t".'<td>';
|
53 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<label>Update database to reflect current status of files.</label>';
|
54 |
+
$echo_str .= "\n\t\t\t\t\t".'</td>';
|
55 |
+
$echo_str .= "\n\t\t\t\t".'</tr>';
|
56 |
+
$echo_str .= "\n\t\t\t\t".'<tr>';
|
57 |
+
$echo_str .= "\n\t\t\t\t\t".'<th scope="row">';
|
58 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<a href="" class="button" title="Clean database log" onclick="wfu_cleanlog_selector_toggle(true); return false;">Clean Log</a>';
|
59 |
+
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
60 |
+
$echo_str .= "\n\t\t\t\t\t".'<td>';
|
61 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<label>Clean-up database log, either all or of specific period, including file information, user data and optionally the files.</label>';
|
62 |
+
$echo_str .= "\n\t\t\t\t\t".'</td>';
|
63 |
+
$echo_str .= "\n\t\t\t\t".'</tr>';
|
64 |
+
$echo_str .= "\n\t\t\t\t".'<tr class="wfu_cleanlog_tr">';
|
65 |
+
$echo_str .= "\n\t\t\t\t\t".'<th scope="row"></th>';
|
66 |
+
$echo_str .= "\n\t\t\t\t\t".'<td>';
|
67 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<div>';
|
68 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<label>Select Clean-Up Period</label>';
|
69 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<select id="wfu_cleanlog_period" onchange="wfu_cleanlog_period_changed();">';
|
70 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<option value="older_than_date">Clean-up log older than date</option>';
|
71 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<option value="older_than_period">Clean-up log older than period</option>';
|
72 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<option value="between_dates">Clean-up log between dates</option>';
|
73 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<option value="all">Clean-up all log</option>';
|
74 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'</select>';
|
75 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<div class="wfu_selectdate_container">';
|
76 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<label>Select date</label>';
|
77 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<input id="wfu_cleanlog_dateold" type="text" />';
|
78 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'</div>';
|
79 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<div class="wfu_selectperiod_container">';
|
80 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<label>Select period</label>';
|
81 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<input id="wfu_cleanlog_periodold" type="number" min="1" />';
|
82 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<select id="wfu_cleanlog_periodtype">';
|
83 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t\t".'<option value="days">days</option>';
|
84 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t\t".'<option value="months">months</option>';
|
85 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t\t".'<option value="years">years</option>';
|
86 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'</select>';
|
87 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'</div>';
|
88 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<div class="wfu_selectdates_container">';
|
89 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<label>Select period from</label>';
|
90 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<input id="wfu_cleanlog_datefrom" type="text" />';
|
91 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<label>back to</label>';
|
92 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<input id="wfu_cleanlog_dateto" type="text" />';
|
93 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'</div>';
|
94 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<div class="wfu_includefiles_container">';
|
95 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<label for="wfu_includefiles">Clean-up also affected files</label>';
|
96 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<input id="wfu_includefiles" type="checkbox" />';
|
97 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'</div>';
|
98 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<div class="wfu_buttons_container">';
|
99 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<a href="" class="button" title="Close" onclick="wfu_cleanlog_selector_toggle(false); return false;">Close</a>';
|
100 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<a href="" class="button wfu_cleanlog_proceed" title="Proceed to log clean-up" onclick="if (wfu_cleanlog_selector_checkproceed()) return true; else return false; ">Proceed</a>';
|
101 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<span class="wfu_cleanlog_error hidden">Error</span>';
|
102 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<input id="wfu_cleanlog_href" type="hidden" value="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=clean_log_ask&nonce='.$wfu_maintenance_nonce.'" />';
|
103 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'</div>';
|
104 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</div>';
|
105 |
+
$echo_str .= "\n\t\t\t\t\t".'</td>';
|
106 |
+
$echo_str .= "\n\t\t\t\t".'</tr>';
|
107 |
+
$echo_str .= "\n\t\t\t\t".'<tr>';
|
108 |
+
$echo_str .= "\n\t\t\t\t\t".'<th scope="row">';
|
109 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=purge_data_ask&nonce='.$wfu_maintenance_nonce.'" class="button" title="Remove all plugin data from website" style="color:red;">Purge All Data</a>';
|
110 |
+
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
111 |
+
$echo_str .= "\n\t\t\t\t\t".'<td>';
|
112 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<label>Purge all plugin options and tables from database, as well as any session data. The plugin will be deactivated after this action.</label>';
|
113 |
+
$echo_str .= "\n\t\t\t\t\t".'</td>';
|
114 |
+
$echo_str .= "\n\t\t\t\t".'</tr>';
|
115 |
+
$echo_str .= "\n\t\t\t".'</tbody>';
|
116 |
+
$echo_str .= "\n\t\t".'</table>';
|
117 |
+
$echo_str .= "\n\t".'</div>';
|
118 |
+
//export actions
|
119 |
+
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
120 |
+
$echo_str .= "\n\t\t".'<h3 style="margin-bottom: 10px;">Export Actions</h3>';
|
121 |
+
$echo_str .= "\n\t\t".'<table class="form-table">';
|
122 |
+
$echo_str .= "\n\t\t\t".'<tbody>';
|
123 |
+
$echo_str .= "\n\t\t\t\t".'<tr>';
|
124 |
+
$echo_str .= "\n\t\t\t\t\t".'<th scope="row">';
|
125 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<a href="javascript:wfu_download_file(\'exportdata\', 1);" class="button" title="Export uploaded file data">Export Uploaded File Data</a>';
|
126 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<input id="wfu_download_file_nonce" type="hidden" value="'.wp_create_nonce('wfu_download_file_invoker').'" />';
|
127 |
+
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
128 |
+
$echo_str .= "\n\t\t\t\t\t".'<td>';
|
129 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<label>Export uploaded valid file data, together with any userdata fields, to a comma-separated text file.</label>';
|
130 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<div id="wfu_file_download_container_1" style="display: none;"></div>';
|
131 |
+
$echo_str .= "\n\t\t\t\t\t".'</td>';
|
132 |
+
$echo_str .= "\n\t\t\t\t".'</tr>';
|
133 |
+
$echo_str .= "\n\t\t\t".'</tbody>';
|
134 |
+
$echo_str .= "\n\t\t".'</table>';
|
135 |
+
$echo_str .= "\n\t".'</div>';
|
136 |
+
$handler = 'function() { wfu_cleanlog_initialize_elements(); }';
|
137 |
+
$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>';
|
138 |
+
$echo_str .= "\n".'</div>';
|
139 |
+
|
140 |
+
echo $echo_str;
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Check and Execute Database Synchronization.
|
145 |
+
*
|
146 |
+
* This function performs security checks whether database synchronization can
|
147 |
+
* be executed and then executes this operation.
|
148 |
+
*
|
149 |
+
* @since 4.6.0
|
150 |
+
*
|
151 |
+
* @param string $nonce A string that verifies that the request came from
|
152 |
+
* Maintenance Actions page.
|
153 |
+
*
|
154 |
+
* @return int The number of records affected by synchronization.
|
155 |
+
*/
|
156 |
+
function wfu_sync_database_controller($nonce) {
|
157 |
+
if ( !current_user_can( 'manage_options' ) ) return -1;
|
158 |
+
if ( !wp_verify_nonce($nonce, 'wfu_maintenance_actions') ) return -1;
|
159 |
+
|
160 |
+
return wfu_sync_database();
|
161 |
+
}
|
162 |
+
|
163 |
+
/**
|
164 |
+
* Prepare Data for Log Cleaning.
|
165 |
+
*
|
166 |
+
* This function prepares data for executing log cleaning operation.
|
167 |
+
*
|
168 |
+
* @since 4.6.0
|
169 |
+
*
|
170 |
+
* @param string $data An encoded string containing information about what
|
171 |
+
* records to clean.
|
172 |
+
*
|
173 |
+
* @return array An array containing log cleaning data.
|
174 |
+
*/
|
175 |
+
function wfu_clean_log_parse_data($data) {
|
176 |
+
$ret = array( "result" => true );
|
177 |
+
$data = sanitize_text_field($data);
|
178 |
+
$data_array = explode(":", $data);
|
179 |
+
if ( count($data_array) == 0 ) $ret["result"] = false;
|
180 |
+
elseif ( $data_array[0] == "00" || $data_array[0] == "01" ) {
|
181 |
+
$ret["code"] = "0";
|
182 |
+
$ret["include_files"] = ( substr($data_array[0], 1, 1) == "1" );
|
183 |
+
if ( count($data_array) != 2 || strlen($data_array[1]) != 8 ) $ret["result"] = false;
|
184 |
+
else {
|
185 |
+
$ret["dateold"] = strtotime(substr($data_array[1], 0, 4)."-".substr($data_array[1], 4, 2)."-".substr($data_array[1], 6, 2)." 00:00");
|
186 |
+
if ( $ret["dateold"] > time() ) $ret["result"] = false;
|
187 |
+
}
|
188 |
+
}
|
189 |
+
elseif ( $data_array[0] == "10" || $data_array[0] == "11" ) {
|
190 |
+
$ret["code"] = "1";
|
191 |
+
$ret["include_files"] = ( substr($data_array[0], 1, 1) == "1" );
|
192 |
+
if ( count($data_array) != 3 ) $ret["result"] = false;
|
193 |
+
else {
|
194 |
+
$ret["periodold"] = (int)$data_array[1];
|
195 |
+
if ( $ret["periodold"] <= 0 ) $ret["result"] = false;
|
196 |
+
elseif ( $data_array[2] == 'd' ) $ret["periodtype"] = 'days';
|
197 |
+
elseif ( $data_array[2] == 'm' ) $ret["periodtype"] = 'months';
|
198 |
+
elseif ( $data_array[2] == 'y' ) $ret["periodtype"] = 'years';
|
199 |
+
else $ret["result"] = false;
|
200 |
+
}
|
201 |
+
}
|
202 |
+
elseif ( $data_array[0] == "20" || $data_array[0] == "21" ) {
|
203 |
+
$ret["code"] = "2";
|
204 |
+
$ret["include_files"] = ( substr($data_array[0], 1, 1) == "1" );
|
205 |
+
if ( count($data_array) != 3 || strlen($data_array[1]) != 8 || strlen($data_array[2]) != 8 ) $ret["result"] = false;
|
206 |
+
$ret["datefrom"] = strtotime(substr($data_array[1], 0, 4)."-".substr($data_array[1], 4, 2)."-".substr($data_array[1], 6, 2)." 00:00");
|
207 |
+
if ( $ret["datefrom"] > time() ) $ret["result"] = false;
|
208 |
+
else {
|
209 |
+
$ret["dateto"] = strtotime(substr($data_array[2], 0, 4)."-".substr($data_array[2], 4, 2)."-".substr($data_array[2], 6, 2)." 00:00");
|
210 |
+
if ( $ret["dateto"] > $ret["datefrom"] ) $ret["result"] = false;
|
211 |
+
}
|
212 |
+
}
|
213 |
+
elseif ( $data_array[0] == "30" || $data_array[0] == "31" ) {
|
214 |
+
$ret["code"] = "3";
|
215 |
+
$ret["include_files"] = ( substr($data_array[0], 1, 1) == "1" );
|
216 |
+
if ( count($data_array) != 1 ) $ret["result"] = false;
|
217 |
+
}
|
218 |
+
else $ret["result"] = false;
|
219 |
+
|
220 |
+
return $ret;
|
221 |
+
}
|
222 |
+
|
223 |
+
/**
|
224 |
+
* Prepare Query for Log Cleaning.
|
225 |
+
*
|
226 |
+
* This function prepares the SQL WHERE clause of the query for log cleaning.
|
227 |
+
*
|
228 |
+
* @since 4.9.1
|
229 |
+
*
|
230 |
+
* @param array $data An array containing log cleaning data.
|
231 |
+
*
|
232 |
+
* @return string An SQL WHERE clause that defines which database records will
|
233 |
+
* be affected by log cleaning operation.
|
234 |
+
*/
|
235 |
+
function wfu_clean_log_where_query($data) {
|
236 |
+
$query = "";
|
237 |
+
if ( $data["code"] == "0" ) $query = " WHERE date_from < '".date('Y-m-d H:i:s', $data["dateold"])."'";
|
238 |
+
elseif ( $data["code"] == "1" ) {
|
239 |
+
$date = strtotime(date('Y-m-d', strtotime('-'.$data["periodold"].' '.$data["periodtype"]))." 00:00");
|
240 |
+
$query = " WHERE date_from < '".date('Y-m-d H:i:s', $date)."'";
|
241 |
+
}
|
242 |
+
elseif ( $data["code"] == "2" ) $query = " WHERE date_from < '".date('Y-m-d H:i:s', $data["datefrom"] + 86400)."' AND date_from >= '".date('Y-m-d H:i:s', $data["dateto"])."'";
|
243 |
+
|
244 |
+
return $query;
|
245 |
+
}
|
246 |
+
|
247 |
+
/**
|
248 |
+
* Confirm Log Cleaning Operation.
|
249 |
+
*
|
250 |
+
* This function shows a page to confirm log cleaning operation.
|
251 |
+
*
|
252 |
+
* @since 3.3.1
|
253 |
+
*
|
254 |
+
* @param string $nonce A string that verifies that the request came from
|
255 |
+
* Maintenance Actions page.
|
256 |
+
* @param string $data_enc An encoded string containing information about what
|
257 |
+
* records to clean.
|
258 |
+
*
|
259 |
+
* @return string The HTML code of the confirmation page.
|
260 |
+
*/
|
261 |
+
function wfu_clean_log_prompt($nonce, $data_enc) {
|
262 |
+
global $wpdb;
|
263 |
+
$table_name1 = $wpdb->prefix . "wfu_log";
|
264 |
+
$siteurl = site_url();
|
265 |
+
|
266 |
+
if ( !current_user_can( 'manage_options' ) || !wp_verify_nonce($nonce, 'wfu_maintenance_actions') ) return wfu_maintenance_actions();
|
267 |
+
//parse data
|
268 |
+
$data = wfu_clean_log_parse_data($data_enc);
|
269 |
+
if ( $data["result"] == false ) return wfu_maintenance_actions();
|
270 |
+
|
271 |
+
$echo_str = "\n".'<div class="wrap">';
|
272 |
+
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
273 |
+
$echo_str .= "\n\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=maintenance_actions" class="button" title="go back">Go back</a>';
|
274 |
+
$echo_str .= "\n\t".'</div>';
|
275 |
+
$echo_str .= "\n\t".'<h2 style="margin-bottom: 10px;">Clean Database Log</h2>';
|
276 |
+
$echo_str .= "\n\t".'<form enctype="multipart/form-data" name="clean_log" id="clean_log" method="post" action="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload" class="validate">';
|
277 |
+
$nonce = wp_nonce_field('wfu_clean_log', '_wpnonce', false, false);
|
278 |
+
$nonce_ref = wp_referer_field(false);
|
279 |
+
$echo_str .= "\n\t\t".$nonce;
|
280 |
+
$echo_str .= "\n\t\t".$nonce_ref;
|
281 |
+
$echo_str .= "\n\t\t".'<input type="hidden" name="action" value="clean_log">';
|
282 |
+
$echo_str .= "\n\t\t".'<input type="hidden" name="data" value="'.$data_enc.'">';
|
283 |
+
if ( $data["include_files"] ) {
|
284 |
+
if ( $data["code"] == "0" )
|
285 |
+
$echo_str .= "\n\t\t".'<label>This will erase all files uploaded <strong>before '.date("Y-m-d", $data["dateold"]).'</strong> together with associated records kept by the plugin in the database (like file metadata and userdata).</label><br/>';
|
286 |
+
elseif ( $data["code"] == "1" )
|
287 |
+
$echo_str .= "\n\t\t".'<label>This will erase all files uploaded <strong>'.$data["periodold"].' '.$data["periodtype"].' ago or older</strong> together with associated records kept by the plugin in the database (like file metadata and userdata).</label><br/>';
|
288 |
+
elseif ( $data["code"] == "2" )
|
289 |
+
$echo_str .= "\n\t\t".'<label>This will erase all files uploaded <strong>between '.date("Y-m-d", $data["datefrom"]).' and '.date("Y-m-d", $data["dateto"]).'</strong> together with associated records kept by the plugin in the database (like file metadata and userdata).</label><br/>';
|
290 |
+
else
|
291 |
+
$echo_str .= "\n\t\t".'<label>This will erase <strong>ALL</strong> files and associated records kept by the plugin in the database (like file metadata and userdata).</label><br/>';
|
292 |
+
$affected_recs = $wpdb->get_results("SELECT * FROM $table_name1".wfu_clean_log_where_query($data));
|
293 |
+
$affected_files = wfu_get_valid_affected_files($affected_recs);
|
294 |
+
$echo_str .= "\n\t\t".'<br/><div class="wfu_cleanlog_files">';
|
295 |
+
$echo_str .= "\n\t\t\t".'<div>';
|
296 |
+
$echo_str .= "\n\t\t\t\t".'<label style="vertical-align: middle;"><strong>'.count($affected_files).'</strong> files will be deleted</label>';
|
297 |
+
$echo_str .= "\n\t\t\t\t".'<button id="wfu_cleanlog_prompt_button" onclick="document.querySelector(\'.wfu_cleanlog_files\').classList.toggle(\'visible\');return false;" style="vertical-align: middle;"></button>';
|
298 |
+
$echo_str .= "\n\t\t\t".'</div>';
|
299 |
+
$echo_str .= "\n\t\t\t".'<div id="wfu_cleanlog_prompt_list" style="margin-top:10px;">';
|
300 |
+
$echo_str .= "\n\t\t\t\t".'<textarea readonly="readonly" style="width:250px; height:150px; overflow:scroll; white-space:pre; resize:both;">';
|
301 |
+
foreach ( $affected_files as $file ) {
|
302 |
+
$echo_str .= $file."\n";
|
303 |
+
}
|
304 |
+
$echo_str .= "\n\t\t\t\t".'</textarea>';
|
305 |
+
$echo_str .= "\n\t\t\t".'</div>';
|
306 |
+
$echo_str .= "\n\t\t".'</div>';
|
307 |
+
$echo_str .= "\n\t\t".'<br/><label>Are you sure that you want to continue?</label><br/>';
|
308 |
+
$echo_str .= "\n\t\t".'<style>';
|
309 |
+
$echo_str .= "\n\t\t".'.wfu_cleanlog_files button:before { content: "Click to see affected files"; } ';
|
310 |
+
$echo_str .= "\n\t\t".'.wfu_cleanlog_files.visible button:before { content: "Close list"; } ';
|
311 |
+
$echo_str .= "\n\t\t".'.wfu_cleanlog_files #wfu_cleanlog_prompt_list { display: none; } ';
|
312 |
+
$echo_str .= "\n\t\t".'.wfu_cleanlog_files.visible #wfu_cleanlog_prompt_list { display: block; } ';
|
313 |
+
$echo_str .= "\n\t\t".'</style>';
|
314 |
+
}
|
315 |
+
else {
|
316 |
+
if ( $data["code"] == "0" )
|
317 |
+
$echo_str .= "\n\t\t".'<label>This will erase all records <strong>before '.date("Y-m-d", $data["dateold"]).'</strong> kept by the plugin in the database (like file metadata and userdata, however files uploaded by the plugin will be maintained). Are you sure that you want to continue?</label><br/>';
|
318 |
+
elseif ( $data["code"] == "1" )
|
319 |
+
$echo_str .= "\n\t\t".'<label>This will erase all records <strong>older than '.$data["periodold"].' '.$data["periodtype"].'</strong> kept by the plugin in the database (like file metadata and userdata, however files uploaded by the plugin will be maintained). Are you sure that you want to continue?</label><br/>';
|
320 |
+
elseif ( $data["code"] == "2" )
|
321 |
+
$echo_str .= "\n\t\t".'<label>This will erase all records <strong>between '.date("Y-m-d", $data["datefrom"]).' and '.date("Y-m-d", $data["dateto"]).'</strong> kept by the plugin in the database (like file metadata and userdata, however files uploaded by the plugin will be maintained). Are you sure that you want to continue?</label><br/>';
|
322 |
+
else
|
323 |
+
$echo_str .= "\n\t\t".'<label>This will erase <strong>ALL</strong> records kept by the plugin in the database (like file metadata and userdata, however files uploaded by the plugin will be maintained). Are you sure that you want to continue?</label><br/>';
|
324 |
+
}
|
325 |
+
$echo_str .= "\n\t\t".'<p class="submit">';
|
326 |
+
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Yes">';
|
327 |
+
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Cancel">';
|
328 |
+
$echo_str .= "\n\t\t".'</p>';
|
329 |
+
$echo_str .= "\n\t".'</form>';
|
330 |
+
$echo_str .= "\n".'</div>';
|
331 |
+
return $echo_str;
|
332 |
+
}
|
333 |
+
|
334 |
+
/**
|
335 |
+
* Execute Log Cleaning.
|
336 |
+
*
|
337 |
+
* This function cleans the database log based on criteria selected by the
|
338 |
+
* admin.
|
339 |
+
*
|
340 |
+
* @since 3.3.1
|
341 |
+
*
|
342 |
+
* @redeclarable
|
343 |
+
*
|
344 |
+
* @return array An array containing the number of records and files affected by
|
345 |
+
* cleaning operation.
|
346 |
+
*/
|
347 |
+
function wfu_clean_log() {
|
348 |
+
$a = func_get_args(); $a = WFU_FUNCTION_HOOK(__FUNCTION__, $a, $out); if (isset($out['vars'])) foreach($out['vars'] as $p => $v) $$p = $v; switch($a) { case 'R': return $out['output']; break; case 'D': die($out['output']); }
|
349 |
+
global $wpdb;
|
350 |
+
|
351 |
+
if ( !current_user_can( 'manage_options' ) ) return array( "recs_count" => -1, "files_count" => -1 );
|
352 |
+
if ( !check_admin_referer('wfu_clean_log') ) return array( "recs_count" => -1, "files_count" => -1 );
|
353 |
+
|
354 |
+
$recs_count = 0;
|
355 |
+
if ( isset($_POST['data']) && isset($_POST['submit']) && $_POST['submit'] == "Yes" ) {
|
356 |
+
$data = wfu_clean_log_parse_data($_POST['data']);
|
357 |
+
if ( $data["result"] ) {
|
358 |
+
$table_name1 = $wpdb->prefix . "wfu_log";
|
359 |
+
$table_name2 = $wpdb->prefix . "wfu_userdata";
|
360 |
+
//$table_name3 = $wpdb->prefix . "wfu_dbxqueue";
|
361 |
+
|
362 |
+
$affected_files = array();
|
363 |
+
if ( $data["include_files"] ) {
|
364 |
+
$affected_recs = $wpdb->get_results("SELECT * FROM $table_name1".wfu_clean_log_where_query($data));
|
365 |
+
$affected_files = wfu_get_valid_affected_files($affected_recs);
|
366 |
+
}
|
367 |
+
$query1 = "DELETE FROM $table_name1";
|
368 |
+
$query2 = "DELETE FROM $table_name2";
|
369 |
+
//$query3 = "DELETE FROM $table_name3";
|
370 |
+
if ( $data["code"] == "0" ) {
|
371 |
+
$query1 .= " WHERE date_from < '".date('Y-m-d H:i:s', $data["dateold"])."'";
|
372 |
+
$query2 .= " WHERE date_from < '".date('Y-m-d H:i:s', $data["dateold"])."'";
|
373 |
+
}
|
374 |
+
elseif ( $data["code"] == "1" ) {
|
375 |
+
$date = strtotime(date('Y-m-d', strtotime('-'.$data["periodold"].' '.$data["periodtype"]))." 00:00");
|
376 |
+
$query1 .= " WHERE date_from < '".date('Y-m-d H:i:s', $date)."'";
|
377 |
+
$query2 .= " WHERE date_from < '".date('Y-m-d H:i:s', $date)."'";
|
378 |
+
}
|
379 |
+
elseif ( $data["code"] == "2" ) {
|
380 |
+
$query1 .= " WHERE date_from < '".date('Y-m-d H:i:s', $data["datefrom"] + 86400)."' AND date_from >= '".date('Y-m-d H:i:s', $data["dateto"])."'";
|
381 |
+
$query2 .= " WHERE date_from < '".date('Y-m-d H:i:s', $data["datefrom"] + 86400)."' AND date_from >= '".date('Y-m-d H:i:s', $data["dateto"])."'";
|
382 |
+
}
|
383 |
+
$recs_count = $wpdb->query($query1);
|
384 |
+
$recs_count += $wpdb->query($query2);
|
385 |
+
//$recs_count += $wpdb->query($query3);
|
386 |
+
|
387 |
+
//delete affected files
|
388 |
+
$files_count = 0;
|
389 |
+
foreach( $affected_files as $file ) {
|
390 |
+
wfu_unlink($file, "wfu_clean_log");
|
391 |
+
if ( !wfu_file_exists($file, "wfu_clean_log") ) $files_count ++;
|
392 |
+
}
|
393 |
+
}
|
394 |
+
}
|
395 |
+
|
396 |
+
return array( "recs_count" => $recs_count, "files_count" => $files_count );
|
397 |
+
}
|
398 |
+
|
399 |
+
/**
|
400 |
+
* Confirm Purge of Data Operation.
|
401 |
+
*
|
402 |
+
* This function shows a page to confirm purge of data operation. Purge
|
403 |
+
* operation deletes all plugin data from the website.
|
404 |
+
*
|
405 |
+
* @since 4.9.1
|
406 |
+
*
|
407 |
+
* @param string $nonce A string that verifies that the request came from
|
408 |
+
* Maintenance Actions page.
|
409 |
+
*
|
410 |
+
* @return string The HTML code of the confirmation page.
|
411 |
+
*/
|
412 |
+
function wfu_purge_data_prompt($nonce) {
|
413 |
+
$siteurl = site_url();
|
414 |
+
|
415 |
+
if ( !current_user_can( 'manage_options' ) || !wp_verify_nonce($nonce, 'wfu_maintenance_actions') ) return wfu_maintenance_actions();
|
416 |
+
|
417 |
+
$echo_str = "\n".'<div class="wrap">';
|
418 |
+
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
419 |
+
$echo_str .= "\n\t\t".'<a href="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=maintenance_actions" class="button" title="go back">Go back</a>';
|
420 |
+
$echo_str .= "\n\t".'</div>';
|
421 |
+
$echo_str .= "\n\t".'<h2 style="margin-bottom: 10px;">Purge All Data</h2>';
|
422 |
+
$echo_str .= "\n\t".'<form enctype="multipart/form-data" name="purge_data" id="purge_data" method="post" action="'.$siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload" class="validate">';
|
423 |
+
$nonce = wp_nonce_field('wfu_purge_data', '_wpnonce', false, false);
|
424 |
+
$nonce_ref = wp_referer_field(false);
|
425 |
+
$echo_str .= "\n\t\t".$nonce;
|
426 |
+
$echo_str .= "\n\t\t".$nonce_ref;
|
427 |
+
$echo_str .= "\n\t\t".'<input type="hidden" name="action" value="purge_data">';
|
428 |
+
$echo_str .= "\n\t\t".'<label>This action will remove all plugin options and records from database, data stored in session and will dectivate the plugin. Use it only if you want to entirely remove the plugin from the website.</label><br/>';
|
429 |
+
$echo_str .= "\n\t\t".'<br/><label>Are you sure you want to continue?</label><br/>';
|
430 |
+
$echo_str .= "\n\t\t".'<p class="submit">';
|
431 |
+
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Yes">';
|
432 |
+
$echo_str .= "\n\t\t\t".'<input type="submit" class="button-primary" name="submit" value="Cancel">';
|
433 |
+
$echo_str .= "\n\t\t".'</p>';
|
434 |
+
$echo_str .= "\n\t".'</form>';
|
435 |
+
$echo_str .= "\n".'</div>';
|
436 |
+
return $echo_str;
|
437 |
+
}
|
438 |
+
|
439 |
+
/**
|
440 |
+
* Purge Plugin Data.
|
441 |
+
*
|
442 |
+
* This function deletes all plugin data from the website. It drops the tables
|
443 |
+
* of the plugin from the database, it deletes all plugin options and all plugin
|
444 |
+
* data stored in session.
|
445 |
+
*
|
446 |
+
* @since 4.9.1
|
447 |
+
*
|
448 |
+
* @redeclarable
|
449 |
+
*
|
450 |
+
* @return bool Always true.
|
451 |
+
*/
|
452 |
+
function wfu_purge_data() {
|
453 |
+
$a = func_get_args(); $a = WFU_FUNCTION_HOOK(__FUNCTION__, $a, $out); if (isset($out['vars'])) foreach($out['vars'] as $p => $v) $$p = $v; switch($a) { case 'R': return $out['output']; break; case 'D': die($out['output']); }
|
454 |
+
global $wpdb;
|
455 |
+
|
456 |
+
if ( !current_user_can( 'manage_options' ) ) return;
|
457 |
+
if ( !check_admin_referer('wfu_purge_data') ) return;
|
458 |
+
|
459 |
+
if ( isset($_POST['submit']) && $_POST['submit'] == "Yes" ) {
|
460 |
+
$all_options = array_keys(wp_load_alloptions());
|
461 |
+
$all_session = array_keys($_SESSION);
|
462 |
+
$wfu_options = wfu_get_all_plugin_options();
|
463 |
+
//first delete relevant db options
|
464 |
+
foreach ( $all_options as $opt1 )
|
465 |
+
foreach ( $wfu_options as $opt2 )
|
466 |
+
if ( $opt2[2] && $opt2[1] == "db" ) {
|
467 |
+
if (( substr($opt2[0], 0, 1) != "*" && substr($opt2[0], -1) != "*" && $opt1 == $opt2[0] ) ||
|
468 |
+
( substr($opt2[0], 0, 1) != "*" && substr($opt2[0], -1) == "*" && substr($opt1, 0, strlen($opt2[0])) == substr($opt2[0], 0, -1) ) ||
|
469 |
+
( substr($opt2[0], 0, 1) == "*" && substr($opt2[0], -1) != "*" && substr($opt1, -strlen($opt2[0])) == substr($opt2[0], 1) ) ||
|
470 |
+
( substr($opt2[0], 0, 1) == "*" && substr($opt2[0], -1) == "*" && strpos($opt1, substr($opt2[0], 1, -1)) !== false ))
|
471 |
+
delete_option($opt1);
|
472 |
+
}
|
473 |
+
//then delete relevant session data
|
474 |
+
foreach ( $all_session as $opt1 )
|
475 |
+
foreach ( $wfu_options as $opt2 )
|
476 |
+
if ( $opt2[2] && $opt2[1] == "session" ) {
|
477 |
+
if (( substr($opt2[0], 0, 1) != "*" && substr($opt2[0], -1) != "*" && $opt1 == $opt2[0] ) ||
|
478 |
+
( substr($opt2[0], 0, 1) != "*" && substr($opt2[0], -1) == "*" && substr($opt1, 0, strlen($opt2[0])) == substr($opt2[0], 0, -1) ) ||
|
479 |
+
( substr($opt2[0], 0, 1) == "*" && substr($opt2[0], -1) != "*" && substr($opt1, -strlen($opt2[0])) == substr($opt2[0], 1) ) ||
|
480 |
+
( substr($opt2[0], 0, 1) == "*" && substr($opt2[0], -1) == "*" && strpos($opt1, substr($opt2[0], 1, -1)) !== false ))
|
481 |
+
unset($_SESSION[$opt1]);
|
482 |
+
}
|
483 |
+
//then delete relevant tables
|
484 |
+
$wpdb->query( "DROP TABLE IF EXISTS ".$wpdb->prefix."wfu_log" );
|
485 |
+
$wpdb->query( "DROP TABLE IF EXISTS ".$wpdb->prefix."wfu_userdata" );
|
486 |
+
$wpdb->query( "DROP TABLE IF EXISTS ".$wpdb->prefix."wfu_dbxqueue" );
|
487 |
+
//then deactivate the plugin
|
488 |
+
deactivate_plugins( plugin_basename( WPFILEUPLOAD_PLUGINFILE ) );
|
489 |
+
}
|
490 |
+
else return;
|
491 |
+
|
492 |
+
return true;
|
493 |
+
}
|
494 |
+
|
495 |
+
|
496 |
+
/**
|
497 |
+
* Update File Transfers.
|
498 |
+
*
|
499 |
+
* This function causes the file transfers manager to re-check the pending file
|
500 |
+
* tranfers immediately.
|
501 |
+
*
|
502 |
+
* @since 4.6.0
|
503 |
+
*
|
504 |
+
* @redeclarable
|
505 |
+
*
|
506 |
+
* @param bool $clearfiles Optional. If it is true then all pending file
|
507 |
+
* transfers will be cleared.
|
508 |
+
*/
|
509 |
+
function wfu_process_all_transfers($clearfiles = false) {
|
510 |
+
$a = func_get_args(); $a = WFU_FUNCTION_HOOK(__FUNCTION__, $a, $out); if (isset($out['vars'])) foreach($out['vars'] as $p => $v) $$p = $v; switch($a) { case 'R': return $out['output']; break; case 'D': die($out['output']); }
|
511 |
+
global $wpdb;
|
512 |
+
if ( $clearfiles ) {
|
513 |
+
$table_name1 = $wpdb->prefix . "wfu_log";
|
514 |
+
$table_name3 = $wpdb->prefix . "wfu_dbxqueue";
|
515 |
+
$wpdb->query('DELETE FROM '.$table_name3);
|
516 |
+
}
|
517 |
+
wfu_schedule_transfermanager(true);
|
518 |
+
}
|
519 |
+
|
520 |
+
/**
|
521 |
+
* Check and Execute Reset of File Transfers.
|
522 |
+
*
|
523 |
+
* This function performs security checks whether reset of file transfers can be
|
524 |
+
* executed and then executes this operation.
|
525 |
+
*
|
526 |
+
* @since 4.6.0
|
527 |
+
*
|
528 |
+
* @param string $nonce A string that verifies that the request came from
|
529 |
+
* Maintenance Actions page.
|
530 |
+
*
|
531 |
+
* @return bool Always true.
|
532 |
+
*/
|
533 |
+
function wfu_reset_all_transfers_controller($nonce) {
|
534 |
+
if ( !current_user_can( 'manage_options' ) ) return false;
|
535 |
+
if ( !wp_verify_nonce($nonce, 'wfu_maintenance_actions') ) return false;
|
536 |
+
|
537 |
+
wfu_process_all_transfers();
|
538 |
+
|
539 |
+
return true;
|
540 |
+
}
|
541 |
+
|
542 |
+
/**
|
543 |
+
* Check and Execute Clear of File Transfers.
|
544 |
+
*
|
545 |
+
* This function performs security checks whether clear of file transfers can be
|
546 |
+
* executed and then executes this operation.
|
547 |
+
*
|
548 |
+
* @since 4.6.0
|
549 |
+
*
|
550 |
+
* @param string $nonce A string that verifies that the request came from
|
551 |
+
* Maintenance Actions page.
|
552 |
+
*
|
553 |
+
* @return bool Always true.
|
554 |
+
*/
|
555 |
+
function wfu_clear_all_transfers_controller($nonce) {
|
556 |
+
if ( !current_user_can( 'manage_options' ) ) return false;
|
557 |
+
if ( !wp_verify_nonce($nonce, 'wfu_maintenance_actions') ) return false;
|
558 |
+
|
559 |
+
wfu_process_all_transfers(true);
|
560 |
+
|
561 |
+
return true;
|
562 |
}
|
lib/wfu_admin_settings.php
CHANGED
@@ -1,329 +1,329 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Settings Page in Dashboard Area of Plugin
|
5 |
-
*
|
6 |
-
* This file contains functions related to Settings page of plugin's Dashboard
|
7 |
-
* area.
|
8 |
-
*
|
9 |
-
* @link /lib/wfu_admin_settings.php
|
10 |
-
*
|
11 |
-
* @package WordPress File Upload Plugin
|
12 |
-
* @subpackage Core Components
|
13 |
-
* @since 3.0.0
|
14 |
-
*/
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Initialize Plugin's Settings.
|
18 |
-
*
|
19 |
-
* This function initializes the plugin's settings.
|
20 |
-
*
|
21 |
-
* @since 4.1.0
|
22 |
-
*
|
23 |
-
* @return array Array containing plugin settings and their default values.
|
24 |
-
*/
|
25 |
-
function wfu_settings_definitions() {
|
26 |
-
$settings = array(
|
27 |
-
"version" => array("number", "1.0"),
|
28 |
-
"shortcode" => array("string", ""),
|
29 |
-
"hashfiles" => array("number", ""),
|
30 |
-
"basedir" => array("string", ""),
|
31 |
-
"personaldata" => array("number", ""),
|
32 |
-
"postmethod" => array("number", ""),
|
33 |
-
"modsecurity" => array("number", ""),
|
34 |
-
"userstatehandler" => array("number", "dboption"),
|
35 |
-
"relaxcss" => array("number", ""),
|
36 |
-
"admindomain" => array("number", ""),
|
37 |
-
"mediacustom" => array("number", ""),
|
38 |
-
"createthumbnails" => array("number", ""),
|
39 |
-
"includeotherfiles" => array("number", ""),
|
40 |
-
"altserver" => array("number", ""),
|
41 |
-
"captcha_sitekey" => array("string", ""),
|
42 |
-
"captcha_secretkey" => array("string", ""),
|
43 |
-
"browser_permissions" => array("array", "")
|
44 |
-
);
|
45 |
-
/**
|
46 |
-
* Customize settings definitions.
|
47 |
-
*
|
48 |
-
* This filter allows extensions to add their own settings.
|
49 |
-
*
|
50 |
-
* @since 4.1.0
|
51 |
-
*
|
52 |
-
* @param array $settings Array containing plugin settings and their
|
53 |
-
* default values.
|
54 |
-
*/
|
55 |
-
$settings = apply_filters("_wfu_settings_definitions", $settings);
|
56 |
-
|
57 |
-
return $settings;
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Encode Plugin Settings.
|
62 |
-
*
|
63 |
-
* This function encodes the plugin settings array into a string.
|
64 |
-
*
|
65 |
-
* @since 2.1.3
|
66 |
-
*
|
67 |
-
* @param array $plugin_options The plugin settings.
|
68 |
-
*
|
69 |
-
* @return string The encoded plugin settings.
|
70 |
-
*/
|
71 |
-
function wfu_encode_plugin_options($plugin_options) {
|
72 |
-
$settings = wfu_settings_definitions();
|
73 |
-
$encoded_options = array();
|
74 |
-
foreach ( $settings as $setting => $data ) {
|
75 |
-
$encoded = $setting."=";
|
76 |
-
if ( !isset($plugin_options[$setting]) ) $encoded .= $data[1];
|
77 |
-
elseif ( $data[0] == "string" ) $encoded .= wfu_plugin_encode_string($plugin_options[$setting]);
|
78 |
-
elseif ( $data[0] == "array" ) $encoded .= wfu_encode_array_to_string($plugin_options[$setting]);
|
79 |
-
else $encoded .= $plugin_options[$setting];
|
80 |
-
array_push($encoded_options, $encoded);
|
81 |
-
}
|
82 |
-
|
83 |
-
return implode(";", $encoded_options);
|
84 |
-
}
|
85 |
-
|
86 |
-
/**
|
87 |
-
* Decode Plugin Settings.
|
88 |
-
*
|
89 |
-
* This function decodes the plugin settings string into an array.
|
90 |
-
*
|
91 |
-
* @since 2.1.3
|
92 |
-
*
|
93 |
-
* @param string $encoded_options The encoded plugin settings.
|
94 |
-
*
|
95 |
-
* @return array The decoded plugin settings.
|
96 |
-
*/
|
97 |
-
function wfu_decode_plugin_options($encoded_options) {
|
98 |
-
$settings = wfu_settings_definitions();
|
99 |
-
foreach ( $settings as $setting => $data )
|
100 |
-
$plugin_options[$setting] = $data[1];
|
101 |
-
|
102 |
-
$decoded_array = explode(';', $encoded_options);
|
103 |
-
foreach ($decoded_array as $decoded_item) {
|
104 |
-
if ( trim($decoded_item) != "" ) {
|
105 |
-
list($item_key, $item_value) = explode("=", $decoded_item, 2);
|
106 |
-
if ( isset($settings[$item_key]) ) {
|
107 |
-
if ( $settings[$item_key][0] == "string" ) $plugin_options[$item_key] = wfu_plugin_decode_string($item_value);
|
108 |
-
elseif ( $settings[$item_key][0] == "array" ) $plugin_options[$item_key] = wfu_decode_array_from_string($item_value);
|
109 |
-
else $plugin_options[$item_key] = $item_value;
|
110 |
-
}
|
111 |
-
}
|
112 |
-
}
|
113 |
-
|
114 |
-
return $plugin_options;
|
115 |
-
}
|
116 |
-
|
117 |
-
/**
|
118 |
-
* Display the Settings Page.
|
119 |
-
*
|
120 |
-
* This function displays the Settings page of the plugin's Dashboard area.
|
121 |
-
*
|
122 |
-
* @since 2.1.2
|
123 |
-
*
|
124 |
-
* @param string $message Optional. A message to display on top of the page.
|
125 |
-
*
|
126 |
-
* @return string The HTML output of the plugin's Settings Dashboard page.
|
127 |
-
*/
|
128 |
-
function wfu_manage_settings($message = '') {
|
129 |
-
if ( !current_user_can( 'manage_options' ) ) return;
|
130 |
-
|
131 |
-
$siteurl = site_url();
|
132 |
-
$plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
|
133 |
-
|
134 |
-
$echo_str = '<div class="wrap">';
|
135 |
-
$echo_str .= "\n\t".'<h2>Wordpress File Upload Control Panel</h2>';
|
136 |
-
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
137 |
-
$echo_str .= wfu_generate_dashboard_menu("\n\t\t", "Settings");
|
138 |
-
$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">';
|
139 |
-
$nonce = wp_nonce_field('wfu_edit_admin_settings', '_wpnonce', false, false);
|
140 |
-
$nonce_ref = wp_referer_field(false);
|
141 |
-
$echo_str .= "\n\t\t\t".$nonce;
|
142 |
-
$echo_str .= "\n\t\t\t".$nonce_ref;
|
143 |
-
$echo_str .= "\n\t\t\t".'<input type="hidden" name="action" value="edit_settings">';
|
144 |
-
$echo_str .= "\n\t\t\t".'<table class="form-table">';
|
145 |
-
$echo_str .= "\n\t\t\t\t".'<tbody>';
|
146 |
-
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
147 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
148 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<h3>General Settings</h3>';
|
149 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
150 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
151 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
152 |
-
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
153 |
-
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
154 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
155 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<label for="wfu_hashfiles">Hash Files</label>';
|
156 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
157 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
158 |
-
$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';
|
159 |
-
$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>';
|
160 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
161 |
-
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
162 |
-
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
163 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
164 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<label for="wfu_basedir">Base Directory</label>';
|
165 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
166 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
167 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<input name="wfu_basedir" id="wfu_basedir" type="text" value="'.$plugin_options['basedir'].'" />';
|
168 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<p style="cursor: text; font-size:9px; padding: 0px; margin: 0px; width: 95%; color: #AAAAAA;">Current value: <strong>'.$plugin_options['basedir'].'</strong></p>';
|
169 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
170 |
-
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
171 |
-
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
172 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
173 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<label for="wfu_personaldata">Personal Data</label>';
|
174 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
175 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
176 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<input name="wfu_personaldata" id="wfu_personaldata" type="checkbox"'.($plugin_options['personaldata'] == '1' ? ' checked="checked"' : '' ).' style="width:auto;" /> Enable this option if your website is subject to EU GDPR regulation and you want to define how to handle personal data';
|
177 |
-
$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['personaldata'] == '1' ? 'Yes' : 'No' ).'</strong></p>';
|
178 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
179 |
-
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
180 |
-
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
181 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
182 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<label for="wfu_postmethod">Post Method</label>';
|
183 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
184 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
185 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<select name="wfu_postmethod" id="wfu_postmethod" value="'.$plugin_options['postmethod'].'">';
|
186 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<option value="fopen"'.( $plugin_options['postmethod'] == 'fopen' || $plugin_options['postmethod'] == '' ? ' selected="selected"' : '' ).'>Using fopen (default)</option>';
|
187 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<option value="curl"'.( $plugin_options['postmethod'] == 'curl' ? ' selected="selected"' : '' ).'>Using cURL</option>';
|
188 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<option value="socket"'.( $plugin_options['postmethod'] == 'socket' ? ' selected="selected"' : '' ).'>Using Sockets</option>';
|
189 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'</select>';
|
190 |
-
$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['postmethod'] == 'fopen' || $plugin_options['postmethod'] == '' ? 'Using fopen' : ( $plugin_options['postmethod'] == 'curl' ? 'Using cURL' : 'Using Sockets' ) ).'</strong></p>';
|
191 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
192 |
-
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
193 |
-
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
194 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
195 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<label for="wfu_userstatehandler">User State Handler</label>';
|
196 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
197 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
198 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<select name="wfu_userstatehandler" id="wfu_userstatehandler" value="'.$plugin_options['userstatehandler'].'">';
|
199 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<option value="dboption"'.( $plugin_options['userstatehandler'] == 'dboption' ? ' selected="selected"' : '' ).'>Cookies/DB (default)</option>';
|
200 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<option value="session"'.( $plugin_options['userstatehandler'] == 'session' || $plugin_options['userstatehandler'] == '' ? ' selected="selected"' : '' ).'>Session</option>';
|
201 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'</select>';
|
202 |
-
$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['userstatehandler'] == 'session' || $plugin_options['userstatehandler'] == '' ? 'Session' : ( $plugin_options['userstatehandler'] == 'dboption' ? 'Cookies/DB' : 'Session' ) ).'</strong></p>';
|
203 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
204 |
-
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
205 |
-
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
206 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
207 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<label for="wfu_relaxcss">Relax CSS Rules</label>';
|
208 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
209 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
210 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<input name="wfu_relaxcss" id="wfu_relaxcss" type="checkbox"'.($plugin_options['relaxcss'] == '1' ? ' checked="checked"' : '' ).' style="width:auto;" /> If enabled then the textboxes and the buttons of the plugin will inherit the theme\'s styling';
|
211 |
-
$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['relaxcss'] == '1' ? 'Yes' : 'No' ).'</strong></p>';
|
212 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
213 |
-
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
214 |
-
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
215 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
216 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<label for="wfu_admindomain">Admin Domain</label>';
|
217 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
218 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
219 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<select name="wfu_admindomain" id="wfu_admindomain" value="'.$plugin_options['admindomain'].'">';
|
220 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<option value="siteurl"'.( $plugin_options['admindomain'] == 'siteurl' || $plugin_options['admindomain'] == '' ? ' selected="selected"' : '' ).'>Using site_url (default)</option>';
|
221 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<option value="adminurl"'.( $plugin_options['admindomain'] == 'adminurl' ? ' selected="selected"' : '' ).'>Using admin_url</option>';
|
222 |
-
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<option value="homeurl"'.( $plugin_options['admindomain'] == 'homeurl' ? ' selected="selected"' : '' ).'>Using home_url</option>';
|
223 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'</select>';
|
224 |
-
$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['admindomain'] == 'siteurl' || $plugin_options['admindomain'] == '' ? 'Using site_url' : ( $plugin_options['admindomain'] == 'adminurl' ? 'Using admin_url' : 'Using home_url' ) ).'</strong></p>';
|
225 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
226 |
-
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
227 |
-
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
228 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
229 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<label for="wfu_mediacustom">Show Custom Fields in Media Library</label>';
|
230 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
231 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
232 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<input name="wfu_mediacustom" id="wfu_mediacustom" type="checkbox"'.($plugin_options['mediacustom'] == '1' ? ' checked="checked"' : '' ).' style="width:auto;" /> If enabled and the uploaded files are added to Media Library then any user fields submitted together with the files will be shown in Media Library';
|
233 |
-
$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['mediacustom'] == '1' ? 'Yes' : 'No' ).'</strong></p>';
|
234 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
235 |
-
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
236 |
-
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
237 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
238 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<label for="wfu_includeotherfiles">Include Other Files in Plugin\'s Database</label>';
|
239 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
240 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
241 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<input name="wfu_includeotherfiles" id="wfu_includeotherfiles" type="checkbox"'.($plugin_options['includeotherfiles'] == '1' ? ' checked="checked"' : '' ).' style="width:auto;" /> If enabled administrators can include in the plugin\'s database additional files through the File Browser';
|
242 |
-
$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['includeotherfiles'] == '1' ? 'Yes' : 'No' ).'</strong></p>';
|
243 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
244 |
-
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
245 |
-
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
246 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
247 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<label for="wfu_altserver">Use Alternative Iptanus Server</label>';
|
248 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
249 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
250 |
-
$echo_str .= "\n\t\t\t\t\t\t\t".'<input name="wfu_altserver" id="wfu_altserver" type="checkbox"'.($plugin_options['altserver'] == '1' ? ' checked="checked"' : '' ).' style="width:auto;" /> Switches to the alternative Iptanus server, residing on Google Cloud, for getting information such as latest version number.';
|
251 |
-
$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['altserver'] == '1' ? 'Yes' : 'No' ).'</strong></p>';
|
252 |
-
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
253 |
-
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
254 |
-
$echo_str .= "\n\t\t\t\t".'</tbody>';
|
255 |
-
$echo_str .= "\n\t\t\t".'</table>';
|
256 |
-
$echo_str .= "\n\t\t\t".'<p class="submit">';
|
257 |
-
$echo_str .= "\n\t\t\t\t".'<input type="submit" class="button-primary" name="submitform" value="Update" />';
|
258 |
-
$echo_str .= "\n\t\t\t".'</p>';
|
259 |
-
$echo_str .= "\n\t\t".'</form>';
|
260 |
-
$echo_str .= "\n\t".'</div>';
|
261 |
-
$echo_str .= "\n".'</div>';
|
262 |
-
|
263 |
-
echo $echo_str;
|
264 |
-
}
|
265 |
-
|
266 |
-
|
267 |
-
/**
|
268 |
-
* Update Settings.
|
269 |
-
*
|
270 |
-
* This function updates plugin's settings.
|
271 |
-
*
|
272 |
-
* @since 2.1.2
|
273 |
-
*
|
274 |
-
* @return bool Always true.
|
275 |
-
*/
|
276 |
-
function wfu_update_settings() {
|
277 |
-
if ( !current_user_can( 'manage_options' ) ) return;
|
278 |
-
if ( !check_admin_referer('wfu_edit_admin_settings') ) return;
|
279 |
-
$plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
|
280 |
-
$new_plugin_options = array();
|
281 |
-
|
282 |
-
// $enabled = ( isset($_POST['wfu_enabled']) ? ( $_POST['wfu_enabled'] == "on" ? 1 : 0 ) : 0 );
|
283 |
-
$hashfiles = ( isset($_POST['wfu_hashfiles']) ? ( $_POST['wfu_hashfiles'] == "on" ? 1 : 0 ) : 0 );
|
284 |
-
$personaldata = ( isset($_POST['wfu_personaldata']) ? ( $_POST['wfu_personaldata'] == "on" ? 1 : 0 ) : 0 );
|
285 |
-
$relaxcss = ( isset($_POST['wfu_relaxcss']) ? ( $_POST['wfu_relaxcss'] == "on" ? 1 : 0 ) : 0 );
|
286 |
-
$mediacustom = ( isset($_POST['wfu_mediacustom']) ? ( $_POST['wfu_mediacustom'] == "on" ? 1 : 0 ) : 0 );
|
287 |
-
$includeotherfiles = ( isset($_POST['wfu_includeotherfiles']) ? ( $_POST['wfu_includeotherfiles'] == "on" ? 1 : 0 ) : 0 );
|
288 |
-
$altserver = ( isset($_POST['wfu_altserver']) ? ( $_POST['wfu_altserver'] == "on" ? 1 : 0 ) : 0 );
|
289 |
-
if ( isset($_POST['wfu_basedir']) && isset($_POST['wfu_postmethod']) && isset($_POST['wfu_userstatehandler']) && isset($_POST['wfu_admindomain']) && isset($_POST['submitform']) ) {
|
290 |
-
if ( $_POST['submitform'] == "Update" ) {
|
291 |
-
$new_plugin_options['version'] = '1.0';
|
292 |
-
$new_plugin_options['shortcode'] = $plugin_options['shortcode'];
|
293 |
-
$new_plugin_options['hashfiles'] = $hashfiles;
|
294 |
-
$new_plugin_options['basedir'] = sanitize_text_field($_POST['wfu_basedir']);
|
295 |
-
$new_plugin_options['personaldata'] = $personaldata;
|
296 |
-
$new_plugin_options['postmethod'] = sanitize_text_field($_POST['wfu_postmethod']);
|
297 |
-
$new_plugin_options['userstatehandler'] = sanitize_text_field($_POST['wfu_userstatehandler']);
|
298 |
-
$new_plugin_options['relaxcss'] = $relaxcss;
|
299 |
-
$new_plugin_options['admindomain'] = sanitize_text_field($_POST['wfu_admindomain']);
|
300 |
-
$new_plugin_options['mediacustom'] = $mediacustom;
|
301 |
-
$new_plugin_options['includeotherfiles'] = $includeotherfiles;
|
302 |
-
$new_plugin_options['altserver'] = $altserver;
|
303 |
-
$encoded_options = wfu_encode_plugin_options($new_plugin_options);
|
304 |
-
update_option( "wordpress_file_upload_options", $encoded_options );
|
305 |
-
if ( $new_plugin_options['hashfiles'] == '1' && $plugin_options['hashfiles'] != '1' )
|
306 |
-
wfu_reassign_hashes();
|
307 |
-
}
|
308 |
-
}
|
309 |
-
|
310 |
-
return true;
|
311 |
-
}
|
312 |
-
|
313 |
-
/**
|
314 |
-
* Update a Plugin Setting.
|
315 |
-
*
|
316 |
-
* This function updates an individual plugin setting.
|
317 |
-
*
|
318 |
-
* @since 4.12.0
|
319 |
-
*
|
320 |
-
* @param string $option The plugin option to change.
|
321 |
-
* @param mixed $value The new value of the option.
|
322 |
-
*/
|
323 |
-
function wfu_update_setting($option, $value) {
|
324 |
-
$plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
|
325 |
-
$plugin_options[$option] = $value;
|
326 |
-
$encoded_options = wfu_encode_plugin_options($plugin_options);
|
327 |
-
update_option( "wordpress_file_upload_options", $encoded_options );
|
328 |
-
}
|
329 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Settings Page in Dashboard Area of Plugin
|
5 |
+
*
|
6 |
+
* This file contains functions related to Settings page of plugin's Dashboard
|
7 |
+
* area.
|
8 |
+
*
|
9 |
+
* @link /lib/wfu_admin_settings.php
|
10 |
+
*
|
11 |
+
* @package WordPress File Upload Plugin
|
12 |
+
* @subpackage Core Components
|
13 |
+
* @since 3.0.0
|
14 |
+
*/
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Initialize Plugin's Settings.
|
18 |
+
*
|
19 |
+
* This function initializes the plugin's settings.
|
20 |
+
*
|
21 |
+
* @since 4.1.0
|
22 |
+
*
|
23 |
+
* @return array Array containing plugin settings and their default values.
|
24 |
+
*/
|
25 |
+
function wfu_settings_definitions() {
|
26 |
+
$settings = array(
|
27 |
+
"version" => array("number", "1.0"),
|
28 |
+
"shortcode" => array("string", ""),
|
29 |
+
"hashfiles" => array("number", ""),
|
30 |
+
"basedir" => array("string", ""),
|
31 |
+
"personaldata" => array("number", ""),
|
32 |
+
"postmethod" => array("number", ""),
|
33 |
+
"modsecurity" => array("number", ""),
|
34 |
+
"userstatehandler" => array("number", "dboption"),
|
35 |
+
"relaxcss" => array("number", ""),
|
36 |
+
"admindomain" => array("number", ""),
|
37 |
+
"mediacustom" => array("number", ""),
|
38 |
+
"createthumbnails" => array("number", ""),
|
39 |
+
"includeotherfiles" => array("number", ""),
|
40 |
+
"altserver" => array("number", ""),
|
41 |
+
"captcha_sitekey" => array("string", ""),
|
42 |
+
"captcha_secretkey" => array("string", ""),
|
43 |
+
"browser_permissions" => array("array", "")
|
44 |
+
);
|
45 |
+
/**
|
46 |
+
* Customize settings definitions.
|
47 |
+
*
|
48 |
+
* This filter allows extensions to add their own settings.
|
49 |
+
*
|
50 |
+
* @since 4.1.0
|
51 |
+
*
|
52 |
+
* @param array $settings Array containing plugin settings and their
|
53 |
+
* default values.
|
54 |
+
*/
|
55 |
+
$settings = apply_filters("_wfu_settings_definitions", $settings);
|
56 |
+
|
57 |
+
return $settings;
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Encode Plugin Settings.
|
62 |
+
*
|
63 |
+
* This function encodes the plugin settings array into a string.
|
64 |
+
*
|
65 |
+
* @since 2.1.3
|
66 |
+
*
|
67 |
+
* @param array $plugin_options The plugin settings.
|
68 |
+
*
|
69 |
+
* @return string The encoded plugin settings.
|
70 |
+
*/
|
71 |
+
function wfu_encode_plugin_options($plugin_options) {
|
72 |
+
$settings = wfu_settings_definitions();
|
73 |
+
$encoded_options = array();
|
74 |
+
foreach ( $settings as $setting => $data ) {
|
75 |
+
$encoded = $setting."=";
|
76 |
+
if ( !isset($plugin_options[$setting]) ) $encoded .= $data[1];
|
77 |
+
elseif ( $data[0] == "string" ) $encoded .= wfu_plugin_encode_string($plugin_options[$setting]);
|
78 |
+
elseif ( $data[0] == "array" ) $encoded .= wfu_encode_array_to_string($plugin_options[$setting]);
|
79 |
+
else $encoded .= $plugin_options[$setting];
|
80 |
+
array_push($encoded_options, $encoded);
|
81 |
+
}
|
82 |
+
|
83 |
+
return implode(";", $encoded_options);
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Decode Plugin Settings.
|
88 |
+
*
|
89 |
+
* This function decodes the plugin settings string into an array.
|
90 |
+
*
|
91 |
+
* @since 2.1.3
|
92 |
+
*
|
93 |
+
* @param string $encoded_options The encoded plugin settings.
|
94 |
+
*
|
95 |
+
* @return array The decoded plugin settings.
|
96 |
+
*/
|
97 |
+
function wfu_decode_plugin_options($encoded_options) {
|
98 |
+
$settings = wfu_settings_definitions();
|
99 |
+
foreach ( $settings as $setting => $data )
|
100 |
+
$plugin_options[$setting] = $data[1];
|
101 |
+
|
102 |
+
$decoded_array = explode(';', $encoded_options);
|
103 |
+
foreach ($decoded_array as $decoded_item) {
|
104 |
+
if ( trim($decoded_item) != "" ) {
|
105 |
+
list($item_key, $item_value) = explode("=", $decoded_item, 2);
|
106 |
+
if ( isset($settings[$item_key]) ) {
|
107 |
+
if ( $settings[$item_key][0] == "string" ) $plugin_options[$item_key] = wfu_plugin_decode_string($item_value);
|
108 |
+
elseif ( $settings[$item_key][0] == "array" ) $plugin_options[$item_key] = wfu_decode_array_from_string($item_value);
|
109 |
+
else $plugin_options[$item_key] = $item_value;
|
110 |
+
}
|
111 |
+
}
|
112 |
+
}
|
113 |
+
|
114 |
+
return $plugin_options;
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Display the Settings Page.
|
119 |
+
*
|
120 |
+
* This function displays the Settings page of the plugin's Dashboard area.
|
121 |
+
*
|
122 |
+
* @since 2.1.2
|
123 |
+
*
|
124 |
+
* @param string $message Optional. A message to display on top of the page.
|
125 |
+
*
|
126 |
+
* @return string The HTML output of the plugin's Settings Dashboard page.
|
127 |
+
*/
|
128 |
+
function wfu_manage_settings($message = '') {
|
129 |
+
if ( !current_user_can( 'manage_options' ) ) return;
|
130 |
+
|
131 |
+
$siteurl = site_url();
|
132 |
+
$plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
|
133 |
+
|
134 |
+
$echo_str = '<div class="wrap">';
|
135 |
+
$echo_str .= "\n\t".'<h2>Wordpress File Upload Control Panel</h2>';
|
136 |
+
$echo_str .= "\n\t".'<div style="margin-top:20px;">';
|
137 |
+
$echo_str .= wfu_generate_dashboard_menu("\n\t\t", "Settings");
|
138 |
+
$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">';
|
139 |
+
$nonce = wp_nonce_field('wfu_edit_admin_settings', '_wpnonce', false, false);
|
140 |
+
$nonce_ref = wp_referer_field(false);
|
141 |
+
$echo_str .= "\n\t\t\t".$nonce;
|
142 |
+
$echo_str .= "\n\t\t\t".$nonce_ref;
|
143 |
+
$echo_str .= "\n\t\t\t".'<input type="hidden" name="action" value="edit_settings">';
|
144 |
+
$echo_str .= "\n\t\t\t".'<table class="form-table">';
|
145 |
+
$echo_str .= "\n\t\t\t\t".'<tbody>';
|
146 |
+
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
147 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
148 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<h3>General Settings</h3>';
|
149 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
150 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
151 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
152 |
+
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
153 |
+
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
154 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
155 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<label for="wfu_hashfiles">Hash Files</label>';
|
156 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
157 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
158 |
+
$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';
|
159 |
+
$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>';
|
160 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
161 |
+
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
162 |
+
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
163 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
164 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<label for="wfu_basedir">Base Directory</label>';
|
165 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
166 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
167 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<input name="wfu_basedir" id="wfu_basedir" type="text" value="'.$plugin_options['basedir'].'" />';
|
168 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<p style="cursor: text; font-size:9px; padding: 0px; margin: 0px; width: 95%; color: #AAAAAA;">Current value: <strong>'.$plugin_options['basedir'].'</strong></p>';
|
169 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
170 |
+
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
171 |
+
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
172 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
173 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<label for="wfu_personaldata">Personal Data</label>';
|
174 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
175 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
176 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<input name="wfu_personaldata" id="wfu_personaldata" type="checkbox"'.($plugin_options['personaldata'] == '1' ? ' checked="checked"' : '' ).' style="width:auto;" /> Enable this option if your website is subject to EU GDPR regulation and you want to define how to handle personal data';
|
177 |
+
$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['personaldata'] == '1' ? 'Yes' : 'No' ).'</strong></p>';
|
178 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
179 |
+
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
180 |
+
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
181 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
182 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<label for="wfu_postmethod">Post Method</label>';
|
183 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
184 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
185 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<select name="wfu_postmethod" id="wfu_postmethod" value="'.$plugin_options['postmethod'].'">';
|
186 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<option value="fopen"'.( $plugin_options['postmethod'] == 'fopen' || $plugin_options['postmethod'] == '' ? ' selected="selected"' : '' ).'>Using fopen (default)</option>';
|
187 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<option value="curl"'.( $plugin_options['postmethod'] == 'curl' ? ' selected="selected"' : '' ).'>Using cURL</option>';
|
188 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<option value="socket"'.( $plugin_options['postmethod'] == 'socket' ? ' selected="selected"' : '' ).'>Using Sockets</option>';
|
189 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'</select>';
|
190 |
+
$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['postmethod'] == 'fopen' || $plugin_options['postmethod'] == '' ? 'Using fopen' : ( $plugin_options['postmethod'] == 'curl' ? 'Using cURL' : 'Using Sockets' ) ).'</strong></p>';
|
191 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
192 |
+
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
193 |
+
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
194 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
195 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<label for="wfu_userstatehandler">User State Handler</label>';
|
196 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
197 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
198 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<select name="wfu_userstatehandler" id="wfu_userstatehandler" value="'.$plugin_options['userstatehandler'].'">';
|
199 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<option value="dboption"'.( $plugin_options['userstatehandler'] == 'dboption' ? ' selected="selected"' : '' ).'>Cookies/DB (default)</option>';
|
200 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<option value="session"'.( $plugin_options['userstatehandler'] == 'session' || $plugin_options['userstatehandler'] == '' ? ' selected="selected"' : '' ).'>Session</option>';
|
201 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'</select>';
|
202 |
+
$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['userstatehandler'] == 'session' || $plugin_options['userstatehandler'] == '' ? 'Session' : ( $plugin_options['userstatehandler'] == 'dboption' ? 'Cookies/DB' : 'Session' ) ).'</strong></p>';
|
203 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
204 |
+
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
205 |
+
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
206 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
207 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<label for="wfu_relaxcss">Relax CSS Rules</label>';
|
208 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
209 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
210 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<input name="wfu_relaxcss" id="wfu_relaxcss" type="checkbox"'.($plugin_options['relaxcss'] == '1' ? ' checked="checked"' : '' ).' style="width:auto;" /> If enabled then the textboxes and the buttons of the plugin will inherit the theme\'s styling';
|
211 |
+
$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['relaxcss'] == '1' ? 'Yes' : 'No' ).'</strong></p>';
|
212 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
213 |
+
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
214 |
+
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
215 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
216 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<label for="wfu_admindomain">Admin Domain</label>';
|
217 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
218 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
219 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<select name="wfu_admindomain" id="wfu_admindomain" value="'.$plugin_options['admindomain'].'">';
|
220 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<option value="siteurl"'.( $plugin_options['admindomain'] == 'siteurl' || $plugin_options['admindomain'] == '' ? ' selected="selected"' : '' ).'>Using site_url (default)</option>';
|
221 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<option value="adminurl"'.( $plugin_options['admindomain'] == 'adminurl' ? ' selected="selected"' : '' ).'>Using admin_url</option>';
|
222 |
+
$echo_str .= "\n\t\t\t\t\t\t\t\t".'<option value="homeurl"'.( $plugin_options['admindomain'] == 'homeurl' ? ' selected="selected"' : '' ).'>Using home_url</option>';
|
223 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'</select>';
|
224 |
+
$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['admindomain'] == 'siteurl' || $plugin_options['admindomain'] == '' ? 'Using site_url' : ( $plugin_options['admindomain'] == 'adminurl' ? 'Using admin_url' : 'Using home_url' ) ).'</strong></p>';
|
225 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
226 |
+
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
227 |
+
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
228 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
229 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<label for="wfu_mediacustom">Show Custom Fields in Media Library</label>';
|
230 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
231 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
232 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<input name="wfu_mediacustom" id="wfu_mediacustom" type="checkbox"'.($plugin_options['mediacustom'] == '1' ? ' checked="checked"' : '' ).' style="width:auto;" /> If enabled and the uploaded files are added to Media Library then any user fields submitted together with the files will be shown in Media Library';
|
233 |
+
$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['mediacustom'] == '1' ? 'Yes' : 'No' ).'</strong></p>';
|
234 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
235 |
+
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
236 |
+
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
237 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
238 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<label for="wfu_includeotherfiles">Include Other Files in Plugin\'s Database</label>';
|
239 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
240 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
241 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<input name="wfu_includeotherfiles" id="wfu_includeotherfiles" type="checkbox"'.($plugin_options['includeotherfiles'] == '1' ? ' checked="checked"' : '' ).' style="width:auto;" /> If enabled administrators can include in the plugin\'s database additional files through the File Browser';
|
242 |
+
$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['includeotherfiles'] == '1' ? 'Yes' : 'No' ).'</strong></p>';
|
243 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
244 |
+
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
245 |
+
$echo_str .= "\n\t\t\t\t\t".'<tr>';
|
246 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<th scope="row">';
|
247 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<label for="wfu_altserver">Use Alternative Iptanus Server</label>';
|
248 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</th>';
|
249 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<td>';
|
250 |
+
$echo_str .= "\n\t\t\t\t\t\t\t".'<input name="wfu_altserver" id="wfu_altserver" type="checkbox"'.($plugin_options['altserver'] == '1' ? ' checked="checked"' : '' ).' style="width:auto;" /> Switches to the alternative Iptanus server, residing on Google Cloud, for getting information such as latest version number.';
|
251 |
+
$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['altserver'] == '1' ? 'Yes' : 'No' ).'</strong></p>';
|
252 |
+
$echo_str .= "\n\t\t\t\t\t\t".'</td>';
|
253 |
+
$echo_str .= "\n\t\t\t\t\t".'</tr>';
|
254 |
+
$echo_str .= "\n\t\t\t\t".'</tbody>';
|
255 |
+
$echo_str .= "\n\t\t\t".'</table>';
|
256 |
+
$echo_str .= "\n\t\t\t".'<p class="submit">';
|
257 |
+
$echo_str .= "\n\t\t\t\t".'<input type="submit" class="button-primary" name="submitform" value="Update" />';
|
258 |
+
$echo_str .= "\n\t\t\t".'</p>';
|
259 |
+
$echo_str .= "\n\t\t".'</form>';
|
260 |
+
$echo_str .= "\n\t".'</div>';
|
261 |
+
$echo_str .= "\n".'</div>';
|
262 |
+
|
263 |
+
echo $echo_str;
|
264 |
+
}
|
265 |
+
|
266 |
+
|
267 |
+
/**
|
268 |
+
* Update Settings.
|
269 |
+
*
|
270 |
+
* This function updates plugin's settings.
|
271 |
+
*
|
272 |
+
* @since 2.1.2
|
273 |
+
*
|
274 |
+
* @return bool Always true.
|
275 |
+
*/
|
276 |
+
function wfu_update_settings() {
|
277 |
+
if ( !current_user_can( 'manage_options' ) ) return;
|
278 |
+
if ( !check_admin_referer('wfu_edit_admin_settings') ) return;
|
279 |
+
$plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
|
280 |
+
$new_plugin_options = array();
|
281 |
+
|
282 |
+
// $enabled = ( isset($_POST['wfu_enabled']) ? ( $_POST['wfu_enabled'] == "on" ? 1 : 0 ) : 0 );
|
283 |
+
$hashfiles = ( isset($_POST['wfu_hashfiles']) ? ( $_POST['wfu_hashfiles'] == "on" ? 1 : 0 ) : 0 );
|
284 |
+
$personaldata = ( isset($_POST['wfu_personaldata']) ? ( $_POST['wfu_personaldata'] == "on" ? 1 : 0 ) : 0 );
|
285 |
+
$relaxcss = ( isset($_POST['wfu_relaxcss']) ? ( $_POST['wfu_relaxcss'] == "on" ? 1 : 0 ) : 0 );
|
286 |
+
$mediacustom = ( isset($_POST['wfu_mediacustom']) ? ( $_POST['wfu_mediacustom'] == "on" ? 1 : 0 ) : 0 );
|
287 |
+
$includeotherfiles = ( isset($_POST['wfu_includeotherfiles']) ? ( $_POST['wfu_includeotherfiles'] == "on" ? 1 : 0 ) : 0 );
|
288 |
+
$altserver = ( isset($_POST['wfu_altserver']) ? ( $_POST['wfu_altserver'] == "on" ? 1 : 0 ) : 0 );
|
289 |
+
if ( isset($_POST['wfu_basedir']) && isset($_POST['wfu_postmethod']) && isset($_POST['wfu_userstatehandler']) && isset($_POST['wfu_admindomain']) && isset($_POST['submitform']) ) {
|
290 |
+
if ( $_POST['submitform'] == "Update" ) {
|
291 |
+
$new_plugin_options['version'] = '1.0';
|
292 |
+
$new_plugin_options['shortcode'] = $plugin_options['shortcode'];
|
293 |
+
$new_plugin_options['hashfiles'] = $hashfiles;
|
294 |
+
$new_plugin_options['basedir'] = sanitize_text_field($_POST['wfu_basedir']);
|
295 |
+
$new_plugin_options['personaldata'] = $personaldata;
|
296 |
+
$new_plugin_options['postmethod'] = sanitize_text_field($_POST['wfu_postmethod']);
|
297 |
+
$new_plugin_options['userstatehandler'] = sanitize_text_field($_POST['wfu_userstatehandler']);
|
298 |
+
$new_plugin_options['relaxcss'] = $relaxcss;
|
299 |
+
$new_plugin_options['admindomain'] = sanitize_text_field($_POST['wfu_admindomain']);
|
300 |
+
$new_plugin_options['mediacustom'] = $mediacustom;
|
301 |
+
$new_plugin_options['includeotherfiles'] = $includeotherfiles;
|
302 |
+
$new_plugin_options['altserver'] = $altserver;
|
303 |
+
$encoded_options = wfu_encode_plugin_options($new_plugin_options);
|
304 |
+
update_option( "wordpress_file_upload_options", $encoded_options );
|
305 |
+
if ( $new_plugin_options['hashfiles'] == '1' && $plugin_options['hashfiles'] != '1' )
|
306 |
+
wfu_reassign_hashes();
|
307 |
+
}
|
308 |
+
}
|
309 |
+
|
310 |
+
return true;
|
311 |
+
}
|
312 |
+
|
313 |
+
/**
|
314 |
+
* Update a Plugin Setting.
|
315 |
+
*
|
316 |
+
* This function updates an individual plugin setting.
|
317 |
+
*
|
318 |
+
* @since 4.12.0
|
319 |
+
*
|
320 |
+
* @param string $option The plugin option to change.
|
321 |
+
* @param mixed $value The new value of the option.
|
322 |
+
*/
|
323 |
+
function wfu_update_setting($option, $value) {
|
324 |
+
$plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
|
325 |
+
$plugin_options[$option] = $value;
|
326 |
+
$encoded_options = wfu_encode_plugin_options($plugin_options);
|
327 |
+
update_option( "wordpress_file_upload_options", $encoded_options );
|
328 |
+
}
|
329 |
+
|
lib/wfu_admin_uploadedfiles.php
CHANGED
@@ -1,676 +1,676 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Uploaded Files Page in Dashboard Area of Plugin
|
5 |
-
*
|
6 |
-
* This file contains functions related to Uploaded Files page of plugin's
|
7 |
-
* Dashboard area.
|
8 |
-
*
|
9 |
-
* @link /lib/wfu_admin_uploadedfiles.php
|
10 |
-
*
|
11 |
-
* @package WordPress File Upload Plugin
|
12 |
-
* @subpackage Core Components
|
13 |
-
* @since 4.7.0
|
14 |
-
*/
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Process Dashboard Requests for Uploaded Files Page
|
18 |
-
*
|
19 |
-
* This function processes Dashboard requests and shows main Uploaded Files page
|
20 |
-
* of the plugin.
|
21 |
-
*
|
22 |
-
* @since 4.7.0
|
23 |
-
*/
|
24 |
-
function wfu_uploadedfiles_menu() {
|
25 |
-
$_GET = stripslashes_deep($_GET);
|
26 |
-
$tag = (!empty($_GET['tag']) ? $_GET['tag'] : '1');
|
27 |
-
$page = max((int)$tag, 1);
|
28 |
-
echo wfu_uploadedfiles_manager($page);
|
29 |
-
}
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Display the Uploaded Files Page.
|
33 |
-
*
|
34 |
-
* This function displays the Uploaded Files page of the plugin.
|
35 |
-
*
|
36 |
-
* @since 4.7.0
|
37 |
-
*
|
38 |
-
* @param integer $page Optional. The page to display in case contents are
|
39 |
-
* paginated.
|
40 |
-
* @param bool $only_table_rows Optional. Return only the HTML code of the table
|
41 |
-
* rows.
|
42 |
-
*
|
43 |
-
* @return string The HTML output of the plugin's Uploaded Files Dashboard page.
|
44 |
-
*/
|
45 |
-
function wfu_uploadedfiles_manager($page = 1, $only_table_rows = false) {
|
46 |
-
global $wpdb;
|
47 |
-
$table_name1 = $wpdb->prefix . "wfu_log";
|
48 |
-
$table_name3 = $wpdb->prefix . "wfu_dbxqueue";
|
49 |
-
$def_other_cols = array( 'upload_date', 'user', 'properties', 'remarks', 'actions' );
|
50 |
-
|
51 |
-
if ( !current_user_can( 'manage_options' ) ) return;
|
52 |
-
|
53 |
-
$siteurl = site_url();
|
54 |
-
$maxrows = (int)WFU_VAR("WFU_UPLOADEDFILES_TABLE_MAXROWS");
|
55 |
-
|
56 |
-
//get log data from database
|
57 |
-
//$files_total = $wpdb->get_var('SELECT COUNT(idlog) FROM '.$table_name1.' WHERE action = \'upload\'');
|
58 |
-
//$filerecs = $wpdb->get_results('SELECT * FROM '.$table_name1.' WHERE action = \'upload\' ORDER BY date_from DESC'.( $maxrows > 0 ? ' LIMIT '.$maxrows.' OFFSET '.(($page - 1) * $maxrows) : '' ));
|
59 |
-
$files_total = 0;
|
60 |
-
$filerecs = array();
|
61 |
-
$has_history = false;
|
62 |
-
extract(wfu_uploadedfiles_get_filerecs($page));
|
63 |
-
|
64 |
-
//get last record already read
|
65 |
-
$last_idlog = get_option( "wordpress_file_upload_last_idlog", array( "pre" => 0, "post" => 0, "time" => 0 ) );
|
66 |
-
|
67 |
-
//get visible columns and their order
|
68 |
-
$cols = array();
|
69 |
-
$cols_raw = explode(',', WFU_VAR("WFU_UPLOADEDFILES_COLUMNS"));
|
70 |
-
//normalize column list
|
71 |
-
foreach ( $cols_raw as $ind => $col ) $cols_raw[$ind] = strtolower(trim($col));
|
72 |
-
//check if '#' column is visible
|
73 |
-
$id_visible = in_array('#', $cols_raw);
|
74 |
-
//'file' column is always visible and follows '#' column
|
75 |
-
//create an associative array $cols where keys are the columns and values
|
76 |
-
//are either true for visible columns or false for hidden ones
|
77 |
-
$visible_cols_count = 0;
|
78 |
-
foreach ( $cols_raw as $col )
|
79 |
-
if ( ($key = array_search($col, $def_other_cols)) !== false ) {
|
80 |
-
unset($def_other_cols[$key]);
|
81 |
-
$cols[$col] = true;
|
82 |
-
$visible_cols_count ++;
|
83 |
-
}
|
84 |
-
foreach ( $def_other_cols as $col ) $cols[$col] = false;
|
85 |
-
|
86 |
-
//prepare html
|
87 |
-
$echo_str = "";
|
88 |
-
if ( !$only_table_rows ) {
|
89 |
-
//Update last_idlog option so that next time Uploaded Files menu item is
|
90 |
-
//pressed files have been read.
|
91 |
-
//Option last_idlog requires a minimum interval of some seconds, defined
|
92 |
-
//by advanced variable WFU_UPLOADEDFILES_RESET_TIME, before it can be
|
93 |
-
//updated. This way, if the admin presses Uploaded Files menu item two
|
94 |
-
//times immediately, the same number of unread files will not change.
|
95 |
-
//It is noted that last_idlog option uses two values, 'pre' and 'post'.
|
96 |
-
//The way they are updated makes sure that the number of unread files
|
97 |
-
//gets reset only when Uploaded Files menu item is pressed and not
|
98 |
-
//when the admin browses through the pages of the list (when pagination
|
99 |
-
//is activated).
|
100 |
-
$limit = (int)WFU_VAR("WFU_UPLOADEDFILES_RESET_TIME");
|
101 |
-
if ( $limit == -1 || time() > $last_idlog["time"] + $limit ) {
|
102 |
-
$last_idlog["pre"] = $last_idlog["post"];
|
103 |
-
$last_idlog["post"] = $wpdb->get_var('SELECT MAX(idlog) FROM '.$table_name1);
|
104 |
-
$last_idlog["time"] = time();
|
105 |
-
update_option( "wordpress_file_upload_last_idlog", $last_idlog );
|
106 |
-
}
|
107 |
-
|
108 |
-
$echo_str .= "\n".'<div class="wrap">';
|
109 |
-
$echo_str .= "\n\t".'<h2>List of Uploaded Files</h2>';
|
110 |
-
$echo_str .= "\n\t".'<div style="position:relative;">';
|
111 |
-
$echo_str .= wfu_add_loading_overlay("\n\t\t", "uploadedfiles");
|
112 |
-
$echo_str .= "\n\t\t".'<div class="wfu_uploadedfiles_header" style="width: 100%;">';
|
113 |
-
if ( $maxrows > 0 ) {
|
114 |
-
$pages = ceil($files_total / $maxrows);
|
115 |
-
$echo_str .= wfu_add_pagination_header("\n\t\t\t", "uploadedfiles", $page, $pages);
|
116 |
-
}
|
117 |
-
$echo_str .= "\n\t\t\t".'<input id="wfu_download_file_nonce" type="hidden" value="'.wp_create_nonce('wfu_download_file_invoker').'" />';
|
118 |
-
$echo_str .= "\n\t\t".'</div>';
|
119 |
-
$echo_str .= "\n\t\t".'<table id="wfu_uploadedfiles_table" class="wfu-uploadedfiles wp-list-table widefat fixed striped">';
|
120 |
-
$echo_str .= "\n\t\t\t".'<thead>';
|
121 |
-
$echo_str .= "\n\t\t\t\t".'<tr>';
|
122 |
-
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="5%" class="manage-column'.( $id_visible ? '' : ' hidden' ).'">';
|
123 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<label>#</label>';
|
124 |
-
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
125 |
-
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="30%" class="manage-column column-primary">';
|
126 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<label>File</label>';
|
127 |
-
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
128 |
-
foreach ( $cols as $col => $is_visible ) {
|
129 |
-
if ( $col == 'upload_date' ) {
|
130 |
-
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="10%" class="manage-column'.( $is_visible ? '' : ' hidden' ).'">';
|
131 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<label>Upload Date</label>';
|
132 |
-
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
133 |
-
}
|
134 |
-
elseif ( $col == 'user' ) {
|
135 |
-
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="10%" class="manage-column'.( $is_visible ? '' : ' hidden' ).'">';
|
136 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<label>User</label>';
|
137 |
-
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
138 |
-
}
|
139 |
-
elseif ( $col == 'properties' ) {
|
140 |
-
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="10%" class="manage-column'.( $is_visible ? '' : ' hidden' ).'">';
|
141 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<label>Properties</label>';
|
142 |
-
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
143 |
-
}
|
144 |
-
elseif ( $col == 'remarks' ) {
|
145 |
-
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="25%" class="manage-column'.( $is_visible ? '' : ' hidden' ).'">';
|
146 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<label>Remarks</label>';
|
147 |
-
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
148 |
-
}
|
149 |
-
elseif ( $col == 'actions' ) {
|
150 |
-
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="10%" class="manage-column'.( $is_visible ? '' : ' hidden' ).'">';
|
151 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<label>Actions</label>';
|
152 |
-
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
153 |
-
}
|
154 |
-
}
|
155 |
-
$echo_str .= "\n\t\t\t\t".'</tr>';
|
156 |
-
$echo_str .= "\n\t\t\t".'</thead>';
|
157 |
-
$echo_str .= "\n\t\t\t".'<tbody>';
|
158 |
-
}
|
159 |
-
//echo the number of unread uploaded files in order to update the
|
160 |
-
//notification bubble of the toplevel menu item
|
161 |
-
$unread_files_count = wfu_get_new_files_count($last_idlog["pre"]);
|
162 |
-
$echo_str .= "\n\t\t\t".'<!-- wfu_uploadedfiles_unread['.$unread_files_count.'] -->';
|
163 |
-
|
164 |
-
$i = ($page - 1) * $maxrows;
|
165 |
-
$abspath_notrailing_slash = substr(wfu_abspath(), 0, -1);
|
166 |
-
$pagecode = wfu_safe_store_browser_params('wfu_uploaded_files&tag='.$page);
|
167 |
-
$nopagecode = wfu_safe_store_browser_params('no_referer');
|
168 |
-
foreach ( $filerecs as $filerec ) {
|
169 |
-
$i ++;
|
170 |
-
$initialrec = $filerec;
|
171 |
-
//get all newer associated file records
|
172 |
-
$historyrecs = array();
|
173 |
-
if ( $has_history ) $historyrecs = $filerec->history;
|
174 |
-
else $historyrecs = wfu_get_rec_new_history($initialrec->idlog);
|
175 |
-
//get the latest record of this upload
|
176 |
-
$filerec = $historyrecs[count($historyrecs) - 1];
|
177 |
-
$filedata = wfu_get_filedata_from_rec($filerec, false, true, false);
|
178 |
-
if ( $filedata == null ) $filedata = array();
|
179 |
-
|
180 |
-
$echo_str .= "\n\t\t\t\t".'<tr class="wfu_row-'.$i.( $initialrec->idlog > $last_idlog["pre"] ? ' wfu_unread' : '' ).'">';
|
181 |
-
$file_abspath = wfu_path_rel2abs($filerec->filepath);
|
182 |
-
$file_relpath = ( substr($filerec->filepath, 0, 4) == 'abs:' ? substr($filerec->filepath, 4) : $filerec->filepath );
|
183 |
-
$displayed_data = array(
|
184 |
-
"file" => $file_relpath,
|
185 |
-
"date" => get_date_from_gmt($initialrec->date_from),
|
186 |
-
"user" => wfu_get_username_by_id($filerec->uploaduserid),
|
187 |
-
"properties" => '',
|
188 |
-
"remarks" => '<div class="wfu-remarks-container"></div>',
|
189 |
-
"actions" => ''
|
190 |
-
);
|
191 |
-
$properties = wfu_init_uploadedfiles_properties();
|
192 |
-
$actions = wfu_init_uploadedfiles_actions();
|
193 |
-
$remarks = '';
|
194 |
-
//check if file is stored in FTP location
|
195 |
-
$file_in_ftp = ( substr($file_abspath, 0, 6) == 'ftp://' || substr($file_abspath, 0, 7) == 'ftps://' || substr($file_abspath, 0, 7) == 'sftp://' );
|
196 |
-
//check if file resides inside WP root
|
197 |
-
$file_in_root = ( !$file_in_ftp && substr($file_abspath, 0, strlen($abspath_notrailing_slash)) == $abspath_notrailing_slash );
|
198 |
-
//check if file exists for non-ftp uploads
|
199 |
-
$file_exists = (
|
200 |
-
//check if record is obsolete
|
201 |
-
$obsolete = ( $filerec->date_to != "0000-00-00 00:00:00" );
|
202 |
-
//check if file is associated with Media item
|
203 |
-
$has_media = ( $file_in_root && $file_exists && !$obsolete && isset($filedata["media"]) );
|
204 |
-
|
205 |
-
//update properties
|
206 |
-
$properties['status']['icon'] = ( $file_exists ? ( $obsolete ? "obsolete" : "ok" ) : "notexists" );
|
207 |
-
$properties['userdata']['visible'] = ( count(wfu_get_userdata_from_rec($filerec)) > 0 );
|
208 |
-
if ( $has_media ) {
|
209 |
-
$properties['media']['visible'] = true;
|
210 |
-
$properties['media']['remarks'] = 'File is associated with Media item ID <strong>'.$filedata["media"]["attach_id"].'</strong>';
|
211 |
-
}
|
212 |
-
$properties['ftp']['visible'] = $file_in_ftp;
|
213 |
-
/**
|
214 |
-
* Customize Uploaded File Properties.
|
215 |
-
*
|
216 |
-
* This filter allows scripts to customize the list of properties of an
|
217 |
-
* uploaded file.
|
218 |
-
*
|
219 |
-
* @since 4.8.0
|
220 |
-
*
|
221 |
-
* @param array $properties The list of properties of the file.
|
222 |
-
* @param object $filerec The database record of the uploaded file.
|
223 |
-
* @param integer $i The file's index in the list of uploaded files.
|
224 |
-
*/
|
225 |
-
$properties = apply_filters("_wfu_uploadefiles_file_properties", $properties, $filerec, $i);
|
226 |
-
|
227 |
-
//update actions
|
228 |
-
$details_href_net = $siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_details&file=byID:'.$filerec->idlog;
|
229 |
-
if ( $actions['details']['allowed'] ) {
|
230 |
-
$actions['details']['visible'] = true;
|
231 |
-
$actions['details']['href'] = $details_href_net.'&invoker='.$nopagecode;
|
232 |
-
}
|
233 |
-
$media_href = null;
|
234 |
-
if ( $has_media && $actions['media']['allowed'] ) {
|
235 |
-
$actions['media']['visible'] = true;
|
236 |
-
$media_href = get_attachment_link( $filedata["media"]["attach_id"] );
|
237 |
-
$actions['media']['href'] = $media_href;
|
238 |
-
}
|
239 |
-
$adminbrowser_href = false;
|
240 |
-
if ( $file_in_root && $file_exists && !$obsolete && $actions['adminbrowser']['allowed'] ) {
|
241 |
-
$only_path = wfu_basedir($file_relpath);
|
242 |
-
$dir_code = wfu_prepare_to_batch_safe_store_filepath($only_path.'{{'.wfu_basename($file_relpath).'}}');
|
243 |
-
$adminbrowser_href = $siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$dir_code;
|
244 |
-
$actions['adminbrowser']['visible'] = true;
|
245 |
-
$actions['adminbrowser']['href'] = $adminbrowser_href;
|
246 |
-
}
|
247 |
-
$historylog_href = $siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=view_log&invoker='.$initialrec->idlog;
|
248 |
-
if ( $actions['historylog']['allowed'] ) {
|
249 |
-
$actions['historylog']['visible'] = true;
|
250 |
-
$actions['historylog']['href'] = $historylog_href;
|
251 |
-
}
|
252 |
-
$link_href = ( $file_in_root ? site_url().( substr($file_relpath, 0, 1) == '/' ? '' : '/' ) : '' ).$file_relpath;
|
253 |
-
if (
|
254 |
-
$actions['link']['visible'] = true;
|
255 |
-
$actions['link']['href'] = $link_href;
|
256 |
-
}
|
257 |
-
$download_href = false;
|
258 |
-
if (
|
259 |
-
$file_code = wfu_prepare_to_batch_safe_store_filepath(wfu_path_abs2rel($file_abspath));
|
260 |
-
$download_href = 'javascript:wfu_download_file(\''.$file_code.'\', '.$i.');';
|
261 |
-
$actions['download']['visible'] = true;
|
262 |
-
$actions['download']['href'] = $download_href;
|
263 |
-
$actions['download']['newtab'] = false;
|
264 |
-
}
|
265 |
-
/**
|
266 |
-
* Customize Uploaded File Actions.
|
267 |
-
*
|
268 |
-
* This filter allows scripts to customize the list of actions of an
|
269 |
-
* uploaded file.
|
270 |
-
*
|
271 |
-
* @since 4.8.0
|
272 |
-
*
|
273 |
-
* @param array $actions The list of actions of the file.
|
274 |
-
* @param object $filerec The database record of the uploaded file.
|
275 |
-
* @param integer $i The file's index in the list of uploaded files.
|
276 |
-
*/
|
277 |
-
$actions = apply_filters("_wfu_uploadefiles_file_actions", $actions, $filerec, $i);
|
278 |
-
|
279 |
-
//update default file link action
|
280 |
-
$default_link = $displayed_data["file"];
|
281 |
-
if ( WFU_VAR("WFU_UPLOADEDFILES_DEFACTION") == "details" )
|
282 |
-
$default_link = '<a href="'.$details_href_net.'&invoker='.$pagecode.'" title="Go to file details">'.$file_relpath.'</a>';
|
283 |
-
elseif ( $file_in_root && $file_exists && !$obsolete && WFU_VAR("WFU_UPLOADEDFILES_DEFACTION") == "adminbrowser" ) {
|
284 |
-
if ( $adminbrowser_href === false ) {
|
285 |
-
$only_path = wfu_basedir($file_relpath);
|
286 |
-
$dir_code = wfu_prepare_to_batch_safe_store_filepath($only_path.'{{'.wfu_basename($file_relpath).'}}');
|
287 |
-
$adminbrowser_href = $siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$dir_code;
|
288 |
-
}
|
289 |
-
$default_link = '<a href="'.$adminbrowser_href.'" title="Open file in File Browser">'.$file_relpath.'</a>';
|
290 |
-
}
|
291 |
-
elseif ( WFU_VAR("WFU_UPLOADEDFILES_DEFACTION") == "historylog" )
|
292 |
-
$default_link = '<a href="'.$historylog_href.'" title="Go to View Log record of file">'.$file_relpath.'</a>';
|
293 |
-
elseif ( ( $file_in_ftp || $file_in_root ) && $file_exists && !$obsolete && WFU_VAR("WFU_UPLOADEDFILES_DEFACTION") == "link" )
|
294 |
-
$default_link = '<a href="'.$link_href.'" title="Open file link">'.$file_relpath.'</a>';
|
295 |
-
elseif ( !$file_in_ftp && $file_exists && !$obsolete && WFU_VAR("WFU_UPLOADEDFILES_DEFACTION") == "download" ) {
|
296 |
-
if ( $download_href === false ) {
|
297 |
-
$file_code = wfu_prepare_to_batch_safe_store_filepath(wfu_path_abs2rel($file_abspath));
|
298 |
-
$download_href = 'javascript:wfu_download_file(\''.$file_code.'\', '.$i.');';
|
299 |
-
}
|
300 |
-
$default_link = '<a href="'.$download_href.'" title="Download file">'.$file_relpath.'</a>';
|
301 |
-
}
|
302 |
-
/**
|
303 |
-
* Customize Default File Link.
|
304 |
-
*
|
305 |
-
* This filter allows scripts to customize the default file link action
|
306 |
-
* of an uploaded file.
|
307 |
-
*
|
308 |
-
* @since 4.8.0
|
309 |
-
*
|
310 |
-
* @param string $default_link The default file link action.
|
311 |
-
* @param object $filerec The database record of the uploaded file.
|
312 |
-
* @param integer $i The file's index in the list of uploaded files.
|
313 |
-
*/
|
314 |
-
$default_link = apply_filters("_wfu_uploadefiles_file_link", $default_link, $filerec, $i);
|
315 |
-
|
316 |
-
$displayed_data["file"] = $default_link;
|
317 |
-
$displayed_data["properties"] = wfu_render_uploadedfiles_properties($properties, $i);
|
318 |
-
$displayed_data["actions"] = wfu_render_uploadedfiles_actions($actions);
|
319 |
-
$echo_str .= "\n\t\t\t\t\t".'<th style="word-wrap: break-word;"'.( $id_visible ? '' : ' class="hidden"' ).'>'.$i.'</th>';
|
320 |
-
$echo_str .= "\n\t\t\t\t\t".'<td class="column-primary" data-colname="File">'.$displayed_data["file"];
|
321 |
-
$echo_str .= "\n\t\t\t\t\t\t".'<div id="wfu_file_download_container_'.$i.'" style="display: none;"></div>';
|
322 |
-
if ( $visible_cols_count > 0 ) $echo_str .= "\n\t\t\t\t\t\t".'<button type="button" class="toggle-row"><span class="screen-reader-text">Show more details</span></button>';
|
323 |
-
$echo_str .= "\n\t\t\t\t\t".'</td>';
|
324 |
-
foreach ( $cols as $col => $is_visible )
|
325 |
-
if ( $col == 'upload_date' ) $echo_str .= "\n\t\t\t\t\t".'<td data-colname="Upload Date"'.( $is_visible ? '' : ' class="hidden"' ).'>'.$displayed_data["date"].'</td>';
|
326 |
-
elseif ( $col == 'user' ) $echo_str .= "\n\t\t\t\t\t".'<td data-colname="User"'.( $is_visible ? '' : ' class="hidden"' ).'>'.$displayed_data["user"].'</td>';
|
327 |
-
elseif ( $col == 'properties' ) $echo_str .= "\n\t\t\t\t\t".'<td data-colname="Properties"'.( $is_visible ? '' : ' class="hidden"' ).'>'.$displayed_data["properties"].'</td>';
|
328 |
-
elseif ( $col == 'remarks' ) $echo_str .= "\n\t\t\t\t\t".'<td data-colname="Remarks"'.( $is_visible ? '' : ' class="hidden"' ).'>'.$displayed_data["remarks"].'</td>';
|
329 |
-
elseif ( $col == 'actions' ) $echo_str .= "\n\t\t\t\t\t".'<td data-colname="Actions"'.( $is_visible ? '' : ' class="hidden"' ).'>'.$displayed_data["actions"].'</td>';
|
330 |
-
$echo_str .= "\n\t\t\t\t".'</tr>';
|
331 |
-
}
|
332 |
-
//store file paths to safe
|
333 |
-
wfu_batch_safe_store_filepaths();
|
334 |
-
if ( !$only_table_rows ) {
|
335 |
-
$echo_str .= "\n\t\t\t".'</tbody>';
|
336 |
-
$echo_str .= "\n\t\t".'</table>';
|
337 |
-
$echo_str .= "\n\t".'</div>';
|
338 |
-
$handler = 'function() { wfu_attach_uploadedfiles_events(); }';
|
339 |
-
$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>';
|
340 |
-
$echo_str .= "\n".'</div>';
|
341 |
-
}
|
342 |
-
|
343 |
-
/**
|
344 |
-
* Customize Uploaded Files Page Output.
|
345 |
-
*
|
346 |
-
* This filter allows scripts to customize the HTML code of Uploaded Files
|
347 |
-
* Dashboard page.
|
348 |
-
*
|
349 |
-
* @since 4.8.0
|
350 |
-
*
|
351 |
-
* @param string $echo_str The HTML code of Uploaded Files page.
|
352 |
-
* @param integer $page The current shown page of uploaded files list.
|
353 |
-
* @param bool $only_table_rows Return only HTML code of table rows.
|
354 |
-
*/
|
355 |
-
$echo_str = apply_filters("_wfu_uploadedfiles_output", $echo_str, $page, $only_table_rows);
|
356 |
-
return $echo_str;
|
357 |
-
}
|
358 |
-
|
359 |
-
/**
|
360 |
-
* Get List of Uploaded Files.
|
361 |
-
*
|
362 |
-
* This function returns the list of uploaded files to be displayed in Uploaded
|
363 |
-
* Files Dashboard page.
|
364 |
-
*
|
365 |
-
* @since 4.9.1
|
366 |
-
*
|
367 |
-
* @redeclarable
|
368 |
-
*
|
369 |
-
* @param integer $page The page number where the uploaded files belong.
|
370 |
-
*
|
371 |
-
* @return array An array holding the list of uploaded files.
|
372 |
-
*/
|
373 |
-
function wfu_uploadedfiles_get_filerecs($page) {
|
374 |
-
$a = func_get_args(); $a = WFU_FUNCTION_HOOK(__FUNCTION__, $a, $out); if (isset($out['vars'])) foreach($out['vars'] as $p => $v) $$p = $v; switch($a) { case 'R': return $out['output']; break; case 'D': die($out['output']); }
|
375 |
-
global $wpdb;
|
376 |
-
$table_name1 = $wpdb->prefix . "wfu_log";
|
377 |
-
$maxrows = (int)WFU_VAR("WFU_UPLOADEDFILES_TABLE_MAXROWS");
|
378 |
-
$ret = array(
|
379 |
-
"files_total" => 0,
|
380 |
-
"filerecs" => array(),
|
381 |
-
"has_history" => false
|
382 |
-
);
|
383 |
-
|
384 |
-
if ( WFU_VAR("WFU_UPLOADEDFILES_HIDEINVALID") != "true" ) {
|
385 |
-
$ret["files_total"] = $wpdb->get_var('SELECT COUNT(idlog) FROM '.$table_name1.' WHERE action = \'upload\'');
|
386 |
-
$ret["filerecs"] = $wpdb->get_results('SELECT * FROM '.$table_name1.' WHERE action = \'upload\' ORDER BY date_from DESC'.( $maxrows > 0 ? ' LIMIT '.$maxrows.' OFFSET '.(($page - 1) * $maxrows) : '' ));
|
387 |
-
}
|
388 |
-
else {
|
389 |
-
$filerecs = $wpdb->get_results('SELECT * FROM '.$table_name1.' WHERE action = \'upload\' ORDER BY date_from DESC');
|
390 |
-
foreach ( $filerecs as $ind => $filerec ) {
|
391 |
-
$initialrec = $filerec;
|
392 |
-
//get all newer associated file records
|
393 |
-
$historyrecs = wfu_get_rec_new_history($initialrec->idlog);
|
394 |
-
//get the latest record of this upload
|
395 |
-
$filerec = $historyrecs[count($historyrecs) - 1];
|
396 |
-
$file_abspath = wfu_path_rel2abs($filerec->filepath);
|
397 |
-
//check if file is stored in FTP location
|
398 |
-
$file_in_ftp = ( substr($file_abspath, 0, 6) == 'ftp://' || substr($file_abspath, 0, 7) == 'ftps://' || substr($file_abspath, 0, 7) == 'sftp://' );
|
399 |
-
//check if file exists for non-ftp uploads
|
400 |
-
$file_exists = ( $file_in_ftp ? true :
|
401 |
-
//check if record is obsolete
|
402 |
-
$obsolete = ( $filerec->date_to != "0000-00-00 00:00:00" );
|
403 |
-
if ( !$file_exists || $obsolete ) unset($filerecs[$ind]);
|
404 |
-
else $filerecs[$ind]->history = $historyrecs;
|
405 |
-
}
|
406 |
-
$ret["files_total"] = count($filerecs);
|
407 |
-
if ( $maxrows > 0 ) $filerecs = array_slice($filerecs, ($page - 1) * $maxrows, $maxrows);
|
408 |
-
$ret["filerecs"] = $filerecs;
|
409 |
-
$ret["has_history"] = true;
|
410 |
-
}
|
411 |
-
|
412 |
-
return $ret;
|
413 |
-
}
|
414 |
-
|
415 |
-
/**
|
416 |
-
* Generate Default List of Properties of an Uploaded File.
|
417 |
-
*
|
418 |
-
* This function generates the list of default properties of an uploaded file.
|
419 |
-
* Each property has an icon, a title (when the mouse hovers over the icon) and
|
420 |
-
* remarks (shown in Remarks column when the mouse hovers over the icon).
|
421 |
-
*
|
422 |
-
* @since 4.7.0
|
423 |
-
*
|
424 |
-
* @return array An array of properties of an uploaded file.
|
425 |
-
*/
|
426 |
-
function wfu_init_uploadedfiles_properties() {
|
427 |
-
$props["status"] = array(
|
428 |
-
"icon" => "obsolete",
|
429 |
-
"icon-list" => array(
|
430 |
-
"ok" => "dashicons-yes",
|
431 |
-
"notexists" => "dashicons-trash",
|
432 |
-
"obsolete" => "dashicons-warning"
|
433 |
-
),
|
434 |
-
"title" => "",
|
435 |
-
"title-list" => array(
|
436 |
-
"ok" => "File is Ok",
|
437 |
-
"notexists" => "File does not exist",
|
438 |
-
"obsolete" => "Record is invalid"
|
439 |
-
),
|
440 |
-
"visible" => true,
|
441 |
-
"remarks" => '',
|
442 |
-
"remarks-list" => array(
|
443 |
-
"ok" => "File uploaded successfully to the website",
|
444 |
-
"notexists" => "File does not exist anymore in the website",
|
445 |
-
"obsolete" => "Record is not valid anymore"
|
446 |
-
),
|
447 |
-
"code" => wfu_create_random_string(6)
|
448 |
-
);
|
449 |
-
$props["userdata"] = array(
|
450 |
-
"icon" => "dashicons-id-alt",
|
451 |
-
"title" => "File has user data",
|
452 |
-
"visible" => false,
|
453 |
-
"remarks" => 'File has user data, accessible in File Details',
|
454 |
-
"code" => wfu_create_random_string(6)
|
455 |
-
);
|
456 |
-
$props["media"] = array(
|
457 |
-
"icon" => "dashicons-admin-media",
|
458 |
-
"title" => "File is associated with Media item",
|
459 |
-
"visible" => false,
|
460 |
-
"remarks" => 'File is associated with Media item',
|
461 |
-
"code" => wfu_create_random_string(6)
|
462 |
-
);
|
463 |
-
$props["ftp"] = array(
|
464 |
-
"icon" => "wfu-dashicons-ftp",
|
465 |
-
"title" => "File saved in FTP",
|
466 |
-
"visible" => false,
|
467 |
-
"remarks" => 'File has been saved in FTP location',
|
468 |
-
"code" => wfu_create_random_string(6)
|
469 |
-
);
|
470 |
-
|
471 |
-
return $props;
|
472 |
-
}
|
473 |
-
|
474 |
-
/**
|
475 |
-
* Generate Default List of Actions of an Uploaded File.
|
476 |
-
*
|
477 |
-
* This function generates the list of default actions of an uploaded file. Each
|
478 |
-
* action has an icon, a title (when the mouse hovers over the icon) and a link
|
479 |
-
* URL (the action itself).
|
480 |
-
*
|
481 |
-
* @since 4.7.0
|
482 |
-
*
|
483 |
-
* @return array An array of properties of an uploaded file.
|
484 |
-
*/
|
485 |
-
function wfu_init_uploadedfiles_actions() {
|
486 |
-
$def_actions["details"] = array(
|
487 |
-
"icon" => "dashicons-info",
|
488 |
-
"title" => "View file details",
|
489 |
-
"allowed" => false,
|
490 |
-
"visible" => false,
|
491 |
-
"href" => "",
|
492 |
-
"newtab" => true,
|
493 |
-
"color" => "default"
|
494 |
-
);
|
495 |
-
$def_actions["media"] = array(
|
496 |
-
"icon" => "wfu-dashicons-media-external",
|
497 |
-
"title" => "Open associated Media item",
|
498 |
-
"allowed" => false,
|
499 |
-
"visible" => false,
|
500 |
-
"href" => "",
|
501 |
-
"newtab" => true,
|
502 |
-
"color" => "default"
|
503 |
-
);
|
504 |
-
$def_actions["adminbrowser"] = array(
|
505 |
-
"icon" => "dashicons-portfolio",
|
506 |
-
"title" => "Locate file in File Browser",
|
507 |
-
"allowed" => false,
|
508 |
-
"visible" => false,
|
509 |
-
"href" => "",
|
510 |
-
"newtab" => true,
|
511 |
-
"color" => "default"
|
512 |
-
);
|
513 |
-
$def_actions["historylog"] = array(
|
514 |
-
"icon" => "dashicons-backup",
|
515 |
-
"title" => "Locate file record in View Log",
|
516 |
-
"allowed" => false,
|
517 |
-
"visible" => false,
|
518 |
-
"href" => "",
|
519 |
-
"newtab" => true,
|
520 |
-
"color" => "default"
|
521 |
-
);
|
522 |
-
$def_actions["link"] = array(
|
523 |
-
"icon" => "dashicons-external",
|
524 |
-
"title" => "Open file link",
|
525 |
-
"allowed" => false,
|
526 |
-
"visible" => false,
|
527 |
-
"href" => "",
|
528 |
-
"newtab" => true,
|
529 |
-
"color" => "default"
|
530 |
-
);
|
531 |
-
$def_actions["download"] = array(
|
532 |
-
"icon" => "dashicons-download",
|
533 |
-
"title" => "Download file",
|
534 |
-
"allowed" => false,
|
535 |
-
"visible" => false,
|
536 |
-
"href" => "",
|
537 |
-
"newtab" => true,
|
538 |
-
"color" => "default"
|
539 |
-
);
|
540 |
-
|
541 |
-
//get visible actions and their order
|
542 |
-
$actions = array();
|
543 |
-
$actions_raw = explode(',', WFU_VAR("WFU_UPLOADEDFILES_ACTIONS"));
|
544 |
-
//normalize action list
|
545 |
-
foreach ( $actions_raw as $ind => $action ) $actions_raw[$ind] = strtolower(trim($action));
|
546 |
-
//generate associative array of actions adjusting order and 'allowed'
|
547 |
-
//property
|
548 |
-
foreach ( $actions_raw as $ind => $action )
|
549 |
-
if ( isset($def_actions[$action]) ) {
|
550 |
-
$actions[$action] = $def_actions[$action];
|
551 |
-
$actions[$action]['allowed'] = true;
|
552 |
-
unset($def_actions[$action]);
|
553 |
-
}
|
554 |
-
foreach ( $def_actions as $action => $props ) $actions[$action] = $props;
|
555 |
-
|
556 |
-
return $actions;
|
557 |
-
}
|
558 |
-
|
559 |
-
/**
|
560 |
-
* Display Properties of an Uploaded File.
|
561 |
-
*
|
562 |
-
* This function generates the HTML code of the properties of an uploaded file
|
563 |
-
* that will be shown in Properties column.
|
564 |
-
*
|
565 |
-
* @since 4.7.0
|
566 |
-
*
|
567 |
-
* @redeclarable
|
568 |
-
*
|
569 |
-
* @param array $props The properties of the uploaded file.
|
570 |
-
* @param integer $index The index of the uploaded file.
|
571 |
-
*
|
572 |
-
* @return string The HTML code of the properties of an uploaded file.
|
573 |
-
*/
|
574 |
-
function wfu_render_uploadedfiles_properties($props, $index) {
|
575 |
-
$a = func_get_args(); switch(WFU_FUNCTION_HOOK(__FUNCTION__, $a, $out)) { case 'X': break; case 'R': return $out; break; case 'D': die($out); break; }
|
576 |
-
$i = 0;
|
577 |
-
$echo_str = "";
|
578 |
-
foreach ( $props as $key => $prop ) {
|
579 |
-
$ii = $i + 1;
|
580 |
-
$iconclass = $prop['icon'];
|
581 |
-
if ( isset($prop['icon-list']) ) $iconclass = $prop['icon-list'][$prop['icon']];
|
582 |
-
$title = $prop['title'];
|
583 |
-
if ( isset($prop['title-list']) ) $title = $prop['title-list'][$prop['icon']];
|
584 |
-
$remarks = $prop['remarks'];
|
585 |
-
if ( isset($prop['remarks-list']) ) $remarks = $prop['remarks-list'][$prop['icon']];
|
586 |
-
$echo_str .= '<div id="p_'.$index.'_'.$ii.'" class="wfu-properties dashicons '.$iconclass.( $i == 0 ? '' : ' wfu-dashicons-after' ).( $prop['visible'] ? '' : ' wfu-dashicons-hidden' ).'" title="'.$title.'"><input type="hidden" class="wfu-remarks" value="'.wfu_plugin_encode_string($remarks).'" /></div>';
|
587 |
-
$i ++;
|
588 |
-
}
|
589 |
-
|
590 |
-
return $echo_str;
|
591 |
-
}
|
592 |
-
|
593 |
-
/**
|
594 |
-
* Display Actions of an Uploaded File.
|
595 |
-
*
|
596 |
-
* This function generates the HTML code of the actions of an uploaded file that
|
597 |
-
* will be shown in Actions column.
|
598 |
-
*
|
599 |
-
* @since 4.7.0
|
600 |
-
*
|
601 |
-
* @redeclarable
|
602 |
-
*
|
603 |
-
* @param array $actions The actions of the uploaded file.
|
604 |
-
*
|
605 |
-
* @return string The HTML code of the actions of an uploaded file.
|
606 |
-
*/
|
607 |
-
function wfu_render_uploadedfiles_actions($actions) {
|
608 |
-
$a = func_get_args(); switch(WFU_FUNCTION_HOOK(__FUNCTION__, $a, $out)) { case 'X': break; case 'R': return $out; break; case 'D': die($out); break; }
|
609 |
-
$i = 0;
|
610 |
-
$echo_str = "";
|
611 |
-
foreach ( $actions as $key => $action ) {
|
612 |
-
$iconclass = $action['icon'];
|
613 |
-
if ( isset($action['icon-list']) ) $iconclass = $action['icon-list'][$action['icon']];
|
614 |
-
$title = $action['title'];
|
615 |
-
if ( isset($action['title-list']) ) $title = $action['title-list'][$action['icon']];
|
616 |
-
$echo_str .= '<a class="dashicons '.$iconclass.( $i == 0 ? '' : ' wfu-dashicons-after' ).( $action['visible'] ? '' : ' wfu-dashicons-hidden' ).'" href="'.$action['href'].'" target="'.( !isset($action['newtab']) || $action['newtab'] ? '_blank' : '_self' ).'" title="'.$title.'"'.( isset($action['color']) && $action['color'] != 'default' ? ' style="color:'.$action['color'].';"' : '' ).'></a>';
|
617 |
-
$i ++;
|
618 |
-
}
|
619 |
-
|
620 |
-
return $echo_str;
|
621 |
-
}
|
622 |
-
|
623 |
-
/**
|
624 |
-
* Display Unread Uploaded File in Admin Bar.
|
625 |
-
*
|
626 |
-
* This function displays the number of unread uploaded files in Admin Bar.
|
627 |
-
*
|
628 |
-
* @since 4.8.0
|
629 |
-
*/
|
630 |
-
function wfu_admin_toolbar_new_uploads() {
|
631 |
-
global $wp_admin_bar;
|
632 |
-
$is_admin = current_user_can( 'manage_options' );
|
633 |
-
|
634 |
-
if ( $is_admin && WFU_VAR("WFU_UPLOADEDFILES_BARMENU") == "true" ) {
|
635 |
-
//get the number of new (unread) uploaded files
|
636 |
-
$unread_files_count = wfu_get_unread_files_count();
|
637 |
-
$text = $unread_files_count;
|
638 |
-
if ( $unread_files_count > 99 ) $text = "99+";
|
639 |
-
$title = ( $unread_files_count == 0 ? 'No new files uploaded' : ( $unread_files_count == 1 ? '1 new file uploaded' : $unread_files_count.' files uploaded' ) );
|
640 |
-
|
641 |
-
$args = array(
|
642 |
-
'id' => 'wfu_uploads',
|
643 |
-
'title' => '<span class="ab-icon"></span><span class="ab-label">'.$unread_files_count.'</span><span class="screen-reader-text">'.$title.'</span>',
|
644 |
-
'href' => admin_url( 'admin.php?page=wfu_uploaded_files' ),
|
645 |
-
'group' => false,
|
646 |
-
'meta' => array(
|
647 |
-
'title' => $title,
|
648 |
-
'class' => ( $unread_files_count == 0 && WFU_VAR("WFU_UPLOADEDFILES_BARAUTOHIDE") == "true" ? 'hidden' : '' )
|
649 |
-
),
|
650 |
-
);
|
651 |
-
$wp_admin_bar->add_menu( $args );
|
652 |
-
}
|
653 |
-
}
|
654 |
-
|
655 |
-
/**
|
656 |
-
* Display Files Per Page in Uploaded Files Screen Options.
|
657 |
-
*
|
658 |
-
* This function displays the number of uploaded files per page to display in
|
659 |
-
* the screen options section of Uploaded Files Dashboard page.
|
660 |
-
*
|
661 |
-
* @since 4.8.0
|
662 |
-
*/
|
663 |
-
function wfu_uploadedfiles_screen_options() {
|
664 |
-
global $wfu_uploadedfiles_hook_suffix;
|
665 |
-
|
666 |
-
$screen = get_current_screen();
|
667 |
-
// get out of here if we are not on uploadedfiles page
|
668 |
-
if( !is_object($screen) || $screen->id != $wfu_uploadedfiles_hook_suffix ) return;
|
669 |
-
|
670 |
-
$args = array(
|
671 |
-
'label' => 'Files per page',
|
672 |
-
'default' => WFU_VAR("WFU_UPLOADEDFILES_TABLE_MAXROWS"),
|
673 |
-
'option' => 'wfu_uploadedfiles_per_page'
|
674 |
-
);
|
675 |
-
add_screen_option( 'per_page', $args );
|
676 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Uploaded Files Page in Dashboard Area of Plugin
|
5 |
+
*
|
6 |
+
* This file contains functions related to Uploaded Files page of plugin's
|
7 |
+
* Dashboard area.
|
8 |
+
*
|
9 |
+
* @link /lib/wfu_admin_uploadedfiles.php
|
10 |
+
*
|
11 |
+
* @package WordPress File Upload Plugin
|
12 |
+
* @subpackage Core Components
|
13 |
+
* @since 4.7.0
|
14 |
+
*/
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Process Dashboard Requests for Uploaded Files Page
|
18 |
+
*
|
19 |
+
* This function processes Dashboard requests and shows main Uploaded Files page
|
20 |
+
* of the plugin.
|
21 |
+
*
|
22 |
+
* @since 4.7.0
|
23 |
+
*/
|
24 |
+
function wfu_uploadedfiles_menu() {
|
25 |
+
$_GET = stripslashes_deep($_GET);
|
26 |
+
$tag = (!empty($_GET['tag']) ? $_GET['tag'] : '1');
|
27 |
+
$page = max((int)$tag, 1);
|
28 |
+
echo wfu_uploadedfiles_manager($page);
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Display the Uploaded Files Page.
|
33 |
+
*
|
34 |
+
* This function displays the Uploaded Files page of the plugin.
|
35 |
+
*
|
36 |
+
* @since 4.7.0
|
37 |
+
*
|
38 |
+
* @param integer $page Optional. The page to display in case contents are
|
39 |
+
* paginated.
|
40 |
+
* @param bool $only_table_rows Optional. Return only the HTML code of the table
|
41 |
+
* rows.
|
42 |
+
*
|
43 |
+
* @return string The HTML output of the plugin's Uploaded Files Dashboard page.
|
44 |
+
*/
|
45 |
+
function wfu_uploadedfiles_manager($page = 1, $only_table_rows = false) {
|
46 |
+
global $wpdb;
|
47 |
+
$table_name1 = $wpdb->prefix . "wfu_log";
|
48 |
+
$table_name3 = $wpdb->prefix . "wfu_dbxqueue";
|
49 |
+
$def_other_cols = array( 'upload_date', 'user', 'properties', 'remarks', 'actions' );
|
50 |
+
|
51 |
+
if ( !current_user_can( 'manage_options' ) ) return;
|
52 |
+
|
53 |
+
$siteurl = site_url();
|
54 |
+
$maxrows = (int)WFU_VAR("WFU_UPLOADEDFILES_TABLE_MAXROWS");
|
55 |
+
|
56 |
+
//get log data from database
|
57 |
+
//$files_total = $wpdb->get_var('SELECT COUNT(idlog) FROM '.$table_name1.' WHERE action = \'upload\'');
|
58 |
+
//$filerecs = $wpdb->get_results('SELECT * FROM '.$table_name1.' WHERE action = \'upload\' ORDER BY date_from DESC'.( $maxrows > 0 ? ' LIMIT '.$maxrows.' OFFSET '.(($page - 1) * $maxrows) : '' ));
|
59 |
+
$files_total = 0;
|
60 |
+
$filerecs = array();
|
61 |
+
$has_history = false;
|
62 |
+
extract(wfu_uploadedfiles_get_filerecs($page));
|
63 |
+
|
64 |
+
//get last record already read
|
65 |
+
$last_idlog = get_option( "wordpress_file_upload_last_idlog", array( "pre" => 0, "post" => 0, "time" => 0 ) );
|
66 |
+
|
67 |
+
//get visible columns and their order
|
68 |
+
$cols = array();
|
69 |
+
$cols_raw = explode(',', WFU_VAR("WFU_UPLOADEDFILES_COLUMNS"));
|
70 |
+
//normalize column list
|
71 |
+
foreach ( $cols_raw as $ind => $col ) $cols_raw[$ind] = strtolower(trim($col));
|
72 |
+
//check if '#' column is visible
|
73 |
+
$id_visible = in_array('#', $cols_raw);
|
74 |
+
//'file' column is always visible and follows '#' column
|
75 |
+
//create an associative array $cols where keys are the columns and values
|
76 |
+
//are either true for visible columns or false for hidden ones
|
77 |
+
$visible_cols_count = 0;
|
78 |
+
foreach ( $cols_raw as $col )
|
79 |
+
if ( ($key = array_search($col, $def_other_cols)) !== false ) {
|
80 |
+
unset($def_other_cols[$key]);
|
81 |
+
$cols[$col] = true;
|
82 |
+
$visible_cols_count ++;
|
83 |
+
}
|
84 |
+
foreach ( $def_other_cols as $col ) $cols[$col] = false;
|
85 |
+
|
86 |
+
//prepare html
|
87 |
+
$echo_str = "";
|
88 |
+
if ( !$only_table_rows ) {
|
89 |
+
//Update last_idlog option so that next time Uploaded Files menu item is
|
90 |
+
//pressed files have been read.
|
91 |
+
//Option last_idlog requires a minimum interval of some seconds, defined
|
92 |
+
//by advanced variable WFU_UPLOADEDFILES_RESET_TIME, before it can be
|
93 |
+
//updated. This way, if the admin presses Uploaded Files menu item two
|
94 |
+
//times immediately, the same number of unread files will not change.
|
95 |
+
//It is noted that last_idlog option uses two values, 'pre' and 'post'.
|
96 |
+
//The way they are updated makes sure that the number of unread files
|
97 |
+
//gets reset only when Uploaded Files menu item is pressed and not
|
98 |
+
//when the admin browses through the pages of the list (when pagination
|
99 |
+
//is activated).
|
100 |
+
$limit = (int)WFU_VAR("WFU_UPLOADEDFILES_RESET_TIME");
|
101 |
+
if ( $limit == -1 || time() > $last_idlog["time"] + $limit ) {
|
102 |
+
$last_idlog["pre"] = $last_idlog["post"];
|
103 |
+
$last_idlog["post"] = $wpdb->get_var('SELECT MAX(idlog) FROM '.$table_name1);
|
104 |
+
$last_idlog["time"] = time();
|
105 |
+
update_option( "wordpress_file_upload_last_idlog", $last_idlog );
|
106 |
+
}
|
107 |
+
|
108 |
+
$echo_str .= "\n".'<div class="wrap">';
|
109 |
+
$echo_str .= "\n\t".'<h2>List of Uploaded Files</h2>';
|
110 |
+
$echo_str .= "\n\t".'<div style="position:relative;">';
|
111 |
+
$echo_str .= wfu_add_loading_overlay("\n\t\t", "uploadedfiles");
|
112 |
+
$echo_str .= "\n\t\t".'<div class="wfu_uploadedfiles_header" style="width: 100%;">';
|
113 |
+
if ( $maxrows > 0 ) {
|
114 |
+
$pages = ceil($files_total / $maxrows);
|
115 |
+
$echo_str .= wfu_add_pagination_header("\n\t\t\t", "uploadedfiles", $page, $pages);
|
116 |
+
}
|
117 |
+
$echo_str .= "\n\t\t\t".'<input id="wfu_download_file_nonce" type="hidden" value="'.wp_create_nonce('wfu_download_file_invoker').'" />';
|
118 |
+
$echo_str .= "\n\t\t".'</div>';
|
119 |
+
$echo_str .= "\n\t\t".'<table id="wfu_uploadedfiles_table" class="wfu-uploadedfiles wp-list-table widefat fixed striped">';
|
120 |
+
$echo_str .= "\n\t\t\t".'<thead>';
|
121 |
+
$echo_str .= "\n\t\t\t\t".'<tr>';
|
122 |
+
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="5%" class="manage-column'.( $id_visible ? '' : ' hidden' ).'">';
|
123 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<label>#</label>';
|
124 |
+
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
125 |
+
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="30%" class="manage-column column-primary">';
|
126 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<label>File</label>';
|
127 |
+
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
128 |
+
foreach ( $cols as $col => $is_visible ) {
|
129 |
+
if ( $col == 'upload_date' ) {
|
130 |
+
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="10%" class="manage-column'.( $is_visible ? '' : ' hidden' ).'">';
|
131 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<label>Upload Date</label>';
|
132 |
+
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
133 |
+
}
|
134 |
+
elseif ( $col == 'user' ) {
|
135 |
+
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="10%" class="manage-column'.( $is_visible ? '' : ' hidden' ).'">';
|
136 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<label>User</label>';
|
137 |
+
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
138 |
+
}
|
139 |
+
elseif ( $col == 'properties' ) {
|
140 |
+
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="10%" class="manage-column'.( $is_visible ? '' : ' hidden' ).'">';
|
141 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<label>Properties</label>';
|
142 |
+
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
143 |
+
}
|
144 |
+
elseif ( $col == 'remarks' ) {
|
145 |
+
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="25%" class="manage-column'.( $is_visible ? '' : ' hidden' ).'">';
|
146 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<label>Remarks</label>';
|
147 |
+
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
148 |
+
}
|
149 |
+
elseif ( $col == 'actions' ) {
|
150 |
+
$echo_str .= "\n\t\t\t\t\t".'<th scope="col" width="10%" class="manage-column'.( $is_visible ? '' : ' hidden' ).'">';
|
151 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<label>Actions</label>';
|
152 |
+
$echo_str .= "\n\t\t\t\t\t".'</th>';
|
153 |
+
}
|
154 |
+
}
|
155 |
+
$echo_str .= "\n\t\t\t\t".'</tr>';
|
156 |
+
$echo_str .= "\n\t\t\t".'</thead>';
|
157 |
+
$echo_str .= "\n\t\t\t".'<tbody>';
|
158 |
+
}
|
159 |
+
//echo the number of unread uploaded files in order to update the
|
160 |
+
//notification bubble of the toplevel menu item
|
161 |
+
$unread_files_count = wfu_get_new_files_count($last_idlog["pre"]);
|
162 |
+
$echo_str .= "\n\t\t\t".'<!-- wfu_uploadedfiles_unread['.$unread_files_count.'] -->';
|
163 |
+
|
164 |
+
$i = ($page - 1) * $maxrows;
|
165 |
+
$abspath_notrailing_slash = substr(wfu_abspath(), 0, -1);
|
166 |
+
$pagecode = wfu_safe_store_browser_params('wfu_uploaded_files&tag='.$page);
|
167 |
+
$nopagecode = wfu_safe_store_browser_params('no_referer');
|
168 |
+
foreach ( $filerecs as $filerec ) {
|
169 |
+
$i ++;
|
170 |
+
$initialrec = $filerec;
|
171 |
+
//get all newer associated file records
|
172 |
+
$historyrecs = array();
|
173 |
+
if ( $has_history ) $historyrecs = $filerec->history;
|
174 |
+
else $historyrecs = wfu_get_rec_new_history($initialrec->idlog);
|
175 |
+
//get the latest record of this upload
|
176 |
+
$filerec = $historyrecs[count($historyrecs) - 1];
|
177 |
+
$filedata = wfu_get_filedata_from_rec($filerec, false, true, false);
|
178 |
+
if ( $filedata == null ) $filedata = array();
|
179 |
+
|
180 |
+
$echo_str .= "\n\t\t\t\t".'<tr class="wfu_row-'.$i.( $initialrec->idlog > $last_idlog["pre"] ? ' wfu_unread' : '' ).'">';
|
181 |
+
$file_abspath = wfu_path_rel2abs($filerec->filepath);
|
182 |
+
$file_relpath = ( substr($filerec->filepath, 0, 4) == 'abs:' ? substr($filerec->filepath, 4) : $filerec->filepath );
|
183 |
+
$displayed_data = array(
|
184 |
+
"file" => wfu_hide_credentials_from_ftpurl($file_relpath),
|
185 |
+
"date" => get_date_from_gmt($initialrec->date_from),
|
186 |
+
"user" => wfu_get_username_by_id($filerec->uploaduserid),
|
187 |
+
"properties" => '',
|
188 |
+
"remarks" => '<div class="wfu-remarks-container"></div>',
|
189 |
+
"actions" => ''
|
190 |
+
);
|
191 |
+
$properties = wfu_init_uploadedfiles_properties();
|
192 |
+
$actions = wfu_init_uploadedfiles_actions();
|
193 |
+
$remarks = '';
|
194 |
+
//check if file is stored in FTP location
|
195 |
+
$file_in_ftp = ( substr($file_abspath, 0, 6) == 'ftp://' || substr($file_abspath, 0, 7) == 'ftps://' || substr($file_abspath, 0, 7) == 'sftp://' );
|
196 |
+
//check if file resides inside WP root
|
197 |
+
$file_in_root = ( !$file_in_ftp && substr($file_abspath, 0, strlen($abspath_notrailing_slash)) == $abspath_notrailing_slash );
|
198 |
+
//check if file exists for non-ftp uploads
|
199 |
+
$file_exists = wfu_file_exists($file_abspath, "wfu_uploadedfiles_manager");
|
200 |
+
//check if record is obsolete
|
201 |
+
$obsolete = ( $filerec->date_to != "0000-00-00 00:00:00" );
|
202 |
+
//check if file is associated with Media item
|
203 |
+
$has_media = ( $file_in_root && $file_exists && !$obsolete && isset($filedata["media"]) );
|
204 |
+
|
205 |
+
//update properties
|
206 |
+
$properties['status']['icon'] = ( $file_exists ? ( $obsolete ? "obsolete" : "ok" ) : "notexists" );
|
207 |
+
$properties['userdata']['visible'] = ( count(wfu_get_userdata_from_rec($filerec)) > 0 );
|
208 |
+
if ( $has_media ) {
|
209 |
+
$properties['media']['visible'] = true;
|
210 |
+
$properties['media']['remarks'] = 'File is associated with Media item ID <strong>'.$filedata["media"]["attach_id"].'</strong>';
|
211 |
+
}
|
212 |
+
$properties['ftp']['visible'] = $file_in_ftp;
|
213 |
+
/**
|
214 |
+
* Customize Uploaded File Properties.
|
215 |
+
*
|
216 |
+
* This filter allows scripts to customize the list of properties of an
|
217 |
+
* uploaded file.
|
218 |
+
*
|
219 |
+
* @since 4.8.0
|
220 |
+
*
|
221 |
+
* @param array $properties The list of properties of the file.
|
222 |
+
* @param object $filerec The database record of the uploaded file.
|
223 |
+
* @param integer $i The file's index in the list of uploaded files.
|
224 |
+
*/
|
225 |
+
$properties = apply_filters("_wfu_uploadefiles_file_properties", $properties, $filerec, $i);
|
226 |
+
|
227 |
+
//update actions
|
228 |
+
$details_href_net = $siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_details&file=byID:'.$filerec->idlog;
|
229 |
+
if ( $actions['details']['allowed'] ) {
|
230 |
+
$actions['details']['visible'] = true;
|
231 |
+
$actions['details']['href'] = $details_href_net.'&invoker='.$nopagecode;
|
232 |
+
}
|
233 |
+
$media_href = null;
|
234 |
+
if ( $has_media && $actions['media']['allowed'] ) {
|
235 |
+
$actions['media']['visible'] = true;
|
236 |
+
$media_href = get_attachment_link( $filedata["media"]["attach_id"] );
|
237 |
+
$actions['media']['href'] = $media_href;
|
238 |
+
}
|
239 |
+
$adminbrowser_href = false;
|
240 |
+
if ( $file_in_root && $file_exists && !$obsolete && $actions['adminbrowser']['allowed'] ) {
|
241 |
+
$only_path = wfu_basedir($file_relpath);
|
242 |
+
$dir_code = wfu_prepare_to_batch_safe_store_filepath($only_path.'{{'.wfu_basename($file_relpath).'}}');
|
243 |
+
$adminbrowser_href = $siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$dir_code;
|
244 |
+
$actions['adminbrowser']['visible'] = true;
|
245 |
+
$actions['adminbrowser']['href'] = $adminbrowser_href;
|
246 |
+
}
|
247 |
+
$historylog_href = $siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=view_log&invoker='.$initialrec->idlog;
|
248 |
+
if ( $actions['historylog']['allowed'] ) {
|
249 |
+
$actions['historylog']['visible'] = true;
|
250 |
+
$actions['historylog']['href'] = $historylog_href;
|
251 |
+
}
|
252 |
+
$link_href = ( $file_in_root ? site_url().( substr($file_relpath, 0, 1) == '/' ? '' : '/' ) : '' ).$file_relpath;
|
253 |
+
if ( $file_in_root && $file_exists && !$obsolete && $actions['link']['allowed'] ) {
|
254 |
+
$actions['link']['visible'] = true;
|
255 |
+
$actions['link']['href'] = $link_href;
|
256 |
+
}
|
257 |
+
$download_href = false;
|
258 |
+
if ( $file_exists && !$obsolete && $actions['download']['allowed'] ) {
|
259 |
+
$file_code = wfu_prepare_to_batch_safe_store_filepath(wfu_path_abs2rel($file_abspath));
|
260 |
+
$download_href = 'javascript:wfu_download_file(\''.$file_code.'\', '.$i.');';
|
261 |
+
$actions['download']['visible'] = true;
|
262 |
+
$actions['download']['href'] = $download_href;
|
263 |
+
$actions['download']['newtab'] = false;
|
264 |
+
}
|
265 |
+
/**
|
266 |
+
* Customize Uploaded File Actions.
|
267 |
+
*
|
268 |
+
* This filter allows scripts to customize the list of actions of an
|
269 |
+
* uploaded file.
|
270 |
+
*
|
271 |
+
* @since 4.8.0
|
272 |
+
*
|
273 |
+
* @param array $actions The list of actions of the file.
|
274 |
+
* @param object $filerec The database record of the uploaded file.
|
275 |
+
* @param integer $i The file's index in the list of uploaded files.
|
276 |
+
*/
|
277 |
+
$actions = apply_filters("_wfu_uploadefiles_file_actions", $actions, $filerec, $i);
|
278 |
+
|
279 |
+
//update default file link action
|
280 |
+
$default_link = $displayed_data["file"];
|
281 |
+
if ( WFU_VAR("WFU_UPLOADEDFILES_DEFACTION") == "details" )
|
282 |
+
$default_link = '<a href="'.$details_href_net.'&invoker='.$pagecode.'" title="Go to file details">'.$file_relpath.'</a>';
|
283 |
+
elseif ( $file_in_root && $file_exists && !$obsolete && WFU_VAR("WFU_UPLOADEDFILES_DEFACTION") == "adminbrowser" ) {
|
284 |
+
if ( $adminbrowser_href === false ) {
|
285 |
+
$only_path = wfu_basedir($file_relpath);
|
286 |
+
$dir_code = wfu_prepare_to_batch_safe_store_filepath($only_path.'{{'.wfu_basename($file_relpath).'}}');
|
287 |
+
$adminbrowser_href = $siteurl.'/wp-admin/options-general.php?page=wordpress_file_upload&action=file_browser&dir='.$dir_code;
|
288 |
+
}
|
289 |
+
$default_link = '<a href="'.$adminbrowser_href.'" title="Open file in File Browser">'.$file_relpath.'</a>';
|
290 |
+
}
|
291 |
+
elseif ( WFU_VAR("WFU_UPLOADEDFILES_DEFACTION") == "historylog" )
|
292 |
+
$default_link = '<a href="'.$historylog_href.'" title="Go to View Log record of file">'.$file_relpath.'</a>';
|
293 |
+
elseif ( ( $file_in_ftp || $file_in_root ) && $file_exists && !$obsolete && WFU_VAR("WFU_UPLOADEDFILES_DEFACTION") == "link" )
|
294 |
+
$default_link = '<a href="'.$link_href.'" title="Open file link">'.$file_relpath.'</a>';
|
295 |
+
elseif ( !$file_in_ftp && $file_exists && !$obsolete && WFU_VAR("WFU_UPLOADEDFILES_DEFACTION") == "download" ) {
|
296 |
+
if ( $download_href === false ) {
|
297 |
+
$file_code = wfu_prepare_to_batch_safe_store_filepath(wfu_path_abs2rel($file_abspath));
|
298 |
+
$download_href = 'javascript:wfu_download_file(\''.$file_code.'\', '.$i.');';
|
299 |
+
}
|
300 |
+
$default_link = '<a href="'.$download_href.'" title="Download file">'.$file_relpath.'</a>';
|
301 |
+
}
|
302 |
+
/**
|
303 |
+
* Customize Default File Link.
|
304 |
+
*
|
305 |
+
* This filter allows scripts to customize the default file link action
|
306 |
+
* of an uploaded file.
|
307 |
+
*
|
308 |
+
* @since 4.8.0
|
309 |
+
*
|
310 |
+
* @param string $default_link The default file link action.
|
311 |
+
* @param object $filerec The database record of the uploaded file.
|
312 |
+
* @param integer $i The file's index in the list of uploaded files.
|
313 |
+
*/
|
314 |
+
$default_link = apply_filters("_wfu_uploadefiles_file_link", $default_link, $filerec, $i);
|
315 |
+
|
316 |
+
$displayed_data["file"] = $default_link;
|
317 |
+
$displayed_data["properties"] = wfu_render_uploadedfiles_properties($properties, $i);
|
318 |
+
$displayed_data["actions"] = wfu_render_uploadedfiles_actions($actions);
|
319 |
+
$echo_str .= "\n\t\t\t\t\t".'<th style="word-wrap: break-word;"'.( $id_visible ? '' : ' class="hidden"' ).'>'.$i.'</th>';
|
320 |
+
$echo_str .= "\n\t\t\t\t\t".'<td class="column-primary" data-colname="File">'.$displayed_data["file"];
|
321 |
+
$echo_str .= "\n\t\t\t\t\t\t".'<div id="wfu_file_download_container_'.$i.'" style="display: none;"></div>';
|
322 |
+
if ( $visible_cols_count > 0 ) $echo_str .= "\n\t\t\t\t\t\t".'<button type="button" class="toggle-row"><span class="screen-reader-text">Show more details</span></button>';
|
323 |
+
$echo_str .= "\n\t\t\t\t\t".'</td>';
|
324 |
+
foreach ( $cols as $col => $is_visible )
|
325 |
+
if ( $col == 'upload_date' ) $echo_str .= "\n\t\t\t\t\t".'<td data-colname="Upload Date"'.( $is_visible ? '' : ' class="hidden"' ).'>'.$displayed_data["date"].'</td>';
|
326 |
+
elseif ( $col == 'user' ) $echo_str .= "\n\t\t\t\t\t".'<td data-colname="User"'.( $is_visible ? '' : ' class="hidden"' ).'>'.$displayed_data["user"].'</td>';
|
327 |
+
elseif ( $col == 'properties' ) $echo_str .= "\n\t\t\t\t\t".'<td data-colname="Properties"'.( $is_visible ? '' : ' class="hidden"' ).'>'.$displayed_data["properties"].'</td>';
|
328 |
+
elseif ( $col == 'remarks' ) $echo_str .= "\n\t\t\t\t\t".'<td data-colname="Remarks"'.( $is_visible ? '' : ' class="hidden"' ).'>'.$displayed_data["remarks"].'</td>';
|
329 |
+
elseif ( $col == 'actions' ) $echo_str .= "\n\t\t\t\t\t".'<td data-colname="Actions"'.( $is_visible ? '' : ' class="hidden"' ).'>'.$displayed_data["actions"].'</td>';
|
330 |
+
$echo_str .= "\n\t\t\t\t".'</tr>';
|
331 |
+
}
|
332 |
+
//store file paths to safe
|
333 |
+
wfu_batch_safe_store_filepaths();
|
334 |
+
if ( !$only_table_rows ) {
|
335 |
+
$echo_str .= "\n\t\t\t".'</tbody>';
|
336 |
+
$echo_str .= "\n\t\t".'</table>';
|
337 |
+
$echo_str .= "\n\t".'</div>';
|
338 |
+
$handler = 'function() { wfu_attach_uploadedfiles_events(); }';
|
339 |
+
$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>';
|
340 |
+
$echo_str .= "\n".'</div>';
|
341 |
+
}
|
342 |
+
|
343 |
+
/**
|
344 |
+
* Customize Uploaded Files Page Output.
|
345 |
+
*
|
346 |
+
* This filter allows scripts to customize the HTML code of Uploaded Files
|
347 |
+
* Dashboard page.
|
348 |
+
*
|
349 |
+
* @since 4.8.0
|
350 |
+
*
|
351 |
+
* @param string $echo_str The HTML code of Uploaded Files page.
|
352 |
+
* @param integer $page The current shown page of uploaded files list.
|
353 |
+
* @param bool $only_table_rows Return only HTML code of table rows.
|
354 |
+
*/
|
355 |
+
$echo_str = apply_filters("_wfu_uploadedfiles_output", $echo_str, $page, $only_table_rows);
|
356 |
+
return $echo_str;
|
357 |
+
}
|
358 |
+
|
359 |
+
/**
|
360 |
+
* Get List of Uploaded Files.
|
361 |
+
*
|
362 |
+
* This function returns the list of uploaded files to be displayed in Uploaded
|
363 |
+
* Files Dashboard page.
|
364 |
+
*
|
365 |
+
* @since 4.9.1
|
366 |
+
*
|
367 |
+
* @redeclarable
|
368 |
+
*
|
369 |
+
* @param integer $page The page number where the uploaded files belong.
|
370 |
+
*
|
371 |
+
* @return array An array holding the list of uploaded files.
|
372 |
+
*/
|
373 |
+
function wfu_uploadedfiles_get_filerecs($page) {
|
374 |
+
$a = func_get_args(); $a = WFU_FUNCTION_HOOK(__FUNCTION__, $a, $out); if (isset($out['vars'])) foreach($out['vars'] as $p => $v) $$p = $v; switch($a) { case 'R': return $out['output']; break; case 'D': die($out['output']); }
|
375 |
+
global $wpdb;
|
376 |
+
$table_name1 = $wpdb->prefix . "wfu_log";
|
377 |
+
$maxrows = (int)WFU_VAR("WFU_UPLOADEDFILES_TABLE_MAXROWS");
|
378 |
+
$ret = array(
|
379 |
+
"files_total" => 0,
|
380 |
+
"filerecs" => array(),
|
381 |
+
"has_history" => false
|
382 |
+
);
|
383 |
+
|
384 |
+
if ( WFU_VAR("WFU_UPLOADEDFILES_HIDEINVALID") != "true" ) {
|
385 |
+
$ret["files_total"] = $wpdb->get_var('SELECT COUNT(idlog) FROM '.$table_name1.' WHERE action = \'upload\'');
|
386 |
+
$ret["filerecs"] = $wpdb->get_results('SELECT * FROM '.$table_name1.' WHERE action = \'upload\' ORDER BY date_from DESC'.( $maxrows > 0 ? ' LIMIT '.$maxrows.' OFFSET '.(($page - 1) * $maxrows) : '' ));
|
387 |
+
}
|
388 |
+
else {
|
389 |
+
$filerecs = $wpdb->get_results('SELECT * FROM '.$table_name1.' WHERE action = \'upload\' ORDER BY date_from DESC');
|
390 |
+
foreach ( $filerecs as $ind => $filerec ) {
|
391 |
+
$initialrec = $filerec;
|
392 |
+
//get all newer associated file records
|
393 |
+
$historyrecs = wfu_get_rec_new_history($initialrec->idlog);
|
394 |
+
//get the latest record of this upload
|
395 |
+
$filerec = $historyrecs[count($historyrecs) - 1];
|
396 |
+
$file_abspath = wfu_path_rel2abs($filerec->filepath);
|
397 |
+
//check if file is stored in FTP location
|
398 |
+
$file_in_ftp = ( substr($file_abspath, 0, 6) == 'ftp://' || substr($file_abspath, 0, 7) == 'ftps://' || substr($file_abspath, 0, 7) == 'sftp://' );
|
399 |
+
//check if file exists for non-ftp uploads
|
400 |
+
$file_exists = ( $file_in_ftp ? true : wfu_file_exists($file_abspath, "wfu_uploadedfiles_get_filerecs") );
|
401 |
+
//check if record is obsolete
|
402 |
+
$obsolete = ( $filerec->date_to != "0000-00-00 00:00:00" );
|
403 |
+
if ( !$file_exists || $obsolete ) unset($filerecs[$ind]);
|
404 |
+
else $filerecs[$ind]->history = $historyrecs;
|
405 |
+
}
|
406 |
+
$ret["files_total"] = count($filerecs);
|
407 |
+
if ( $maxrows > 0 ) $filerecs = array_slice($filerecs, ($page - 1) * $maxrows, $maxrows);
|
408 |
+
$ret["filerecs"] = $filerecs;
|
409 |
+
$ret["has_history"] = true;
|
410 |
+
}
|
411 |
+
|
412 |
+
return $ret;
|
413 |
+
}
|
414 |
+
|
415 |
+
/**
|
416 |
+
* Generate Default List of Properties of an Uploaded File.
|
417 |
+
*
|
418 |
+
* This function generates the list of default properties of an uploaded file.
|
419 |
+
* Each property has an icon, a title (when the mouse hovers over the icon) and
|
420 |
+
* remarks (shown in Remarks column when the mouse hovers over the icon).
|
421 |
+
*
|
422 |
+
* @since 4.7.0
|
423 |
+
*
|
424 |
+
* @return array An array of properties of an uploaded file.
|
425 |
+
*/
|
426 |
+
function wfu_init_uploadedfiles_properties() {
|
427 |
+
$props["status"] = array(
|
428 |
+
"icon" => "obsolete",
|
429 |
+
"icon-list" => array(
|
430 |
+
"ok" => "dashicons-yes",
|
431 |
+
"notexists" => "dashicons-trash",
|
432 |
+
"obsolete" => "dashicons-warning"
|
433 |
+
),
|
434 |
+
"title" => "",
|
435 |
+
"title-list" => array(
|
436 |
+
"ok" => "File is Ok",
|
437 |
+
"notexists" => "File does not exist",
|
438 |
+
"obsolete" => "Record is invalid"
|
439 |
+
),
|
440 |
+
"visible" => true,
|
441 |
+
"remarks" => '',
|
442 |
+
"remarks-list" => array(
|
443 |
+
"ok" => "File uploaded successfully to the website",
|
444 |
+
"notexists" => "File does not exist anymore in the website",
|
445 |
+
"obsolete" => "Record is not valid anymore"
|
446 |
+
),
|
447 |
+
"code" => wfu_create_random_string(6)
|
448 |
+
);
|
449 |
+
$props["userdata"] = array(
|
450 |
+
"icon" => "dashicons-id-alt",
|
451 |
+
"title" => "File has user data",
|
452 |
+
"visible" => false,
|
453 |
+
"remarks" => 'File has user data, accessible in File Details',
|
454 |
+
"code" => wfu_create_random_string(6)
|
455 |
+
);
|
456 |
+
$props["media"] = array(
|
457 |
+
"icon" => "dashicons-admin-media",
|
458 |
+
"title" => "File is associated with Media item",
|
459 |
+
"visible" => false,
|
460 |
+
"remarks" => 'File is associated with Media item',
|
461 |
+
"code" => wfu_create_random_string(6)
|
462 |
+
);
|
463 |
+
$props["ftp"] = array(
|
464 |
+
"icon" => "wfu-dashicons-ftp",
|
465 |
+
"title" => "File saved in FTP",
|
466 |
+
"visible" => false,
|
467 |
+
"remarks" => 'File has been saved in FTP location',
|
468 |
+
"code" => wfu_create_random_string(6)
|
469 |
+
);
|
470 |
+
|
471 |
+
return $props;
|
472 |
+
}
|
473 |
+
|
474 |
+
/**
|
475 |
+
* Generate Default List of Actions of an Uploaded File.
|
476 |
+
*
|
477 |
+
* This function generates the list of default actions of an uploaded file. Each
|
478 |
+
* action has an icon, a title (when the mouse hovers over the icon) and a link
|
479 |
+
* URL (the action itself).
|
480 |
+
*
|
481 |
+
* @since 4.7.0
|
482 |
+
*
|
483 |
+
* @return array An array of properties of an uploaded file.
|
484 |
+
*/
|
485 |
+
function wfu_init_uploadedfiles_actions() {
|
486 |
+
$def_actions["details"] = array(
|
487 |
+
"icon" => "dashicons-info",
|
488 |
+
"title" => "View file details",
|
489 |
+
"allowed" => false,
|
490 |
+
"visible" => false,
|
491 |
+
"href" => "",
|
492 |
+
"newtab" => true,
|
493 |
+
"color" => "default"
|
494 |
+
);
|
495 |
+
$def_actions["media"] = array(
|
496 |
+
"icon" => "wfu-dashicons-media-external",
|
497 |
+
"title" => "Open associated Media item",
|
498 |
+
"allowed" => false,
|
499 |
+
"visible" => false,
|
500 |
+
"href" => "",
|
501 |
+
"newtab" => true,
|
502 |
+
"color" => "default"
|
503 |
+
);
|
504 |
+
$def_actions["adminbrowser"] = array(
|
505 |
+
"icon" => "dashicons-portfolio",
|
506 |
+
"title" => "Locate file in File Browser",
|
507 |
+
"allowed" => false,
|
508 |
+
"visible" => false,
|
509 |
+
"href" => "",
|
510 |
+
"newtab" => true,
|
511 |
+
"color" => "default"
|
512 |
+
);
|
513 |
+
$def_actions["historylog"] = array(
|
514 |
+
"icon" => "dashicons-backup",
|
515 |
+
"title" => "Locate file record in View Log",
|
516 |
+
"allowed" => false,
|
517 |
+
"visible" => false,
|
518 |
+
"href" => "",
|
519 |
+
"newtab" => true,
|
520 |
+
"color" => "default"
|
521 |
+
);
|
522 |
+
$def_actions["link"] = array(
|
523 |
+
"icon" => "dashicons-external",
|
524 |
+
"title" => "Open file link",
|
525 |
+
"allowed" => false,
|
526 |
+
"visible" => false,
|
527 |
+
"href" => "",
|
528 |
+
"newtab" => true,
|
529 |
+
"color" => "default"
|
530 |
+
);
|
531 |
+
$def_actions["download"] = array(
|
532 |
+
"icon" => "dashicons-download",
|
533 |
+
"title" => "Download file",
|
534 |
+
"allowed" => false,
|
535 |
+
"visible" => false,
|
536 |
+
"href" => "",
|
537 |
+
"newtab" => true,
|
538 |
+
"color" => "default"
|
539 |
+
);
|
540 |
+
|
541 |
+
//get visible actions and their order
|
542 |
+
$actions = array();
|
543 |
+
$actions_raw = explode(',', WFU_VAR("WFU_UPLOADEDFILES_ACTIONS"));
|
544 |
+
//normalize action list
|
545 |
+
foreach ( $actions_raw as $ind => $action ) $actions_raw[$ind] = strtolower(trim($action));
|
546 |
+
//generate associative array of actions adjusting order and 'allowed'
|
547 |
+
//property
|
548 |
+
foreach ( $actions_raw as $ind => $action )
|
549 |
+
if ( isset($def_actions[$action]) ) {
|
550 |
+
$actions[$action] = $def_actions[$action];
|
551 |
+
$actions[$action]['allowed'] = true;
|
552 |
+
unset($def_actions[$action]);
|
553 |
+
}
|
554 |
+
foreach ( $def_actions as $action => $props ) $actions[$action] = $props;
|
555 |
+
|
556 |
+
return $actions;
|
557 |
+
}
|
558 |
+
|
559 |
+
/**
|
560 |
+
* Display Properties of an Uploaded File.
|
561 |
+
*
|
562 |
+
* This function generates the HTML code of the properties of an uploaded file
|
563 |
+
* that will be shown in Properties column.
|
564 |
+
*
|
565 |
+
* @since 4.7.0
|
566 |
+
*
|
567 |
+
* @redeclarable
|
568 |
+
*
|
569 |
+
* @param array $props The properties of the uploaded file.
|
570 |
+
* @param integer $index The index of the uploaded file.
|
571 |
+
*
|
572 |
+
* @return string The HTML code of the properties of an uploaded file.
|
573 |
+
*/
|
574 |
+
function wfu_render_uploadedfiles_properties($props, $index) {
|
575 |
+
$a = func_get_args(); switch(WFU_FUNCTION_HOOK(__FUNCTION__, $a, $out)) { case 'X': break; case 'R': return $out; break; case 'D': die($out); break; }
|
576 |
+
$i = 0;
|
577 |
+
$echo_str = "";
|
578 |
+
foreach ( $props as $key => $prop ) {
|
579 |
+
$ii = $i + 1;
|
580 |
+
$iconclass = $prop['icon'];
|
581 |
+
if ( isset($prop['icon-list']) ) $iconclass = $prop['icon-list'][$prop['icon']];
|
582 |
+
$title = $prop['title'];
|
583 |
+
if ( isset($prop['title-list']) ) $title = $prop['title-list'][$prop['icon']];
|
584 |
+
$remarks = $prop['remarks'];
|
585 |
+
if ( isset($prop['remarks-list']) ) $remarks = $prop['remarks-list'][$prop['icon']];
|
586 |
+
$echo_str .= '<div id="p_'.$index.'_'.$ii.'" class="wfu-properties dashicons '.$iconclass.( $i == 0 ? '' : ' wfu-dashicons-after' ).( $prop['visible'] ? '' : ' wfu-dashicons-hidden' ).'" title="'.$title.'"><input type="hidden" class="wfu-remarks" value="'.wfu_plugin_encode_string($remarks).'" /></div>';
|
587 |
+
$i ++;
|
588 |
+
}
|
589 |
+
|
590 |
+
return $echo_str;
|
591 |
+
}
|
592 |
+
|
593 |
+
/**
|
594 |
+
* Display Actions of an Uploaded File.
|
595 |
+
*
|
596 |
+
* This function generates the HTML code of the actions of an uploaded file that
|
597 |
+
* will be shown in Actions column.
|
598 |
+
*
|
599 |
+
* @since 4.7.0
|
600 |
+
*
|
601 |
+
* @redeclarable
|
602 |
+
*
|
603 |
+
* @param array $actions The actions of the uploaded file.
|
604 |
+
*
|
605 |
+
* @return string The HTML code of the actions of an uploaded file.
|
606 |
+
*/
|
607 |
+
function wfu_render_uploadedfiles_actions($actions) {
|
608 |
+
$a = func_get_args(); switch(WFU_FUNCTION_HOOK(__FUNCTION__, $a, $out)) { case 'X': break; case 'R': return $out; break; case 'D': die($out); break; }
|
609 |
+
$i = 0;
|
610 |
+
$echo_str = "";
|
611 |
+
foreach ( $actions as $key => $action ) {
|
612 |
+
$iconclass = $action['icon'];
|
613 |
+
if ( isset($action['icon-list']) ) $iconclass = $action['icon-list'][$action['icon']];
|
614 |
+
$title = $action['title'];
|
615 |
+
if ( isset($action['title-list']) ) $title = $action['title-list'][$action['icon']];
|
616 |
+
$echo_str .= '<a class="dashicons '.$iconclass.( $i == 0 ? '' : ' wfu-dashicons-after' ).( $action['visible'] ? '' : ' wfu-dashicons-hidden' ).'" href="'.$action['href'].'" target="'.( !isset($action['newtab']) || $action['newtab'] ? '_blank' : '_self' ).'" title="'.$title.'"'.( isset($action['color']) && $action['color'] != 'default' ? ' style="color:'.$action['color'].';"' : '' ).'></a>';
|
617 |
+
$i ++;
|
618 |
+
}
|
619 |
+
|
620 |
+
return $echo_str;
|
621 |
+
}
|
622 |
+
|
623 |
+
/**
|
624 |
+
* Display Unread Uploaded File in Admin Bar.
|
625 |
+
*
|
626 |
+
* This function displays the number of unread uploaded files in Admin Bar.
|
627 |
+
*
|
628 |
+
* @since 4.8.0
|
629 |
+
*/
|
630 |
+
function wfu_admin_toolbar_new_uploads() {
|
631 |
+
global $wp_admin_bar;
|
632 |
+
$is_admin = current_user_can( 'manage_options' );
|
633 |
+
|
634 |
+
if ( $is_admin && WFU_VAR("WFU_UPLOADEDFILES_BARMENU") == "true" ) {
|
635 |
+
//get the number of new (unread) uploaded files
|
636 |
+
$unread_files_count = wfu_get_unread_files_count();
|
637 |
+
$text = $unread_files_count;
|
638 |
+
if ( $unread_files_count > 99 ) $text = "99+";
|
639 |
+
$title = ( $unread_files_count == 0 ? 'No new files uploaded' : ( $unread_files_count == 1 ? '1 new file uploaded' : $unread_files_count.' files uploaded' ) );
|
640 |
+
|
641 |
+
$args = array(
|
642 |
+
'id' => 'wfu_uploads',
|
643 |
+
'title' => '<span class="ab-icon"></span><span class="ab-label">'.$unread_files_count.'</span><span class="screen-reader-text">'.$title.'</span>',
|
644 |
+
'href' => admin_url( 'admin.php?page=wfu_uploaded_files' ),
|
645 |
+
'group' => false,
|
646 |
+
'meta' => array(
|
647 |
+
'title' => $title,
|
648 |
+
'class' => ( $unread_files_count == 0 && WFU_VAR("WFU_UPLOADEDFILES_BARAUTOHIDE") == "true" ? 'hidden' : '' )
|
649 |
+
),
|
650 |
+
);
|
651 |
+
$wp_admin_bar->add_menu( $args );
|
652 |
+
}
|
653 |
+
}
|
654 |
+
|
655 |
+
/**
|
656 |
+
* Display Files Per Page in Uploaded Files Screen Options.
|
657 |
+
*
|
658 |
+
* This function displays the number of uploaded files per page to display in
|
659 |
+
* the screen options section of Uploaded Files Dashboard page.
|
660 |
+
*
|
661 |
+
* @since 4.8.0
|
662 |
+
*/
|
663 |
+
function wfu_uploadedfiles_screen_options() {
|
664 |
+
global $wfu_uploadedfiles_hook_suffix;
|
665 |
+
|
666 |
+
$screen = get_current_screen();
|
667 |
+
// get out of here if we are not on uploadedfiles page
|
668 |
+
if( !is_object($screen) || $screen->id != $wfu_uploadedfiles_hook_suffix ) return;
|
669 |
+
|
670 |
+
$args = array(
|
671 |
+
'label' => 'Files per page',
|
672 |
+
'default' => WFU_VAR("WFU_UPLOADEDFILES_TABLE_MAXROWS"),
|
673 |
+
'option' => 'wfu_uploadedfiles_per_page'
|
674 |
+
);
|
675 |
+
add_screen_option( 'per_page', $args );
|
676 |
}
|
lib/wfu_ajaxactions.php
CHANGED
@@ -1,1344 +1,1344 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* AJAX Handlers of the Plugin
|
5 |
-
*
|
6 |
-
* This file contains AJAX handlers of the plugin.
|
7 |
-
*
|
8 |
-
* @link /lib/wfu_ajaxactions.php
|
9 |
-
*
|
10 |
-
* @package WordPress File Upload Plugin
|
11 |
-
* @subpackage Core Components
|
12 |
-
* @since 2.1.2
|
13 |
-
*/
|
14 |
-
|
15 |
-
/**
|
16 |
-
* Execute Email Notification Dispatching
|
17 |
-
*
|
18 |
-
* This function sends an email notification after files have been uploaded.
|
19 |
-
*
|
20 |
-
* @since 2.1.2
|
21 |
-
*/
|
22 |
-
function wfu_ajax_action_send_email_notification() {
|
23 |
-
$_POST = stripslashes_deep($_POST);
|
24 |
-
|
25 |
-
$user = wp_get_current_user();
|
26 |
-
if ( 0 == $user->ID ) $is_admin = false;
|
27 |
-
else $is_admin = current_user_can('manage_options');
|
28 |
-
|
29 |
-
$params_index = sanitize_text_field($_POST['params_index']);
|
30 |
-
$session_token = sanitize_text_field($_POST['session_token']);
|
31 |
-
|
32 |
-
$arr = wfu_get_params_fields_from_index($params_index, $session_token);
|
33 |
-
//check referer using server sessions to avoid CSRF attacks
|
34 |
-
$sid = $arr['shortcode_id'];
|
35 |
-
if ( WFU_USVAR("wfu_token_".$sid) != $session_token ) die();
|
36 |
-
if ( $user->user_login != $arr['user_login'] ) {
|
37 |
-
$arr = wfu_get_params_fields_from_index($params_index.'[|][|]'.$arr['page_id'].'[|][|]'.$sid.'[|][|]'.$arr['user_login'], $session_token);
|
38 |
-
if ( $user->user_login != $arr['user_login'] ) die();
|
39 |
-
}
|
40 |
-
|
41 |
-
$params_str = get_option('wfu_params_'.$arr['unique_id']);
|
42 |
-
$params = wfu_decode_array_from_string($params_str);
|
43 |
-
/**
|
44 |
-
* Customize Params Array.
|
45 |
-
*
|
46 |
-
* This is an internal filter which allows to modify params array before it
|
47 |
-
* is used by the function.
|
48 |
-
*
|
49 |
-
* @since 4.14.0
|
50 |
-
*
|
51 |
-
* @param array $params The params array
|
52 |
-
* @param array $arr {
|
53 |
-
* Basic information about the upload.
|
54 |
-
*
|
55 |
-
* @type string $unique_id Optional. The unique ID of the upload.
|
56 |
-
* @type string $page_id Optional. The post ID of the upload form.
|
57 |
-
* @type array $shortcode_id Optional. The ID of the upload form.
|
58 |
-
* @type array $user_login Optional. The username of the upload user.
|
59 |
-
* }
|
60 |
-
* @param string $caller A string identifying the caller of this filter.
|
61 |
-
*/
|
62 |
-
$params = apply_filters("_wfu_get_params", $params, $arr, 'wfu_ajax_action_send_email_notification');
|
63 |
-
|
64 |
-
//check whether email notifications are activated
|
65 |
-
if ( $params["notify"] != "true" ) die();
|
66 |
-
|
67 |
-
$uniqueid = ( isset($_POST['uniqueuploadid_'.$sid]) ? sanitize_text_field($_POST['uniqueuploadid_'.$sid]) : "" );
|
68 |
-
//uniqueid cannot be empty and cannot be "no-ajax"
|
69 |
-
if ( $uniqueid == "" || $uniqueid == "no-ajax" ) die();
|
70 |
-
|
71 |
-
//retrieve the list of uploaded files from session
|
72 |
-
$target_path_list = array();
|
73 |
-
$all_files_count = 0;
|
74 |
-
if ( WFU_USVAR_exists("filedata_".$uniqueid) && is_array(WFU_USVAR("filedata_".$uniqueid)) ) {
|
75 |
-
$all_files_count = count(WFU_USVAR("filedata_".$uniqueid));
|
76 |
-
foreach ( WFU_USVAR("filedata_".$uniqueid) as $file ) {
|
77 |
-
if ( $file["upload_result"] == "success" || $file["upload_result"] == "warning" )
|
78 |
-
array_push($target_path_list, $file["filepath"]);
|
79 |
-
}
|
80 |
-
}
|
81 |
-
$uploaded_files_count = count($target_path_list);
|
82 |
-
$nofileupload = ( $params["allownofile"] == "true" && $all_files_count == 0 );
|
83 |
-
$force_notifications = ( WFU_VAR("WFU_FORCE_NOTIFICATIONS") == "true" );
|
84 |
-
|
85 |
-
//in case no files have been uploaded and this is not a nofileupload
|
86 |
-
//situation and Force Email Notifications option is not active then abort
|
87 |
-
if ( $uploaded_files_count == 0 && !$nofileupload && !$force_notifications ) die();
|
88 |
-
|
89 |
-
/* initialize return array */
|
90 |
-
$params_output_array["version"] = "full";
|
91 |
-
$params_output_array["general"]['shortcode_id'] = $params["uploadid"];
|
92 |
-
$params_output_array["general"]['unique_id'] = $uniqueid;
|
93 |
-
$params_output_array["general"]['state'] = 0;
|
94 |
-
$params_output_array["general"]['files_count'] = 0;
|
95 |
-
$params_output_array["general"]['update_wpfilebase'] = "";
|
96 |
-
$params_output_array["general"]['redirect_link'] = "";
|
97 |
-
$params_output_array["general"]['upload_finish_time'] = "";
|
98 |
-
$params_output_array["general"]['message'] = "";
|
99 |
-
$params_output_array["general"]['message_type'] = "";
|
100 |
-
$params_output_array["general"]['admin_messages']['wpfilebase'] = "";
|
101 |
-
$params_output_array["general"]['admin_messages']['notify'] = "";
|
102 |
-
$params_output_array["general"]['admin_messages']['redirect'] = "";
|
103 |
-
$params_output_array["general"]['admin_messages']['other'] = "";
|
104 |
-
$params_output_array["general"]['errors']['wpfilebase'] = "";
|
105 |
-
$params_output_array["general"]['errors']['notify'] = "";
|
106 |
-
$params_output_array["general"]['errors']['redirect'] = "";
|
107 |
-
$params_output_array["general"]['color'] = "black";
|
108 |
-
$params_output_array["general"]['bgcolor'] = "#F5F5F5";
|
109 |
-
$params_output_array["general"]['borcolor'] = "#D3D3D3";
|
110 |
-
$params_output_array["general"]['notify_by_email'] = 0;
|
111 |
-
$params_output_array["general"]['fail_message'] = WFU_ERROR_UNKNOWN;
|
112 |
-
|
113 |
-
//retrieve userdata, first get default userdata from $params
|
114 |
-
$userdata_fields = $params["userdata_fields"];
|
115 |
-
//remove any honeypot fields and initialize default values
|
116 |
-
foreach ( $userdata_fields as $userdata_key => $userdata_field )
|
117 |
-
if ( $userdata_field["type"] == "honeypot" ) unset($userdata_fields[$userdata_key]);
|
118 |
-
else $userdata_fields[$userdata_key]["value"] = "";
|
119 |
-
//then retrieve userdata from session if files exist
|
120 |
-
if ( $all_files_count > 0 && WFU_USVAR_exists("filedata_".$uniqueid) && is_array(WFU_USVAR("filedata_".$uniqueid)) ) {
|
121 |
-
foreach ( WFU_USVAR("filedata_".$uniqueid) as $file ) {
|
122 |
-
if ( isset($file["user_data"]) ) {
|
123 |
-
$userdata_fields = array();
|
124 |
-
foreach ( $file["user_data"] as $userdata_key => $userdata_field )
|
125 |
-
$userdata_fields[$userdata_key] = array( "label" => $userdata_field["label"], "value" => $userdata_field["value"] );
|
126 |
-
break;
|
127 |
-
}
|
128 |
-
}
|
129 |
-
}
|
130 |
-
//in case there are no files in session (because allownofile attribute is
|
131 |
-
//active and the user did not select any files for upload) then retrieve
|
132 |
-
//userdata from the database based on uploadid
|
133 |
-
else {
|
134 |
-
$userdata_saved = wfu_get_userdata_from_uploadid($uniqueid);
|
135 |
-
if ( $userdata_saved != null && is_array($userdata_saved) ) {
|
136 |
-
$userdata_fields = array();
|
137 |
-
foreach ( $userdata_saved as $userdata_saved_rec )
|
138 |
-
$userdata_fields[$userdata_saved_rec->propkey] = array( "label" => $userdata_saved_rec->property, "value" => $userdata_saved_rec->propvalue );
|
139 |
-
}
|
140 |
-
}
|
141 |
-
|
142 |
-
$send_error = wfu_send_notification_email($user, $target_path_list, $userdata_fields, $params);
|
143 |
-
|
144 |
-
/* suppress any errors if user is not admin */
|
145 |
-
if ( !$is_admin ) $send_error = "";
|
146 |
-
|
147 |
-
if ( $send_error != "" ) {
|
148 |
-
$params_output_array["general"]['admin_messages']['notify'] = $send_error;
|
149 |
-
$params_output_array["general"]['errors']['notify'] = "error";
|
150 |
-
}
|
151 |
-
|
152 |
-
/* construct safe output */
|
153 |
-
$sout = "0;".WFU_VAR("WFU_DEFAULTMESSAGECOLORS").";0";
|
154 |
-
|
155 |
-
$echo_str = "wfu_fileupload_success::".$sout.":".wfu_encode_array_to_string($params_output_array);
|
156 |
-
/**
|
157 |
-
* Customise Email Notification Result.
|
158 |
-
*
|
159 |
-
* This filter allows scripts to customise the result of email notification
|
160 |
-
* operation.
|
161 |
-
*
|
162 |
-
* @since 4.0.0
|
163 |
-
*
|
164 |
-
* @param string $echo_str The result of email notification operation.
|
165 |
-
*/
|
166 |
-
$echo_str = apply_filters('_wfu_ajax_action_send_email_notification', $echo_str);
|
167 |
-
|
168 |
-
die($echo_str);
|
169 |
-
}
|
170 |
-
|
171 |
-
/**
|
172 |
-
* Execute Pre-Upload Actions
|
173 |
-
*
|
174 |
-
* This function executes server-side actions before the upload starts, in order
|
175 |
-
* to determine whether the upload will continue, or any other custom actions.
|
176 |
-
*
|
177 |
-
* @since 3.7.0
|
178 |
-
*/
|
179 |
-
function wfu_ajax_action_ask_server() {
|
180 |
-
if ( !isset($_REQUEST['session_token']) || !isset($_REQUEST['sid']) || !isset($_REQUEST['unique_id']) ) die();
|
181 |
-
|
182 |
-
$_REQUEST = stripslashes_deep($_REQUEST);
|
183 |
-
|
184 |
-
$session_token = sanitize_text_field( $_REQUEST["session_token"] );
|
185 |
-
$sid = sanitize_text_field( $_REQUEST["sid"] );
|
186 |
-
$unique_id = wfu_sanitize_code($_REQUEST['unique_id']);
|
187 |
-
if ( $session_token == "" ) die();
|
188 |
-
//check referrer using Wordpress nonces and server sessions to avoid CSRF attacks
|
189 |
-
check_ajax_referer( 'wfu-uploader-nonce', 'wfu_uploader_nonce' );
|
190 |
-
if ( WFU_USVAR("wfu_token_".$sid) != $session_token ) die();
|
191 |
-
|
192 |
-
//prepare parameters for before-upload filters
|
193 |
-
$ret = array( "status" => "", "echo" => "" );
|
194 |
-
//retrieve file names and sizes from request parameters
|
195 |
-
$filenames_raw = ( isset($_REQUEST['filenames']) ? $_REQUEST['filenames'] : "" );
|
196 |
-
$filenames = array();
|
197 |
-
if ( trim($filenames_raw) != "" ) $filenames = explode(";", $filenames_raw);
|
198 |
-
//use wfu_basename() function in order to avoid directory traversal attacks
|
199 |
-
foreach ( $filenames as $ind => $filename ) $filenames[$ind] = wfu_basename(esc_attr(wfu_plugin_decode_string(trim($filename))));
|
200 |
-
$filesizes_raw = ( isset($_REQUEST['filesizes']) ? $_REQUEST['filesizes'] : "" );
|
201 |
-
$filesizes = array();
|
202 |
-
if ( trim($filesizes_raw) != "" ) $filesizes = explode(";", $filesizes_raw);
|
203 |
-
foreach ( $filesizes as $ind => $filesize ) $filesizes[$ind] = wfu_sanitize_int($filesize);
|
204 |
-
$files = array();
|
205 |
-
foreach ( $filenames as $ind => $filename ) {
|
206 |
-
$filesize = "";
|
207 |
-
if ( isset($filesizes[$ind]) ) $filesize = $filesizes[$ind];
|
208 |
-
array_push($files, array( "filename" => $filename, "filesize" => $filesize ));
|
209 |
-
}
|
210 |
-
$attr = array( "sid" => $sid, "unique_id" => $unique_id, "files" => $files );
|
211 |
-
//execute before upload filters
|
212 |
-
$echo_str = "";
|
213 |
-
//first execute any custom filters created by admin
|
214 |
-
if ( has_filter("wfu_before_upload") ) {
|
215 |
-
$changable_data = array( "error_message" => "", "js_script" => "" );
|
216 |
-
/**
|
217 |
-
* Execute Custom Actions Before Upload Starts.
|
218 |
-
*
|
219 |
-
* This filter allows to execute custom actions before upload starts. It
|
220 |
-
* can cancel the upload returning an error message.
|
221 |
-
*
|
222 |
-
* @since 3.7.0
|
223 |
-
*
|
224 |
-
* @param array $changable_data {
|
225 |
-
* Controls the upload.
|
226 |
-
*
|
227 |
-
* @type string $error_message An error message to display if the
|
228 |
-
* upload must be cancelled.
|
229 |
-
* @type string $js_script Javascript code to execute on user's
|
230 |
-
* browser after this filter finishes.
|
231 |
-
* }
|
232 |
-
* @param array $attr {
|
233 |
-
* Various attributes of the upload.
|
234 |
-
*
|
235 |
-
* @type string $sid The ID of the shortcode.
|
236 |
-
* @type string $unique_id The unique ID of the upload.
|
237 |
-
* @type array $files {
|
238 |
-
* Contains an array of the uploaded files.
|
239 |
-
*
|
240 |
-
* @type array $file {
|
241 |
-
* Contains information for each uploaded file.
|
242 |
-
*
|
243 |
-
* @type string $filename The filename of the file.
|
244 |
-
* @type int $filesize The size of the file.
|
245 |
-
* }
|
246 |
-
* }
|
247 |
-
* }
|
248 |
-
*/
|
249 |
-
$changable_data = apply_filters("wfu_before_upload", $changable_data, $attr);
|
250 |
-
if ( $changable_data["error_message"] == "" ) $ret["status"] = "success";
|
251 |
-
else {
|
252 |
-
$ret["status"] = "error";
|
253 |
-
$echo_str .= "CBUV[".$changable_data["error_message"]."]";
|
254 |
-
}
|
255 |
-
if ( $changable_data["js_script"] != "" ) $echo_str .= "CBUVJS[".wfu_plugin_encode_string($changable_data["js_script"])."]";
|
256 |
-
}
|
257 |
-
/**
|
258 |
-
* Execute Custom Internal Actions Before Upload Starts.
|
259 |
-
*
|
260 |
-
* This filter allows to execute custom internal actions by extensions
|
261 |
-
* before upload starts. It can cancel the upload.
|
262 |
-
*
|
263 |
-
* @since 3.7.0
|
264 |
-
*
|
265 |
-
* @param array $ret {
|
266 |
-
* Controls the upload and output of this function.
|
267 |
-
*
|
268 |
-
* @type string $status The status of the upload. It must be 'success'
|
269 |
-
* or 'error'.
|
270 |
-
* @type string $echo Additional content to the echoed by the function.
|
271 |
-
* }
|
272 |
-
* @param array $attr {
|
273 |
-
* Various attributes of the upload.
|
274 |
-
*
|
275 |
-
* @type string $sid The ID of the shortcode.
|
276 |
-
* @type string $unique_id The unique ID of the upload.
|
277 |
-
* @type array $files {
|
278 |
-
* Contains an array of the uploaded files.
|
279 |
-
*
|
280 |
-
* @type array $file {
|
281 |
-
* Contains information for each uploaded file.
|
282 |
-
*
|
283 |
-
* @type string $filename The filename of the file.
|
284 |
-
* @type int $filesize The size of the file.
|
285 |
-
* }
|
286 |
-
* }
|
287 |
-
* }
|
288 |
-
*/
|
289 |
-
$ret = apply_filters("_wfu_before_upload", $ret, $attr);
|
290 |
-
$echo_str .= $ret["echo"];
|
291 |
-
//in case that no filters were executed, because $ret["status"] is
|
292 |
-
//empty, then this call to wfu_ajax_action_ask_server was erroneous
|
293 |
-
if ( $ret["status"] == "" ) $ret["status"] = "die";
|
294 |
-
//create an internal flag stored in session regarding the status of this
|
295 |
-
//upload, that will be used to verify or not the upload
|
296 |
-
if ( $ret["status"] == "success" ) WFU_USVAR_store("wfu_uploadstatus_".$attr["unique_id"], 1);
|
297 |
-
else WFU_USVAR_store("wfu_uploadstatus_".$attr["unique_id"], 0);
|
298 |
-
|
299 |
-
if ( $ret["status"] == "success" || $ret["status"] == "error" )
|
300 |
-
echo "wfu_askserver_".$ret["status"].":".$echo_str;
|
301 |
-
|
302 |
-
die();
|
303 |
-
}
|
304 |
-
|
305 |
-
/**
|
306 |
-
* Execute Cancellation of Classic Upload
|
307 |
-
*
|
308 |
-
* This function sets the necessary User State variables to denote cancellation
|
309 |
-
* of the upload that was requested by the user. This function applies only to
|
310 |
-
* classic (non-AJAX) uploads.
|
311 |
-
*
|
312 |
-
* @since 4.0.0
|
313 |
-
*/
|
314 |
-
function wfu_ajax_action_cancel_upload() {
|
315 |
-
if ( !isset($_REQUEST['session_token']) || !isset($_REQUEST['sid']) || !isset($_REQUEST['unique_id']) ) die();
|
316 |
-
|
317 |
-
$_REQUEST = stripslashes_deep($_REQUEST);
|
318 |
-
|
319 |
-
$session_token = sanitize_text_field( $_REQUEST["session_token"] );
|
320 |
-
$sid = sanitize_text_field( $_REQUEST["sid"] );
|
321 |
-
$unique_id = wfu_sanitize_code($_REQUEST['unique_id']);
|
322 |
-
if ( $session_token == "" ) die();
|
323 |
-
//check referrer using Wordpress nonces and server sessions to avoid CSRF attacks
|
324 |
-
check_ajax_referer( 'wfu-uploader-nonce', 'wfu_uploader_nonce' );
|
325 |
-
if ( WFU_USVAR("wfu_token_".$sid) != $session_token ) die();
|
326 |
-
|
327 |
-
//setting status to 0 denotes cancelling of the upload
|
328 |
-
WFU_USVAR_store("wfu_uploadstatus_".$unique_id, 0);
|
329 |
-
|
330 |
-
die("success");
|
331 |
-
}
|
332 |
-
|
333 |
-
/**
|
334 |
-
* Execute AJAX Upload
|
335 |
-
*
|
336 |
-
* This function is the main callback of an AJAX upload of a whole file or a
|
337 |
-
* chunk. It performs security checks to verify the user, then it performs pre-
|
338 |
-
* upload actions, then it executes wfu_process_files() function that processes
|
339 |
-
* and saves the files and then performs post-upload actions and filters.
|
340 |
-
*
|
341 |
-
* @since 2.1.2
|
342 |
-
*
|
343 |
-
* @global string $wfu_user_state_handler The defined User State handler.
|
344 |
-
*/
|
345 |
-
function wfu_ajax_action_callback() {
|
346 |
-
global $wfu_user_state_handler;
|
347 |
-
if ( !isset($_REQUEST['session_token']) ) die();
|
348 |
-
|
349 |
-
$_REQUEST = stripslashes_deep($_REQUEST);
|
350 |
-
$_POST = stripslashes_deep($_POST);
|
351 |
-
|
352 |
-
$session_token = sanitize_text_field( $_REQUEST["session_token"] );
|
353 |
-
if ( $session_token == "" ) die();
|
354 |
-
check_ajax_referer( 'wfu-uploader-nonce', 'wfu_uploader_nonce' );
|
355 |
-
|
356 |
-
if ( !isset($_REQUEST['params_index']) ) die();
|
357 |
-
|
358 |
-
$params_index = sanitize_text_field( $_REQUEST["params_index"] );
|
359 |
-
|
360 |
-
if ( $params_index == "" ) die();
|
361 |
-
|
362 |
-
$user = wp_get_current_user();
|
363 |
-
$arr = wfu_get_params_fields_from_index($params_index, $session_token);
|
364 |
-
$sid = $arr['shortcode_id'];
|
365 |
-
//check referrer using server sessions to avoid CSRF attacks
|
366 |
-
if ( WFU_USVAR("wfu_token_".$sid) != $session_token ) {
|
367 |
-
$echo_str = "Session failed!<br/><br/>Session Data:<br/>";
|
368 |
-
$echo_str .= print_r(wfu_sanitize(WFU_USALL()), true);
|
369 |
-
$echo_str .= "<br/><br/>Post Data:<br/>";
|
370 |
-
$echo_str .= print_r(wfu_sanitize($_REQUEST), true);
|
371 |
-
$echo_str .= 'force_errorabort_code';
|
372 |
-
/**
|
373 |
-
* Customise Output on Session Error.
|
374 |
-
*
|
375 |
-
* This filter allows scripts to customise output of the function in
|
376 |
-
* case of session error.
|
377 |
-
*
|
378 |
-
* @since 3.11.0
|
379 |
-
*
|
380 |
-
* @param string $echo_str The output in case of session error.
|
381 |
-
*/
|
382 |
-
$echo_str = apply_filters('_wfu_upload_session_failed', $echo_str);
|
383 |
-
die($echo_str);
|
384 |
-
}
|
385 |
-
|
386 |
-
if ( $user->user_login != $arr['user_login'] ) {
|
387 |
-
$arr = wfu_get_params_fields_from_index($params_index.'[|][|]'.$arr['page_id'].'[|][|]'.$sid.'[|][|]'.$arr['user_login'], $session_token);
|
388 |
-
if ( $user->user_login != $arr['user_login'] ) {
|
389 |
-
$echo_str = "User failed!<br/><br/>User Data:<br/>";
|
390 |
-
$echo_str .= print_r(wfu_sanitize($user), true);
|
391 |
-
$echo_str .= "<br/><br/>Post Data:<br/>";
|
392 |
-
$echo_str .= print_r(wfu_sanitize($_REQUEST), true);
|
393 |
-
$echo_str .= "<br/><br/>Params Data:<br/>";
|
394 |
-
$echo_str .= print_r(wfu_sanitize($arr), true);
|
395 |
-
$echo_str .= 'force_errorabort_code';
|
396 |
-
/**
|
397 |
-
* Customise Output on User Error.
|
398 |
-
*
|
399 |
-
* This filter allows scripts to customise output of the function in
|
400 |
-
* case of user error.
|
401 |
-
*
|
402 |
-
* @since 3.11.0
|
403 |
-
*
|
404 |
-
* @param string $echo_str The output in case of user error.
|
405 |
-
*/
|
406 |
-
$echo_str = apply_filters('_wfu_upload_user_failed', $echo_str);
|
407 |
-
die($echo_str);
|
408 |
-
}
|
409 |
-
}
|
410 |
-
|
411 |
-
//if force_connection_close is set, then the first pass to this callback
|
412 |
-
//script is for closing the previous connection
|
413 |
-
if ( isset($_POST["force_connection_close"]) && $_POST["force_connection_close"] === "1" ) {
|
414 |
-
header("Connection: Close");
|
415 |
-
/**
|
416 |
-
* Customise Output on Forced Connection Close.
|
417 |
-
*
|
418 |
-
* This filter allows scripts to customise return of the function in
|
419 |
-
* case of forced connection close.
|
420 |
-
*
|
421 |
-
* @since 3.11.0
|
422 |
-
*
|
423 |
-
* @param string $echo_str The return in case of forced connection
|
424 |
-
* close.
|
425 |
-
*/
|
426 |
-
die(apply_filters('_wfu_upload_force_connection_close', 'success'));
|
427 |
-
}
|
428 |
-
|
429 |
-
//get the unique id of the upload
|
430 |
-
$unique_id = ( isset($_POST['uniqueuploadid_'.$sid]) ? sanitize_text_field($_POST['uniqueuploadid_'.$sid]) : "" );
|
431 |
-
if ( strlen($unique_id) != 10 ) {
|
432 |
-
/**
|
433 |
-
* Customise Output on Unique ID Fail.
|
434 |
-
*
|
435 |
-
* This filter allows scripts to customise return of the function in
|
436 |
-
* case that the retrieved unique ID is invalid.
|
437 |
-
*
|
438 |
-
* @since 3.11.0
|
439 |
-
*
|
440 |
-
* @param string $echo_str The return in case of unique ID fail.
|
441 |
-
*/
|
442 |
-
die(apply_filters('_wfu_upload_uniqueid_failed', 'force_errorabort_code'));
|
443 |
-
}
|
444 |
-
|
445 |
-
//if before upload actions have been executed and they have rejected the
|
446 |
-
//upload, but for some reason (hack attempt) the upload continued, then
|
447 |
-
//terminate it
|
448 |
-
if ( WFU_USVAR_exists("wfu_uploadstatus_".$unique_id) && WFU_USVAR("wfu_uploadstatus_".$unique_id) == 0 ) die('force_errorabort_code');
|
449 |
-
|
450 |
-
//get stored shortcode parameters
|
451 |
-
$params_str = get_option('wfu_params_'.$arr['unique_id']);
|
452 |
-
$params = wfu_decode_array_from_string($params_str);
|
453 |
-
/** This filter is documented above. */
|
454 |
-
$params = apply_filters("_wfu_get_params", $params, $arr, 'wfu_ajax_action_callback');
|
455 |
-
|
456 |
-
//if upload has finished then perform post upload actions
|
457 |
-
if ( isset($_POST["upload_finished"]) && $_POST["upload_finished"] === "1" ) {
|
458 |
-
//remove any queues that were generated during the upload process
|
459 |
-
wfu_remove_queue($unique_id);
|
460 |
-
$echo_str = "";
|
461 |
-
//execute after upload filters
|
462 |
-
$ret = wfu_execute_after_upload_filters($sid, $unique_id, $params);
|
463 |
-
if ( $ret["js_script"] != "" ) $echo_str = "CBUVJS[".wfu_plugin_encode_string($ret["js_script"])."]";
|
464 |
-
die($echo_str);
|
465 |
-
}
|
466 |
-
|
467 |
-
//check if honeypot userdata fields have been added to the form and if they
|
468 |
-
//contain any data; if wfu_check_remove_honeypot_fields returns true this
|
469 |
-
//means that at least one honeypot field has beed filled with a value and
|
470 |
-
//the upload must be aborted because it was not done by a human
|
471 |
-
if ( $params["userdata"] == "true" && wfu_check_remove_honeypot_fields($params["userdata_fields"], 'hiddeninput_'.$sid.'_userdata_') ) die("force_abortsuccess_code");
|
472 |
-
|
473 |
-
//apply filters to determine if the upload will continue or stop
|
474 |
-
$ret = array( "status" => "", "echo" => "" );
|
475 |
-
$attr = array( "sid" => $sid, "unique_id" => $unique_id, "params" => $params );
|
476 |
-
/**
|
477 |
-
* Execute Pre-Upload Checks.
|
478 |
-
*
|
479 |
-
* This is an internal filter which allows to execute custom actions right
|
480 |
-
* before an upload starts. It can cancel the upload.
|
481 |
-
*
|
482 |
-
* @since 3.7.0
|
483 |
-
*
|
484 |
-
* @param array $ret {
|
485 |
-
* Controls the Upload.
|
486 |
-
*
|
487 |
-
* @type string $status Status of the upload. If it is 'die' then the
|
488 |
-
* upload will be cancelled.
|
489 |
-
* @type string $echo A message to return in case of upload
|
490 |
-
* cancellation.
|
491 |
-
* }
|
492 |
-
* @param array $attr {
|
493 |
-
* Various attributes of the upload.
|
494 |
-
*
|
495 |
-
* @type string $sid The ID of the shortcode.
|
496 |
-
* @type string $unique_id The unique ID of the upload.
|
497 |
-
* @type array $params The shortcode parameters of the upload form.
|
498 |
-
*/
|
499 |
-
$ret = apply_filters("_wfu_pre_upload_check", $ret, $attr);
|
500 |
-
if ( $ret["status"] == "die" ) die($ret["echo"]);
|
501 |
-
|
502 |
-
//if this is the first pass of an upload attempt then perform pre-upload actions
|
503 |
-
if ( !WFU_USVAR_exists('wfu_upload_first_pass_'.$unique_id) || WFU_USVAR('wfu_upload_first_pass_'.$unique_id) != 'true' ) {
|
504 |
-
WFU_USVAR_store('wfu_upload_first_pass_'.$unique_id, 'true');
|
505 |
-
}
|
506 |
-
|
507 |
-
if ( !isset($_POST["subdir_sel_index"]) ) die();
|
508 |
-
$subdir_sel_index = sanitize_text_field( $_POST["subdir_sel_index"] );
|
509 |
-
$params['subdir_selection_index'] = $subdir_sel_index;
|
510 |
-
WFU_USVAR_store('wfu_check_refresh_'.$params["uploadid"], 'do not process');
|
511 |
-
|
512 |
-
//update consent status of user
|
513 |
-
$plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
|
514 |
-
$params["consent_result"] = wfu_check_user_consent($user);
|
515 |
-
$require_consent = ( $plugin_options["personaldata"] == "1" && ( $params["notrememberconsent"] == "true" || $params["consent_result"] == "" ) && $params["askconsent"] == "true" );
|
516 |
-
if ( $require_consent ) {
|
517 |
-
if ( !isset($_POST['consent_result']) ) die();
|
518 |
-
$consent_result = ( $_POST['consent_result'] == "yes" ? "yes" : ( $_POST['consent_result'] == "no" ? "no" : "" ) );
|
519 |
-
$params["consent_result"] = ( $_POST['consent_result'] == "yes" ? "1" : ( $_POST['consent_result'] == "no" ? "0" : "" ) );
|
520 |
-
wfu_update_user_consent($user, $consent_result);
|
521 |
-
}
|
522 |
-
|
523 |
-
if ( $wfu_user_state_handler == "dboption" )
|
524 |
-
$proc_ret = wfu_run_process_in_queue($unique_id, "wfu_process_files", array( $params, 'ajax' ));
|
525 |
-
else {
|
526 |
-
$proc_ret["result"] = true;
|
527 |
-
$proc_ret["output"] = wfu_process_files($params, 'ajax');
|
528 |
-
}
|
529 |
-
$echo_str = "";
|
530 |
-
if ( $proc_ret["result"] ) {
|
531 |
-
$wfu_process_file_array = $proc_ret["output"];
|
532 |
-
//extract safe_output from wfu_process_file_array and pass it as
|
533 |
-
//separate part of the response text
|
534 |
-
$safe_output = $wfu_process_file_array["general"]['safe_output'];
|
535 |
-
unset($wfu_process_file_array["general"]['safe_output']);
|
536 |
-
//get javascript code that has been defined in wfu_after_file_upload
|
537 |
-
//action
|
538 |
-
$js_script = wfu_plugin_encode_string($wfu_process_file_array["general"]['js_script']);
|
539 |
-
unset($wfu_process_file_array["general"]['js_script']);
|
540 |
-
|
541 |
-
$echo_str = "wfu_fileupload_success:".$js_script.":".$safe_output.":".wfu_encode_array_to_string($wfu_process_file_array);
|
542 |
-
}
|
543 |
-
elseif ( $proc_ret["error"] == "abort_thread" ) wfu_advance_queue($unique_id);
|
544 |
-
/**
|
545 |
-
* Customise Output of Successful AJAX Upload.
|
546 |
-
*
|
547 |
-
* This filter allows scripts to customise return of the function in case
|
548 |
-
* that the AJAX upload was successful.
|
549 |
-
*
|
550 |
-
* @since 3.11.0
|
551 |
-
*
|
552 |
-
* @param string $echo_str The return in case of successful AJAX upload.
|
553 |
-
*/
|
554 |
-
$echo_str = apply_filters('_wfu_upload_callback_success', $echo_str);
|
555 |
-
die($echo_str);
|
556 |
-
}
|
557 |
-
|
558 |
-
/**
|
559 |
-
* Execute Saving of Shortcode
|
560 |
-
*
|
561 |
-
* This function executes saving of a shortcode after it has been edited through
|
562 |
-
* the shortcode composer.
|
563 |
-
*
|
564 |
-
* @since 2.1.3
|
565 |
-
*/
|
566 |
-
function wfu_ajax_action_save_shortcode() {
|
567 |
-
$is_admin = current_user_can( 'manage_options' );
|
568 |
-
$can_open_composer = ( WFU_VAR("WFU_SHORTCODECOMPOSER_NOADMIN") == "true" && ( current_user_can( 'edit_pages' ) || current_user_can( 'edit_posts' ) ) );
|
569 |
-
if ( !$is_admin && !$can_open_composer ) die();
|
570 |
-
if ( !isset($_POST['shortcode']) || !isset($_POST['shortcode_original']) || !isset($_POST['post_id']) || !isset($_POST['post_hash']) || !isset($_POST['shortcode_position']) || !isset($_POST['shortcode_tag']) || !isset($_POST['widget_id']) ) die();
|
571 |
-
|
572 |
-
$_POST = stripslashes_deep($_POST);
|
573 |
-
|
574 |
-
//sanitize parameters
|
575 |
-
$shortcode = wfu_sanitize_code($_POST['shortcode']);
|
576 |
-
$shortcode_original = wfu_sanitize_code($_POST['shortcode_original']);
|
577 |
-
$post_id = wfu_sanitize_int($_POST['post_id']);
|
578 |
-
$post_hash = wfu_sanitize_code($_POST['post_hash']);
|
579 |
-
$shortcode_position = wfu_sanitize_int($_POST['shortcode_position']);
|
580 |
-
$shortcode_tag = wfu_sanitize_tag($_POST['shortcode_tag']);
|
581 |
-
$widget_id = sanitize_text_field($_POST['widget_id']);
|
582 |
-
|
583 |
-
$shortcode = wfu_sanitize_shortcode(wfu_plugin_decode_string($shortcode), $shortcode_tag);
|
584 |
-
|
585 |
-
if ( $post_id == "" && $widget_id == "" ) {
|
586 |
-
die();
|
587 |
-
}
|
588 |
-
else {
|
589 |
-
$data['post_id'] = $post_id;
|
590 |
-
$data['post_hash'] = $post_hash;
|
591 |
-
$data['shortcode'] = wfu_plugin_decode_string($shortcode_original);
|
592 |
-
$data['position'] = $shortcode_position;
|
593 |
-
if ( $post_id != "" && !wfu_check_edit_shortcode($data) ) $echo_str = "wfu_save_shortcode:fail:post_modified";
|
594 |
-
else {
|
595 |
-
if ( $widget_id == "" ) {
|
596 |
-
$new_shortcode = "[".$shortcode_tag." ".$shortcode."]";
|
597 |
-
if ( wfu_replace_shortcode($data, $new_shortcode) ) {
|
598 |
-
$post = get_post($post_id);
|
599 |
-
/** This filter is described in wfu_loader.php */
|
600 |
-
$content = apply_filters("_wfu_get_post_content", $post->post_content, $post);
|
601 |
-
$hash = hash('md5', $content);
|
602 |
-
$echo_str = "wfu_save_shortcode:success:".$hash;
|
603 |
-
}
|
604 |
-
else $echo_str = "wfu_save_shortcode:fail:post_update_failed";
|
605 |
-
}
|
606 |
-
else {
|
607 |
-
$widget_obj = wfu_get_widget_obj_from_id($widget_id);
|
608 |
-
if ( $widget_obj === false ) $echo_str = "wfu_save_shortcode:fail:post_update_failed";
|
609 |
-
else {
|
610 |
-
$widget_sidebar = is_active_widget(false, $widget_id, "wordpress_file_upload_widget");
|
611 |
-
if ( !$widget_sidebar ) $echo_str = "wfu_save_shortcode:fail:post_update_failed";
|
612 |
-
else {
|
613 |
-
$widget_obj->update_external($shortcode);
|
614 |
-
$hash = $data['post_hash'];
|
615 |
-
$echo_str = "wfu_save_shortcode:success:".$hash;
|
616 |
-
}
|
617 |
-
}
|
618 |
-
}
|
619 |
-
}
|
620 |
-
}
|
621 |
-
|
622 |
-
/**
|
623 |
-
* Customise Output on Shortcode Saving.
|
624 |
-
*
|
625 |
-
* This filter allows scripts to customise return of the function after
|
626 |
-
* finish of it.
|
627 |
-
*
|
628 |
-
* @since 3.11.0
|
629 |
-
*
|
630 |
-
* @param string $echo_str The return of the function.
|
631 |
-
*/
|
632 |
-
$echo_str = apply_filters('_wfu_ajax_action_save_shortcode', $echo_str);
|
633 |
-
die($echo_str);
|
634 |
-
}
|
635 |
-
|
636 |
-
/**
|
637 |
-
* Execute Checking of Post Contents
|
638 |
-
*
|
639 |
-
* This function executes checking of post contents to determine whether they
|
640 |
-
* are current or obsolete (they have changed).
|
641 |
-
*
|
642 |
-
* @since 2.6.0
|
643 |
-
*/
|
644 |
-
function wfu_ajax_action_check_page_contents() {
|
645 |
-
if ( !current_user_can( 'manage_options' ) ) die();
|
646 |
-
if ( !isset($_POST['post_id']) || !isset($_POST['post_hash']) ) die();
|
647 |
-
if ( $_POST['post_id'] == "" ) die();
|
648 |
-
|
649 |
-
$_POST = stripslashes_deep($_POST);
|
650 |
-
|
651 |
-
$data['post_id'] = wfu_sanitize_int($_POST['post_id']);
|
652 |
-
$data['post_hash'] = wfu_sanitize_code($_POST['post_hash']);
|
653 |
-
if ( wfu_check_edit_shortcode($data) ) $echo_str = "wfu_check_page_contents:current:";
|
654 |
-
else $echo_str = "wfu_check_page_contents:obsolete:";
|
655 |
-
|
656 |
-
/**
|
657 |
-
* Customise Output of Post Contents Checking Function.
|
658 |
-
*
|
659 |
-
* This filter allows scripts to customise return of this function after
|
660 |
-
* finish of it.
|
661 |
-
*
|
662 |
-
* @since 3.11.0
|
663 |
-
*
|
664 |
-
* @param string $echo_str The return of the function.
|
665 |
-
*/
|
666 |
-
$echo_str = apply_filters('_wfu_ajax_action_check_page_contents', $echo_str);
|
667 |
-
die($echo_str);
|
668 |
-
}
|
669 |
-
|
670 |
-
/**
|
671 |
-
* Initiate Editing of Shortcode
|
672 |
-
*
|
673 |
-
* This function invokes the shortcode composer in order to edit a shortcode. It
|
674 |
-
* applies when editing a shortcode from Main page of the plugin in Dashboard or
|
675 |
-
* from a front-end post or page or from a sidebar.
|
676 |
-
*
|
677 |
-
* @since 2.6.0
|
678 |
-
*/
|
679 |
-
function wfu_ajax_action_edit_shortcode() {
|
680 |
-
global $wp_registered_widgets;
|
681 |
-
global $wp_registered_sidebars;
|
682 |
-
|
683 |
-
$is_admin = current_user_can( 'manage_options' );
|
684 |
-
$can_open_composer = ( WFU_VAR("WFU_SHORTCODECOMPOSER_NOADMIN") == "true" && ( current_user_can( 'edit_pages' ) || current_user_can( 'edit_posts' ) ) );
|
685 |
-
if ( !$is_admin && !$can_open_composer ) die();
|
686 |
-
if ( !isset($_POST['upload_id']) || !isset($_POST['post_id']) || !isset($_POST['post_hash']) || !isset($_POST['shortcode_tag']) || !isset($_POST['widget_id']) ) die();
|
687 |
-
|
688 |
-
$_POST = stripslashes_deep($_POST);
|
689 |
-
|
690 |
-
//sanitize parameters
|
691 |
-
$upload_id = sanitize_text_field($_POST['upload_id']);
|
692 |
-
$widget_id = sanitize_text_field($_POST['widget_id']);
|
693 |
-
$post_id = wfu_sanitize_int($_POST['post_id']);
|
694 |
-
$post_hash = wfu_sanitize_code($_POST['post_hash']);
|
695 |
-
$shortcode_tag = wfu_sanitize_tag($_POST['shortcode_tag']);
|
696 |
-
|
697 |
-
$keyname = "uploadid";
|
698 |
-
if ( $shortcode_tag == "wordpress_file_upload_browser" ) $keyname = "browserid";
|
699 |
-
|
700 |
-
$data['post_id'] = $post_id;
|
701 |
-
$data['post_hash'] = $post_hash;
|
702 |
-
if ( wfu_check_edit_shortcode($data) ) {
|
703 |
-
if ( $widget_id == "" ) {
|
704 |
-
$post = get_post($data['post_id']);
|
705 |
-
//get default value for uploadid
|
706 |
-
if ( $shortcode_tag == "wordpress_file_upload_browser" ) $defs = wfu_browser_attribute_definitions();
|
707 |
-
else $defs = wfu_attribute_definitions();
|
708 |
-
$default = "";
|
709 |
-
foreach ( $defs as $key => $def ) {
|
710 |
-
if ( $def['attribute'] == $keyname ) {
|
711 |
-
$default = $def['value'];
|
712 |
-
break;
|
713 |
-
}
|
714 |
-
}
|
715 |
-
//get page shortcodes
|
716 |
-
$wfu_shortcodes = wfu_get_content_shortcodes($post, $shortcode_tag);
|
717 |
-
//find the shortcodes' uploadid and the correct one
|
718 |
-
$validkey = -1;
|
719 |
-
foreach ( $wfu_shortcodes as $key => $data ) {
|
720 |
-
$shortcode = trim(substr($data['shortcode'], strlen('['.$shortcode_tag), -1));
|
721 |
-
$shortcode_attrs = wfu_shortcode_string_to_array($shortcode);
|
722 |
-
if ( array_key_exists($keyname, $shortcode_attrs) ) $uploadid = $shortcode_attrs[$keyname];
|
723 |
-
else $uploadid = $default;
|
724 |
-
if ( $uploadid == $upload_id ) {
|
725 |
-
$validkey = $key;
|
726 |
-
break;
|
727 |
-
}
|
728 |
-
}
|
729 |
-
if ( $validkey == -1 ) die();
|
730 |
-
$data_enc = wfu_safe_store_shortcode_data(wfu_encode_array_to_string($wfu_shortcodes[$validkey]));
|
731 |
-
}
|
732 |
-
else {
|
733 |
-
$widget_obj = wfu_get_widget_obj_from_id($widget_id);
|
734 |
-
if ( $widget_obj === false ) die();
|
735 |
-
$widget_sidebar = is_active_widget(false, $widget_id, "wordpress_file_upload_widget");
|
736 |
-
if ( !$widget_sidebar ) die();
|
737 |
-
if ( isset($wp_registered_sidebars[$widget_sidebar]) && isset($wp_registered_sidebars[$widget_sidebar]['name']) ) $widget_sidebar = $wp_registered_sidebars[$widget_sidebar]['name'];
|
738 |
-
$data['shortcode'] = $widget_obj->shortcode();
|
739 |
-
$data['position'] = 0;
|
740 |
-
$data['widgetid'] = $widget_id;
|
741 |
-
$data['sidebar'] = $widget_sidebar;
|
742 |
-
$data_enc = wfu_safe_store_shortcode_data(wfu_encode_array_to_string($data));
|
743 |
-
}
|
744 |
-
if( $is_admin ) $url = site_url().'/wp-admin/options-general.php?page=wordpress_file_upload&tag='.$shortcode_tag.'&action=edit_shortcode&data='.$data_enc;
|
745 |
-
//conditional that will open the shortcode composer for non-admin users
|
746 |
-
//who can edit posts or pages
|
747 |
-
else $url = site_url().'/wp-admin/admin.php?page=wordpress_file_upload&tag='.$shortcode_tag.'&action=edit_shortcode&data='.$data_enc;
|
748 |
-
$echo_str = "wfu_edit_shortcode:success:".wfu_plugin_encode_string($url);
|
749 |
-
}
|
750 |
-
else $echo_str = "wfu_edit_shortcode:check_page_obsolete:".WFU_ERROR_PAGE_OBSOLETE;
|
751 |
-
|
752 |
-
/**
|
753 |
-
* Customise Output of Shortcode Editing Initiation Function.
|
754 |
-
*
|
755 |
-
* This filter allows scripts to customise return of this function after
|
756 |
-
* finish of it.
|
757 |
-
*
|
758 |
-
* @since 3.11.0
|
759 |
-
*
|
760 |
-
* @param string $echo_str The return of the function.
|
761 |
-
*/
|
762 |
-
$echo_str = apply_filters('_wfu_ajax_action_edit_shortcode', $echo_str);
|
763 |
-
die($echo_str);
|
764 |
-
}
|
765 |
-
|
766 |
-
/**
|
767 |
-
* Initiate Editing of Shortcode in Gutenberg Editor
|
768 |
-
*
|
769 |
-
* This function invokes the shortcode composer in order to edit a shortcode. It
|
770 |
-
* applies when editing a shortcode from the new Gutenberg page editor of
|
771 |
-
* Wordpress.
|
772 |
-
*
|
773 |
-
* @since 4.11.0
|
774 |
-
*/
|
775 |
-
function wfu_ajax_action_gutedit_shortcode() {
|
776 |
-
$is_admin = current_user_can( 'manage_options' );
|
777 |
-
$can_open_composer = ( WFU_VAR("WFU_SHORTCODECOMPOSER_NOADMIN") == "true" && ( current_user_can( 'edit_pages' ) || current_user_can( 'edit_posts' ) ) );
|
778 |
-
if ( !$is_admin && !$can_open_composer ) die();
|
779 |
-
if ( !isset($_POST['shortcode']) || !isset($_POST['post_id']) || !isset($_POST['shortcode_tag']) ) die();
|
780 |
-
|
781 |
-
$_POST = stripslashes_deep($_POST);
|
782 |
-
|
783 |
-
//sanitize parameters
|
784 |
-
$shortcode = wfu_sanitize_code($_POST['shortcode']);
|
785 |
-
$post_id = wfu_sanitize_int($_POST['post_id']);
|
786 |
-
$shortcode_tag = wfu_sanitize_tag($_POST['shortcode_tag']);
|
787 |
-
|
788 |
-
$shortcode = wfu_sanitize_shortcode(wfu_plugin_decode_string($shortcode), $shortcode_tag);
|
789 |
-
|
790 |
-
if ( $post_id == "" ) die();
|
791 |
-
|
792 |
-
$data['shortcode'] = '['.$shortcode_tag.' '.$shortcode.']';
|
793 |
-
$data['post_id'] = $post_id;
|
794 |
-
$data['post_hash'] = '';
|
795 |
-
$data['position'] = 0;
|
796 |
-
$data_enc = wfu_safe_store_shortcode_data(wfu_encode_array_to_string($data));
|
797 |
-
if ( $is_admin ) $url = site_url().'/wp-admin/options-general.php?page=wordpress_file_upload&tag='.$shortcode_tag.'&action=edit_shortcode&data='.$data_enc.'&referer=guteditor';
|
798 |
-
//conditional that will open the shortcode composer for non-admin users who
|
799 |
-
//can edit posts or pages
|
800 |
-
else $url = site_url().'/wp-admin/admin.php?page=wordpress_file_upload&tag='.$shortcode_tag.'&action=edit_shortcode&data='.$data_enc.'&referer=guteditor';
|
801 |
-
|
802 |
-
$echo_str = "wfu_gutedit_shortcode:success:".wfu_plugin_encode_string($url);
|
803 |
-
/**
|
804 |
-
* Customise Output of Gutenberg Shortcode Editing Initiation Function.
|
805 |
-
*
|
806 |
-
* This filter allows scripts to customise return of this function after
|
807 |
-
* finish of it.
|
808 |
-
*
|
809 |
-
* @since 4.11.0
|
810 |
-
*
|
811 |
-
* @param string $echo_str The return of the function.
|
812 |
-
*/
|
813 |
-
$echo_str = apply_filters('_wfu_ajax_action_gutedit_shortcode', $echo_str);
|
814 |
-
die($echo_str);
|
815 |
-
}
|
816 |
-
|
817 |
-
/**
|
818 |
-
* Retrieve Subfolder Structure of a Folder
|
819 |
-
*
|
820 |
-
* This function is used to retrieve the subfolder structure of a folder,
|
821 |
-
* together with the subfolder structure of one of the subfolders. It is used
|
822 |
-
* when defining the subfolders of the subfolders element of the upload form
|
823 |
-
* using the shortcoe composer.
|
824 |
-
*
|
825 |
-
* @since 2.4.1
|
826 |
-
*/
|
827 |
-
function wfu_ajax_action_read_subfolders() {
|
828 |
-
if ( !isset($_POST['folder1']) || !isset($_POST['folder2']) ) die();
|
829 |
-
|
830 |
-
$_POST = stripslashes_deep($_POST);
|
831 |
-
|
832 |
-
$folder1 = wfu_sanitize_code($_POST['folder1']);
|
833 |
-
$folder1 = wfu_sanitize_url(wfu_plugin_decode_string($folder1));
|
834 |
-
$folder2 = wfu_sanitize_code($_POST['folder2']);
|
835 |
-
$folder2 = wfu_sanitize_url(wfu_plugin_decode_string($folder2));
|
836 |
-
if ( wfu_plugin_encode_string($folder1) != $_POST['folder1'] || wfu_plugin_encode_string($folder2) != $_POST['folder2'] ) die();
|
837 |
-
|
838 |
-
$temp_params = array( 'uploadpath' => $folder1, 'accessmethod' => 'normal', 'ftpinfo' => '', 'useftpdomain' => 'false' );
|
839 |
-
$path = wfu_upload_plugin_full_path($temp_params);
|
840 |
-
|
841 |
-
if ( !is_dir($path) ) {
|
842 |
-
/**
|
843 |
-
* Customise Output of Shortcode Subfolder Structure Retrieval.
|
844 |
-
*
|
845 |
-
* This filter allows scripts to customise return of this function after
|
846 |
-
* finish of it.
|
847 |
-
*
|
848 |
-
* @since 3.11.0
|
849 |
-
*
|
850 |
-
* @param string $echo_str The return of the function.
|
851 |
-
*/
|
852 |
-
die(apply_filters('_wfu_ajax_action_read_subfolders', 'wfu_read_subfolders:error:Parent folder is not valid! Cannot retrieve subfolder list.'));
|
853 |
-
}
|
854 |
-
|
855 |
-
$path2 = $folder2;
|
856 |
-
$dirlist = "";
|
857 |
-
if ( $handle = opendir($path) ) {
|
858 |
-
$blacklist = array('.', '..');
|
859 |
-
while ( false !== ($file = readdir($handle)) )
|
860 |
-
if ( !in_array($file, $blacklist) ) {
|
861 |
-
$filepath = $path.$file;
|
862 |
-
if ( is_dir($filepath) ) {
|
863 |
-
if ( $file == $path2 ) $file = '[['.$file.']]';
|
864 |
-
$dirlist .= ( $dirlist == "" ? "" : "," ).$file;
|
865 |
-
}
|
866 |
-
}
|
867 |
-
closedir($handle);
|
868 |
-
}
|
869 |
-
if ( $path2 != "" ) {
|
870 |
-
$dirlist2 = $path2;
|
871 |
-
$path .= $path2."/";
|
872 |
-
if ( is_dir($path) ) {
|
873 |
-
if ( $handle = opendir($path) ) {
|
874 |
-
$blacklist = array('.', '..');
|
875 |
-
while ( false !== ($file = readdir($handle)) )
|
876 |
-
if ( !in_array($file, $blacklist) ) {
|
877 |
-
$filepath = $path.$file;
|
878 |
-
if ( is_dir($filepath) )
|
879 |
-
$dirlist2 .= ",*".$file;
|
880 |
-
}
|
881 |
-
closedir($handle);
|
882 |
-
}
|
883 |
-
}
|
884 |
-
$dirlist = str_replace('[['.$path2.']]', $dirlist2, $dirlist);
|
885 |
-
}
|
886 |
-
|
887 |
-
/** This filter is documnted above. */
|
888 |
-
die(apply_filters('_wfu_ajax_action_read_subfolders', "wfu_read_subfolders:success:".wfu_plugin_encode_string($dirlist)));
|
889 |
-
}
|
890 |
-
|
891 |
-
/**
|
892 |
-
* Initiate a File Download
|
893 |
-
*
|
894 |
-
* This function initiates a file download. It will first check whether the user
|
895 |
-
* has the right to download the file. Then it will return an iframe element
|
896 |
-
* that will start the download. Short life tokens are used in order to avoid
|
897 |
-
* CSRF attacks. Download is executed outside Wordpress enviroment because some
|
898 |
-
* times Wordpress environment outputs warnings that are downloaded with the
|
899 |
-
* file, resulting in a broken download.
|
900 |
-
*
|
901 |
-
* @since 2.6.0
|
902 |
-
*/
|
903 |
-
function wfu_ajax_action_download_file_invoker() {
|
904 |
-
global $wfu_user_state_handler;
|
905 |
-
|
906 |
-
$_POST = stripslashes_deep($_POST);
|
907 |
-
$_GET = stripslashes_deep($_GET);
|
908 |
-
|
909 |
-
$file_code = (isset($_POST['file']) ? $_POST['file'] : (isset($_GET['file']) ? $_GET['file'] : ''));
|
910 |
-
$nonce = (isset($_POST['nonce']) ? $_POST['nonce'] : (isset($_GET['nonce']) ? $_GET['nonce'] : ''));
|
911 |
-
if ( $file_code == '' || $nonce == '' ) die();
|
912 |
-
|
913 |
-
//security check to avoid CSRF attacks
|
914 |
-
if ( !wp_verify_nonce($nonce, 'wfu_download_file_invoker') ) die();
|
915 |
-
|
916 |
-
//check if user is allowed to download files
|
917 |
-
if ( !current_user_can( 'manage_options' ) ) {
|
918 |
-
die();
|
919 |
-
}
|
920 |
-
|
921 |
-
$cookies = array();
|
922 |
-
$use_cookies = ( $wfu_user_state_handler == "dboption" && WFU_VAR("WFU_US_DBOPTION_BASE") == "cookies" );
|
923 |
-
$file_code = sanitize_text_field($file_code);
|
924 |
-
//if file_code is exportdata, then export of data has been requested and
|
925 |
-
//we need to create a file with export data and recreate file_code
|
926 |
-
if ( substr($file_code, 0, 10) == "exportdata" && current_user_can( 'manage_options' ) ) {
|
927 |
-
$params = null;
|
928 |
-
$params_str = substr($file_code, 11);
|
929 |
-
if ( trim($params_str) != "" ) $params = json_decode($params_str, true);
|
930 |
-
$filepath = wfu_export_uploaded_files($params);
|
931 |
-
if ( $filepath === false ) die();
|
932 |
-
$file_code = "exportdata".wfu_safe_store_filepath($filepath);
|
933 |
-
//store filepath in user state otherwise it can not be retrieved by
|
934 |
-
//downloader script
|
935 |
-
if ( !$use_cookies ) WFU_USVAR_store_session('wfu_storage_'.substr($file_code, 10), $filepath);
|
936 |
-
else array_push($cookies, '{name: "wfu_storage_'.substr($file_code, 10).'", value: "'.$filepath.'", expires: 30}');
|
937 |
-
}
|
938 |
-
//else get the file path from the safe
|
939 |
-
else {
|
940 |
-
$filepath = wfu_get_filepath_from_safe($file_code);
|
941 |
-
if ( $filepath === false ) die();
|
942 |
-
$filepath = wfu_path_rel2abs(wfu_flatten_path($filepath));
|
943 |
-
//reject download of blacklisted file types for security reasons
|
944 |
-
if ( wfu_file_extension_blacklisted($filepath) ) {
|
945 |
-
/**
|
946 |
-
* Customise Output of Download Initiation Operation.
|
947 |
-
*
|
948 |
-
* This filter allows scripts to customise return of this function
|
949 |
-
* after finish of it.
|
950 |
-
*
|
951 |
-
* @since 3.11.0
|
952 |
-
*
|
953 |
-
* @param string $echo_str The return of the function.
|
954 |
-
*/
|
955 |
-
die(apply_filters('_wfu_ajax_action_download_file_invoker', 'wfu_ajax_action_download_file_invoker:not_allowed:'.( isset($_POST['browser']) ? WFU_BROWSER_DOWNLOADFILE_NOTALLOWED : 'You are not allowed to download this file!' )));
|
956 |
-
}
|
957 |
-
//for front-end browser apply wfu_browser_check_file_action filter to
|
958 |
-
//allow or restrict the download
|
959 |
-
if ( isset($_POST['browser']) ) {
|
960 |
-
$changable_data["error_message"] = "";
|
961 |
-
$filerec = wfu_get_file_rec($filepath, true);
|
962 |
-
$userdata = array();
|
963 |
-
foreach ( $filerec->userdata as $data )
|
964 |
-
array_push($userdata, array( "label" => $data->property, "value" => $data->propvalue ));
|
965 |
-
$additional_data = array(
|
966 |
-
"file_action" => "download",
|
967 |
-
"filepath" => $filepath,
|
968 |
-
"uploaduser" => $filerec->uploaduserid,
|
969 |
-
"userdata" => $userdata
|
970 |
-
);
|
971 |
-
/**
|
972 |
-
* Check if Action is Allowed in Front-End File Browser.
|
973 |
-
*
|
974 |
-
* This filter allows scripts to check whether the action on a file
|
975 |
-
* from the front-end file browser is allowed.
|
976 |
-
*
|
977 |
-
* @since 3.7.2
|
978 |
-
*
|
979 |
-
* @param array $changable_data {
|
980 |
-
* Controls allowance or rejection of the action.
|
981 |
-
*
|
982 |
-
* @type string $error_message An error message to return in
|
983 |
-
* case the action must be rejected.
|
984 |
-
* }
|
985 |
-
* @param array $additional_data {
|
986 |
-
* Additional data of the file action operation.
|
987 |
-
*
|
988 |
-
* @type string $file_action The performed action.
|
989 |
-
* @type string $filepath The full path of the file.
|
990 |
-
* @type string $uploaduser The ID of the user who uploaded
|
991 |
-
* the file.
|
992 |
-
* @type array $userdata Each item of the array contains the
|
993 |
-
* label and value of any additional userdata exist
|
994 |
-
* together with the file.
|
995 |
-
* }
|
996 |
-
*/
|
997 |
-
$changable_data = apply_filters("wfu_browser_check_file_action", $changable_data, $additional_data);
|
998 |
-
if ( $changable_data["error_message"] != "" )
|
999 |
-
/** This filter is documented above. */
|
1000 |
-
die(apply_filters('_wfu_ajax_action_download_file_invoker', 'wfu_ajax_action_download_file_invoker:not_allowed:'.$changable_data["error_message"]));
|
1001 |
-
}
|
1002 |
-
//for back-end browser check if user is allowed to perform this action
|
1003 |
-
//on this file
|
1004 |
-
if ( !wfu_current_user_owes_file($filepath) ) die();
|
1005 |
-
//store filepath in user state otherwise it can not be retrieved by
|
1006 |
-
//downloader script
|
1007 |
-
if ( !$use_cookies ) WFU_USVAR_store_session('wfu_storage_'.$file_code, wfu_get_filepath_from_safe($file_code));
|
1008 |
-
else array_push($cookies, '{name: "wfu_storage_'.$file_code.'", value: "'.wfu_get_filepath_from_safe($file_code).'", expires: 30}');
|
1009 |
-
}
|
1010 |
-
|
1011 |
-
//generate download unique id to monitor this download
|
1012 |
-
$download_id = wfu_create_random_string(16);
|
1013 |
-
//store download status of this download in user state, so that it can be
|
1014 |
-
//changed by downloader script; it is noted that the downloader script
|
1015 |
-
//does not load WP environment, so in case of dboption it cannot access the
|
1016 |
-
//download status (which is stored in the database); however the downloader
|
1017 |
-
//script does not need to read it; it only needs to change it after the
|
1018 |
-
//download; so after the download, the downloader script loads WP
|
1019 |
-
//environment, so that it can change download status
|
1020 |
-
WFU_USVAR_store('wfu_download_status_'.$download_id, 'starting');
|
1021 |
-
//generate download ticket which expires in 30sec and store it in user
|
1022 |
-
//state; it will be used as security measure for the downloader script,
|
1023 |
-
//which runs outside Wordpress environment; it is noted that the downloader
|
1024 |
-
//script needs to read download ticket before the download; however in the
|
1025 |
-
//case of dboption the only way to achieve this is to store it in a cookie
|
1026 |
-
if ( !$use_cookies ) WFU_USVAR_store_session('wfu_download_ticket_'.$download_id, time() + 30);
|
1027 |
-
else array_push($cookies, '{name: "wfu_download_ticket_'.$download_id.'", value: '.(time() + 30).', expires: 30}');
|
1028 |
-
//generate download monitor ticket which expires in 30sec and store it in
|
1029 |
-
//user state; it will be used as security measure for the monitor script
|
1030 |
-
//that will check download status; it is noted that there is no reason to
|
1031 |
-
//store download monitor ticket in a cookie in case of dboption, because it
|
1032 |
-
//is not needed to be read by the downloader script
|
1033 |
-
WFU_USVAR_store('wfu_download_monitor_ticket_'.$download_id, time() + 30);
|
1034 |
-
|
1035 |
-
//store ABSPATH in user state so that it can be used by download script;
|
1036 |
-
//again, in case of dboption, the only way the downloader script can read it
|
1037 |
-
//is to store it in a cookie
|
1038 |
-
if ( !$use_cookies ) WFU_USVAR_store_session('wfu_ABSPATH', wfu_abspath());
|
1039 |
-
else array_push($cookies, '{name: "wfu_ABSPATH", value: "'.urlencode(wfu_abspath()).'", expires: 30}');
|
1040 |
-
//store translatable strings to user state so that they can be used by a
|
1041 |
-
//script that runs outside Wordpress environment
|
1042 |
-
if ( !$use_cookies ) WFU_USVAR_store_session('wfu_browser_downloadfile_notexist', ( isset($_POST['browser']) ? WFU_BROWSER_DOWNLOADFILE_NOTEXIST : 'File does not exist!' ));
|
1043 |
-
else array_push($cookies, '{name: "wfu_browser_downloadfile_notexist", value: "'.( isset($_POST['browser']) ? WFU_BROWSER_DOWNLOADFILE_NOTEXIST : 'File does not exist!' ).'", expires: 30}');
|
1044 |
-
if ( !$use_cookies ) WFU_USVAR_store_session('wfu_browser_downloadfile_failed', ( isset($_POST['browser']) ? WFU_BROWSER_DOWNLOADFILE_FAILED : 'Could not download file!' ));
|
1045 |
-
else array_push($cookies, '{name: "wfu_browser_downloadfile_failed", value: "'.( isset($_POST['browser']) ? WFU_BROWSER_DOWNLOADFILE_FAILED : 'Could not download file!' ).'", expires: 30}');
|
1046 |
-
|
1047 |
-
//this routine returns a dynamically created iframe element, that will call
|
1048 |
-
//the actual download script; the actual download script runs outside
|
1049 |
-
//Wordpress environment in order to ensure that no php warnings or echo from
|
1050 |
-
//other plugins is generated, that could scramble the downloaded file; a
|
1051 |
-
//ticket, similar to nonces, is passed to the download script to check that
|
1052 |
-
//it is not a CSRF attack; moreover,the ticket is destroyed by the time it
|
1053 |
-
//is consumed by the download script, so it cannot be used again
|
1054 |
-
$urlparams = 'file='.$file_code.'&ticket='.$download_id.'&handler='.$wfu_user_state_handler.'&session_legacy='.( WFU_VAR("WFU_US_SESSION_LEGACY") == "true" ? '1' : '0' ).'&dboption_base='.WFU_VAR("WFU_US_DBOPTION_BASE").'&dboption_useold='.( WFU_VAR("WFU_US_DBOPTION_USEOLD") == "true" ? '1' : '0' ).'&wfu_cookie='.WPFILEUPLOAD_COOKIE;
|
1055 |
-
$response["html"] = '<iframe src="'.WFU_DOWNLOADER_URL.'?'.$urlparams.'" style="display: none;"></iframe>';
|
1056 |
-
//if user state handler is set to dboption (cookies), then tickets and other
|
1057 |
-
//variables must pass to the download script as cookies; the cookies are
|
1058 |
-
//passed in the response of this function, so that the client browser can
|
1059 |
-
//add them in cookies by executing wfu_add_cookies() function
|
1060 |
-
$response["js"] = ( count($cookies) > 0 ? 'wfu_add_cookies(['.implode(", ", $cookies).']);' : '' );
|
1061 |
-
$response = wfu_encode_array_to_string($response);
|
1062 |
-
|
1063 |
-
/** This filter is documented above. */
|
1064 |
-
die(apply_filters('_wfu_ajax_action_download_file_invoker', 'wfu_ajax_action_download_file_invoker:wfu_download_id;'.$download_id.':'.$response));
|
1065 |
-
}
|
1066 |
-
|
1067 |
-
/**
|
1068 |
-
* Monitor a File Download
|
1069 |
-
*
|
1070 |
-
* This function monitors a file download and performs post-download actions in
|
1071 |
-
* case the download has ended.
|
1072 |
-
*
|
1073 |
-
* @since 2.6.0
|
1074 |
-
*/
|
1075 |
-
function wfu_ajax_action_download_file_monitor() {
|
1076 |
-
$_POST = stripslashes_deep($_POST);
|
1077 |
-
$_GET = stripslashes_deep($_GET);
|
1078 |
-
|
1079 |
-
$file_code = (isset($_POST['file']) ? $_POST['file'] : (isset($_GET['file']) ? $_GET['file'] : ''));
|
1080 |
-
$id = (isset($_POST['id']) ? $_POST['id'] : (isset($_GET['id']) ? $_GET['id'] : ''));
|
1081 |
-
if ( $file_code == '' || $id == '' ) die();
|
1082 |
-
$id = wfu_sanitize_code($id);
|
1083 |
-
|
1084 |
-
//ensure that this is not a CSRF attack by checking validity of a security
|
1085 |
-
//ticket
|
1086 |
-
if ( !WFU_USVAR_exists('wfu_download_monitor_ticket_'.$id) || time() > WFU_USVAR('wfu_download_monitor_ticket_'.$id) ) {
|
1087 |
-
WFU_USVAR_unset('wfu_download_monitor_ticket_'.$id);
|
1088 |
-
WFU_USVAR_unset('wfu_download_status_'.$id);
|
1089 |
-
die();
|
1090 |
-
}
|
1091 |
-
//destroy monitor ticket so it cannot be used again
|
1092 |
-
WFU_USVAR_unset('wfu_download_monitor_ticket_'.$id);
|
1093 |
-
|
1094 |
-
//initiate loop of 30secs to check the download status of the file;
|
1095 |
-
//the download status is controlled by the actual download script;
|
1096 |
-
//if the file finishes within the 30secs of the loop, then this routine logs
|
1097 |
-
//the action and notifies the client side about the download status of the
|
1098 |
-
//file, otherwise an instruction to the client side to repeat this routine
|
1099 |
-
//and wait for another 30secs is dispatched
|
1100 |
-
$end_time = time() + 30;
|
1101 |
-
$upload_ended = false;
|
1102 |
-
while ( time() < $end_time ) {
|
1103 |
-
$upload_ended = ( WFU_USVAR_exists('wfu_download_status_'.$id) ? ( WFU_USVAR('wfu_download_status_'.$id) == 'downloaded' || WFU_USVAR('wfu_download_status_'.$id) == 'failed' ? true : false ) : false );
|
1104 |
-
if ( $upload_ended ) break;
|
1105 |
-
usleep(100);
|
1106 |
-
}
|
1107 |
-
|
1108 |
-
if ( $upload_ended ) {
|
1109 |
-
$upload_result = WFU_USVAR('wfu_download_status_'.$id);
|
1110 |
-
WFU_USVAR_unset('wfu_download_status_'.$id);
|
1111 |
-
$user = wp_get_current_user();
|
1112 |
-
// $filepath = wfu_plugin_decode_string($file_code);
|
1113 |
-
$filepath = wfu_get_filepath_from_safe($file_code);
|
1114 |
-
if ( $filepath === false ) die();
|
1115 |
-
$filepath = wfu_path_rel2abs(wfu_flatten_path($filepath));
|
1116 |
-
wfu_log_action('download', $filepath, $user->ID, '', 0, 0, '', null);
|
1117 |
-
/**
|
1118 |
-
* Customise Output of Download Monitoring Operation.
|
1119 |
-
*
|
1120 |
-
* This filter allows scripts to customise return of this function after
|
1121 |
-
* finish of it.
|
1122 |
-
*
|
1123 |
-
* @since 3.11.0
|
1124 |
-
*
|
1125 |
-
* @param string $echo_str The return of the function.
|
1126 |
-
*/
|
1127 |
-
die(apply_filters('_wfu_ajax_action_download_file_monitor', 'wfu_ajax_action_download_file_monitor:'.$upload_result.':'));
|
1128 |
-
}
|
1129 |
-
else {
|
1130 |
-
//regenerate monitor ticket
|
1131 |
-
WFU_USVAR_store('wfu_download_monitor_ticket_'.$id, time() + 30);
|
1132 |
-
/** This filter is documented above. */
|
1133 |
-
die(apply_filters('_wfu_ajax_action_download_file_monitor', 'wfu_ajax_action_download_file_monitor:repeat:'.$id));
|
1134 |
-
}
|
1135 |
-
}
|
1136 |
-
|
1137 |
-
/**
|
1138 |
-
* Get View Log Page
|
1139 |
-
*
|
1140 |
-
* This function returns the HTML code of a specific page of View Log feature of
|
1141 |
-
* the plugin in Dashboard.
|
1142 |
-
*
|
1143 |
-
* @since 3.5.0
|
1144 |
-
*/
|
1145 |
-
function wfu_ajax_action_get_historylog_page() {
|
1146 |
-
if ( !isset($_POST['token']) || !isset($_POST['page']) ) die();
|
1147 |
-
check_ajax_referer( 'wfu-historylog-page', 'token' );
|
1148 |
-
if ( !current_user_can( 'manage_options' ) ) die();
|
1149 |
-
if ( WFU_VAR("WFU_HISTORYLOG_TABLE_MAXROWS") <= 0 ) die();
|
1150 |
-
|
1151 |
-
$_POST = stripslashes_deep($_POST);
|
1152 |
-
|
1153 |
-
$page = wfu_sanitize_int($_POST['page']);
|
1154 |
-
$rows = wfu_view_log($page, true);
|
1155 |
-
|
1156 |
-
/**
|
1157 |
-
* Customise Output of View Log Page Retrieval.
|
1158 |
-
*
|
1159 |
-
* This filter allows scripts to customise return of this function after
|
1160 |
-
* finish of it.
|
1161 |
-
*
|
1162 |
-
* @since 3.11.0
|
1163 |
-
*
|
1164 |
-
* @param string $echo_str The return of the function.
|
1165 |
-
*/
|
1166 |
-
die(apply_filters('_wfu_ajax_action_get_historylog_page', 'wfu_historylog_page_success:'.wfu_plugin_encode_string($rows)));
|
1167 |
-
}
|
1168 |
-
|
1169 |
-
/**
|
1170 |
-
* Get Uploaded Files Page
|
1171 |
-
*
|
1172 |
-
* This function returns the HTML code of a specific page of Uploaded Files area
|
1173 |
-
* of the plugin in Dashboard.
|
1174 |
-
*
|
1175 |
-
* @since 4.7.0
|
1176 |
-
*/
|
1177 |
-
function wfu_ajax_action_get_uploadedfiles_page() {
|
1178 |
-
if ( !isset($_POST['token']) || !isset($_POST['page']) ) die();
|
1179 |
-
check_ajax_referer( 'wfu-uploadedfiles-page', 'token' );
|
1180 |
-
if ( !current_user_can( 'manage_options' ) ) die();
|
1181 |
-
if ( WFU_VAR("WFU_UPLOADEDFILES_TABLE_MAXROWS") <= 0 ) die();
|
1182 |
-
|
1183 |
-
$_POST = stripslashes_deep($_POST);
|
1184 |
-
|
1185 |
-
$page = wfu_sanitize_int($_POST['page']);
|
1186 |
-
$rows = wfu_uploadedfiles_manager($page, true);
|
1187 |
-
|
1188 |
-
/**
|
1189 |
-
* Customise Output of Uploaded Files Page Retrieval.
|
1190 |
-
*
|
1191 |
-
* This filter allows scripts to customise return of this function after
|
1192 |
-
* finish of it.
|
1193 |
-
*
|
1194 |
-
* @since 4.7.0
|
1195 |
-
*
|
1196 |
-
* @param string $echo_str The return of the function.
|
1197 |
-
*/
|
1198 |
-
die(apply_filters('_wfu_ajax_action_get_uploadedfiles_page', 'wfu_uploadedfiles_page_success:'.wfu_plugin_encode_string($rows)));
|
1199 |
-
}
|
1200 |
-
|
1201 |
-
/**
|
1202 |
-
* Get File Browser Page
|
1203 |
-
*
|
1204 |
-
* This function returns the HTML code of a specific page of File Browser
|
1205 |
-
* feature of the plugin in Dashboard.
|
1206 |
-
*
|
1207 |
-
* @since 4.6.1
|
1208 |
-
*/
|
1209 |
-
function wfu_ajax_action_get_adminbrowser_page() {
|
1210 |
-
if ( !isset($_POST['code']) || !isset($_POST['token']) || !isset($_POST['page']) ) die();
|
1211 |
-
|
1212 |
-
$_POST = stripslashes_deep($_POST);
|
1213 |
-
|
1214 |
-
check_ajax_referer( 'wfu-adminbrowser-page', 'token' );
|
1215 |
-
if ( !current_user_can( 'manage_options' ) ) die();
|
1216 |
-
if ( WFU_VAR("WFU_ADMINBROWSER_TABLE_MAXROWS") <= 0 ) die();
|
1217 |
-
|
1218 |
-
$code = wfu_sanitize_code($_POST['code']);
|
1219 |
-
$page = wfu_sanitize_int($_POST['page']);
|
1220 |
-
//get list of files
|
1221 |
-
$rows = wfu_browse_files($code, $page, true);
|
1222 |
-
|
1223 |
-
/**
|
1224 |
-
* Customise Output of File Browser Page Retrieval.
|
1225 |
-
*
|
1226 |
-
* This filter allows scripts to customise return of this function after
|
1227 |
-
* finish of it.
|
1228 |
-
*
|
1229 |
-
* @since 4.6.1
|
1230 |
-
*
|
1231 |
-
* @param string $echo_str The return of the function.
|
1232 |
-
*/
|
1233 |
-
die(apply_filters('_wfu_ajax_action_get_adminbrowser_page', 'wfu_adminbrowser_page_success:'.wfu_plugin_encode_string($rows)));
|
1234 |
-
}
|
1235 |
-
|
1236 |
-
/**
|
1237 |
-
* Include a File in Plugin Database
|
1238 |
-
*
|
1239 |
-
* This function includes a file in the plugin database.
|
1240 |
-
*
|
1241 |
-
* @since 3.8.2
|
1242 |
-
*/
|
1243 |
-
function wfu_ajax_action_include_file() {
|
1244 |
-
$_POST = stripslashes_deep($_POST);
|
1245 |
-
$_GET = stripslashes_deep($_GET);
|
1246 |
-
|
1247 |
-
$file_code = (isset($_POST['file']) ? $_POST['file'] : (isset($_GET['file']) ? $_GET['file'] : ''));
|
1248 |
-
$nonce = (isset($_POST['nonce']) ? $_POST['nonce'] : (isset($_GET['nonce']) ? $_GET['nonce'] : ''));
|
1249 |
-
if ( $file_code == '' || $nonce == '' ) die();
|
1250 |
-
|
1251 |
-
if ( !current_user_can( 'manage_options' ) ) die();
|
1252 |
-
//security check to avoid CSRF attacks
|
1253 |
-
if ( !wp_verify_nonce($nonce, 'wfu_include_file') ) die();
|
1254 |
-
|
1255 |
-
$plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
|
1256 |
-
if ( $plugin_options['includeotherfiles'] != "1" ) die();
|
1257 |
-
|
1258 |
-
$dec_file = wfu_get_filepath_from_safe($file_code);
|
1259 |
-
if ( $dec_file === false ) die();
|
1260 |
-
|
1261 |
-
$user = wp_get_current_user();
|
1262 |
-
$dec_file = wfu_path_rel2abs(wfu_flatten_path($dec_file));
|
1263 |
-
$fileid = wfu_log_action('include', $dec_file, $user->ID, '', '', get_current_blog_id(), '', null);
|
1264 |
-
|
1265 |
-
if ( $fileid !== false ) {
|
1266 |
-
/**
|
1267 |
-
* Customise Output of File Inclusion Operation.
|
1268 |
-
*
|
1269 |
-
* This filter allows scripts to customise return of this function after
|
1270 |
-
* finish of it.
|
1271 |
-
*
|
1272 |
-
* @since 3.11.0
|
1273 |
-
*
|
1274 |
-
* @param string $echo_str The return of the function.
|
1275 |
-
*/
|
1276 |
-
die(apply_filters('_wfu_ajax_action_include_file', "wfu_include_file:success:".$fileid));
|
1277 |
-
}
|
1278 |
-
/** This filter is documented above. */
|
1279 |
-
else die(apply_filters('_wfu_ajax_action_include_file', 'wfu_include_file:fail:'));
|
1280 |
-
}
|
1281 |
-
|
1282 |
-
/**
|
1283 |
-
* Update WPFilebase Manager Plugin
|
1284 |
-
*
|
1285 |
-
* This function instructs WPFilebase Manager plugin to synchronize its list of
|
1286 |
-
* files, after a file upload.
|
1287 |
-
*
|
1288 |
-
* @since 2.4.1
|
1289 |
-
*/
|
1290 |
-
function wfu_ajax_action_notify_wpfilebase() {
|
1291 |
-
$_POST = stripslashes_deep($_POST);
|
1292 |
-
$_GET = stripslashes_deep($_GET);
|
1293 |
-
|
1294 |
-
$params_index = (isset($_POST['params_index']) ? $_POST['params_index'] : (isset($_GET['params_index']) ? $_GET['params_index'] : ''));
|
1295 |
-
$session_token = (isset($_POST['session_token']) ? $_POST['session_token'] : (isset($_GET['session_token']) ? $_GET['session_token'] : ''));
|
1296 |
-
if ( $params_index == '' || $session_token == '' ) die();
|
1297 |
-
|
1298 |
-
$params_index = sanitize_text_field($params_index);
|
1299 |
-
$session_token = sanitize_text_field($session_token);
|
1300 |
-
|
1301 |
-
$arr = wfu_get_params_fields_from_index($params_index, $session_token);
|
1302 |
-
//check referer using server sessions to avoid CSRF attacks
|
1303 |
-
if ( WFU_USVAR("wfu_token_".$arr['shortcode_id']) != $session_token ) die();
|
1304 |
-
|
1305 |
-
//execute WPFilebase plugin sunchronization by calling 'wpfilebase_sync'
|
1306 |
-
//action
|
1307 |
-
do_action('wpfilebase_sync');
|
1308 |
-
|
1309 |
-
die();
|
1310 |
-
}
|
1311 |
-
|
1312 |
-
/**
|
1313 |
-
* Get List of Users
|
1314 |
-
*
|
1315 |
-
* This function returns a list of users meeting specific criteria. Only the
|
1316 |
-
* first 100 users will be returned, for avoiding performance issues.
|
1317 |
-
*
|
1318 |
-
* @since 4.5.0
|
1319 |
-
*/
|
1320 |
-
function wfu_ajax_action_pdusers_get_users() {
|
1321 |
-
$_POST = stripslashes_deep($_POST);
|
1322 |
-
$_GET = stripslashes_deep($_GET);
|
1323 |
-
|
1324 |
-
$nonce = (isset($_POST['nonce']) ? $_POST['nonce'] : (isset($_GET['nonce']) ? $_GET['nonce'] : ''));
|
1325 |
-
$query = (isset($_POST['query']) ? $_POST['query'] : (isset($_GET['query']) ? $_GET['query'] : ''));
|
1326 |
-
if ( $nonce == '' || $query == '' ) die();
|
1327 |
-
|
1328 |
-
if ( !current_user_can( 'manage_options' ) ) die();
|
1329 |
-
//security check to avoid CSRF attacks
|
1330 |
-
if ( !wp_verify_nonce($nonce, 'wfu_edit_policy') ) die();
|
1331 |
-
|
1332 |
-
$query = sanitize_text_field($query);
|
1333 |
-
$args = array(
|
1334 |
-
'search' => $query,
|
1335 |
-
'search_columns' => array( 'user_login', 'display_name' ),
|
1336 |
-
'fields' => array( 'user_login', 'display_name' ),
|
1337 |
-
'number' => 100
|
1338 |
-
);
|
1339 |
-
/** This filter is documented in lib/wfu_admin_browser.php */
|
1340 |
-
$args = apply_filters("_wfu_get_users", $args, "manage_pdusers");
|
1341 |
-
$users = get_users($args);
|
1342 |
-
|
1343 |
-
die("pdusers_get_users:".wfu_encode_array_to_string($users));
|
1344 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* AJAX Handlers of the Plugin
|
5 |
+
*
|
6 |
+
* This file contains AJAX handlers of the plugin.
|
7 |
+
*
|
8 |
+
* @link /lib/wfu_ajaxactions.php
|
9 |
+
*
|
10 |
+
* @package WordPress File Upload Plugin
|
11 |
+
* @subpackage Core Components
|
12 |
+
* @since 2.1.2
|
13 |
+
*/
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Execute Email Notification Dispatching
|
17 |
+
*
|
18 |
+
* This function sends an email notification after files have been uploaded.
|
19 |
+
*
|
20 |
+
* @since 2.1.2
|
21 |
+
*/
|
22 |
+
function wfu_ajax_action_send_email_notification() {
|
23 |
+
$_POST = stripslashes_deep($_POST);
|
24 |
+
|
25 |
+
$user = wp_get_current_user();
|
26 |
+
if ( 0 == $user->ID ) $is_admin = false;
|
27 |
+
else $is_admin = current_user_can('manage_options');
|
28 |
+
|
29 |
+
$params_index = sanitize_text_field($_POST['params_index']);
|
30 |
+
$session_token = sanitize_text_field($_POST['session_token']);
|
31 |
+
|
32 |
+
$arr = wfu_get_params_fields_from_index($params_index, $session_token);
|
33 |
+
//check referer using server sessions to avoid CSRF attacks
|
34 |
+
$sid = $arr['shortcode_id'];
|
35 |
+
if ( WFU_USVAR("wfu_token_".$sid) != $session_token ) die();
|
36 |
+
if ( $user->user_login != $arr['user_login'] ) {
|
37 |
+
$arr = wfu_get_params_fields_from_index($params_index.'[|][|]'.$arr['page_id'].'[|][|]'.$sid.'[|][|]'.$arr['user_login'], $session_token);
|
38 |
+
if ( $user->user_login != $arr['user_login'] ) die();
|
39 |
+
}
|
40 |
+
|
41 |
+
$params_str = get_option('wfu_params_'.$arr['unique_id']);
|
42 |
+
$params = wfu_decode_array_from_string($params_str);
|
43 |
+
/**
|
44 |
+
* Customize Params Array.
|
45 |
+
*
|
46 |
+
* This is an internal filter which allows to modify params array before it
|
47 |
+
* is used by the function.
|
48 |
+
*
|
49 |
+
* @since 4.14.0
|
50 |
+
*
|
51 |
+
* @param array $params The params array
|
52 |
+
* @param array $arr {
|
53 |
+
* Basic information about the upload.
|
54 |
+
*
|
55 |
+
* @type string $unique_id Optional. The unique ID of the upload.
|
56 |
+
* @type string $page_id Optional. The post ID of the upload form.
|
57 |
+
* @type array $shortcode_id Optional. The ID of the upload form.
|
58 |
+
* @type array $user_login Optional. The username of the upload user.
|
59 |
+
* }
|
60 |
+
* @param string $caller A string identifying the caller of this filter.
|
61 |
+
*/
|
62 |
+
$params = apply_filters("_wfu_get_params", $params, $arr, 'wfu_ajax_action_send_email_notification');
|
63 |
+
|
64 |
+
//check whether email notifications are activated
|
65 |
+
if ( $params["notify"] != "true" ) die();
|
66 |
+
|
67 |
+
$uniqueid = ( isset($_POST['uniqueuploadid_'.$sid]) ? sanitize_text_field($_POST['uniqueuploadid_'.$sid]) : "" );
|
68 |
+
//uniqueid cannot be empty and cannot be "no-ajax"
|
69 |
+
if ( $uniqueid == "" || $uniqueid == "no-ajax" ) die();
|
70 |
+
|
71 |
+
//retrieve the list of uploaded files from session
|
72 |
+
$target_path_list = array();
|
73 |
+
$all_files_count = 0;
|
74 |
+
if ( WFU_USVAR_exists("filedata_".$uniqueid) && is_array(WFU_USVAR("filedata_".$uniqueid)) ) {
|
75 |
+
$all_files_count = count(WFU_USVAR("filedata_".$uniqueid));
|
76 |
+
foreach ( WFU_USVAR("filedata_".$uniqueid) as $file ) {
|
77 |
+
if ( $file["upload_result"] == "success" || $file["upload_result"] == "warning" )
|
78 |
+
array_push($target_path_list, $file["filepath"]);
|
79 |
+
}
|
80 |
+
}
|
81 |
+
$uploaded_files_count = count($target_path_list);
|
82 |
+
$nofileupload = ( $params["allownofile"] == "true" && $all_files_count == 0 );
|
83 |
+
$force_notifications = ( WFU_VAR("WFU_FORCE_NOTIFICATIONS") == "true" );
|
84 |
+
|
85 |
+
//in case no files have been uploaded and this is not a nofileupload
|
86 |
+
//situation and Force Email Notifications option is not active then abort
|
87 |
+
if ( $uploaded_files_count == 0 && !$nofileupload && !$force_notifications ) die();
|
88 |
+
|
89 |
+
/* initialize return array */
|
90 |
+
$params_output_array["version"] = "full";
|
91 |
+
$params_output_array["general"]['shortcode_id'] = $params["uploadid"];
|
92 |
+
$params_output_array["general"]['unique_id'] = $uniqueid;
|
93 |
+
$params_output_array["general"]['state'] = 0;
|
94 |
+
$params_output_array["general"]['files_count'] = 0;
|
95 |
+
$params_output_array["general"]['update_wpfilebase'] = "";
|
96 |
+
$params_output_array["general"]['redirect_link'] = "";
|
97 |
+
$params_output_array["general"]['upload_finish_time'] = "";
|
98 |
+
$params_output_array["general"]['message'] = "";
|
99 |
+
$params_output_array["general"]['message_type'] = "";
|
100 |
+
$params_output_array["general"]['admin_messages']['wpfilebase'] = "";
|
101 |
+
$params_output_array["general"]['admin_messages']['notify'] = "";
|
102 |
+
$params_output_array["general"]['admin_messages']['redirect'] = "";
|
103 |
+
$params_output_array["general"]['admin_messages']['other'] = "";
|
104 |
+
$params_output_array["general"]['errors']['wpfilebase'] = "";
|
105 |
+
$params_output_array["general"]['errors']['notify'] = "";
|
106 |
+
$params_output_array["general"]['errors']['redirect'] = "";
|
107 |
+
$params_output_array["general"]['color'] = "black";
|
108 |
+
$params_output_array["general"]['bgcolor'] = "#F5F5F5";
|
109 |
+
$params_output_array["general"]['borcolor'] = "#D3D3D3";
|
110 |
+
$params_output_array["general"]['notify_by_email'] = 0;
|
111 |
+
$params_output_array["general"]['fail_message'] = WFU_ERROR_UNKNOWN;
|
112 |
+
|
113 |
+
//retrieve userdata, first get default userdata from $params
|
114 |
+
$userdata_fields = $params["userdata_fields"];
|
115 |
+
//remove any honeypot fields and initialize default values
|
116 |
+
foreach ( $userdata_fields as $userdata_key => $userdata_field )
|
117 |
+
if ( $userdata_field["type"] == "honeypot" ) unset($userdata_fields[$userdata_key]);
|
118 |
+
else $userdata_fields[$userdata_key]["value"] = "";
|
119 |
+
//then retrieve userdata from session if files exist
|
120 |
+
if ( $all_files_count > 0 && WFU_USVAR_exists("filedata_".$uniqueid) && is_array(WFU_USVAR("filedata_".$uniqueid)) ) {
|
121 |
+
foreach ( WFU_USVAR("filedata_".$uniqueid) as $file ) {
|
122 |
+
if ( isset($file["user_data"]) ) {
|
123 |
+
$userdata_fields = array();
|
124 |
+
foreach ( $file["user_data"] as $userdata_key => $userdata_field )
|
125 |
+
$userdata_fields[$userdata_key] = array( "label" => $userdata_field["label"], "value" => $userdata_field["value"] );
|
126 |
+
break;
|
127 |
+
}
|
128 |
+
}
|
129 |
+
}
|
130 |
+
//in case there are no files in session (because allownofile attribute is
|
131 |
+
//active and the user did not select any files for upload) then retrieve
|
132 |
+
//userdata from the database based on uploadid
|
133 |
+
else {
|
134 |
+
$userdata_saved = wfu_get_userdata_from_uploadid($uniqueid);
|
135 |
+
if ( $userdata_saved != null && is_array($userdata_saved) ) {
|
136 |
+
$userdata_fields = array();
|
137 |
+
foreach ( $userdata_saved as $userdata_saved_rec )
|
138 |
+
$userdata_fields[$userdata_saved_rec->propkey] = array( "label" => $userdata_saved_rec->property, "value" => $userdata_saved_rec->propvalue );
|
139 |
+
}
|
140 |
+
}
|
141 |
+
|
142 |
+
$send_error = wfu_send_notification_email($user, $target_path_list, $userdata_fields, $params);
|
143 |
+
|
144 |
+
/* suppress any errors if user is not admin */
|
145 |
+
if ( !$is_admin ) $send_error = "";
|
146 |
+
|
147 |
+
if ( $send_error != "" ) {
|
148 |
+
$params_output_array["general"]['admin_messages']['notify'] = $send_error;
|
149 |
+
$params_output_array["general"]['errors']['notify'] = "error";
|
150 |
+
}
|
151 |
+
|
152 |
+
/* construct safe output */
|
153 |
+
$sout = "0;".WFU_VAR("WFU_DEFAULTMESSAGECOLORS").";0";
|
154 |
+
|
155 |
+
$echo_str = "wfu_fileupload_success::".$sout.":".wfu_encode_array_to_string($params_output_array);
|
156 |
+
/**
|
157 |
+
* Customise Email Notification Result.
|
158 |
+
*
|
159 |
+
* This filter allows scripts to customise the result of email notification
|
160 |
+
* operation.
|
161 |
+
*
|
162 |
+
* @since 4.0.0
|
163 |
+
*
|
164 |
+
* @param string $echo_str The result of email notification operation.
|
165 |
+
*/
|
166 |
+
$echo_str = apply_filters('_wfu_ajax_action_send_email_notification', $echo_str);
|
167 |
+
|
168 |
+
die($echo_str);
|
169 |
+
}
|
170 |
+
|
171 |
+
/**
|
172 |
+
* Execute Pre-Upload Actions
|
173 |
+
*
|
174 |
+
* This function executes server-side actions before the upload starts, in order
|
175 |
+
* to determine whether the upload will continue, or any other custom actions.
|
176 |
+
*
|
177 |
+
* @since 3.7.0
|
178 |
+
*/
|
179 |
+
function wfu_ajax_action_ask_server() {
|
180 |
+
if ( !isset($_REQUEST['session_token']) || !isset($_REQUEST['sid']) || !isset($_REQUEST['unique_id']) ) die();
|
181 |
+
|
182 |
+
$_REQUEST = stripslashes_deep($_REQUEST);
|
183 |
+
|
184 |
+
$session_token = sanitize_text_field( $_REQUEST["session_token"] );
|
185 |
+
$sid = sanitize_text_field( $_REQUEST["sid"] );
|
186 |
+
$unique_id = wfu_sanitize_code($_REQUEST['unique_id']);
|
187 |
+
if ( $session_token == "" ) die();
|
188 |
+
//check referrer using Wordpress nonces and server sessions to avoid CSRF attacks
|
189 |
+
check_ajax_referer( 'wfu-uploader-nonce', 'wfu_uploader_nonce' );
|
190 |
+
if ( WFU_USVAR("wfu_token_".$sid) != $session_token ) die();
|
191 |
+
|
192 |
+
//prepare parameters for before-upload filters
|
193 |
+
$ret = array( "status" => "", "echo" => "" );
|
194 |
+
//retrieve file names and sizes from request parameters
|
195 |
+
$filenames_raw = ( isset($_REQUEST['filenames']) ? $_REQUEST['filenames'] : "" );
|
196 |
+
$filenames = array();
|
197 |
+
if ( trim($filenames_raw) != "" ) $filenames = explode(";", $filenames_raw);
|
198 |
+
//use wfu_basename() function in order to avoid directory traversal attacks
|
199 |
+
foreach ( $filenames as $ind => $filename ) $filenames[$ind] = wfu_basename(esc_attr(wfu_plugin_decode_string(trim($filename))));
|
200 |
+
$filesizes_raw = ( isset($_REQUEST['filesizes']) ? $_REQUEST['filesizes'] : "" );
|
201 |
+
$filesizes = array();
|
202 |
+
if ( trim($filesizes_raw) != "" ) $filesizes = explode(";", $filesizes_raw);
|
203 |
+
foreach ( $filesizes as $ind => $filesize ) $filesizes[$ind] = wfu_sanitize_int($filesize);
|
204 |
+
$files = array();
|
205 |
+
foreach ( $filenames as $ind => $filename ) {
|
206 |
+
$filesize = "";
|
207 |
+
if ( isset($filesizes[$ind]) ) $filesize = $filesizes[$ind];
|
208 |
+
array_push($files, array( "filename" => $filename, "filesize" => $filesize ));
|
209 |
+
}
|
210 |
+
$attr = array( "sid" => $sid, "unique_id" => $unique_id, "files" => $files );
|
211 |
+
//execute before upload filters
|
212 |
+
$echo_str = "";
|
213 |
+
//first execute any custom filters created by admin
|
214 |
+
if ( has_filter("wfu_before_upload") ) {
|
215 |
+
$changable_data = array( "error_message" => "", "js_script" => "" );
|
216 |
+
/**
|
217 |
+
* Execute Custom Actions Before Upload Starts.
|
218 |
+
*
|
219 |
+
* This filter allows to execute custom actions before upload starts. It
|
220 |
+
* can cancel the upload returning an error message.
|
221 |
+
*
|
222 |
+
* @since 3.7.0
|
223 |
+
*
|
224 |
+
* @param array $changable_data {
|
225 |
+
* Controls the upload.
|
226 |
+
*
|
227 |
+
* @type string $error_message An error message to display if the
|
228 |
+
* upload must be cancelled.
|
229 |
+
* @type string $js_script Javascript code to execute on user's
|
230 |
+
* browser after this filter finishes.
|
231 |
+
* }
|
232 |
+
* @param array $attr {
|
233 |
+
* Various attributes of the upload.
|
234 |
+
*
|
235 |
+
* @type string $sid The ID of the shortcode.
|
236 |
+
* @type string $unique_id The unique ID of the upload.
|
237 |
+
* @type array $files {
|
238 |
+
* Contains an array of the uploaded files.
|
239 |
+
*
|
240 |
+
* @type array $file {
|
241 |
+
* Contains information for each uploaded file.
|
242 |
+
*
|
243 |
+
* @type string $filename The filename of the file.
|
244 |
+
* @type int $filesize The size of the file.
|
245 |
+
* }
|
246 |
+
* }
|
247 |
+
* }
|
248 |
+
*/
|
249 |
+
$changable_data = apply_filters("wfu_before_upload", $changable_data, $attr);
|
250 |
+
if ( $changable_data["error_message"] == "" ) $ret["status"] = "success";
|
251 |
+
else {
|
252 |
+
$ret["status"] = "error";
|
253 |
+
$echo_str .= "CBUV[".$changable_data["error_message"]."]";
|
254 |
+
}
|
255 |
+
if ( $changable_data["js_script"] != "" ) $echo_str .= "CBUVJS[".wfu_plugin_encode_string($changable_data["js_script"])."]";
|
256 |
+
}
|
257 |
+
/**
|
258 |
+
* Execute Custom Internal Actions Before Upload Starts.
|
259 |
+
*
|
260 |
+
* This filter allows to execute custom internal actions by extensions
|
261 |
+
* before upload starts. It can cancel the upload.
|
262 |
+
*
|
263 |
+
* @since 3.7.0
|
264 |
+
*
|
265 |
+
* @param array $ret {
|
266 |
+
* Controls the upload and output of this function.
|
267 |
+
*
|
268 |
+
* @type string $status The status of the upload. It must be 'success'
|
269 |
+
* or 'error'.
|
270 |
+
* @type string $echo Additional content to the echoed by the function.
|
271 |
+
* }
|
272 |
+
* @param array $attr {
|
273 |
+
* Various attributes of the upload.
|
274 |
+
*
|
275 |
+
* @type string $sid The ID of the shortcode.
|
276 |
+
* @type string $unique_id The unique ID of the upload.
|
277 |
+
* @type array $files {
|
278 |
+
* Contains an array of the uploaded files.
|
279 |
+
*
|
280 |
+
* @type array $file {
|
281 |
+
* Contains information for each uploaded file.
|
282 |
+
*
|
283 |
+
* @type string $filename The filename of the file.
|
284 |
+
* @type int $filesize The size of the file.
|
285 |
+
* }
|
286 |
+
* }
|
287 |
+
* }
|
288 |
+
*/
|
289 |
+
$ret = apply_filters("_wfu_before_upload", $ret, $attr);
|
290 |
+
$echo_str .= $ret["echo"];
|
291 |
+
//in case that no filters were executed, because $ret["status"] is
|
292 |
+
//empty, then this call to wfu_ajax_action_ask_server was erroneous
|
293 |
+
if ( $ret["status"] == "" ) $ret["status"] = "die";
|
294 |
+
//create an internal flag stored in session regarding the status of this
|
295 |
+
//upload, that will be used to verify or not the upload
|
296 |
+
if ( $ret["status"] == "success" ) WFU_USVAR_store("wfu_uploadstatus_".$attr["unique_id"], 1);
|
297 |
+
else WFU_USVAR_store("wfu_uploadstatus_".$attr["unique_id"], 0);
|
298 |
+
|
299 |
+
if ( $ret["status"] == "success" || $ret["status"] == "error" )
|
300 |
+
echo "wfu_askserver_".$ret["status"].":".$echo_str;
|
301 |
+
|
302 |
+
die();
|
303 |
+
}
|
304 |
+
|
305 |
+
/**
|
306 |
+
* Execute Cancellation of Classic Upload
|
307 |
+
*
|
308 |
+
* This function sets the necessary User State variables to denote cancellation
|
309 |
+
* of the upload that was requested by the user. This function applies only to
|
310 |
+
* classic (non-AJAX) uploads.
|
311 |
+
*
|
312 |
+
* @since 4.0.0
|
313 |
+
*/
|
314 |
+
function wfu_ajax_action_cancel_upload() {
|
315 |
+
if ( !isset($_REQUEST['session_token']) || !isset($_REQUEST['sid']) || !isset($_REQUEST['unique_id']) ) die();
|
316 |
+
|
317 |
+
$_REQUEST = stripslashes_deep($_REQUEST);
|
318 |
+
|
319 |
+
$session_token = sanitize_text_field( $_REQUEST["session_token"] );
|
320 |
+
$sid = sanitize_text_field( $_REQUEST["sid"] );
|
321 |
+
$unique_id = wfu_sanitize_code($_REQUEST['unique_id']);
|
322 |
+
if ( $session_token == "" ) die();
|
323 |
+
//check referrer using Wordpress nonces and server sessions to avoid CSRF attacks
|
324 |
+
check_ajax_referer( 'wfu-uploader-nonce', 'wfu_uploader_nonce' );
|
325 |
+
if ( WFU_USVAR("wfu_token_".$sid) != $session_token ) die();
|
326 |
+
|
327 |
+
//setting status to 0 denotes cancelling of the upload
|
328 |
+
WFU_USVAR_store("wfu_uploadstatus_".$unique_id, 0);
|
329 |
+
|
330 |
+
die("success");
|
331 |
+
}
|
332 |
+
|
333 |
+
/**
|
334 |
+
* Execute AJAX Upload
|
335 |
+
*
|
336 |
+
* This function is the main callback of an AJAX upload of a whole file or a
|
337 |
+
* chunk. It performs security checks to verify the user, then it performs pre-
|
338 |
+
* upload actions, then it executes wfu_process_files() function that processes
|
339 |
+
* and saves the files and then performs post-upload actions and filters.
|
340 |
+
*
|
341 |
+
* @since 2.1.2
|
342 |
+
*
|
343 |
+
* @global string $wfu_user_state_handler The defined User State handler.
|
344 |
+
*/
|
345 |
+
function wfu_ajax_action_callback() {
|
346 |
+
global $wfu_user_state_handler;
|
347 |
+
if ( !isset($_REQUEST['session_token']) ) die();
|
348 |
+
|
349 |
+
$_REQUEST = stripslashes_deep($_REQUEST);
|
350 |
+
$_POST = stripslashes_deep($_POST);
|
351 |
+
|
352 |
+
$session_token = sanitize_text_field( $_REQUEST["session_token"] );
|
353 |
+
if ( $session_token == "" ) die();
|
354 |
+
check_ajax_referer( 'wfu-uploader-nonce', 'wfu_uploader_nonce' );
|
355 |
+
|
356 |
+
if ( !isset($_REQUEST['params_index']) ) die();
|
357 |
+
|
358 |
+
$params_index = sanitize_text_field( $_REQUEST["params_index"] );
|
359 |
+
|
360 |
+
if ( $params_index == "" ) die();
|
361 |
+
|
362 |
+
$user = wp_get_current_user();
|
363 |
+
$arr = wfu_get_params_fields_from_index($params_index, $session_token);
|
364 |
+
$sid = $arr['shortcode_id'];
|
365 |
+
//check referrer using server sessions to avoid CSRF attacks
|
366 |
+
if ( WFU_USVAR("wfu_token_".$sid) != $session_token ) {
|
367 |
+
$echo_str = "Session failed!<br/><br/>Session Data:<br/>";
|
368 |
+
$echo_str .= print_r(wfu_sanitize(WFU_USALL()), true);
|
369 |
+
$echo_str .= "<br/><br/>Post Data:<br/>";
|
370 |
+
$echo_str .= print_r(wfu_sanitize($_REQUEST), true);
|
371 |
+
$echo_str .= 'force_errorabort_code';
|
372 |
+
/**
|
373 |
+
* Customise Output on Session Error.
|
374 |
+
*
|
375 |
+
* This filter allows scripts to customise output of the function in
|
376 |
+
* case of session error.
|
377 |
+
*
|
378 |
+
* @since 3.11.0
|
379 |
+
*
|
380 |
+
* @param string $echo_str The output in case of session error.
|
381 |
+
*/
|
382 |
+
$echo_str = apply_filters('_wfu_upload_session_failed', $echo_str);
|
383 |
+
die($echo_str);
|
384 |
+
}
|
385 |
+
|
386 |
+
if ( $user->user_login != $arr['user_login'] ) {
|
387 |
+
$arr = wfu_get_params_fields_from_index($params_index.'[|][|]'.$arr['page_id'].'[|][|]'.$sid.'[|][|]'.$arr['user_login'], $session_token);
|
388 |
+
if ( $user->user_login != $arr['user_login'] ) {
|
389 |
+
$echo_str = "User failed!<br/><br/>User Data:<br/>";
|
390 |
+
$echo_str .= print_r(wfu_sanitize($user), true);
|
391 |
+
$echo_str .= "<br/><br/>Post Data:<br/>";
|
392 |
+
$echo_str .= print_r(wfu_sanitize($_REQUEST), true);
|
393 |
+
$echo_str .= "<br/><br/>Params Data:<br/>";
|
394 |
+
$echo_str .= print_r(wfu_sanitize($arr), true);
|
395 |
+
$echo_str .= 'force_errorabort_code';
|
396 |
+
/**
|
397 |
+
* Customise Output on User Error.
|
398 |
+
*
|
399 |
+
* This filter allows scripts to customise output of the function in
|
400 |
+
* case of user error.
|
401 |
+
*
|
402 |
+
* @since 3.11.0
|
403 |
+
*
|
404 |
+
* @param string $echo_str The output in case of user error.
|
405 |
+
*/
|
406 |
+
$echo_str = apply_filters('_wfu_upload_user_failed', $echo_str);
|
407 |
+
die($echo_str);
|
408 |
+
}
|
409 |
+
}
|
410 |
+
|
411 |
+
//if force_connection_close is set, then the first pass to this callback
|
412 |
+
//script is for closing the previous connection
|
413 |
+
if ( isset($_POST["force_connection_close"]) && $_POST["force_connection_close"] === "1" ) {
|
414 |
+
header("Connection: Close");
|
415 |
+
/**
|
416 |
+
* Customise Output on Forced Connection Close.
|
417 |
+
*
|
418 |
+
* This filter allows scripts to customise return of the function in
|
419 |
+
* case of forced connection close.
|
420 |
+
*
|
421 |
+
* @since 3.11.0
|
422 |
+
*
|
423 |
+
* @param string $echo_str The return in case of forced connection
|
424 |
+
* close.
|
425 |
+
*/
|
426 |
+
die(apply_filters('_wfu_upload_force_connection_close', 'success'));
|
427 |
+
}
|
428 |
+
|
429 |
+
//get the unique id of the upload
|
430 |
+
$unique_id = ( isset($_POST['uniqueuploadid_'.$sid]) ? sanitize_text_field($_POST['uniqueuploadid_'.$sid]) : "" );
|
431 |
+
if ( strlen($unique_id) != 10 ) {
|
432 |
+
/**
|
433 |
+
* Customise Output on Unique ID Fail.
|
434 |
+
*
|
435 |
+
* This filter allows scripts to customise return of the function in
|
436 |
+
* case that the retrieved unique ID is invalid.
|
437 |
+
*
|
438 |
+
* @since 3.11.0
|
439 |
+
*
|
440 |
+
* @param string $echo_str The return in case of unique ID fail.
|
441 |
+
*/
|
442 |
+
die(apply_filters('_wfu_upload_uniqueid_failed', 'force_errorabort_code'));
|
443 |
+
}
|
444 |
+
|
445 |
+
//if before upload actions have been executed and they have rejected the
|
446 |
+
//upload, but for some reason (hack attempt) the upload continued, then
|
447 |
+
//terminate it
|
448 |
+
if ( WFU_USVAR_exists("wfu_uploadstatus_".$unique_id) && WFU_USVAR("wfu_uploadstatus_".$unique_id) == 0 ) die('force_errorabort_code');
|
449 |
+
|
450 |
+
//get stored shortcode parameters
|
451 |
+
$params_str = get_option('wfu_params_'.$arr['unique_id']);
|
452 |
+
$params = wfu_decode_array_from_string($params_str);
|
453 |
+
/** This filter is documented above. */
|
454 |
+
$params = apply_filters("_wfu_get_params", $params, $arr, 'wfu_ajax_action_callback');
|
455 |
+
|
456 |
+
//if upload has finished then perform post upload actions
|
457 |
+
if ( isset($_POST["upload_finished"]) && $_POST["upload_finished"] === "1" ) {
|
458 |
+
//remove any queues that were generated during the upload process
|
459 |
+
wfu_remove_queue($unique_id);
|
460 |
+
$echo_str = "";
|
461 |
+
//execute after upload filters
|
462 |
+
$ret = wfu_execute_after_upload_filters($sid, $unique_id, $params);
|
463 |
+
if ( $ret["js_script"] != "" ) $echo_str = "CBUVJS[".wfu_plugin_encode_string($ret["js_script"])."]";
|
464 |
+
die($echo_str);
|
465 |
+
}
|
466 |
+
|
467 |
+
//check if honeypot userdata fields have been added to the form and if they
|
468 |
+
//contain any data; if wfu_check_remove_honeypot_fields returns true this
|
469 |
+
//means that at least one honeypot field has beed filled with a value and
|
470 |
+
//the upload must be aborted because it was not done by a human
|
471 |
+
if ( $params["userdata"] == "true" && wfu_check_remove_honeypot_fields($params["userdata_fields"], 'hiddeninput_'.$sid.'_userdata_') ) die("force_abortsuccess_code");
|
472 |
+
|
473 |
+
//apply filters to determine if the upload will continue or stop
|
474 |
+
$ret = array( "status" => "", "echo" => "" );
|
475 |
+
$attr = array( "sid" => $sid, "unique_id" => $unique_id, "params" => $params );
|
476 |
+
/**
|
477 |
+
* Execute Pre-Upload Checks.
|
478 |
+
*
|
479 |
+
* This is an internal filter which allows to execute custom actions right
|
480 |
+
* before an upload starts. It can cancel the upload.
|
481 |
+
*
|
482 |
+
* @since 3.7.0
|
483 |
+
*
|
484 |
+
* @param array $ret {
|
485 |
+
* Controls the Upload.
|
486 |
+
*
|
487 |
+
* @type string $status Status of the upload. If it is 'die' then the
|
488 |
+
* upload will be cancelled.
|
489 |
+
* @type string $echo A message to return in case of upload
|
490 |
+
* cancellation.
|
491 |
+
* }
|
492 |
+
* @param array $attr {
|
493 |
+
* Various attributes of the upload.
|
494 |
+
*
|
495 |
+
* @type string $sid The ID of the shortcode.
|
496 |
+
* @type string $unique_id The unique ID of the upload.
|
497 |
+
* @type array $params The shortcode parameters of the upload form.
|
498 |
+
*/
|
499 |
+
$ret = apply_filters("_wfu_pre_upload_check", $ret, $attr);
|
500 |
+
if ( $ret["status"] == "die" ) die($ret["echo"]);
|
501 |
+
|
502 |
+
//if this is the first pass of an upload attempt then perform pre-upload actions
|
503 |
+
if ( !WFU_USVAR_exists('wfu_upload_first_pass_'.$unique_id) || WFU_USVAR('wfu_upload_first_pass_'.$unique_id) != 'true' ) {
|
504 |
+
WFU_USVAR_store('wfu_upload_first_pass_'.$unique_id, 'true');
|
505 |
+
}
|
506 |
+
|
507 |
+
if ( !isset($_POST["subdir_sel_index"]) ) die();
|
508 |
+
$subdir_sel_index = sanitize_text_field( $_POST["subdir_sel_index"] );
|
509 |
+
$params['subdir_selection_index'] = $subdir_sel_index;
|
510 |
+
WFU_USVAR_store('wfu_check_refresh_'.$params["uploadid"], 'do not process');
|
511 |
+
|
512 |
+
//update consent status of user
|
513 |
+
$plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
|
514 |
+
$params["consent_result"] = wfu_check_user_consent($user);
|
515 |
+
$require_consent = ( $plugin_options["personaldata"] == "1" && ( $params["notrememberconsent"] == "true" || $params["consent_result"] == "" ) && $params["askconsent"] == "true" );
|
516 |
+
if ( $require_consent ) {
|
517 |
+
if ( !isset($_POST['consent_result']) ) die();
|
518 |
+
$consent_result = ( $_POST['consent_result'] == "yes" ? "yes" : ( $_POST['consent_result'] == "no" ? "no" : "" ) );
|
519 |
+
$params["consent_result"] = ( $_POST['consent_result'] == "yes" ? "1" : ( $_POST['consent_result'] == "no" ? "0" : "" ) );
|
520 |
+
wfu_update_user_consent($user, $consent_result);
|
521 |
+
}
|
522 |
+
|
523 |
+
if ( $wfu_user_state_handler == "dboption" )
|
524 |
+
$proc_ret = wfu_run_process_in_queue($unique_id, "wfu_process_files", array( $params, 'ajax' ));
|
525 |
+
else {
|
526 |
+
$proc_ret["result"] = true;
|
527 |
+
$proc_ret["output"] = wfu_process_files($params, 'ajax');
|
528 |
+
}
|
529 |
+
$echo_str = "";
|
530 |
+
if ( $proc_ret["result"] ) {
|
531 |
+
$wfu_process_file_array = $proc_ret["output"];
|
532 |
+
//extract safe_output from wfu_process_file_array and pass it as
|
533 |
+
//separate part of the response text
|
534 |
+
$safe_output = $wfu_process_file_array["general"]['safe_output'];
|
535 |
+
unset($wfu_process_file_array["general"]['safe_output']);
|
536 |
+
//get javascript code that has been defined in wfu_after_file_upload
|
537 |
+
//action
|
538 |
+
$js_script = wfu_plugin_encode_string($wfu_process_file_array["general"]['js_script']);
|
539 |
+
unset($wfu_process_file_array["general"]['js_script']);
|
540 |
+
|
541 |
+
$echo_str = "wfu_fileupload_success:".$js_script.":".$safe_output.":".wfu_encode_array_to_string($wfu_process_file_array);
|
542 |
+
}
|
543 |
+
elseif ( $proc_ret["error"] == "abort_thread" ) wfu_advance_queue($unique_id);
|
544 |
+
/**
|
545 |
+
* Customise Output of Successful AJAX Upload.
|
546 |
+
*
|
547 |
+
* This filter allows scripts to customise return of the function in case
|
548 |
+
* that the AJAX upload was successful.
|
549 |
+
*
|
550 |
+
* @since 3.11.0
|
551 |
+
*
|
552 |
+
* @param string $echo_str The return in case of successful AJAX upload.
|
553 |
+
*/
|
554 |
+
$echo_str = apply_filters('_wfu_upload_callback_success', $echo_str);
|
555 |
+
die($echo_str);
|
556 |
+
}
|
557 |
+
|
558 |
+
/**
|
559 |
+
* Execute Saving of Shortcode
|
560 |
+
*
|
561 |
+
* This function executes saving of a shortcode after it has been edited through
|
562 |
+
* the shortcode composer.
|
563 |
+
*
|
564 |
+
* @since 2.1.3
|
565 |
+
*/
|
566 |
+
function wfu_ajax_action_save_shortcode() {
|
567 |
+
$is_admin = current_user_can( 'manage_options' );
|
568 |
+
$can_open_composer = ( WFU_VAR("WFU_SHORTCODECOMPOSER_NOADMIN") == "true" && ( current_user_can( 'edit_pages' ) || current_user_can( 'edit_posts' ) ) );
|
569 |
+
if ( !$is_admin && !$can_open_composer ) die();
|
570 |
+
if ( !isset($_POST['shortcode']) || !isset($_POST['shortcode_original']) || !isset($_POST['post_id']) || !isset($_POST['post_hash']) || !isset($_POST['shortcode_position']) || !isset($_POST['shortcode_tag']) || !isset($_POST['widget_id']) ) die();
|
571 |
+
|
572 |
+
$_POST = stripslashes_deep($_POST);
|
573 |
+
|
574 |
+
//sanitize parameters
|
575 |
+
$shortcode = wfu_sanitize_code($_POST['shortcode']);
|
576 |
+
$shortcode_original = wfu_sanitize_code($_POST['shortcode_original']);
|
577 |
+
$post_id = wfu_sanitize_int($_POST['post_id']);
|
578 |
+
$post_hash = wfu_sanitize_code($_POST['post_hash']);
|
579 |
+
$shortcode_position = wfu_sanitize_int($_POST['shortcode_position']);
|
580 |
+
$shortcode_tag = wfu_sanitize_tag($_POST['shortcode_tag']);
|
581 |
+
$widget_id = sanitize_text_field($_POST['widget_id']);
|
582 |
+
|
583 |
+
$shortcode = wfu_sanitize_shortcode(wfu_plugin_decode_string($shortcode), $shortcode_tag);
|
584 |
+
|
585 |
+
if ( $post_id == "" && $widget_id == "" ) {
|
586 |
+
die();
|
587 |
+
}
|
588 |
+
else {
|
589 |
+
$data['post_id'] = $post_id;
|
590 |
+
$data['post_hash'] = $post_hash;
|
591 |
+
$data['shortcode'] = wfu_plugin_decode_string($shortcode_original);
|
592 |
+
$data['position'] = $shortcode_position;
|
593 |
+
if ( $post_id != "" && !wfu_check_edit_shortcode($data) ) $echo_str = "wfu_save_shortcode:fail:post_modified";
|
594 |
+
else {
|
595 |
+
if ( $widget_id == "" ) {
|
596 |
+
$new_shortcode = "[".$shortcode_tag." ".$shortcode."]";
|
597 |
+
if ( wfu_replace_shortcode($data, $new_shortcode) ) {
|
598 |
+
$post = get_post($post_id);
|
599 |
+
/** This filter is described in wfu_loader.php */
|
600 |
+
$content = apply_filters("_wfu_get_post_content", $post->post_content, $post);
|
601 |
+
$hash = hash('md5', $content);
|
602 |
+
$echo_str = "wfu_save_shortcode:success:".$hash;
|
603 |
+
}
|
604 |
+
else $echo_str = "wfu_save_shortcode:fail:post_update_failed";
|
605 |
+
}
|
606 |
+
else {
|
607 |
+
$widget_obj = wfu_get_widget_obj_from_id($widget_id);
|
608 |
+
if ( $widget_obj === false ) $echo_str = "wfu_save_shortcode:fail:post_update_failed";
|
609 |
+
else {
|
610 |
+
$widget_sidebar = is_active_widget(false, $widget_id, "wordpress_file_upload_widget");
|
611 |
+
if ( !$widget_sidebar ) $echo_str = "wfu_save_shortcode:fail:post_update_failed";
|
612 |
+
else {
|
613 |
+
$widget_obj->update_external($shortcode);
|
614 |
+
$hash = $data['post_hash'];
|
615 |
+
$echo_str = "wfu_save_shortcode:success:".$hash;
|
616 |
+
}
|
617 |
+
}
|
618 |
+
}
|
619 |
+
}
|
620 |
+
}
|
621 |
+
|
622 |
+
/**
|
623 |
+
* Customise Output on Shortcode Saving.
|
624 |
+
*
|
625 |
+
* This filter allows scripts to customise return of the function after
|
626 |
+
* finish of it.
|
627 |
+
*
|
628 |
+
* @since 3.11.0
|
629 |
+
*
|
630 |
+
* @param string $echo_str The return of the function.
|
631 |
+
*/
|
632 |
+
$echo_str = apply_filters('_wfu_ajax_action_save_shortcode', $echo_str);
|
633 |
+
die($echo_str);
|
634 |
+
}
|
635 |
+
|
636 |
+
/**
|
637 |
+
* Execute Checking of Post Contents
|
638 |
+
*
|
639 |
+
* This function executes checking of post contents to determine whether they
|
640 |
+
* are current or obsolete (they have changed).
|
641 |
+
*
|
642 |
+
* @since 2.6.0
|
643 |
+
*/
|
644 |
+
function wfu_ajax_action_check_page_contents() {
|
645 |
+
if ( !current_user_can( 'manage_options' ) ) die();
|
646 |
+
if ( !isset($_POST['post_id']) || !isset($_POST['post_hash']) ) die();
|
647 |
+
if ( $_POST['post_id'] == "" ) die();
|
648 |
+
|
649 |
+
$_POST = stripslashes_deep($_POST);
|
650 |
+
|
651 |
+
$data['post_id'] = wfu_sanitize_int($_POST['post_id']);
|
652 |
+
$data['post_hash'] = wfu_sanitize_code($_POST['post_hash']);
|
653 |
+
if ( wfu_check_edit_shortcode($data) ) $echo_str = "wfu_check_page_contents:current:";
|
654 |
+
else $echo_str = "wfu_check_page_contents:obsolete:";
|
655 |
+
|
656 |
+
/**
|
657 |
+
* Customise Output of Post Contents Checking Function.
|
658 |
+
*
|
659 |
+
* This filter allows scripts to customise return of this function after
|
660 |
+
* finish of it.
|
661 |
+
*
|
662 |
+
* @since 3.11.0
|
663 |
+
*
|
664 |
+
* @param string $echo_str The return of the function.
|
665 |
+
*/
|
666 |
+
$echo_str = apply_filters('_wfu_ajax_action_check_page_contents', $echo_str);
|
667 |
+
die($echo_str);
|
668 |
+
}
|
669 |
+
|
670 |
+
/**
|
671 |
+
* Initiate Editing of Shortcode
|
672 |
+
*
|
673 |
+
* This function invokes the shortcode composer in order to edit a shortcode. It
|
674 |
+
* applies when editing a shortcode from Main page of the plugin in Dashboard or
|
675 |
+
* from a front-end post or page or from a sidebar.
|
676 |
+
*
|
677 |
+
* @since 2.6.0
|
678 |
+
*/
|
679 |
+
function wfu_ajax_action_edit_shortcode() {
|
680 |
+
global $wp_registered_widgets;
|
681 |
+
global $wp_registered_sidebars;
|
682 |
+
|
683 |
+
$is_admin = current_user_can( 'manage_options' );
|
684 |
+
$can_open_composer = ( WFU_VAR("WFU_SHORTCODECOMPOSER_NOADMIN") == "true" && ( current_user_can( 'edit_pages' ) || current_user_can( 'edit_posts' ) ) );
|
685 |
+
if ( !$is_admin && !$can_open_composer ) die();
|
686 |
+
if ( !isset($_POST['upload_id']) || !isset($_POST['post_id']) || !isset($_POST['post_hash']) || !isset($_POST['shortcode_tag']) || !isset($_POST['widget_id']) ) die();
|
687 |
+
|
688 |
+
$_POST = stripslashes_deep($_POST);
|
689 |
+
|
690 |
+
//sanitize parameters
|
691 |
+
$upload_id = sanitize_text_field($_POST['upload_id']);
|
692 |
+
$widget_id = sanitize_text_field($_POST['widget_id']);
|
693 |
+
$post_id = wfu_sanitize_int($_POST['post_id']);
|
694 |
+
$post_hash = wfu_sanitize_code($_POST['post_hash']);
|
695 |
+
$shortcode_tag = wfu_sanitize_tag($_POST['shortcode_tag']);
|
696 |
+
|
697 |
+
$keyname = "uploadid";
|
698 |
+
if ( $shortcode_tag == "wordpress_file_upload_browser" ) $keyname = "browserid";
|
699 |
+
|
700 |
+
$data['post_id'] = $post_id;
|
701 |
+
$data['post_hash'] = $post_hash;
|
702 |
+
if ( wfu_check_edit_shortcode($data) ) {
|
703 |
+
if ( $widget_id == "" ) {
|
704 |
+
$post = get_post($data['post_id']);
|
705 |
+
//get default value for uploadid
|
706 |
+
if ( $shortcode_tag == "wordpress_file_upload_browser" ) $defs = wfu_browser_attribute_definitions();
|
707 |
+
else $defs = wfu_attribute_definitions();
|
708 |
+
$default = "";
|
709 |
+
foreach ( $defs as $key => $def ) {
|
710 |
+
if ( $def['attribute'] == $keyname ) {
|
711 |
+
$default = $def['value'];
|
712 |
+
break;
|
713 |
+
}
|
714 |
+
}
|
715 |
+
//get page shortcodes
|
716 |
+
$wfu_shortcodes = wfu_get_content_shortcodes($post, $shortcode_tag);
|
717 |
+
//find the shortcodes' uploadid and the correct one
|
718 |
+
$validkey = -1;
|
719 |
+
foreach ( $wfu_shortcodes as $key => $data ) {
|
720 |
+
$shortcode = trim(substr($data['shortcode'], strlen('['.$shortcode_tag), -1));
|
721 |
+
$shortcode_attrs = wfu_shortcode_string_to_array($shortcode);
|
722 |
+
if ( array_key_exists($keyname, $shortcode_attrs) ) $uploadid = $shortcode_attrs[$keyname];
|
723 |
+
else $uploadid = $default;
|
724 |
+
if ( $uploadid == $upload_id ) {
|
725 |
+
$validkey = $key;
|
726 |
+
break;
|
727 |
+
}
|
728 |
+
}
|
729 |
+
if ( $validkey == -1 ) die();
|
730 |
+
$data_enc = wfu_safe_store_shortcode_data(wfu_encode_array_to_string($wfu_shortcodes[$validkey]));
|
731 |
+
}
|
732 |
+
else {
|
733 |
+
$widget_obj = wfu_get_widget_obj_from_id($widget_id);
|
734 |
+
if ( $widget_obj === false ) die();
|
735 |
+
$widget_sidebar = is_active_widget(false, $widget_id, "wordpress_file_upload_widget");
|
736 |
+
if ( !$widget_sidebar ) die();
|
737 |
+
if ( isset($wp_registered_sidebars[$widget_sidebar]) && isset($wp_registered_sidebars[$widget_sidebar]['name']) ) $widget_sidebar = $wp_registered_sidebars[$widget_sidebar]['name'];
|
738 |
+
$data['shortcode'] = $widget_obj->shortcode();
|
739 |
+
$data['position'] = 0;
|
740 |
+
$data['widgetid'] = $widget_id;
|
741 |
+
$data['sidebar'] = $widget_sidebar;
|
742 |
+
$data_enc = wfu_safe_store_shortcode_data(wfu_encode_array_to_string($data));
|
743 |
+
}
|
744 |
+
if( $is_admin ) $url = site_url().'/wp-admin/options-general.php?page=wordpress_file_upload&tag='.$shortcode_tag.'&action=edit_shortcode&data='.$data_enc;
|
745 |
+
//conditional that will open the shortcode composer for non-admin users
|
746 |
+
//who can edit posts or pages
|
747 |
+
else $url = site_url().'/wp-admin/admin.php?page=wordpress_file_upload&tag='.$shortcode_tag.'&action=edit_shortcode&data='.$data_enc;
|
748 |
+
$echo_str = "wfu_edit_shortcode:success:".wfu_plugin_encode_string($url);
|
749 |
+
}
|
750 |
+
else $echo_str = "wfu_edit_shortcode:check_page_obsolete:".WFU_ERROR_PAGE_OBSOLETE;
|
751 |
+
|
752 |
+
/**
|
753 |
+
* Customise Output of Shortcode Editing Initiation Function.
|
754 |
+
*
|
755 |
+
* This filter allows scripts to customise return of this function after
|
756 |
+
* finish of it.
|
757 |
+
*
|
758 |
+
* @since 3.11.0
|
759 |
+
*
|
760 |
+
* @param string $echo_str The return of the function.
|
761 |
+
*/
|
762 |
+
$echo_str = apply_filters('_wfu_ajax_action_edit_shortcode', $echo_str);
|
763 |
+
die($echo_str);
|
764 |
+
}
|
765 |
+
|
766 |
+
/**
|
767 |
+
* Initiate Editing of Shortcode in Gutenberg Editor
|
768 |
+
*
|
769 |
+
* This function invokes the shortcode composer in order to edit a shortcode. It
|
770 |
+
* applies when editing a shortcode from the new Gutenberg page editor of
|
771 |
+
* Wordpress.
|
772 |
+
*
|
773 |
+
* @since 4.11.0
|
774 |
+
*/
|
775 |
+
function wfu_ajax_action_gutedit_shortcode() {
|
776 |
+
$is_admin = current_user_can( 'manage_options' );
|
777 |
+
$can_open_composer = ( WFU_VAR("WFU_SHORTCODECOMPOSER_NOADMIN") == "true" && ( current_user_can( 'edit_pages' ) || current_user_can( 'edit_posts' ) ) );
|
778 |
+
if ( !$is_admin && !$can_open_composer ) die();
|
779 |
+
if ( !isset($_POST['shortcode']) || !isset($_POST['post_id']) || !isset($_POST['shortcode_tag']) ) die();
|
780 |
+
|
781 |
+
$_POST = stripslashes_deep($_POST);
|
782 |
+
|
783 |
+
//sanitize parameters
|
784 |
+
$shortcode = wfu_sanitize_code($_POST['shortcode']);
|
785 |
+
$post_id = wfu_sanitize_int($_POST['post_id']);
|
786 |
+
$shortcode_tag = wfu_sanitize_tag($_POST['shortcode_tag']);
|
787 |
+
|
788 |
+
$shortcode = wfu_sanitize_shortcode(wfu_plugin_decode_string($shortcode), $shortcode_tag);
|
789 |
+
|
790 |
+
if ( $post_id == "" ) die();
|
791 |
+
|
792 |
+
$data['shortcode'] = '['.$shortcode_tag.' '.$shortcode.']';
|
793 |
+
$data['post_id'] = $post_id;
|
794 |
+
$data['post_hash'] = '';
|
795 |
+
$data['position'] = 0;
|
796 |
+
$data_enc = wfu_safe_store_shortcode_data(wfu_encode_array_to_string($data));
|
797 |
+
if ( $is_admin ) $url = site_url().'/wp-admin/options-general.php?page=wordpress_file_upload&tag='.$shortcode_tag.'&action=edit_shortcode&data='.$data_enc.'&referer=guteditor';
|
798 |
+
//conditional that will open the shortcode composer for non-admin users who
|
799 |
+
//can edit posts or pages
|
800 |
+
else $url = site_url().'/wp-admin/admin.php?page=wordpress_file_upload&tag='.$shortcode_tag.'&action=edit_shortcode&data='.$data_enc.'&referer=guteditor';
|
801 |
+
|
802 |
+
$echo_str = "wfu_gutedit_shortcode:success:".wfu_plugin_encode_string($url);
|
803 |
+
/**
|
804 |
+
* Customise Output of Gutenberg Shortcode Editing Initiation Function.
|
805 |
+
*
|
806 |
+
* This filter allows scripts to customise return of this function after
|
807 |
+
* finish of it.
|
808 |
+
*
|
809 |
+
* @since 4.11.0
|
810 |
+
*
|
811 |
+
* @param string $echo_str The return of the function.
|
812 |
+
*/
|
813 |
+
$echo_str = apply_filters('_wfu_ajax_action_gutedit_shortcode', $echo_str);
|
814 |
+
die($echo_str);
|
815 |
+
}
|
816 |
+
|
817 |
+
/**
|
818 |
+
* Retrieve Subfolder Structure of a Folder
|
819 |
+
*
|
820 |
+
* This function is used to retrieve the subfolder structure of a folder,
|
821 |
+
* together with the subfolder structure of one of the subfolders. It is used
|
822 |
+
* when defining the subfolders of the subfolders element of the upload form
|
823 |
+
* using the shortcoe composer.
|
824 |
+
*
|
825 |
+
* @since 2.4.1
|
826 |
+
*/
|
827 |
+
function wfu_ajax_action_read_subfolders() {
|
828 |
+
if ( !isset($_POST['folder1']) || !isset($_POST['folder2']) ) die();
|
829 |
+
|
830 |
+
$_POST = stripslashes_deep($_POST);
|
831 |
+
|
832 |
+
$folder1 = wfu_sanitize_code($_POST['folder1']);
|
833 |
+
$folder1 = wfu_sanitize_url(wfu_plugin_decode_string($folder1));
|
834 |
+
$folder2 = wfu_sanitize_code($_POST['folder2']);
|
835 |
+
$folder2 = wfu_sanitize_url(wfu_plugin_decode_string($folder2));
|
836 |
+
if ( wfu_plugin_encode_string($folder1) != $_POST['folder1'] || wfu_plugin_encode_string($folder2) != $_POST['folder2'] ) die();
|
837 |
+
|
838 |
+
$temp_params = array( 'uploadpath' => $folder1, 'accessmethod' => 'normal', 'ftpinfo' => '', 'useftpdomain' => 'false' );
|
839 |
+
$path = wfu_upload_plugin_full_path($temp_params);
|
840 |
+
|
841 |
+
if ( !is_dir($path) ) {
|
842 |
+
/**
|
843 |
+
* Customise Output of Shortcode Subfolder Structure Retrieval.
|
844 |
+
*
|
845 |
+
* This filter allows scripts to customise return of this function after
|
846 |
+
* finish of it.
|
847 |
+
*
|
848 |
+
* @since 3.11.0
|
849 |
+
*
|
850 |
+
* @param string $echo_str The return of the function.
|
851 |
+
*/
|
852 |
+
die(apply_filters('_wfu_ajax_action_read_subfolders', 'wfu_read_subfolders:error:Parent folder is not valid! Cannot retrieve subfolder list.'));
|
853 |
+
}
|
854 |
+
|
855 |
+
$path2 = $folder2;
|
856 |
+
$dirlist = "";
|
857 |
+
if ( $handle = opendir($path) ) {
|
858 |
+
$blacklist = array('.', '..');
|
859 |
+
while ( false !== ($file = readdir($handle)) )
|
860 |
+
if ( !in_array($file, $blacklist) ) {
|
861 |
+
$filepath = $path.$file;
|
862 |
+
if ( is_dir($filepath) ) {
|
863 |
+
if ( $file == $path2 ) $file = '[['.$file.']]';
|
864 |
+
$dirlist .= ( $dirlist == "" ? "" : "," ).$file;
|
865 |
+
}
|
866 |
+
}
|
867 |
+
closedir($handle);
|
868 |
+
}
|
869 |
+
if ( $path2 != "" ) {
|
870 |
+
$dirlist2 = $path2;
|
871 |
+
$path .= $path2."/";
|
872 |
+
if ( is_dir($path) ) {
|
873 |
+
if ( $handle = opendir($path) ) {
|
874 |
+
$blacklist = array('.', '..');
|
875 |
+
while ( false !== ($file = readdir($handle)) )
|
876 |
+
if ( !in_array($file, $blacklist) ) {
|
877 |
+
$filepath = $path.$file;
|
878 |
+
if ( is_dir($filepath) )
|
879 |
+
$dirlist2 .= ",*".$file;
|
880 |
+
}
|
881 |
+
closedir($handle);
|
882 |
+
}
|
883 |
+
}
|
884 |
+
$dirlist = str_replace('[['.$path2.']]', $dirlist2, $dirlist);
|
885 |
+
}
|
886 |
+
|
887 |
+
/** This filter is documnted above. */
|
888 |
+
die(apply_filters('_wfu_ajax_action_read_subfolders', "wfu_read_subfolders:success:".wfu_plugin_encode_string($dirlist)));
|
889 |
+
}
|
890 |
+
|
891 |
+
/**
|
892 |
+
* Initiate a File Download
|
893 |
+
*
|
894 |
+
* This function initiates a file download. It will first check whether the user
|
895 |
+
* has the right to download the file. Then it will return an iframe element
|
896 |
+
* that will start the download. Short life tokens are used in order to avoid
|
897 |
+
* CSRF attacks. Download is executed outside Wordpress enviroment because some
|
898 |
+
* times Wordpress environment outputs warnings that are downloaded with the
|
899 |
+
* file, resulting in a broken download.
|
900 |
+
*
|
901 |
+
* @since 2.6.0
|
902 |
+
*/
|
903 |
+
function wfu_ajax_action_download_file_invoker() {
|
904 |
+
global $wfu_user_state_handler;
|
905 |
+
|
906 |
+
$_POST = stripslashes_deep($_POST);
|
907 |
+
$_GET = stripslashes_deep($_GET);
|
908 |
+
|
909 |
+
$file_code = (isset($_POST['file']) ? $_POST['file'] : (isset($_GET['file']) ? $_GET['file'] : ''));
|
910 |
+
$nonce = (isset($_POST['nonce']) ? $_POST['nonce'] : (isset($_GET['nonce']) ? $_GET['nonce'] : ''));
|
911 |
+
if ( $file_code == '' || $nonce == '' ) die();
|
912 |
+
|
913 |
+
//security check to avoid CSRF attacks
|
914 |
+
if ( !wp_verify_nonce($nonce, 'wfu_download_file_invoker') ) die();
|
915 |
+
|
916 |
+
//check if user is allowed to download files
|
917 |
+
if ( !current_user_can( 'manage_options' ) ) {
|
918 |
+
die();
|
919 |
+
}
|
920 |
+
|
921 |
+
$cookies = array();
|
922 |
+
$use_cookies = ( $wfu_user_state_handler == "dboption" && WFU_VAR("WFU_US_DBOPTION_BASE") == "cookies" );
|
923 |
+
$file_code = sanitize_text_field($file_code);
|
924 |
+
//if file_code is exportdata, then export of data has been requested and
|
925 |
+
//we need to create a file with export data and recreate file_code
|
926 |
+
if ( substr($file_code, 0, 10) == "exportdata" && current_user_can( 'manage_options' ) ) {
|
927 |
+
$params = null;
|
928 |
+
$params_str = substr($file_code, 11);
|
929 |
+
if ( trim($params_str) != "" ) $params = json_decode($params_str, true);
|
930 |
+
$filepath = wfu_export_uploaded_files($params);
|
931 |
+
if ( $filepath === false ) die();
|
932 |
+
$file_code = "exportdata".wfu_safe_store_filepath($filepath);
|
933 |
+
//store filepath in user state otherwise it can not be retrieved by
|
934 |
+
//downloader script
|
935 |
+
if ( !$use_cookies ) WFU_USVAR_store_session('wfu_storage_'.substr($file_code, 10), $filepath);
|
936 |
+
else array_push($cookies, '{name: "wfu_storage_'.substr($file_code, 10).'", value: "'.$filepath.'", expires: 30}');
|
937 |
+
}
|
938 |
+
//else get the file path from the safe
|
939 |
+
else {
|
940 |
+
$filepath = wfu_get_filepath_from_safe($file_code);
|
941 |
+
if ( $filepath === false ) die();
|
942 |
+
$filepath = wfu_path_rel2abs(wfu_flatten_path($filepath));
|
943 |
+
//reject download of blacklisted file types for security reasons
|
944 |
+
if ( wfu_file_extension_blacklisted($filepath) ) {
|
945 |
+
/**
|
946 |
+
* Customise Output of Download Initiation Operation.
|
947 |
+
*
|
948 |
+
* This filter allows scripts to customise return of this function
|
949 |
+
* after finish of it.
|
950 |
+
*
|
951 |
+
* @since 3.11.0
|
952 |
+
*
|
953 |
+
* @param string $echo_str The return of the function.
|
954 |
+
*/
|
955 |
+
die(apply_filters('_wfu_ajax_action_download_file_invoker', 'wfu_ajax_action_download_file_invoker:not_allowed:'.( isset($_POST['browser']) ? WFU_BROWSER_DOWNLOADFILE_NOTALLOWED : 'You are not allowed to download this file!' )));
|
956 |
+
}
|
957 |
+
//for front-end browser apply wfu_browser_check_file_action filter to
|
958 |
+
//allow or restrict the download
|
959 |
+
if ( isset($_POST['browser']) ) {
|
960 |
+
$changable_data["error_message"] = "";
|
961 |
+
$filerec = wfu_get_file_rec($filepath, true);
|
962 |
+
$userdata = array();
|
963 |
+
foreach ( $filerec->userdata as $data )
|
964 |
+
array_push($userdata, array( "label" => $data->property, "value" => $data->propvalue ));
|
965 |
+
$additional_data = array(
|
966 |
+
"file_action" => "download",
|
967 |
+
"filepath" => $filepath,
|
968 |
+
"uploaduser" => $filerec->uploaduserid,
|
969 |
+
"userdata" => $userdata
|
970 |
+
);
|
971 |
+
/**
|
972 |
+
* Check if Action is Allowed in Front-End File Browser.
|
973 |
+
*
|
974 |
+
* This filter allows scripts to check whether the action on a file
|
975 |
+
* from the front-end file browser is allowed.
|
976 |
+
*
|
977 |
+
* @since 3.7.2
|
978 |
+
*
|
979 |
+
* @param array $changable_data {
|
980 |
+
* Controls allowance or rejection of the action.
|
981 |
+
*
|
982 |
+
* @type string $error_message An error message to return in
|
983 |
+
* case the action must be rejected.
|
984 |
+
* }
|
985 |
+
* @param array $additional_data {
|
986 |
+
* Additional data of the file action operation.
|
987 |
+
*
|
988 |
+
* @type string $file_action The performed action.
|
989 |
+
* @type string $filepath The full path of the file.
|
990 |
+
* @type string $uploaduser The ID of the user who uploaded
|
991 |
+
* the file.
|
992 |
+
* @type array $userdata Each item of the array contains the
|
993 |
+
* label and value of any additional userdata exist
|
994 |
+
* together with the file.
|
995 |
+
* }
|
996 |
+
*/
|
997 |
+
$changable_data = apply_filters("wfu_browser_check_file_action", $changable_data, $additional_data);
|
998 |
+
if ( $changable_data["error_message"] != "" )
|
999 |
+
/** This filter is documented above. */
|
1000 |
+
die(apply_filters('_wfu_ajax_action_download_file_invoker', 'wfu_ajax_action_download_file_invoker:not_allowed:'.$changable_data["error_message"]));
|
1001 |
+
}
|
1002 |
+
//for back-end browser check if user is allowed to perform this action
|
1003 |
+
//on this file
|
1004 |
+
if ( !wfu_current_user_owes_file($filepath) ) die();
|
1005 |
+
//store filepath in user state otherwise it can not be retrieved by
|
1006 |
+
//downloader script
|
1007 |
+
if ( !$use_cookies ) WFU_USVAR_store_session('wfu_storage_'.$file_code, wfu_get_filepath_from_safe($file_code));
|
1008 |
+
else array_push($cookies, '{name: "wfu_storage_'.$file_code.'", value: "'.wfu_get_filepath_from_safe($file_code).'", expires: 30}');
|
1009 |
+
}
|
1010 |
+
|
1011 |
+
//generate download unique id to monitor this download
|
1012 |
+
$download_id = wfu_create_random_string(16);
|
1013 |
+
//store download status of this download in user state, so that it can be
|
1014 |
+
//changed by downloader script; it is noted that the downloader script
|
1015 |
+
//does not load WP environment, so in case of dboption it cannot access the
|
1016 |
+
//download status (which is stored in the database); however the downloader
|
1017 |
+
//script does not need to read it; it only needs to change it after the
|
1018 |
+
//download; so after the download, the downloader script loads WP
|
1019 |
+
//environment, so that it can change download status
|
1020 |
+
WFU_USVAR_store('wfu_download_status_'.$download_id, 'starting');
|
1021 |
+
//generate download ticket which expires in 30sec and store it in user
|
1022 |
+
//state; it will be used as security measure for the downloader script,
|
1023 |
+
//which runs outside Wordpress environment; it is noted that the downloader
|
1024 |
+
//script needs to read download ticket before the download; however in the
|
1025 |
+
//case of dboption the only way to achieve this is to store it in a cookie
|
1026 |
+
if ( !$use_cookies ) WFU_USVAR_store_session('wfu_download_ticket_'.$download_id, time() + 30);
|
1027 |
+
else array_push($cookies, '{name: "wfu_download_ticket_'.$download_id.'", value: '.(time() + 30).', expires: 30}');
|
1028 |
+
//generate download monitor ticket which expires in 30sec and store it in
|
1029 |
+
//user state; it will be used as security measure for the monitor script
|
1030 |
+
//that will check download status; it is noted that there is no reason to
|
1031 |
+
//store download monitor ticket in a cookie in case of dboption, because it
|
1032 |
+
//is not needed to be read by the downloader script
|
1033 |
+
WFU_USVAR_store('wfu_download_monitor_ticket_'.$download_id, time() + 30);
|
1034 |
+
|
1035 |
+
//store ABSPATH in user state so that it can be used by download script;
|
1036 |
+
//again, in case of dboption, the only way the downloader script can read it
|
1037 |
+
//is to store it in a cookie
|
1038 |
+
if ( !$use_cookies ) WFU_USVAR_store_session('wfu_ABSPATH', wfu_abspath());
|
1039 |
+
else array_push($cookies, '{name: "wfu_ABSPATH", value: "'.urlencode(wfu_abspath()).'", expires: 30}');
|
1040 |
+
//store translatable strings to user state so that they can be used by a
|
1041 |
+
//script that runs outside Wordpress environment
|
1042 |
+
if ( !$use_cookies ) WFU_USVAR_store_session('wfu_browser_downloadfile_notexist', ( isset($_POST['browser']) ? WFU_BROWSER_DOWNLOADFILE_NOTEXIST : 'File does not exist!' ));
|
1043 |
+
else array_push($cookies, '{name: "wfu_browser_downloadfile_notexist", value: "'.( isset($_POST['browser']) ? WFU_BROWSER_DOWNLOADFILE_NOTEXIST : 'File does not exist!' ).'", expires: 30}');
|
1044 |
+
if ( !$use_cookies ) WFU_USVAR_store_session('wfu_browser_downloadfile_failed', ( isset($_POST['browser']) ? WFU_BROWSER_DOWNLOADFILE_FAILED : 'Could not download file!' ));
|
1045 |
+
else array_push($cookies, '{name: "wfu_browser_downloadfile_failed", value: "'.( isset($_POST['browser']) ? WFU_BROWSER_DOWNLOADFILE_FAILED : 'Could not download file!' ).'", expires: 30}');
|
1046 |
+
|
1047 |
+
//this routine returns a dynamically created iframe element, that will call
|
1048 |
+
//the actual download script; the actual download script runs outside
|
1049 |
+
//Wordpress environment in order to ensure that no php warnings or echo from
|
1050 |
+
//other plugins is generated, that could scramble the downloaded file; a
|
1051 |
+
//ticket, similar to nonces, is passed to the download script to check that
|
1052 |
+
//it is not a CSRF attack; moreover,the ticket is destroyed by the time it
|
1053 |
+
//is consumed by the download script, so it cannot be used again
|
1054 |
+
$urlparams = 'file='.$file_code.'&ticket='.$download_id.'&handler='.$wfu_user_state_handler.'&session_legacy='.( WFU_VAR("WFU_US_SESSION_LEGACY") == "true" ? '1' : '0' ).'&dboption_base='.WFU_VAR("WFU_US_DBOPTION_BASE").'&dboption_useold='.( WFU_VAR("WFU_US_DBOPTION_USEOLD") == "true" ? '1' : '0' ).'&wfu_cookie='.WPFILEUPLOAD_COOKIE;
|
1055 |
+
$response["html"] = '<iframe src="'.WFU_DOWNLOADER_URL.'?'.$urlparams.'" style="display: none;"></iframe>';
|
1056 |
+
//if user state handler is set to dboption (cookies), then tickets and other
|
1057 |
+
//variables must pass to the download script as cookies; the cookies are
|
1058 |
+
//passed in the response of this function, so that the client browser can
|
1059 |
+
//add them in cookies by executing wfu_add_cookies() function
|
1060 |
+
$response["js"] = ( count($cookies) > 0 ? 'wfu_add_cookies(['.implode(", ", $cookies).']);' : '' );
|
1061 |
+
$response = wfu_encode_array_to_string($response);
|
1062 |
+
|
1063 |
+
/** This filter is documented above. */
|
1064 |
+
die(apply_filters('_wfu_ajax_action_download_file_invoker', 'wfu_ajax_action_download_file_invoker:wfu_download_id;'.$download_id.':'.$response));
|
1065 |
+
}
|
1066 |
+
|
1067 |
+
/**
|
1068 |
+
* Monitor a File Download
|
1069 |
+
*
|
1070 |
+
* This function monitors a file download and performs post-download actions in
|
1071 |
+
* case the download has ended.
|
1072 |
+
*
|
1073 |
+
* @since 2.6.0
|
1074 |
+
*/
|
1075 |
+
function wfu_ajax_action_download_file_monitor() {
|
1076 |
+
$_POST = stripslashes_deep($_POST);
|
1077 |
+
$_GET = stripslashes_deep($_GET);
|
1078 |
+
|
1079 |
+
$file_code = (isset($_POST['file']) ? $_POST['file'] : (isset($_GET['file']) ? $_GET['file'] : ''));
|
1080 |
+
$id = (isset($_POST['id']) ? $_POST['id'] : (isset($_GET['id']) ? $_GET['id'] : ''));
|
1081 |
+
if ( $file_code == '' || $id == '' ) die();
|
1082 |
+
$id = wfu_sanitize_code($id);
|
1083 |
+
|
1084 |
+
//ensure that this is not a CSRF attack by checking validity of a security
|
1085 |
+
//ticket
|
1086 |
+
if ( !WFU_USVAR_exists('wfu_download_monitor_ticket_'.$id) || time() > WFU_USVAR('wfu_download_monitor_ticket_'.$id) ) {
|
1087 |
+
WFU_USVAR_unset('wfu_download_monitor_ticket_'.$id);
|
1088 |
+
WFU_USVAR_unset('wfu_download_status_'.$id);
|
1089 |
+
die();
|
1090 |
+
}
|
1091 |
+
//destroy monitor ticket so it cannot be used again
|
1092 |
+
WFU_USVAR_unset('wfu_download_monitor_ticket_'.$id);
|
1093 |
+
|
1094 |
+
//initiate loop of 30secs to check the download status of the file;
|
1095 |
+
//the download status is controlled by the actual download script;
|
1096 |
+
//if the file finishes within the 30secs of the loop, then this routine logs
|
1097 |
+
//the action and notifies the client side about the download status of the
|
1098 |
+
//file, otherwise an instruction to the client side to repeat this routine
|
1099 |
+
//and wait for another 30secs is dispatched
|
1100 |
+
$end_time = time() + 30;
|
1101 |
+
$upload_ended = false;
|
1102 |
+
while ( time() < $end_time ) {
|
1103 |
+
$upload_ended = ( WFU_USVAR_exists('wfu_download_status_'.$id) ? ( WFU_USVAR('wfu_download_status_'.$id) == 'downloaded' || WFU_USVAR('wfu_download_status_'.$id) == 'failed' ? true : false ) : false );
|
1104 |
+
if ( $upload_ended ) break;
|
1105 |
+
usleep(100);
|
1106 |
+
}
|
1107 |
+
|
1108 |
+
if ( $upload_ended ) {
|
1109 |
+
$upload_result = WFU_USVAR('wfu_download_status_'.$id);
|
1110 |
+
WFU_USVAR_unset('wfu_download_status_'.$id);
|
1111 |
+
$user = wp_get_current_user();
|
1112 |
+
// $filepath = wfu_plugin_decode_string($file_code);
|
1113 |
+
$filepath = wfu_get_filepath_from_safe($file_code);
|
1114 |
+
if ( $filepath === false ) die();
|
1115 |
+
$filepath = wfu_path_rel2abs(wfu_flatten_path($filepath));
|
1116 |
+
wfu_log_action('download', $filepath, $user->ID, '', 0, 0, '', null);
|
1117 |
+
/**
|
1118 |
+
* Customise Output of Download Monitoring Operation.
|
1119 |
+
*
|
1120 |
+
* This filter allows scripts to customise return of this function after
|
1121 |
+
* finish of it.
|
1122 |
+
*
|
1123 |
+
* @since 3.11.0
|
1124 |
+
*
|
1125 |
+
* @param string $echo_str The return of the function.
|
1126 |
+
*/
|
1127 |
+
die(apply_filters('_wfu_ajax_action_download_file_monitor', 'wfu_ajax_action_download_file_monitor:'.$upload_result.':'));
|
1128 |
+
}
|
1129 |
+
else {
|
1130 |
+
//regenerate monitor ticket
|
1131 |
+
WFU_USVAR_store('wfu_download_monitor_ticket_'.$id, time() + 30);
|
1132 |
+
/** This filter is documented above. */
|
1133 |
+
die(apply_filters('_wfu_ajax_action_download_file_monitor', 'wfu_ajax_action_download_file_monitor:repeat:'.$id));
|
1134 |
+
}
|
1135 |
+
}
|
1136 |
+
|
1137 |
+
/**
|
1138 |
+
* Get View Log Page
|
1139 |
+
*
|
1140 |
+
* This function returns the HTML code of a specific page of View Log feature of
|
1141 |
+
* the plugin in Dashboard.
|
1142 |
+
*
|
1143 |
+
* @since 3.5.0
|
1144 |
+
*/
|
1145 |
+
function wfu_ajax_action_get_historylog_page() {
|
1146 |
+
if ( !isset($_POST['token']) || !isset($_POST['page']) ) die();
|
1147 |
+
check_ajax_referer( 'wfu-historylog-page', 'token' );
|
1148 |
+
if ( !current_user_can( 'manage_options' ) ) die();
|
1149 |
+
if ( WFU_VAR("WFU_HISTORYLOG_TABLE_MAXROWS") <= 0 ) die();
|
1150 |
+
|
1151 |
+
$_POST = stripslashes_deep($_POST);
|
1152 |
+
|
1153 |
+
$page = wfu_sanitize_int($_POST['page']);
|
1154 |
+
$rows = wfu_view_log($page, true);
|
1155 |
+
|
1156 |
+
/**
|
1157 |
+
* Customise Output of View Log Page Retrieval.
|
1158 |
+
*
|
1159 |
+
* This filter allows scripts to customise return of this function after
|
1160 |
+
* finish of it.
|
1161 |
+
*
|
1162 |
+
* @since 3.11.0
|
1163 |
+
*
|
1164 |
+
* @param string $echo_str The return of the function.
|
1165 |
+
*/
|
1166 |
+
die(apply_filters('_wfu_ajax_action_get_historylog_page', 'wfu_historylog_page_success:'.wfu_plugin_encode_string($rows)));
|
1167 |
+
}
|
1168 |
+
|
1169 |
+
/**
|
1170 |
+
* Get Uploaded Files Page
|
1171 |
+
*
|
1172 |
+
* This function returns the HTML code of a specific page of Uploaded Files area
|
1173 |
+
* of the plugin in Dashboard.
|
1174 |
+
*
|
1175 |
+
* @since 4.7.0
|
1176 |
+
*/
|
1177 |
+
function wfu_ajax_action_get_uploadedfiles_page() {
|
1178 |
+
if ( !isset($_POST['token']) || !isset($_POST['page']) ) die();
|
1179 |
+
check_ajax_referer( 'wfu-uploadedfiles-page', 'token' );
|
1180 |
+
if ( !current_user_can( 'manage_options' ) ) die();
|
1181 |
+
if ( WFU_VAR("WFU_UPLOADEDFILES_TABLE_MAXROWS") <= 0 ) die();
|
1182 |
+
|
1183 |
+
$_POST = stripslashes_deep($_POST);
|
1184 |
+
|
1185 |
+
$page = wfu_sanitize_int($_POST['page']);
|
1186 |
+
$rows = wfu_uploadedfiles_manager($page, true);
|
1187 |
+
|
1188 |
+
/**
|
1189 |
+
* Customise Output of Uploaded Files Page Retrieval.
|
1190 |
+
*
|
1191 |
+
* This filter allows scripts to customise return of this function after
|
1192 |
+
* finish of it.
|
1193 |
+
*
|
1194 |
+
* @since 4.7.0
|
1195 |
+
*
|
1196 |
+
* @param string $echo_str The return of the function.
|
1197 |
+
*/
|
1198 |
+
die(apply_filters('_wfu_ajax_action_get_uploadedfiles_page', 'wfu_uploadedfiles_page_success:'.wfu_plugin_encode_string($rows)));
|
1199 |
+
}
|
1200 |
+
|
1201 |
+
/**
|
1202 |
+
* Get File Browser Page
|
1203 |
+
*
|
1204 |
+
* This function returns the HTML code of a specific page of File Browser
|
1205 |
+
* feature of the plugin in Dashboard.
|
1206 |
+
*
|
1207 |
+
* @since 4.6.1
|
1208 |
+
*/
|
1209 |
+
function wfu_ajax_action_get_adminbrowser_page() {
|
1210 |
+
if ( !isset($_POST['code']) || !isset($_POST['token']) || !isset($_POST['page']) ) die();
|
1211 |
+
|
1212 |
+
$_POST = stripslashes_deep($_POST);
|
1213 |
+
|
1214 |
+
check_ajax_referer( 'wfu-adminbrowser-page', 'token' );
|
1215 |
+
if ( !current_user_can( 'manage_options' ) ) die();
|
1216 |
+
if ( WFU_VAR("WFU_ADMINBROWSER_TABLE_MAXROWS") <= 0 ) die();
|
1217 |
+
|
1218 |
+
$code = wfu_sanitize_code($_POST['code']);
|
1219 |
+
$page = wfu_sanitize_int($_POST['page']);
|
1220 |
+
//get list of files
|
1221 |
+
$rows = wfu_browse_files($code, $page, true);
|
1222 |
+
|
1223 |
+
/**
|
1224 |
+
* Customise Output of File Browser Page Retrieval.
|
1225 |
+
*
|
1226 |
+
* This filter allows scripts to customise return of this function after
|
1227 |
+
* finish of it.
|
1228 |
+
*
|
1229 |
+
* @since 4.6.1
|
1230 |
+
*
|
1231 |
+
* @param string $echo_str The return of the function.
|
1232 |
+
*/
|
1233 |
+
die(apply_filters('_wfu_ajax_action_get_adminbrowser_page', 'wfu_adminbrowser_page_success:'.wfu_plugin_encode_string($rows)));
|
1234 |
+
}
|
1235 |
+
|
1236 |
+
/**
|
1237 |
+
* Include a File in Plugin Database
|
1238 |
+
*
|
1239 |
+
* This function includes a file in the plugin database.
|
1240 |
+
*
|
1241 |
+
* @since 3.8.2
|
1242 |
+
*/
|
1243 |
+
function wfu_ajax_action_include_file() {
|
1244 |
+
$_POST = stripslashes_deep($_POST);
|
1245 |
+
$_GET = stripslashes_deep($_GET);
|
1246 |
+
|
1247 |
+
$file_code = (isset($_POST['file']) ? $_POST['file'] : (isset($_GET['file']) ? $_GET['file'] : ''));
|
1248 |
+
$nonce = (isset($_POST['nonce']) ? $_POST['nonce'] : (isset($_GET['nonce']) ? $_GET['nonce'] : ''));
|
1249 |
+
if ( $file_code == '' || $nonce == '' ) die();
|
1250 |
+
|
1251 |
+
if ( !current_user_can( 'manage_options' ) ) die();
|
1252 |
+
//security check to avoid CSRF attacks
|
1253 |
+
if ( !wp_verify_nonce($nonce, 'wfu_include_file') ) die();
|
1254 |
+
|
1255 |
+
$plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
|
1256 |
+
if ( $plugin_options['includeotherfiles'] != "1" ) die();
|
1257 |
+
|
1258 |
+
$dec_file = wfu_get_filepath_from_safe($file_code);
|
1259 |
+
if ( $dec_file === false ) die();
|
1260 |
+
|
1261 |
+
$user = wp_get_current_user();
|
1262 |
+
$dec_file = wfu_path_rel2abs(wfu_flatten_path($dec_file));
|
1263 |
+
$fileid = wfu_log_action('include', $dec_file, $user->ID, '', '', get_current_blog_id(), '', null);
|
1264 |
+
|
1265 |
+
if ( $fileid !== false ) {
|
1266 |
+
/**
|
1267 |
+
* Customise Output of File Inclusion Operation.
|
1268 |
+
*
|
1269 |
+
* This filter allows scripts to customise return of this function after
|
1270 |
+
* finish of it.
|
1271 |
+
*
|
1272 |
+
* @since 3.11.0
|
1273 |
+
*
|
1274 |
+
* @param string $echo_str The return of the function.
|
1275 |
+
*/
|
1276 |
+
die(apply_filters('_wfu_ajax_action_include_file', "wfu_include_file:success:".$fileid));
|
1277 |
+
}
|
1278 |
+
/** This filter is documented above. */
|
1279 |
+
else die(apply_filters('_wfu_ajax_action_include_file', 'wfu_include_file:fail:'));
|
1280 |
+
}
|
1281 |
+
|
1282 |
+
/**
|
1283 |
+
* Update WPFilebase Manager Plugin
|
1284 |
+
*
|
1285 |
+
* This function instructs WPFilebase Manager plugin to synchronize its list of
|
1286 |
+
* files, after a file upload.
|
1287 |
+
*
|
1288 |
+
* @since 2.4.1
|
1289 |
+
*/
|
1290 |
+
function wfu_ajax_action_notify_wpfilebase() {
|
1291 |
+
$_POST = stripslashes_deep($_POST);
|
1292 |
+
$_GET = stripslashes_deep($_GET);
|
1293 |
+
|
1294 |
+
$params_index = (isset($_POST['params_index']) ? $_POST['params_index'] : (isset($_GET['params_index']) ? $_GET['params_index'] : ''));
|
1295 |
+
$session_token = (isset($_POST['session_token']) ? $_POST['session_token'] : (isset($_GET['session_token']) ? $_GET['session_token'] : ''));
|
1296 |
+
if ( $params_index == '' || $session_token == '' ) die();
|
1297 |
+
|
1298 |
+
$params_index = sanitize_text_field($params_index);
|
1299 |
+
$session_token = sanitize_text_field($session_token);
|
1300 |
+
|
1301 |
+
$arr = wfu_get_params_fields_from_index($params_index, $session_token);
|
1302 |
+
//check referer using server sessions to avoid CSRF attacks
|
1303 |
+
if ( WFU_USVAR("wfu_token_".$arr['shortcode_id']) != $session_token ) die();
|
1304 |
+
|
1305 |
+
//execute WPFilebase plugin sunchronization by calling 'wpfilebase_sync'
|
1306 |
+
//action
|
1307 |
+
do_action('wpfilebase_sync');
|
1308 |
+
|
1309 |
+
die();
|
1310 |
+
}
|
1311 |
+
|
1312 |
+
/**
|
1313 |
+
* Get List of Users
|
1314 |
+
*
|
1315 |
+
* This function returns a list of users meeting specific criteria. Only the
|
1316 |
+
* first 100 users will be returned, for avoiding performance issues.
|
1317 |
+
*
|
1318 |
+
* @since 4.5.0
|
1319 |
+
*/
|
1320 |
+
function wfu_ajax_action_pdusers_get_users() {
|
1321 |
+
$_POST = stripslashes_deep($_POST);
|
1322 |
+
$_GET = stripslashes_deep($_GET);
|
1323 |
+
|
1324 |
+
$nonce = (isset($_POST['nonce']) ? $_POST['nonce'] : (isset($_GET['nonce']) ? $_GET['nonce'] : ''));
|
1325 |
+
$query = (isset($_POST['query']) ? $_POST['query'] : (isset($_GET['query']) ? $_GET['query'] : ''));
|
1326 |
+
if ( $nonce == '' || $query == '' ) die();
|
1327 |
+
|
1328 |
+
if ( !current_user_can( 'manage_options' ) ) die();
|
1329 |
+
//security check to avoid CSRF attacks
|
1330 |
+
if ( !wp_verify_nonce($nonce, 'wfu_edit_policy') ) die();
|
1331 |
+
|
1332 |
+
$query = sanitize_text_field($query);
|
1333 |
+
$args = array(
|
1334 |
+
'search' => $query,
|
1335 |
+
'search_columns' => array( 'user_login', 'display_name' ),
|
1336 |
+
'fields' => array( 'user_login', 'display_name' ),
|
1337 |
+
'number' => 100
|
1338 |
+
);
|
1339 |
+
/** This filter is documented in lib/wfu_admin_browser.php */
|
1340 |
+
$args = apply_filters("_wfu_get_users", $args, "manage_pdusers");
|
1341 |
+
$users = get_users($args);
|
1342 |
+
|
1343 |
+
die("pdusers_get_users:".wfu_encode_array_to_string($users));
|
1344 |
}
|
lib/wfu_attributes.php
CHANGED
@@ -1,1853 +1,1853 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Definition of Various Attributes of the Plugin
|
5 |
-
*
|
6 |
-
* This file contains definition of shortcode and formfield attributes of the
|
7 |
-
* plugin.
|
8 |
-
*
|
9 |
-
* @link /lib/wfu_attributes.php
|
10 |
-
*
|
11 |
-
* @package WordPress File Upload Plugin
|
12 |
-
* @subpackage Core Components
|
13 |
-
* @since 2.1.2
|
14 |
-
*/
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Definition of Uploader Form Elements
|
18 |
-
*
|
19 |
-
* This function defines the elements of the plugin upload form.
|
20 |
-
*
|
21 |
-
* @since 2.1.2
|
22 |
-
*
|
23 |
-
* @return array The list of uploader form elements (components).
|
24 |
-
*/
|
25 |
-
function wfu_component_definitions() {
|
26 |
-
$components = array(
|
27 |
-
array(
|
28 |
-
"id" => "title",
|
29 |
-
"name" => "Title",
|
30 |
-
"mode" => "free",
|
31 |
-
"dimensions" => array("plugin/Plugin", "title/Title"),
|
32 |
-
"multiplacements" => false,
|
33 |
-
"help" => "A title text for the plugin"
|
34 |
-
),
|
35 |
-
array(
|
36 |
-
"id" => "filename",
|
37 |
-
"name" => "Filename",
|
38 |
-
"mode" => "free",
|
39 |
-
"dimensions" => null,
|
40 |
-
"multiplacements" => false,
|
41 |
-
"help" => "It shows the name of the selected file (useful only for single file uploads)."
|
42 |
-
),
|
43 |
-
array(
|
44 |
-
"id" => "selectbutton",
|
45 |
-
"name" => "Select Button",
|
46 |
-
"mode" => "free",
|
47 |
-
"dimensions" => null,
|
48 |
-
"multiplacements" => false,
|
49 |
-
"help" => "Represents the button to select the files for upload."
|
50 |
-
),
|
51 |
-
array(
|
52 |
-
"id" => "uploadbutton",
|
53 |
-
"name" => "Upload Button",
|
54 |
-
"mode" => "free",
|
55 |
-
"dimensions" => null,
|
56 |
-
"multiplacements" => false,
|
57 |
-
"help" => "Represents the button to execute the upload after some files have been selected."
|
58 |
-
),
|
59 |
-
array(
|
60 |
-
"id" => "subfolders",
|
61 |
-
"name" => "Subfolders",
|
62 |
-
"mode" => "free",
|
63 |
-
"dimensions" => array("uploadfolder_label/Upload Folder Label", "subfolders/Subfolders", "subfolders_label/Subfolders Label", "subfolders_select/Subfolders List"),
|
64 |
-
"multiplacements" => false,
|
65 |
-
"help" => "Allows the user to select the upload folder from a dropdown list."
|
66 |
-
),
|
67 |
-
array(
|
68 |
-
"id" => "webcam",
|
69 |
-
"name" => "Webcam",
|
70 |
-
"mode" => "commercial",
|
71 |
-
"dimensions" => array("webcam/Webcam Box"),
|
72 |
-
"multiplacements" => false,
|
73 |
-
"help" => "Displays video from the device's webcam. The user can capture and upload screenshots or video streams."
|
74 |
-
),
|
75 |
-
array(
|
76 |
-
"id" => "progressbar",
|
77 |
-
"name" => "Progressbar",
|
78 |
-
"mode" => "free",
|
79 |
-
"dimensions" => null,
|
80 |
-
"multiplacements" => false,
|
81 |
-
"help" => "Displays a simple progress bar, showing total progress of upload."
|
82 |
-
),
|
83 |
-
array(
|
84 |
-
"id" => "userdata",
|
85 |
-
"name" => "User Fields",
|
86 |
-
"mode" => "free",
|
87 |
-
"dimensions" => array("userdata/User Fields", "userdata_label/User Fields Label", "userdata_value/User Fields Value"),
|
88 |
-
"multiplacements" => true,
|
89 |
-
"help" => "Displays additional fields that the user must fill-in together with the uploaded files."
|
90 |
-
),
|
91 |
-
array(
|
92 |
-
"id" => "consent",
|
93 |
-
"name" => "Consent",
|
94 |
-
"mode" => "free",
|
95 |
-
"dimensions" => array("consent/Consent Block"),
|
96 |
-
"multiplacements" => false,
|
97 |
-
"help" => "Displays a checkbox asking user's consent for storing personal data."
|
98 |
-
),
|
99 |
-
array(
|
100 |
-
"id" => "message",
|
101 |
-
"name" => "Message",
|
102 |
-
"mode" => "free",
|
103 |
-
"dimensions" => null,
|
104 |
-
"multiplacements" => false,
|
105 |
-
"help" => "Displays a message block with information about the upload, together with any warnings or errors."
|
106 |
-
)
|
107 |
-
);
|
108 |
-
|
109 |
-
wfu_array_remove_nulls($components);
|
110 |
-
|
111 |
-
return $components;
|
112 |
-
}
|
113 |
-
|
114 |
-
/**
|
115 |
-
* Definition of Uploader Form Attribute Categories
|
116 |
-
*
|
117 |
-
* This function defines the categories of the plugin uploader shortcode
|
118 |
-
* attributes. These categories show up as different tabs of the shortcode
|
119 |
-
* composer.
|
120 |
-
*
|
121 |
-
* @since 2.1.2
|
122 |
-
*
|
123 |
-
* @return array The list of uploader form attribute categories.
|
124 |
-
*/
|
125 |
-
function wfu_category_definitions() {
|
126 |
-
$cats = array(
|
127 |
-
"general" => "General",
|
128 |
-
"placements" => "Placements",
|
129 |
-
"labels" => "Labels",
|
130 |
-
"notifications" => "Notifications",
|
131 |
-
"personaldata" => "Personal Data",
|
132 |
-
"colors" => "Colors",
|
133 |
-
"dimensions" => "Dimensions",
|
134 |
-
"userdata" => "Additional Fields",
|
135 |
-
"interoperability" => "Interoperability",
|
136 |
-
"webcam" => "Webcam"
|
137 |
-
);
|
138 |
-
|
139 |
-
return $cats;
|
140 |
-
}
|
141 |
-
|
142 |
-
/**
|
143 |
-
* Definition of Uploader Form Custom Fields
|
144 |
-
*
|
145 |
-
* This function defines the plugin upload form custom fields and their
|
146 |
-
* attributes.
|
147 |
-
*
|
148 |
-
* @since 3.3.0
|
149 |
-
*
|
150 |
-
* @return array The list of upload form custom fields.
|
151 |
-
*/
|
152 |
-
function wfu_formfield_definitions() {
|
153 |
-
//field properties have 2 parts separated by "/"; the first part determines if the property will be shown to the user (show or hide); the second part determines default value)
|
154 |
-
//when making changes in the structure of formfield definitions, the following are affected:
|
155 |
-
// - wfu_admin_composer.php function wfu_shortcode_composer
|
156 |
-
// variable $fieldprops_basic
|
157 |
-
// variable $fieldprops_default
|
158 |
-
// variable $template
|
159 |
-
// variable wfu_attribute_..._typeprops
|
160 |
-
// variable $from_template
|
161 |
-
// - wfu_functions.php function wfu_parse_userdata_attribute
|
162 |
-
// variable $default
|
163 |
-
// variable $fieldprops
|
164 |
-
// - wfu_blocks.php function wfu_userdata_apply_template
|
165 |
-
// return variable
|
166 |
-
// - wordpress_file_upload_adminfuctions.js function wfu_formdata_type_changed
|
167 |
-
// variable field
|
168 |
-
// - wordpress_file_upload_adminfuctions.js function wfu_formdata_add_field
|
169 |
-
// variable field
|
170 |
-
// - wordpress_file_upload_adminfuctions.js function wfu_formdata_prepare_template
|
171 |
-
// variable fieldprops_basic
|
172 |
-
// variable template
|
173 |
-
// - wordpress_file_upload_adminfuctions.js function wfu_update_formfield_value
|
174 |
-
// variable part
|
175 |
-
// - wordpress_file_upload_adminfuctions.js function wfu_apply_value
|
176 |
-
// variable def
|
177 |
-
// variable fieldprops
|
178 |
-
$formfields = array(
|
179 |
-
array(
|
180 |
-
"type" => "text",
|
181 |
-
"type_description" => "Simple Text",
|
182 |
-
//label properties
|
183 |
-
"label" => "",
|
184 |
-
"label_label" => "Label",
|
185 |
-
"label_hint" => "enter the label that will be shown next to the field",
|
186 |
-
//checkbox properties
|
187 |
-
"required" => "show/false",
|
188 |
-
"required_hint" => "if checked, then this field must have a non-empty value for the file to be uploaded",
|
189 |
-
"donotautocomplete" => "show/false",
|
190 |
-
"donotautocomplete_hint" => "if checked, then the field will notify the browsers not to fill it with autocomplete data when the plugin is reloaded",
|
191 |
-
"validate" => "hide/false",
|
192 |
-
"validate_hint" => "if checked, then the field value entered by the user will be validated before file upload",
|
193 |
-
"typehook" => "hide/false",
|
194 |
-
"typehook_hint" => "if checked, then text suggestions will be shown below the field as the user types more text inside",
|
195 |
-
//dropdown properties
|
196 |
-
"labelposition" => "show/left",
|
197 |
-
"labelposition_hint" => "select the position of the field's label; the position is relative to the field",
|
198 |
-
"hintposition" => "show/right",
|
199 |
-
"hintposition_hint" => "select the position of the hint that will be shown to notify the user that something is wrong\\r\\nthe position is relative to the field",
|
200 |
-
//text properties
|
201 |
-
"default" => "show/",
|
202 |
-
"default_hint" => "enter a default value for the field or leave it empty if you do not want a default value",
|
203 |
-
"data" => "hide/",
|
204 |
-
"data_label" => "Data",
|
205 |
-
"data_hint" => "complete a list of values to be shown to the user",
|
206 |
-
"group" => "hide/",
|
207 |
-
"group_hint" => "if a value is set, then all fields having the same value will belong to the same group",
|
208 |
-
"format" => "hide/",
|
209 |
-
"format_hint" => "enter a format to format user selection"
|
210 |
-
),
|
211 |
-
array(
|
212 |
-
"type" => "multitext",
|
213 |
-
"type_description" => "Multiple Lines Text",
|
214 |
-
//label properties
|
215 |
-
"label" => "",
|
216 |
-
"label_label" => "Label",
|
217 |
-
"label_hint" => "enter the label that will be shown next to the field",
|
218 |
-
//checkbox properties
|
219 |
-
"required" => "show/false",
|
220 |
-
"required_hint" => "if checked, then this field must have a non-empty value for the file to be uploaded",
|
221 |
-
"donotautocomplete" => "hide/true",
|
222 |
-
"donotautocomplete_hint" => "if checked, then the field will notify the browsers not to fill it with autocomplete data when the plugin is reloaded",
|
223 |
-
"validate" => "hide/false",
|
224 |
-
"validate_hint" => "if checked, then the field value entered by the user will be validated before file upload",
|
225 |
-
"typehook" => "hide/false",
|
226 |
-
"typehook_hint" => "if checked, then text suggestions will be shown below the field as the user types more text inside",
|
227 |
-
//dropdown properties
|
228 |
-
"labelposition" => "show/left",
|
229 |
-
"labelposition_hint" => "select the position of the field's label; the position is relative to the field",
|
230 |
-
"hintposition" => "show/right",
|
231 |
-
"hintposition_hint" => "select the position of the hint that will be shown to notify the user that something is wrong\\r\\nthe position is relative to the field",
|
232 |
-
//text properties
|
233 |
-
"default" => "hide/",
|
234 |
-
"default_hint" => "enter a default value for the field or leave it empty if you do not want a default value",
|
235 |
-
"data" => "hide/",
|
236 |
-
"data_label" => "Data",
|
237 |
-
"data_hint" => "complete a list of values to be shown to the user",
|
238 |
-
"group" => "hide/",
|
239 |
-
"group_hint" => "if a value is set, then all fields having the same value will belong to the same group",
|
240 |
-
"format" => "hide/",
|
241 |
-
"format_hint" => "enter a format to format user selection"
|
242 |
-
),
|
243 |
-
array(
|
244 |
-
"type" => "number",
|
245 |
-
"type_description" => "Number",
|
246 |
-
//label properties
|
247 |
-
"label" => "",
|
248 |
-
"label_label" => "Label",
|
249 |
-
"label_hint" => "enter the label that will be shown next to the field",
|
250 |
-
//checkbox properties
|
251 |
-
"required" => "show/false",
|
252 |
-
"required_hint" => "if checked, then this field must have a non-empty value for the file to be uploaded",
|
253 |
-
"donotautocomplete" => "show/true",
|
254 |
-
"donotautocomplete_hint" => "if checked, then the field will notify the browsers not to fill it with autocomplete data when the plugin is reloaded",
|
255 |
-
"validate" => "show/true",
|
256 |
-
"validate_hint" => "if checked, then the number entered by the user will be checked if it is a valid number, based on the format defined, before file upload",
|
257 |
-
"typehook" => "show/false",
|
258 |
-
"typehook_hint" => "if checked, then only valid characters will be allowed during typing",
|
259 |
-
//dropdown properties
|
260 |
-
"labelposition" => "show/left",
|
261 |
-
"labelposition_hint" => "select the position of the field's label; the position is relative to the field",
|
262 |
-
"hintposition" => "show/right",
|
263 |
-
"hintposition_hint" => "select the position of the hint that will be shown to notify the user that something is wrong\\r\\nthe position is relative to the field",
|
264 |
-
//text properties
|
265 |
-
"default" => "show/",
|
266 |
-
"default_hint" => "enter a default value for the field or leave it empty if you do not want a default value",
|
267 |
-
"data" => "hide/",
|
268 |
-
"data_label" => "Data",
|
269 |
-
"data_hint" => "complete a list of values to be shown to the user",
|
270 |
-
"group" => "hide/",
|
271 |
-
"group_hint" => "if a non-empty group value is set, then another email confirmation field belonging to the same group must have the same email value",
|
272 |
-
"format" => "show/d",
|
273 |
-
"format_hint" => "enter a format for the number:\\r\\n d for integers\\r\\n f for floating point numbers\\r\\nthe dot (.) symbol is used as a decimal separator"
|
274 |
-
),
|
275 |
-
array(
|
276 |
-
"type" => "email",
|
277 |
-
"type_description" => "Email",
|
278 |
-
//label properties
|
279 |
-
"label" => "",
|
280 |
-
"label_label" => "Label",
|
281 |
-
"label_hint" => "enter the label that will be shown next to the field",
|
282 |
-
//checkbox properties
|
283 |
-
"required" => "show/false",
|
284 |
-
"required_hint" => "if checked, then this field must have a non-empty value for the file to be uploaded",
|
285 |
-
"donotautocomplete" => "show/true",
|
286 |
-
"donotautocomplete_hint" => "if checked, then the field will notify the browsers not to fill it with autocomplete data when the plugin is reloaded",
|
287 |
-
"validate" => "show/true",
|
288 |
-
"validate_hint" => "if checked, then the email entered by the user will be checked if it is valid before file upload",
|
289 |
-
"typehook" => "hide/false",
|
290 |
-
"typehook_hint" => "if checked, then text suggestions will be shown below the field as the user types more text inside",
|
291 |
-
//dropdown properties
|
292 |
-
"labelposition" => "show/left",
|
293 |
-
"labelposition_hint" => "select the position of the field's label; the position is relative to the field",
|
294 |
-
"hintposition" => "show/right",
|
295 |
-
"hintposition_hint" => "select the position of the hint that will be shown to notify the user that something is wrong\\r\\nthe position is relative to the field",
|
296 |
-
//text properties
|
297 |
-
"default" => "show/",
|
298 |
-
"default_hint" => "enter a default value for the field or leave it empty if you do not want a default value",
|
299 |
-
"data" => "hide/",
|
300 |
-
"data_label" => "Data",
|
301 |
-
"data_hint" => "complete a list of values to be shown to the user",
|
302 |
-
"group" => "show/0",
|
303 |
-
"group_hint" => "if a non-empty group value is set, then another email confirmation field belonging to the same group must have the same email value",
|
304 |
-
"format" => "hide/",
|
305 |
-
"format_hint" => "enter a format to format user selection"
|
306 |
-
),
|
307 |
-
array(
|
308 |
-
"type" => "confirmemail",
|
309 |
-
"type_description" => "Confirmation Email",
|
310 |
-
//label properties
|
311 |
-
"label" => "",
|
312 |
-
"label_label" => "Label",
|
313 |
-
"label_hint" => "enter the label that will be shown next to the field",
|
314 |
-
//checkbox properties
|
315 |
-
"required" => "show/true",
|
316 |
-
"required_hint" => "if checked, then this field must have a non-empty value for the file to be uploaded",
|
317 |
-
"donotautocomplete" => "show/true",
|
318 |
-
"donotautocomplete_hint" => "if checked, then the field will notify the browsers not to fill it with autocomplete data when the plugin is reloaded",
|
319 |
-
"validate" => "hide/true",
|
320 |
-
"validate_hint" => "if checked, then the confirmation email entered by the user will be checked if it is the same with the email belonging to the same group",
|
321 |
-
"typehook" => "hide/false",
|
322 |
-
"typehook_hint" => "if checked, then text suggestions will be shown below the field as the user types more text inside",
|
323 |
-
//dropdown properties
|
324 |
-
"labelposition" => "show/left",
|
325 |
-
"labelposition_hint" => "select the position of the field's label; the position is relative to the field",
|
326 |
-
"hintposition" => "show/right",
|
327 |
-
"hintposition_hint" => "select the position of the hint that will be shown to notify the user that something is wrong\\r\\nthe position is relative to the field",
|
328 |
-
//text properties
|
329 |
-
"default" => "hide/",
|
330 |
-
"default_hint" => "enter a default value for the field or leave it empty if you do not want a default value",
|
331 |
-
"data" => "hide/",
|
332 |
-
"data_label" => "Data",
|
333 |
-
"data_hint" => "complete a list of values to be shown to the user",
|
334 |
-
"group" => "show/0",
|
335 |
-
"group_hint" => "enter a non-empty value to match this email confirmation field with another email field",
|
336 |
-
"format" => "hide/",
|
337 |
-
"format_hint" => "enter a format to format user selection"
|
338 |
-
),
|
339 |
-
array(
|
340 |
-
"type" => "password",
|
341 |
-
"type_description" => "Password",
|
342 |
-
//label properties
|
343 |
-
"label" => "",
|
344 |
-
"label_label" => "Label",
|
345 |
-
"label_hint" => "enter the label that will be shown next to the field",
|
346 |
-
//checkbox properties
|
347 |
-
"required" => "show/true",
|
348 |
-
"required_hint" => "if checked, then this field must have a non-empty value for the file to be uploaded",
|
349 |
-
"donotautocomplete" => "false/true",
|
350 |
-
"donotautocomplete_hint" => "if checked, then the field will notify the browsers not to fill it with autocomplete data when the plugin is reloaded",
|
351 |
-
"validate" => "hide/false",
|
352 |
-
"validate_hint" => "if checked, then the value entered by the user will be validated",
|
353 |
-
"typehook" => "hide/false",
|
354 |
-
"typehook_hint" => "if checked, then text suggestions will be shown below the field as the user types more text inside",
|
355 |
-
//dropdown properties
|
356 |
-
"labelposition" => "show/left",
|
357 |
-
"labelposition_hint" => "select the position of the field's label; the position is relative to the field",
|
358 |
-
"hintposition" => "show/right",
|
359 |
-
"hintposition_hint" => "select the position of the hint that will be shown to notify the user that something is wrong\\r\\nthe position is relative to the field",
|
360 |
-
//text properties
|
361 |
-
"default" => "hide/",
|
362 |
-
"default_hint" => "enter a default value for the field or leave it empty if you do not want a default value",
|
363 |
-
"data" => "hide/",
|
364 |
-
"data_label" => "Data",
|
365 |
-
"data_hint" => "complete a list of values to be shown to the user",
|
366 |
-
"group" => "show/0",
|
367 |
-
"group_hint" => "if a non-empty group value is set, then another password confirmation field belonging to the same group must have the same password",
|
368 |
-
"format" => "hide/",
|
369 |
-
"format_hint" => "enter a format to format user selection"
|
370 |
-
),
|
371 |
-
array(
|
372 |
-
"type" => "confirmpassword",
|
373 |
-
"type_description" => "Confirmation Password",
|
374 |
-
//label properties
|
375 |
-
"label" => "",
|
376 |
-
"label_label" => "Label",
|
377 |
-
"label_hint" => "enter the label that will be shown next to the field",
|
378 |
-
//checkbox properties
|
379 |
-
"required" => "show/true",
|
380 |
-
"required_hint" => "if checked, then this field must have a non-empty value for the file to be uploaded",
|
381 |
-
"donotautocomplete" => "false/true",
|
382 |
-
"donotautocomplete_hint" => "if checked, then the field will notify the browsers not to fill it with autocomplete data when the plugin is reloaded",
|
383 |
-
"validate" => "hide/true",
|
384 |
-
"validate_hint" => "if checked, then the value entered by the user will be validated",
|
385 |
-
"typehook" => "hide/false",
|
386 |
-
"typehook_hint" => "if checked, then text suggestions will be shown below the field as the user types more text inside",
|
387 |
-
//dropdown properties
|
388 |
-
"labelposition" => "show/left",
|
389 |
-
"labelposition_hint" => "select the position of the field's label; the position is relative to the field",
|
390 |
-
"hintposition" => "show/right",
|
391 |
-
"hintposition_hint" => "select the position of the hint that will be shown to notify the user that something is wrong\\r\\nthe position is relative to the field",
|
392 |
-
//text properties
|
393 |
-
"default" => "hide/",
|
394 |
-
"default_hint" => "enter a default value for the field or leave it empty if you do not want a default value",
|
395 |
-
"data" => "hide/",
|
396 |
-
"data_label" => "Data",
|
397 |
-
"data_hint" => "complete a list of values to be shown to the user",
|
398 |
-
"group" => "show/0",
|
399 |
-
"group_hint" => "if a non-empty group value is set, then another password confirmation field belonging to the same group must have the same password",
|
400 |
-
"format" => "hide/",
|
401 |
-
"format_hint" => "enter a format to format user selection"
|
402 |
-
),
|
403 |
-
array(
|
404 |
-
"type" => "checkbox",
|
405 |
-
"type_description" => "Checkbox",
|
406 |
-
//label properties
|
407 |
-
"label" => "",
|
408 |
-
"label_label" => "Label",
|
409 |
-
"label_hint" => "enter the label that will be shown next to the field",
|
410 |
-
//checkbox properties
|
411 |
-
"required" => "show/false",
|
412 |
-
"required_hint" => "if checked, then this checkbox field must be checked before file upload",
|
413 |
-
"donotautocomplete" => "show/true",
|
414 |
-
"donotautocomplete_hint" => "if checked, then the field will not be autocompleted by browsers",
|
415 |
-
"validate" => "hide/false",
|
416 |
-
"validate_hint" => "if checked, then the field value entered by the user will be validated before file upload",
|
417 |
-
"typehook" => "hide/false",
|
418 |
-
"typehook_hint" => "if checked, then text suggestions will be shown below the field as the user types more text inside",
|
419 |
-
//dropdown properties
|
420 |
-
"labelposition" => "show/none",
|
421 |
-
"labelposition_hint" => "select the position of the field's label; the position is relative to the field",
|
422 |
-
"hintposition" => "show/right",
|
423 |
-
"hintposition_hint" => "select the position of the hint that will be shown to notify the user that something is wrong\\r\\nthe position is relative to the field",
|
424 |
-
//text properties
|
425 |
-
"default" => "show/false",
|
426 |
-
"default_hint" => "enter a default value (true or false) for the field or leave it empty if you do not want a default value",
|
427 |
-
"data" => "show/",
|
428 |
-
"data_label" => "Description",
|
429 |
-
"data_hint" => "enter a description for the checkbox",
|
430 |
-
"group" => "hide/",
|
431 |
-
"group_hint" => "if a value is set, then all fields having the same value will belong to the same group",
|
432 |
-
"format" => "show/right",
|
433 |
-
"format_hint" => "define the location of the description in relation to the check box\\r\\npossible values are: top, right, bottom, left"
|
434 |
-
),
|
435 |
-
array(
|
436 |
-
"type" => "radiobutton",
|
437 |
-
"type_description" => "Radio button",
|
438 |
-
//label properties
|
439 |
-
"label" => "",
|
440 |
-
"label_label" => "Label",
|
441 |
-
"label_hint" => "enter the label that will be shown next to the field",
|
442 |
-
//checkbox properties
|
443 |
-
"required" => "show/false",
|
444 |
-
"required_hint" => "if checked, then a radio button must be selected before file upload",
|
445 |
-
"donotautocomplete" => "show/true",
|
446 |
-
"donotautocomplete_hint" => "if checked, then the field will not be autocompleted by browsers",
|
447 |
-
"validate" => "hide/false",
|
448 |
-
"validate_hint" => "if checked, then the field value entered by the user will be validated before file upload",
|
449 |
-
"typehook" => "hide/false",
|
450 |
-
"typehook_hint" => "if checked, then text suggestions will be shown below the field as the user types more text inside",
|
451 |
-
//dropdown properties
|
452 |
-
"labelposition" => "show/left",
|
453 |
-
"labelposition_hint" => "select the position of the field's label; the position is relative to the field",
|
454 |
-
"hintposition" => "show/right",
|
455 |
-
"hintposition_hint" => "select the position of the hint that will be shown to notify the user that something is wrong\\r\\nthe position is relative to the field",
|
456 |
-
//text properties
|
457 |
-
"default" => "show/",
|
458 |
-
"default_hint" => "enter a default value for the field or leave it empty if you do not want a default value",
|
459 |
-
"data" => "show/",
|
460 |
-
"data_label" => "Items",
|
461 |
-
"data_hint" => "enter a comma delimited list of radio button items",
|
462 |
-
"group" => "show/0",
|
463 |
-
"group_hint" => "all radio buttons having the same group id belong to the same group",
|
464 |
-
"format" => "show/",
|
465 |
-
"format_hint" => "define the location of the radio labels in relation to their radio buttons (top, right, bottom, left)\\r\\nand the placement of the radio buttons (horizontal, vertical)"
|
466 |
-
),
|
467 |
-
array(
|
468 |
-
"type" => "date",
|
469 |
-
"type_description" => "Date",
|
470 |
-
//label properties
|
471 |
-
"label" => "",
|
472 |
-
"label_label" => "Label",
|
473 |
-
"label_hint" => "enter the label that will be shown next to the field",
|
474 |
-
//checkbox properties
|
475 |
-
"required" => "show/false",
|
476 |
-
"required_hint" => "if checked, then a date must be entered before file upload",
|
477 |
-
"donotautocomplete" => "show/true",
|
478 |
-
"donotautocomplete_hint" => "if checked, then the field will not be autocompleted by browsers",
|
479 |
-
"validate" => "hide/false",
|
480 |
-
"validate_hint" => "if checked, then the field value entered by the user will be validated before file upload",
|
481 |
-
"typehook" => "hide/false",
|
482 |
-
"typehook_hint" => "if checked, then text suggestions will be shown below the field as the user types more text inside",
|
483 |
-
//dropdown properties
|
484 |
-
"labelposition" => "show/left",
|
485 |
-
"labelposition_hint" => "select the position of the field's label; the position is relative to the field",
|
486 |
-
"hintposition" => "show/right",
|
487 |
-
"hintposition_hint" => "select the position of the hint that will be shown to notify the user that something is wrong\\r\\nthe position is relative to the field",
|
488 |
-
//text properties
|
489 |
-
"default" => "show/",
|
490 |
-
"default_hint" => "enter a default date for the field or leave it empty if you do not want a default value",
|
491 |
-
"data" => "hide/",
|
492 |
-
"data_label" => "Data",
|
493 |
-
"data_hint" => "enter data items",
|
494 |
-
"group" => "hide/",
|
495 |
-
"group_hint" => "enter a group value",
|
496 |
-
"format" => "show/",
|
497 |
-
"format_hint" => "define the format of the date field as follows:\\r\\n d - day of month (no leading zero)\\r\\n dd - day of month (two digit)\\r\\n o - day of the year (no leading zeros)\\r\\n oo - day of the year (three digit)\\r\\n D - day name short\\r\\n DD - day name long\\r\\n m - month of year (no leading zero)\\r\\n mm - month of year (two digit)\\r\\n M - month name short\\r\\n MM - month name long\\r\\n y - year (two digit)\\r\\n yy - year (four digit)\\r\\n @ - Unix timestamp (ms since 01/01/1970)\\r\\n ! - Windows ticks (100ns since 01/01/0001)\\r\\n '...' - literal text\\r\\n '' - single quote\\r\\n anything else - literal text\\r\\nthe format must be in parenthesis ()"
|
498 |
-
),
|
499 |
-
array(
|
500 |
-
"type" => "time",
|
501 |
-
"type_description" => "Time",
|
502 |
-
//label properties
|
503 |
-
"label" => "",
|
504 |
-
"label_label" => "Label",
|
505 |
-
"label_hint" => "enter the label that will be shown next to the field",
|
506 |
-
//checkbox properties
|
507 |
-
"required" => "show/false",
|
508 |
-
"required_hint" => "if checked, then a time must be entered before file upload",
|
509 |
-
"donotautocomplete" => "show/true",
|
510 |
-
"donotautocomplete_hint" => "if checked, then the field will not be autocompleted by browsers",
|
511 |
-
"validate" => "hide/false",
|
512 |
-
"validate_hint" => "if checked, then the field value entered by the user will be validated before file upload",
|
513 |
-
"typehook" => "hide/false",
|
514 |
-
"typehook_hint" => "if checked, then text suggestions will be shown below the field as the user types more text inside",
|
515 |
-
//dropdown properties
|
516 |
-
"labelposition" => "show/left",
|
517 |
-
"labelposition_hint" => "select the position of the field's label; the position is relative to the field",
|
518 |
-
"hintposition" => "show/right",
|
519 |
-
"hintposition_hint" => "select the position of the hint that will be shown to notify the user that something is wrong\\r\\nthe position is relative to the field",
|
520 |
-
//text properties
|
521 |
-
"default" => "show/",
|
522 |
-
"default_hint" => "enter a default time for the field or leave it empty if you do not want a default value",
|
523 |
-
"data" => "hide/",
|
524 |
-
"data_label" => "Data",
|
525 |
-
"data_hint" => "enter data items",
|
526 |
-
"group" => "hide/",
|
527 |
-
"group_hint" => "enter a group value",
|
528 |
-
"format" => "show/",
|
529 |
-
"format_hint" => "define the format of the time field as follows:\\r\\n H - hour with no leading 0 (24 hour)\\r\\n HH - hour with leading 0 (24 hour)\\r\\n h - hour with no leading 0 (12 hour)\\r\\n hh - hour with leading 0 (12 hour)\\r\\n m - minute with no leading 0\\r\\n mm - minute with leading 0\\r\\n s - second with no leading 0\\r\\n ss - second with leading 0\\r\\n l - milliseconds always with leading 0\\r\\n c - microseconds always with leading 0\\r\\n t - a or p for AM/PM\\r\\n T - A or P for AM/PM\\r\\n tt - am or pm for AM/PM\\r\\n TT - AM or PM for AM/PM\\r\\n z - timezone as defined by timezoneList\\r\\n Z - timezone in Iso 8601 format (+04:45)\\r\\n '...' - literal text\\r\\nthe format must be in parenthesis ()"
|
530 |
-
),
|
531 |
-
array(
|
532 |
-
"type" => "datetime",
|
533 |
-
"type_description" => "DateTime",
|
534 |
-
//label properties
|
535 |
-
"label" => "",
|
536 |
-
"label_label" => "Label",
|
537 |
-
"label_hint" => "enter the label that will be shown next to the field",
|
538 |
-
//checkbox properties
|
539 |
-
"required" => "show/false",
|
540 |
-
"required_hint" => "if checked, then a date and time must be entered before file upload",
|
541 |
-
"donotautocomplete" => "show/true",
|
542 |
-
"donotautocomplete_hint" => "if checked, then the field will not be autocompleted by browsers",
|
543 |
-
"validate" => "hide/false",
|
544 |
-
"validate_hint" => "if checked, then the field value entered by the user will be validated before file upload",
|
545 |
-
"typehook" => "hide/false",
|
546 |
-
"typehook_hint" => "if checked, then text suggestions will be shown below the field as the user types more text inside",
|
547 |
-
//dropdown properties
|
548 |
-
"labelposition" => "show/left",
|
549 |
-
"labelposition_hint" => "select the position of the field's label; the position is relative to the field",
|
550 |
-
"hintposition" => "show/right",
|
551 |
-
"hintposition_hint" => "select the position of the hint that will be shown to notify the user that something is wrong\\r\\nthe position is relative to the field",
|
552 |
-
//text properties
|
553 |
-
"default" => "show/",
|
554 |
-
"default_hint" => "enter a default date and time for the field or leave it empty if you do not want a default value",
|
555 |
-
"data" => "hide/",
|
556 |
-
"data_label" => "Data",
|
557 |
-
"data_hint" => "enter data items",
|
558 |
-
"group" => "hide/",
|
559 |
-
"group_hint" => "enter a group value",
|
560 |
-
"format" => "show/",
|
561 |
-
"format_hint" => "define the format of the datetime field as follows:\\r\\n date(dateformat) where dateformat is:\\r\\n d - day of month (no leading zero)\\r\\n dd - day of month (two digit)\\r\\n o - day of the year (no leading zeros)\\r\\n oo - day of the year (three digit)\\r\\n D - day name short\\r\\n DD - day name long\\r\\n m - month of year (no leading zero)\\r\\n mm - month of year (two digit)\\r\\n M - month name short\\r\\n MM - month name long\\r\\n y - year (two digit)\\r\\n yy - year (four digit)\\r\\n @ - Unix timestamp (ms since 01/01/1970)\\r\\n ! - Windows ticks (100ns since 01/01/0001)\\r\\n '...' - literal text\\r\\n '' - single quote\\r\\n anything else - literal text\\r\\n time(timeformat) where timeformat is:\\r\\n H - hour with no leading 0 (24 hour)\\r\\n HH - hour with leading 0 (24 hour)\\r\\n h - hour with no leading 0 (12 hour)\\r\\n hh - hour with leading 0 (12 hour)\\r\\n m - minute with no leading 0\\r\\n mm - minute with leading 0\\r\\n s - second with no leading 0\\r\\n ss - second with leading 0\\r\\n l - milliseconds always with leading 0\\r\\n c - microseconds always with leading 0\\r\\n t - a or p for AM/PM\\r\\n T - A or P for AM/PM\\r\\n tt - am or pm for AM/PM\\r\\n TT - AM or PM for AM/PM\\r\\n z - timezone as defined by timezoneList\\r\\n Z - timezone in Iso 8601 format (+04:45)\\r\\n '...' - literal text"
|
562 |
-
),
|
563 |
-
array(
|
564 |
-
"type" => "list",
|
565 |
-
"type_description" => "Listbox",
|
566 |
-
//label properties
|
567 |
-
"label" => "",
|
568 |
-
"label_label" => "Label",
|
569 |
-
"label_hint" => "enter the label that will be shown next to the field",
|
570 |
-
//checkbox properties
|
571 |
-
"required" => "show/false",
|
572 |
-
"required_hint" => "if checked, then a list item must be selected before file upload",
|
573 |
-
"donotautocomplete" => "show/true",
|
574 |
-
"donotautocomplete_hint" => "if checked, then the field will not be autocompleted by browsers",
|
575 |
-
"validate" => "hide/false",
|
576 |
-
"validate_hint" => "if checked, then the field value entered by the user will be validated before file upload",
|
577 |
-
"typehook" => "hide/false",
|
578 |
-
"typehook_hint" => "if checked, then text suggestions will be shown below the field as the user types more text inside",
|
579 |
-
//dropdown properties
|
580 |
-
"labelposition" => "show/left",
|
581 |
-
"labelposition_hint" => "select the position of the field's label; the position is relative to the field",
|
582 |
-
"hintposition" => "show/right",
|
583 |
-
"hintposition_hint" => "select the position of the hint that will be shown to notify the user that something is wrong\\r\\nthe position is relative to the field",
|
584 |
-
//text properties
|
585 |
-
"default" => "show/",
|
586 |
-
"default_hint" => "enter a default value for the field or leave it empty if you do not want a default value",
|
587 |
-
"data" => "show/",
|
588 |
-
"data_label" => "List Items",
|
589 |
-
"data_hint" => "enter a comma delimited list of items",
|
590 |
-
"group" => "hide/",
|
591 |
-
"group_hint" => "all items having the same group id belong to the same group",
|
592 |
-
"format" => "hide/",
|
593 |
-
"format_hint" => "enter the format of the list"
|
594 |
-
),
|
595 |
-
array(
|
596 |
-
"type" => "dropdown",
|
597 |
-
"type_description" => "Dropdown",
|
598 |
-
//label properties
|
599 |
-
"label" => "",
|
600 |
-
"label_label" => "Label",
|
601 |
-
"label_hint" => "enter the label that will be shown next to the field",
|
602 |
-
//checkbox properties
|
603 |
-
"required" => "show/false",
|
604 |
-
"required_hint" => "if checked, then an item from the dropdown list must be selected before file upload",
|
605 |
-
"donotautocomplete" => "show/true",
|
606 |
-
"donotautocomplete_hint" => "if checked, then the field will not be autocompleted by browsers",
|
607 |
-
"validate" => "hide/false",
|
608 |
-
"validate_hint" => "if checked, then the field value entered by the user will be validated before file upload",
|
609 |
-
"typehook" => "hide/false",
|
610 |
-
"typehook_hint" => "if checked, then text suggestions will be shown below the field as the user types more text inside",
|
611 |
-
//dropdown properties
|
612 |
-
"labelposition" => "show/left",
|
613 |
-
"labelposition_hint" => "select the position of the field's label; the position is relative to the field",
|
614 |
-
"hintposition" => "show/right",
|
615 |
-
"hintposition_hint" => "select the position of the hint that will be shown to notify the user that something is wrong\\r\\nthe position is relative to the field",
|
616 |
-
//text properties
|
617 |
-
"default" => "show/",
|
618 |
-
"default_hint" => "enter a default value for the field or leave it empty if you do not want a default value",
|
619 |
-
"data" => "show/",
|
620 |
-
"data_label" => "List Items",
|
621 |
-
"data_hint" => "enter a comma delimited list of items",
|
622 |
-
"group" => "hide/",
|
623 |
-
"group_hint" => "all items having the same group id belong to the same group",
|
624 |
-
"format" => "hide/",
|
625 |
-
"format_hint" => "enter the format of the list"
|
626 |
-
),
|
627 |
-
array(
|
628 |
-
"type" => "honeypot",
|
629 |
-
"type_description" => "Hidden Honeypot",
|
630 |
-
//label properties
|
631 |
-
"label" => "website",
|
632 |
-
"label_label" => "Name",
|
633 |
-
"label_hint" => "enter the name of the honeypot field; it must be a value that bots can easily recognize, like \'website\' or \'URL\'",
|
634 |
-
//checkbox properties
|
635 |
-
"required" => "hide/false",
|
636 |
-
"required_hint" => "if checked, then this field must have a non-empty value for the file to be uploaded",
|
637 |
-
"donotautocomplete" => "hide/true",
|
638 |
-
"donotautocomplete_hint" => "if checked, then the field will notify the browsers not to fill it with autocomplete data when the plugin is reloaded",
|
639 |
-
"validate" => "hide/false",
|
640 |
-
"validate_hint" => "if checked, then the field value entered by the user will be validated before file upload",
|
641 |
-
"typehook" => "hide/false",
|
642 |
-
"typehook_hint" => "if checked, then text suggestions will be shown below the field as the user types more text inside",
|
643 |
-
//dropdown properties
|
644 |
-
"labelposition" => "hide/none",
|
645 |
-
"labelposition_hint" => "select the position of the field's label; the position is relative to the field",
|
646 |
-
"hintposition" => "hide/none",
|
647 |
-
"hintposition_hint" => "select the position of the hint that will be shown to notify the user that something is wrong\\r\\nthe position is relative to the field",
|
648 |
-
//text properties
|
649 |
-
"default" => "hide/",
|
650 |
-
"default_hint" => "enter a default value for the field or leave it empty if you do not want a default value",
|
651 |
-
"data" => "hide/",
|
652 |
-
"data_label" => "Data",
|
653 |
-
"data_hint" => "complete a list of values to be shown to the user",
|
654 |
-
"group" => "hide/",
|
655 |
-
"group_hint" => "if a value is set, then all fields having the same value will belong to the same group",
|
656 |
-
"format" => "hide/",
|
657 |
-
"format_hint" => "enter a format to format user selection"
|
658 |
-
)
|
659 |
-
);
|
660 |
-
|
661 |
-
return $formfields;
|
662 |
-
}
|
663 |
-
|
664 |
-
/**
|
665 |
-
* Definition of Uploader Form Attributes
|
666 |
-
*
|
667 |
-
* This function defines the plugin uploader shortcode attributes.
|
668 |
-
*
|
669 |
-
* @since 2.1.2
|
670 |
-
*
|
671 |
-
* @return array The list of uploader form attributes.
|
672 |
-
*/
|
673 |
-
function wfu_attribute_definitions() {
|
674 |
-
$defs = array(
|
675 |
-
array(
|
676 |
-
"name" => "Widget ID",
|
677 |
-
"attribute" => "widgetid",
|
678 |
-
"type" => "hidden",
|
679 |
-
"validator" => "text",
|
680 |
-
"listitems" => null,
|
681 |
-
"value" => "",
|
682 |
-
"mode" => "free",
|
683 |
-
"category" => "",
|
684 |
-
"subcategory" => "Basic ",
|
685 |
-
"parent" => "",
|
686 |
-
"dependencies" => null,
|
687 |
-
"variables" => null,
|
688 |
-
"help" => ""
|
689 |
-
),
|
690 |
-
array(
|
691 |
-
"name" => "Plugin ID",
|
692 |
-
"attribute" => "uploadid",
|
693 |
-
"type" => "integer",
|
694 |
-
"validator" => "text",
|
695 |
-
"listitems" => null,
|
696 |
-
"value" => WFU_VAR("WFU_UPLOADID"),
|
697 |
-
"mode" => "free",
|
698 |
-
"category" => "general",
|
699 |
-
"subcategory" => "Basic Functionalities",
|
700 |
-
"parent" => "",
|
701 |
-
"dependencies" => null,
|
702 |
-
"variables" => null,
|
703 |
-
"help" => "The unique id of each shortcode. When you have many shortcodes of this plugin in the same page, then you must use different id for each one."
|
704 |
-
),
|
705 |
-
array(
|
706 |
-
"name" => "Single Button Operation",
|
707 |
-
"attribute" => "singlebutton",
|
708 |
-
"type" => "onoff",
|
709 |
-
"validator" => "text",
|
710 |
-
"listitems" => null,
|
711 |
-
"value" => WFU_VAR("WFU_SINGLEBUTTON"),
|
712 |
-
"mode" => "free",
|
713 |
-
"category" => "general",
|
714 |
-
"subcategory" => "Basic Functionalities",
|
715 |
-
"parent" => "",
|
716 |
-
"dependencies" => array("!uploadbutton"),
|
717 |
-
"variables" => null,
|
718 |
-
"help" => "When it is activated, no Upload button will be shown, but upload will start automatically as soon as files are selected."
|
719 |
-
),
|
720 |
-
array(
|
721 |
-
"name" => "Upload Path",
|
722 |
-
"attribute" => "uploadpath",
|
723 |
-
"type" => "ltext",
|
724 |
-
"validator" => "path",
|
725 |
-
"listitems" => null,
|
726 |
-
"value" => WFU_VAR("WFU_UPLOADPATH"),
|
727 |
-
"mode" => "free",
|
728 |
-
"category" => "general",
|
729 |
-
"subcategory" => "Basic Functionalities",
|
730 |
-
"parent" => "",
|
731 |
-
"dependencies" => null,
|
732 |
-
"variables" => array("%userid%", "%username%", "%blogid%", "%pageid%", "%pagetitle%", "%userdataXXX%"),
|
733 |
-
"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."
|
734 |
-
),
|
735 |
-
array(
|
736 |
-
"name" => "Plugin Fit Mode",
|
737 |
-
"attribute" => "fitmode",
|
738 |
-
"type" => "radio",
|
739 |
-
"validator" => "text",
|
740 |
-
"listitems" => array("fixed", "responsive"),
|
741 |
-
"value" => WFU_VAR("WFU_FITMODE"),
|
742 |
-
"mode" => "free",
|
743 |
-
"category" => "general",
|
744 |
-
"subcategory" => "Basic Functionalities",
|
745 |
-
"parent" => "",
|
746 |
-
"dependencies" => null,
|
747 |
-
"variables" => null,
|
748 |
-
"help" => "This defines how the plugin's elements will fit inside the page/post. If it is set to fixed, then the plugin's element positions will remain fixed no matter the width of the container page/post. If it is set to responsive, then the plugin's elements will wrap to fit the width of the container page/post."
|
749 |
-
),
|
750 |
-
array(
|
751 |
-
"name" => "Allow No File",
|
752 |
-
"attribute" => "allownofile",
|
753 |
-
"type" => "onoff",
|
754 |
-
"validator" => "text",
|
755 |
-
"listitems" => null,
|
756 |
-
"value" => WFU_VAR("WFU_ALLOWNOFILE"),
|
757 |
-
"mode" => "free",
|
758 |
-
"category" => "general",
|
759 |
-
"subcategory" => "Basic Functionalities",
|
760 |
-
"parent" => "",
|
761 |
-
"dependencies" => null,
|
762 |
-
"variables" => null,
|
763 |
-
"help" => "When it is activated a user can submit the upload form even if a file is not selected."
|
764 |
-
),
|
765 |
-
array(
|
766 |
-
"name" => "Reset Form Mode",
|
767 |
-
"attribute" => "resetmode",
|
768 |
-
"type" => "radio",
|
769 |
-
"validator" => "text",
|
770 |
-
"listitems" => array("always", "onsuccess", "never"),
|
771 |
-
"value" => WFU_VAR("WFU_RESETMODE"),
|
772 |
-
"mode" => "free",
|
773 |
-
"category" => "general",
|
774 |
-
"subcategory" => "Basic Functionalities",
|
775 |
-
"parent" => "",
|
776 |
-
"dependencies" => null,
|
777 |
-
"variables" => null,
|
778 |
-
"help" => "It defines whether the form will be reset after upload; 'always' means that it will be reset in any case, 'onsuccess' means that it will be reset only if upload was successful, 'never' means that it will never be reset."
|
779 |
-
),
|
780 |
-
array(
|
781 |
-
"name" => "Upload Roles",
|
782 |
-
"attribute" => "uploadrole",
|
783 |
-
"type" => "rolelist",
|
784 |
-
"validator" => "text",
|
785 |
-
"listitems" => array("default_administrator"),
|
786 |
-
"value" => WFU_VAR("WFU_UPLOADROLE"),
|
787 |
-
"mode" => "free",
|
788 |
-
"category" => "general",
|
789 |
-
"subcategory" => "Filters",
|
790 |
-
"parent" => "",
|
791 |
-
"dependencies" => null,
|
792 |
-
"variables" => null,
|
793 |
-
"help" => "Defines the categories (roles) of users allowed to upload files. Multiple selections can be made. If 'Select All' is checked, then all logged users can upload files. If 'Include Guests' is checked, then guests (not logged users) can also upload files. Default value is 'all,guests'."
|
794 |
-
),
|
795 |
-
array(
|
796 |
-
"name" => "Allowed File Extensions",
|
797 |
-
"attribute" => "uploadpatterns",
|
798 |
-
"type" => "text",
|
799 |
-
"validator" => "text",
|
800 |
-
"listitems" => null,
|
801 |
-
"value" => WFU_VAR("WFU_UPLOADPATTERNS"),
|
802 |
-
"mode" => "free",
|
803 |
-
"category" => "general",
|
804 |
-
"subcategory" => "Filters",
|
805 |
-
"parent" => "",
|
806 |
-
"dependencies" => null,
|
807 |
-
"variables" => null,
|
808 |
-
"help" => "Defines the allowed file extensions. Multiple extentions can be defined, separated with comma (,)."
|
809 |
-
),
|
810 |
-
array(
|
811 |
-
"name" => "Allowed File Size",
|
812 |
-
"attribute" => "maxsize",
|
813 |
-
"type" => "float",
|
814 |
-
"validator" => "float",
|
815 |
-
"listitems" => null,
|
816 |
-
"value" => WFU_VAR("WFU_MAXSIZE"),
|
817 |
-
"mode" => "free",
|
818 |
-
"category" => "general",
|
819 |
-
"subcategory" => "Filters",
|
820 |
-
"parent" => "",
|
821 |
-
"dependencies" => null,
|
822 |
-
"variables" => null,
|
823 |
-
"help" => "Defines the allowed file size in MBytes. Files larger than maxsize will not be uploaded. Floating point numbers can be used (e.g. '2.5')."
|
824 |
-
),
|
825 |
-
array(
|
826 |
-
"name" => "Create Upload Path",
|
827 |
-
"attribute" => "createpath",
|
828 |
-
"type" => "onoff",
|
829 |
-
"validator" => "text",
|
830 |
-
"listitems" => null,
|
831 |
-
"value" => WFU_VAR("WFU_CREATEPATH"),
|
832 |
-
"mode" => "free",
|
833 |
-
"category" => "general",
|
834 |
-
"subcategory" => "Upload Path and Files",
|
835 |
-
"parent" => "",
|
836 |
-
"dependencies" => null,
|
837 |
-
"variables" => null,
|
838 |
-
"help" => "If activated then the plugin will attempt to create the upload path, if it does not exist."
|
839 |
-
),
|
840 |
-
array(
|
841 |
-
"name" => "Do Not Change Filename",
|
842 |
-
"attribute" => "forcefilename",
|
843 |
-
"type" => "onoff",
|
844 |
-
"validator" => "text",
|
845 |
-
"listitems" => null,
|
846 |
-
"value" => WFU_VAR("WFU_FORCEFILENAME"),
|
847 |
-
"mode" => "free",
|
848 |
-
"category" => "general",
|
849 |
-
"subcategory" => "Upload Path and Files",
|
850 |
-
"parent" => "",
|
851 |
-
"dependencies" => null,
|
852 |
-
"variables" => null,
|
853 |
-
"help" => "The plugin by default will modify the filename if it contains invalid or non-english characters. By enabling this attribute the plugin will not change the filename."
|
854 |
-
),
|
855 |
-
array(
|
856 |
-
"name" => "Folder Access Method",
|
857 |
-
"attribute" => "accessmethod",
|
858 |
-
"type" => "radio",
|
859 |
-
"validator" => "text",
|
860 |
-
"listitems" => array("normal", "*ftp"),
|
861 |
-
"value" => WFU_VAR("WFU_ACCESSMETHOD"),
|
862 |
-
"mode" => "free",
|
863 |
-
"category" => "general",
|
864 |
-
"subcategory" => "Upload Path and Files",
|
865 |
-
"parent" => "",
|
866 |
-
"dependencies" => array("ftpinfo", "userftpdomain", "ftppassivemode", "ftpfilepermissions"),
|
867 |
-
"variables" => null,
|
868 |
-
"help" => "Some times files cannot be uploaded to the upload folder because of read/write permissions. A workaround is to use ftp to transfer the files, however ftp credentials must be declared, so use carefully and only if necessary."
|
869 |
-
),
|
870 |
-
array(
|
871 |
-
"name" => "FTP Access Credentials",
|
872 |
-
"attribute" => "ftpinfo",
|
873 |
-
"type" => "ftpinfo",
|
874 |
-
"validator" => "text",
|
875 |
-
"listitems" => null,
|
876 |
-
"value" => WFU_VAR("WFU_FTPINFO"),
|
877 |
-
"mode" => "free",
|
878 |
-
"category" => "general",
|
879 |
-
"subcategory" => "Upload Path and Files",
|
880 |
-
"parent" => "accessmethod",
|
881 |
-
"dependencies" => null,
|
882 |
-
"variables" => null,
|
883 |
-
"help" => "If FTP access method is selected, then FTP credentials must be declared here, in the form username:password@ftpdomain:port, e.g. myusername:mypass@ftpdomain.com:80. Port can be ommitted. The user can use Secure FTP (sftp) by putting the prefix 's' before the port number, e.g. myusername:mypass@ftpdomain.com:s22."
|
884 |
-
),
|
885 |
-
array(
|
886 |
-
"name" => "Use FTP Domain",
|
887 |
-
"attribute" => "useftpdomain",
|
888 |
-
"type" => "onoff",
|
889 |
-
"validator" => "text",
|
890 |
-
"listitems" => null,
|
891 |
-
"value" => WFU_VAR("WFU_USEFTPDOMAIN"),
|
892 |
-
"mode" => "free",
|
893 |
-
"category" => "general",
|
894 |
-
"subcategory" => "Upload Path and Files",
|
895 |
-
"parent" => "accessmethod",
|
896 |
-
"dependencies" => null,
|
897 |
-
"variables" => null,
|
898 |
-
"help" => "If FTP access method is selected, then sometimes the FTP domain is different than the domain of your Wordpress installation. In this case, enable this attribute if upload of files is not successful."
|
899 |
-
),
|
900 |
-
array(
|
901 |
-
"name" => "FTP Passive Mode",
|
902 |
-
"attribute" => "ftppassivemode",
|
903 |
-
"type" => "onoff",
|
904 |
-
"validator" => "text",
|
905 |
-
"listitems" => null,
|
906 |
-
"value" => WFU_VAR("WFU_FTPPASSIVEMODE"),
|
907 |
-
"mode" => "free",
|
908 |
-
"category" => "general",
|
909 |
-
"subcategory" => "Upload Path and Files",
|
910 |
-
"parent" => "accessmethod",
|
911 |
-
"dependencies" => null,
|
912 |
-
"variables" => null,
|
913 |
-
"help" => "If files fail to upload to the ftp domain then switching to passive FTP mode may solve the problem."
|
914 |
-
),
|
915 |
-
array(
|
916 |
-
"name" => "Permissions of Uploaded File",
|
917 |
-
"attribute" => "ftpfilepermissions",
|
918 |
-
"type" => "text",
|
919 |
-
"validator" => "integer",
|
920 |
-
"listitems" => null,
|
921 |
-
"value" => WFU_VAR("WFU_FTPFILEPERMISSIONS"),
|
922 |
-
"mode" => "free",
|
923 |
-
"category" => "general",
|
924 |
-
"subcategory" => "Upload Path and Files",
|
925 |
-
"parent" => "accessmethod",
|
926 |
-
"dependencies" => null,
|
927 |
-
"variables" => null,
|
928 |
-
"help" => "Force the uploaded files to have specific permissions. This is a 4-digit octal number, e.g. 0777. If left empty, then the ftp server will define the permissions."
|
929 |
-
),
|
930 |
-
array(
|
931 |
-
"name" => "Show Upload Folder Path",
|
932 |
-
"attribute" => "showtargetfolder",
|
933 |
-
"type" => "onoff",
|
934 |
-
"validator" => "text",
|
935 |
-
"listitems" => null,
|
936 |
-
"value" => WFU_VAR("WFU_SHOWTARGETFOLDER"),
|
937 |
-
"mode" => "free",
|
938 |
-
"category" => "general",
|
939 |
-
"subcategory" => "Upload Path and Files",
|
940 |
-
"parent" => "",
|
941 |
-
"dependencies" => array("targetfolderlabel"),
|
942 |
-
"variables" => null,
|
943 |
-
"help" => "It defines if a label with the upload directory will be shown."
|
944 |
-
),
|
945 |
-
array(
|
946 |
-
"name" => "Select Subfolder",
|
947 |
-
"attribute" => "askforsubfolders",
|
948 |
-
"type" => "onoff",
|
949 |
-
"validator" => "text",
|
950 |
-
"listitems" => null,
|
951 |
-
"value" => WFU_VAR("WFU_ASKFORSUBFOLDERS"),
|
952 |
-
"mode" => "free",
|
953 |
-
"category" => "general",
|
954 |
-
"subcategory" => "Upload Path and Files",
|
955 |
-
"parent" => "",
|
956 |
-
"dependencies" => array("subfoldertree", "subfolderlabel"),
|
957 |
-
"variables" => null,
|
958 |
-
"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."
|
959 |
-
),
|
960 |
-
array(
|
961 |
-
"name" => "List of Subfolders",
|
962 |
-
"attribute" => "subfoldertree",
|
963 |
-
"type" => "folderlist",
|
964 |
-
"validator" => "text",
|
965 |
-
"listitems" => null,
|
966 |
-
"value" => WFU_VAR("WFU_SUBFOLDERTREE"),
|
967 |
-
"mode" => "free",
|
968 |
-
"category" => "general",
|
969 |
-
"subcategory" => "Upload Path and Files",
|
970 |
-
"parent" => "askforsubfolders",
|
971 |
-
"dependencies" => null,
|
972 |
-
"variables" => null,
|
973 |
-
"help" => "The list of folders a user can select. Please see documentation on how to create the list of folders. If 'Auto-populate list' is selected, then the list will be filled automatically with the first-level subfolders inside the directory defined by uploadpath. If 'List is editable' is selected, then the user will have the capability to type the subfolder and filter the subfolder list and/or define a new subfolder."
|
974 |
-
),
|
975 |
-
array(
|
976 |
-
"name" => "File Duplicates Policy",
|
977 |
-
"attribute" => "duplicatespolicy",
|
978 |
-
"type" => "radio",
|
979 |
-
"validator" => "text",
|
980 |
-
"listitems" => array("overwrite", "reject", "*maintain both"),
|
981 |
-
"value" => WFU_VAR("WFU_DUBLICATESPOLICY"),
|
982 |
-
"mode" => "free",
|
983 |
-
"category" => "general",
|
984 |
-
"subcategory" => "Upload Path and Files",
|
985 |
-
"parent" => "",
|
986 |
-
"dependencies" => array("uniquepattern"),
|
987 |
-
"variables" => null,
|
988 |
-
"help" => "It determines what happens when an uploaded file has the same name with an existing file. The uploaded file can overwrite the existing one, be rejected or both can be kept by renaming the uploaded file according to a rule defined in uniquepattern attribute."
|
989 |
-
),
|
990 |
-
array(
|
991 |
-
"name" => "File Rename Rule",
|
992 |
-
"attribute" => "uniquepattern",
|
993 |
-
"type" => "radio",
|
994 |
-
"validator" => "text",
|
995 |
-
"listitems" => array("index", "datetimestamp"),
|
996 |
-
"value" => WFU_VAR("WFU_UNIQUEPATTERN"),
|
997 |
-
"mode" => "free",
|
998 |
-
"category" => "general",
|
999 |
-
"subcategory" => "Upload Path and Files",
|
1000 |
-
"parent" => "duplicatespolicy",
|
1001 |
-
"dependencies" => null,
|
1002 |
-
"variables" => null,
|
1003 |
-
"help" => "If duplicatespolicy is set to 'maintain both', then this rule defines how the uploaded file will be renamed, in order not to match an existing file. An incremental index number or a datetime stamp can be included in the uploaded file name to make it unique."
|
1004 |
-
),
|
1005 |
-
array(
|
1006 |
-
"name" => "Redirect after Upload",
|
1007 |
-
"attribute" => "redirect",
|
1008 |
-
"type" => "onoff",
|
1009 |
-
"validator" => "text",
|
1010 |
-
"listitems" => null,
|
1011 |
-
"value" => WFU_VAR("WFU_REDIRECT"),
|
1012 |
-
"mode" => "free",
|
1013 |
-
"category" => "general",
|
1014 |
-
"subcategory" => "Redirection",
|
1015 |
-
"parent" => "",
|
1016 |
-
"dependencies" => array("redirectlink"),
|
1017 |
-
"variables" => null,
|
1018 |
-
"help" => "If enabled, the user will be redirected to a url defined in redirectlink attribute upon successful upload of all the files."
|
1019 |
-
),
|
1020 |
-
array(
|
1021 |
-
"name" => "Redirection URL",
|
1022 |
-
"attribute" => "redirectlink",
|
1023 |
-
"type" => "ltext",
|
1024 |
-
"validator" => "link",
|
1025 |
-
"listitems" => null,
|
1026 |
-
"value" => WFU_VAR("WFU_REDIRECTLINK"),
|
1027 |
-
"mode" => "free",
|
1028 |
-
"category" => "general",
|
1029 |
-
"subcategory" => "Redirection",
|
1030 |
-
"parent" => "redirect",
|
1031 |
-
"dependencies" => null,
|
1032 |
-
"variables" => array("%filename%", "%username%"),
|
1033 |
-
"help" => "This is the redirect URL. The URL can be dynamic by using variables. Please see Documentation on how to use variables inside attributes."
|
1034 |
-
),
|
1035 |
-
array(
|
1036 |
-
"name" => "Show Detailed Admin Messages",
|
1037 |
-
"attribute" => "adminmessages",
|
1038 |
-
"type" => "onoff",
|
1039 |
-
"validator" => "text",
|
1040 |
-
"listitems" => null,
|
1041 |
-
"value" => WFU_VAR("WFU_ADMINMESSAGES"),
|
1042 |
-
"mode" => "free",
|
1043 |
-
"category" => "general",
|
1044 |
-
"subcategory" => "Other Administrator Options",
|
1045 |
-
"parent" => "",
|
1046 |
-
"dependencies" => null,
|
1047 |
-
"variables" => null,
|
1048 |
-
"help" => "If enabled then more detailed messages about upload operations will be shown to administrators for debugging or error detection."
|
1049 |
-
),
|
1050 |
-
array(
|
1051 |
-
"name" => "Disable AJAX",
|
1052 |
-
"attribute" => "forceclassic",
|
1053 |
-
"type" => "onoff",
|
1054 |
-
"validator" => "text",
|
1055 |
-
"listitems" => null,
|
1056 |
-
"value" => WFU_VAR("WFU_FORCECLASSIC"),
|
1057 |
-
"mode" => "free",
|
1058 |
-
"category" => "general",
|
1059 |
-
"subcategory" => "Other Administrator Options",
|
1060 |
-
"parent" => "",
|
1061 |
-
"dependencies" => null,
|
1062 |
-
"variables" => null,
|
1063 |
-
"help" => "If AJAX is disabled, then upload of files will be performed using HTML forms, meaning that page will refresh to complete the upload. Use it in case that AJAX is causing problems with your page (although the plugin has an auto-detection feature for checking if user's browser supports AJAX or not)."
|
1064 |
-
),
|
1065 |
-
array(
|
1066 |
-
"name" => "Test Mode",
|
1067 |
-
"attribute" => "testmode",
|
1068 |
-
"type" => "onoff",
|
1069 |
-
"validator" => "text",
|
1070 |
-
"listitems" => null,
|
1071 |
-
"value" => WFU_VAR("WFU_TESTMODE"),
|
1072 |
-
"mode" => "free",
|
1073 |
-
"category" => "general",
|
1074 |
-
"subcategory" => "Other Administrator Options",
|
1075 |
-
"parent" => "",
|
1076 |
-
"dependencies" => null,
|
1077 |
-
"variables" => null,
|
1078 |
-
"help" => "If enabled then the plugin will be shown in test mode, meaning that all selected features will be shown but no upload will be possible. Use it to review how the plugin looks like and style it according to your needs."
|
1079 |
-
),
|
1080 |
-
array(
|
1081 |
-
"name" => "Debug Mode",
|
1082 |
-
"attribute" => "debugmode",
|
1083 |
-
"type" => "onoff",
|
1084 |
-
"validator" => "text",
|
1085 |
-
"listitems" => null,
|
1086 |
-
"value" => WFU_VAR("WFU_DEBUGMODE"),
|
1087 |
-
"mode" => "free",
|
1088 |
-
"category" => "general",
|
1089 |
-
"subcategory" => "Other Administrator Options",
|
1090 |
-
"parent" => "",
|
1091 |
-
"dependencies" => null,
|
1092 |
-
"variables" => null,
|
1093 |
-
"help" => "If enabled then the plugin will show to administrators any internal PHP warnings and errors generated during the upload process inside the message box."
|
1094 |
-
),
|
1095 |
-
array(
|
1096 |
-
"name" => "Plugin Component Positions",
|
1097 |
-
"attribute" => "placements",
|
1098 |
-
"type" => "placements",
|
1099 |
-
"validator" => "text",
|
1100 |
-
"listitems" => null,
|
1101 |
-
"value" => WFU_VAR("WFU_PLACEMENTS"),
|
1102 |
-
"mode" => "free",
|
1103 |
-
"category" => "placements",
|
1104 |
-
"subcategory" => "Plugin Component Positions",
|
1105 |
-
"parent" => "",
|
1106 |
-
"dependencies" => null,
|
1107 |
-
"variables" => null,
|
1108 |
-
"help" => "It defines the positions of the selected plugin components. Drag the components from the right pane and drop them to the left one to define your own component positions."
|
1109 |
-
),
|
1110 |
-
array(
|
1111 |
-
"name" => "Plugin Title",
|
1112 |
-
"attribute" => "uploadtitle",
|
1113 |
-
"type" => "text",
|
1114 |
-
"validator" => "text",
|
1115 |
-
"listitems" => null,
|
1116 |
-
"value" => WFU_UPLOADTITLE,
|
1117 |
-
"mode" => "free",
|
1118 |
-
"category" => "labels",
|
1119 |
-
"subcategory" => "Title",
|
1120 |
-
"parent" => "",
|
1121 |
-
"dependencies" => null,
|
1122 |
-
"variables" => null,
|
1123 |
-
"help" => "A text representing the title of the plugin."
|
1124 |
-
),
|
1125 |
-
array(
|
1126 |
-
"name" => "Select Button Caption",
|
1127 |
-
"attribute" => "selectbutton",
|
1128 |
-
"type" => "text",
|
1129 |
-
"validator" => "text",
|
1130 |
-
"listitems" => null,
|
1131 |
-
"value" => WFU_SELECTBUTTON,
|
1132 |
-
"mode" => "free",
|
1133 |
-
"category" => "labels",
|
1134 |
-
"subcategory" => "Buttons",
|
1135 |
-
"parent" => "",
|
1136 |
-
"dependencies" => null,
|
1137 |
-
"variables" => null,
|
1138 |
-
"help" => "The caption of the button that selects the files for upload."
|
1139 |
-
),
|
1140 |
-
array(
|
1141 |
-
"name" => "Upload Button Caption",
|
1142 |
-
"attribute" => "uploadbutton",
|
1143 |
-
"type" => "text",
|
1144 |
-
"validator" => "text",
|
1145 |
-
"listitems" => null,
|
1146 |
-
"value" => WFU_UPLOADBUTTON,
|
1147 |
-
"mode" => "free",
|
1148 |
-
"category" => "labels",
|
1149 |
-
"subcategory" => "Buttons",
|
1150 |
-
"parent" => "",
|
1151 |
-
"dependencies" => null,
|
1152 |
-
"variables" => null,
|
1153 |
-
"help" => "The caption of the button that starts the upload."
|
1154 |
-
),
|
1155 |
-
array(
|
1156 |
-
"name" => "Upload Folder Label",
|
1157 |
-
"attribute" => "targetfolderlabel",
|
1158 |
-
"type" => "text",
|
1159 |
-
"validator" => "text",
|
1160 |
-
"listitems" => null,
|
1161 |
-
"value" => WFU_VAR("WFU_TARGETFOLDERLABEL"),
|
1162 |
-
"mode" => "free",
|
1163 |
-
"category" => "labels",
|
1164 |
-
"subcategory" => "Upload Folder",
|
1165 |
-
"parent" => "",
|
1166 |
-
"dependencies" => null,
|
1167 |
-
"variables" => null,
|
1168 |
-
"help" => "This is the label before the upload folder path, if the path is selected to be shown using the showtargetfolder attribute."
|
1169 |
-
),
|
1170 |
-
array(
|
1171 |
-
"name" => "Select Subfolder Label",
|
1172 |
-
"attribute" => "subfolderlabel",
|
1173 |
-
"type" => "text",
|
1174 |
-
"validator" => "text",
|
1175 |
-
"listitems" => null,
|
1176 |
-
"value" => WFU_VAR("WFU_SUBFOLDERLABEL"),
|
1177 |
-
"mode" => "free",
|
1178 |
-
"category" => "labels",
|
1179 |
-
"subcategory" => "Upload Folder",
|
1180 |
-
"parent" => "",
|
1181 |
-
"dependencies" => null,
|
1182 |
-
"variables" => null,
|
1183 |
-
"help" => "This is the label of the subfolder dropdown list. It is active when askforsubfolders attribute is on."
|
1184 |
-
),
|
1185 |
-
array(
|
1186 |
-
"name" => "Success Upload Message",
|
1187 |
-
"attribute" => "successmessage",
|
1188 |
-
"type" => "ltext",
|
1189 |
-
"validator" => "text",
|
1190 |
-
"listitems" => null,
|
1191 |
-
"value" => WFU_SUCCESSMESSAGE,
|
1192 |
-
"mode" => "free",
|
1193 |
-
"category" => "labels",
|
1194 |
-
"subcategory" => "Upload Messages",
|
1195 |
-
"parent" => "",
|
1196 |
-
"dependencies" => null,
|
1197 |
-
"variables" => array("%filename%", "%filepath%"),
|
1198 |
-
"help" => "This is the message that will be shown for every file that has been uploaded successfully."
|
1199 |
-
),
|
1200 |
-
array(
|
1201 |
-
"name" => "Warning Upload Message",
|
1202 |
-
"attribute" => "warningmessage",
|
1203 |
-
"type" => "ltext",
|
1204 |
-
"validator" => "text",
|
1205 |
-
"listitems" => null,
|
1206 |
-
"value" => WFU_WARNINGMESSAGE,
|
1207 |
-
"mode" => "free",
|
1208 |
-
"category" => "labels",
|
1209 |
-
"subcategory" => "Upload Messages",
|
1210 |
-
"parent" => "",
|
1211 |
-
"dependencies" => null,
|
1212 |
-
"variables" => array("%filename%", "%filepath%"),
|
1213 |
-
"help" => "This is the message that will be shown for every file that has been uploaded with warnings."
|
1214 |
-
),
|
1215 |
-
array(
|
1216 |
-
"name" => "Error Upload Message",
|
1217 |
-
"attribute" => "errormessage",
|
1218 |
-
"type" => "ltext",
|
1219 |
-
"validator" => "text",
|
1220 |
-
"listitems" => null,
|
1221 |
-
"value" => WFU_ERRORMESSAGE,
|
1222 |
-
"mode" => "free",
|
1223 |
-
"category" => "labels",
|
1224 |
-
"subcategory" => "Upload Messages",
|
1225 |
-
"parent" => "",
|
1226 |
-
"dependencies" => null,
|
1227 |
-
"variables" => array("%filename%", "%filepath%"),
|
1228 |
-
"help" => "This is the message that will be shown for every file that has failed to upload."
|
1229 |
-
),
|
1230 |
-
array(
|
1231 |
-
"name" => "Wait Upload Message",
|
1232 |
-
"attribute" => "waitmessage",
|
1233 |
-
"type" => "ltext",
|
1234 |
-
"validator" => "text",
|
1235 |
-
"listitems" => null,
|
1236 |
-
"value" => WFU_WAITMESSAGE,
|
1237 |
-
"mode" => "free",
|
1238 |
-
"category" => "labels",
|
1239 |
-
"subcategory" => "Upload Messages",
|
1240 |
-
"parent" => "",
|
1241 |
-
"dependencies" => null,
|
1242 |
-
"variables" => array("%filename%", "%filepath%"),
|
1243 |
-
"help" => "This is the message that will be shown while file is uploading."
|
1244 |
-
),
|
1245 |
-
array(
|
1246 |
-
"name" => "Upload Media Button Caption",
|
1247 |
-
"attribute" => "uploadmediabutton",
|
1248 |
-
"type" => "text",
|
1249 |
-
"validator" => "text",
|
1250 |
-
"listitems" => null,
|
1251 |
-
"value" => WFU_UPLOADMEDIABUTTON,
|
1252 |
-
"mode" => "free",
|
1253 |
-
"category" => "labels",
|
1254 |
-
"subcategory" => "Webcam Labels",
|
1255 |
-
"parent" => "",
|
1256 |
-
"dependencies" => null,
|
1257 |
-
"variables" => null,
|
1258 |
-
"help" => "The caption of the button that starts the upload when media capture from the webcam has been activated."
|
1259 |
-
),
|
1260 |
-
array(
|
1261 |
-
"name" => "Video Filename",
|
1262 |
-
"attribute" => "videoname",
|
1263 |
-
"type" => "text",
|
1264 |
-
"validator" => "text",
|
1265 |
-
"listitems" => null,
|
1266 |
-
"value" => WFU_VIDEONAME,
|
1267 |
-
"mode" => "free",
|
1268 |
-
"category" => "labels",
|
1269 |
-
"subcategory" => "Webcam Labels",
|
1270 |
-
"parent" => "",
|
1271 |
-
"dependencies" => null,
|
1272 |
-
"variables" => array("%userid%", "%username%", "%blogid%", "%pageid%", "%pagetitle%", "%userdataXXX%"),
|
1273 |
-
"help" => "This is the file name of the captured video file."
|
1274 |
-
),
|
1275 |
-
array(
|
1276 |
-
"name" => "Image Filename",
|
1277 |
-
"attribute" => "imagename",
|
1278 |
-
"type" => "text",
|
1279 |
-
"validator" => "text",
|
1280 |
-
"listitems" => null,
|
1281 |
-
"value" => WFU_IMAGENAME,
|
1282 |
-
"mode" => "free",
|
1283 |
-
"category" => "labels",
|
1284 |
-
"subcategory" => "Webcam Labels",
|
1285 |
-
"parent" => "",
|
1286 |
-
"dependencies" => null,
|
1287 |
-
"variables" => array("%userid%", "%username%", "%blogid%", "%pageid%", "%pagetitle%", "%userdataXXX%"),
|
1288 |
-
"help" => "This is the file name of the captured image file."
|
1289 |
-
),
|
1290 |
-
array(
|
1291 |
-
"name" => "Required Fields Suffix",
|
1292 |
-
"attribute" => "requiredlabel",
|
1293 |
-
"type" => "text",
|
1294 |
-
"validator" => "text",
|
1295 |
-
"listitems" => null,
|
1296 |
-
"value" => WFU_USERDATA_REQUIREDLABEL,
|
1297 |
-
"mode" => "free",
|
1298 |
-
"category" => "labels",
|
1299 |
-
"subcategory" => "Other Labels",
|
1300 |
-
"parent" => "",
|
1301 |
-
"dependencies" => null,
|
1302 |
-
"variables" => null,
|
1303 |
-
"help" => "This is the keyword that shows up next to user field labels in order to denote that they are required."
|
1304 |
-
),
|
1305 |
-
array(
|
1306 |
-
"name" => "Notify by Email",
|
1307 |
-
"attribute" => "notify",
|
1308 |
-
"type" => "onoff",
|
1309 |
-
"validator" => "text",
|
1310 |
-
"listitems" => null,
|
1311 |
-
"value" => WFU_VAR("WFU_NOTIFY"),
|
1312 |
-
"mode" => "free",
|
1313 |
-
"category" => "notifications",
|
1314 |
-
"subcategory" => "Email Notifications",
|
1315 |
-
"parent" => "",
|
1316 |
-
"dependencies" => array("notifyrecipients", "notifysubject", "notifymessage", "notifyheaders", "attachfile"),
|
1317 |
-
"variables" => null,
|
1318 |
-
"help" => "If activated then email will be sent to inform about successful file uploads."
|
1319 |
-
),
|
1320 |
-
array(
|
1321 |
-
"name" => "Email Recipients",
|
1322 |
-
"attribute" => "notifyrecipients",
|
1323 |
-
"type" => "mtext",
|
1324 |
-
"validator" => "text",
|
1325 |
-
"listitems" => null,
|
1326 |
-
"value" => WFU_VAR("WFU_NOTIFYRECIPIENTS"),
|
1327 |
-
"mode" => "free",
|
1328 |
-
"category" => "notifications",
|
1329 |
-
"subcategory" => "Email Notifications",
|
1330 |
-
"parent" => "notify",
|
1331 |
-
"dependencies" => null,
|
1332 |
-
"variables" => array("%useremail%", "%userdataXXX%", "%n%", "%dq%"),
|
1333 |
-
"help" => "Defines the recipients of the email notification. Can be dynamic by using variables. Please check Documentation on how to use variables in atributes."
|
1334 |
-
),
|
1335 |
-
array(
|
1336 |
-
"name" => "Email Headers",
|
1337 |
-
"attribute" => "notifyheaders",
|
1338 |
-
"type" => "mtext",
|
1339 |
-
"validator" => "emailheaders",
|
1340 |
-
"listitems" => null,
|
1341 |
-
"value" => WFU_VAR("WFU_NOTIFYHEADERS"),
|
1342 |
-
"mode" => "free",
|
1343 |
-
"category" => "notifications",
|
1344 |
-
"subcategory" => "Email Notifications",
|
1345 |
-
"parent" => "notify",
|
1346 |
-
"dependencies" => null,
|
1347 |
-
"variables" => array("%n%", "%dq%"),
|
1348 |
-
"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."
|
1349 |
-
),
|
1350 |
-
array(
|
1351 |
-
"name" => "Email Subject",
|
1352 |
-
"attribute" => "notifysubject",
|
1353 |
-
"type" => "ltext",
|
1354 |
-
"validator" => "emailsubject",
|
1355 |
-
"listitems" => null,
|
1356 |
-
"value" => WFU_NOTIFYSUBJECT,
|
1357 |
-
"mode" => "free",
|
1358 |
-
"category" => "notifications",
|
1359 |
-
"subcategory" => "Email Notifications",
|
1360 |
-
"parent" => "notify",
|
1361 |
-
"dependencies" => null,
|
1362 |
-
"variables" => array("%username%", "%useremail%", "%filename%", "%filepath%", "%blogid%", "%pageid%", "%pagetitle%", "%userdataXXX%", "%dq%"),
|
1363 |
-
"help" => "Defines the email subject. Can be dynamic by using variables. Please check Documentation on how to use variables in atributes."
|
1364 |
-
),
|
1365 |
-
array(
|
1366 |
-
"name" => "Email Body",
|
1367 |
-
"attribute" => "notifymessage",
|
1368 |
-
"type" => "mtext",
|
1369 |
-
"validator" => "emailbody",
|
1370 |
-
"listitems" => null,
|
1371 |
-
"value" => WFU_NOTIFYMESSAGE,
|
1372 |
-
"mode" => "free",
|
1373 |
-
"category" => "notifications",
|
1374 |
-
"subcategory" => "Email Notifications",
|
1375 |
-
"parent" => "notify",
|
1376 |
-
"dependencies" => null,
|
1377 |
-
"variables" => array("%username%", "%useremail%", "%filename%", "%filepath%", "%blogid%", "%pageid%", "%pagetitle%", "%userdataXXX%", "%n%", "%dq%"),
|
1378 |
-
"help" => "Defines the email body. Can be dynamic by using variables. Please check Documentation on how to use variables in atributes."
|
1379 |
-
),
|
1380 |
-
array(
|
1381 |
-
"name" => "Attach Uploaded Files",
|
1382 |
-
"attribute" => "attachfile",
|
1383 |
-
"type" => "onoff",
|
1384 |
-
"validator" => "text",
|
1385 |
-
"listitems" => null,
|
1386 |
-
"value" => WFU_VAR("WFU_ATTACHFILE"),
|
1387 |
-
"mode" => "free",
|
1388 |
-
"category" => "notifications",
|
1389 |
-
"subcategory" => "Email Notifications",
|
1390 |
-
"parent" => "notify",
|
1391 |
-
"dependencies" => null,
|
1392 |
-
"variables" => null,
|
1393 |
-
"help" => "If activated, then uploaded files will be included in the notification email as attachments. Please use carefully."
|
1394 |
-
),
|
1395 |
-
array(
|
1396 |
-
"name" => "Ask for Consent",
|
1397 |
-
"attribute" => "askconsent",
|
1398 |
-
"type" => "onoff",
|
1399 |
-
"validator" => "text",
|
1400 |
-
"listitems" => null,
|
1401 |
-
"value" => WFU_VAR("WFU_ASKCONSENT"),
|
1402 |
-
"mode" => "free",
|
1403 |
-
"category" => "personaldata",
|
1404 |
-
"subcategory" => "General Personal Data Options",
|
1405 |
-
"parent" => "",
|
1406 |
-
"dependencies" => array("personaldatatypes"),
|
1407 |
-
"variables" => null,
|
1408 |
-
"help" => "If activated, then consent from users will be asked for storing their personal data. If users do not give consent, then their data will not be stored in the database, they will only be included in the notification email, if email notifications are active."
|
1409 |
-
),
|
1410 |
-
array(
|
1411 |
-
"name" => "Personal Data Types",
|
1412 |
-
"attribute" => "personaldatatypes",
|
1413 |
-
"type" => "radio",
|
1414 |
-
"validator" => "text",
|
1415 |
-
"listitems" => array("userdata", "userdata and files"),
|
1416 |
-
"value" => WFU_VAR("WFU_PERSONALDATATYPES"),
|
1417 |
-
"mode" => "free",
|
1418 |
-
"category" => "personaldata",
|
1419 |
-
"subcategory" => "General Personal Data Options",
|
1420 |
-
"parent" => "askconsent",
|
1421 |
-
"dependencies" => null,
|
1422 |
-
"variables" => null,
|
1423 |
-
"help" => "Determines which data are considered as personal data. By default only userdata are considered as personal data. If the 2nd option is selected, then files will also be considered as personal data. This means that if the users do not give their consent, then the files will not be uploaded on the website, they will only be inluded in the notification email as attachments, if email notifications are active."
|
1424 |
-
),
|
1425 |
-
array(
|
1426 |
-
"name" => "Do Not Remember Consent Answer",
|
1427 |
-
"attribute" => "notrememberconsent",
|
1428 |
-
"type" => "onoff",
|
1429 |
-
"validator" => "text",
|
1430 |
-
"listitems" => null,
|
1431 |
-
"value" => WFU_VAR("WFU_NOTREMEMBERCONSENT"),
|
1432 |
-
"mode" => "free",
|
1433 |
-
"category" => "personaldata",
|
1434 |
-
"subcategory" => "Consent Behaviour",
|
1435 |
-
"parent" => "",
|
1436 |
-
"dependencies" => null,
|
1437 |
-
"variables" => null,
|
1438 |
-
"help" => "If activated the plugin will not remember the consent answer provided by the user and the consent question will always show."
|
1439 |
-
),
|
1440 |
-
array(
|
1441 |
-
"name" => "Consent Denial Rejects Upload",
|
1442 |
-
"attribute" => "consentrejectupload",
|
1443 |
-
"type" => "onoff",
|
1444 |
-
"validator" => "text",
|
1445 |
-
"listitems" => null,
|
1446 |
-
"value" => WFU_VAR("WFU_CONSENTREJECTUPLOAD"),
|
1447 |
-
"mode" => "free",
|
1448 |
-
"category" => "personaldata",
|
1449 |
-
"subcategory" => "Consent Behaviour",
|
1450 |
-
"parent" => "",
|
1451 |
-
"dependencies" => array("consentrejectmessage"),
|
1452 |
-
"variables" => null,
|
1453 |
-
"help" => "If activated and user has denied consent then the upload will be rejected. If deactivated, then the upload will continue regardless of consent answer."
|
1454 |
-
),
|
1455 |
-
array(
|
1456 |
-
"name" => "Reject Message",
|
1457 |
-
"attribute" => "consentrejectmessage",
|
1458 |
-
"type" => "ltext",
|
1459 |
-
"validator" => "text",
|
1460 |
-
"listitems" => null,
|
1461 |
-
"value" => WFU_CONSENTREJECTMESSAGE,
|
1462 |
-
"mode" => "free",
|
1463 |
-
"category" => "personaldata",
|
1464 |
-
"subcategory" => "Consent Behaviour",
|
1465 |
-
"parent" => "consentrejectupload",
|
1466 |
-
"dependencies" => null,
|
1467 |
-
"variables" => null,
|
1468 |
-
"help" => "It defines the message that will appear to the user if upload cannot continue due to consent denial."
|
1469 |
-
),
|
1470 |
-
array(
|
1471 |
-
"name" => "Consent Format",
|
1472 |
-
"attribute" => "consentformat",
|
1473 |
-
"type" => "radio",
|
1474 |
-
"validator" => "text",
|
1475 |
-
"listitems" => array("checkbox", "radio", "prompt"),
|
1476 |
-
"value" => WFU_VAR("WFU_CONSENTFORMAT"),
|
1477 |
-
"mode" => "free",
|
1478 |
-
"category" => "personaldata",
|
1479 |
-
"subcategory" => "Consent Appearance",
|
1480 |
-
"parent" => "",
|
1481 |
-
"dependencies" => null,
|
1482 |
-
"variables" => null,
|
1483 |
-
"help" => "Determines how consent question will appear to the user. If 'checkbox' is selected then a checkbox will appear inside the upload form which the user needs to tick. If 'radio' is selected then a radio button with 'Yes' and 'No' answers will appear inside the form (this makes sure that the user will select something after all. If 'prompt' is selected then a dialog will appear on the user when pressing the upload button asking for consent."
|
1484 |
-
),
|
1485 |
-
array(
|
1486 |
-
"name" => "Preselected Answer",
|
1487 |
-
"attribute" => "consentpreselect",
|
1488 |
-
"type" => "radio",
|
1489 |
-
"validator" => "text",
|
1490 |
-
"listitems" => array("none", "yes", "no"),
|
1491 |
-
"value" => WFU_VAR("WFU_CONSENTPRESELECT"),
|
1492 |
-
"mode" => "free",
|
1493 |
-
"category" => "personaldata",
|
1494 |
-
"subcategory" => "Consent Appearance",
|
1495 |
-
"parent" => "",
|
1496 |
-
"dependencies" => null,
|
1497 |
-
"variables" => null,
|
1498 |
-
"help" => "Determines whether a default answer will be selected."
|
1499 |
-
),
|
1500 |
-
array(
|
1501 |
-
"name" => "Consent Question for Checkbox",
|
1502 |
-
"attribute" => "consentquestion",
|
1503 |
-
"type" => "ltext",
|
1504 |
-
"validator" => "text",
|
1505 |
-
"listitems" => null,
|
1506 |
-
"value" => WFU_CONSENTQUESTION,
|
1507 |
-
"mode" => "free",
|
1508 |
-
"category" => "personaldata",
|
1509 |
-
"subcategory" => "Consent Appearance",
|
1510 |
-
"parent" => "",
|
1511 |
-
"dependencies" => null,
|
1512 |
-
"variables" => null,
|
1513 |
-
"help" => "Defines the question that will appear to the user next to the checkbox, or radio buttons or inside the prompt dialog. If a word starting and ending with semicolon (:) is added in the question, e.g. :link:, then it will be replaced by a link defined in 'Consent Disclaimer Link' attribute. This way a link to a disclaimer can be added."
|
1514 |
-
),
|
1515 |
-
array(
|
1516 |
-
"name" => "Consent Disclaimer Link",
|
1517 |
-
"attribute" => "consentdisclaimer",
|
1518 |
-
"type" => "ltext",
|
1519 |
-
"validator" => "text",
|
1520 |
-
"listitems" => null,
|
1521 |
-
"value" => WFU_VAR("WFU_CONSENTDISCLAIMER"),
|
1522 |
-
"mode" => "free",
|
1523 |
-
"category" => "personaldata",
|
1524 |
-
"subcategory" => "Consent Appearance",
|
1525 |
-
"parent" => "",
|
1526 |
-
"dependencies" => null,
|
1527 |
-
"variables" => null,
|
1528 |
-
"help" => "Defines a link that displays a disclaimer to the user if the user presses the relevant link that is included inside the consent question."
|
1529 |
-
),
|
1530 |
-
array(
|
1531 |
-
"name" => "Success Upload Message Color",
|
1532 |
-
"attribute" => "successmessagecolor",
|
1533 |
-
"type" => "hidden",
|
1534 |
-
"validator" => "colors",
|
1535 |
-
"listitems" => null,
|
1536 |
-
"value" => WFU_SUCCESSMESSAGECOLOR,
|
1537 |
-
"mode" => "free",
|
1538 |
-
"category" => "colors",
|
1539 |
-
"subcategory" => "Upload Message Colors",
|
1540 |
-
"parent" => "",
|
1541 |
-
"dependencies" => null,
|
1542 |
-
"variables" => null,
|
1543 |
-
"help" => "It defines the color of the success message. This attribute has been replaced by successmessagecolors, however it is kept here for backward compatibility."
|
1544 |
-
),
|
1545 |
-
array(
|
1546 |
-
"name" => "Success Message Colors",
|
1547 |
-
"attribute" => "successmessagecolors",
|
1548 |
-
"type" => "color-triplet",
|
1549 |
-
"validator" => "colors",
|
1550 |
-
"listitems" => null,
|
1551 |
-
"value" => WFU_VAR("WFU_SUCCESSMESSAGECOLORS"),
|
1552 |
-
"mode" => "free",
|
1553 |
-
"category" => "colors",
|
1554 |
-
"subcategory" => "Upload Message Colors",
|
1555 |
-
"parent" => "",
|
1556 |
-
"dependencies" => null,
|
1557 |
-
"variables" => null,
|
1558 |
-
"help" => "It defines the text, background and border color of the success message."
|
1559 |
-
),
|
1560 |
-
array(
|
1561 |
-
"name" => "Warning Message Colors",
|
1562 |
-
"attribute" => "warningmessagecolors",
|
1563 |
-
"type" => "color-triplet",
|
1564 |
-
"validator" => "colors",
|
1565 |
-
"listitems" => null,
|
1566 |
-
"value" => WFU_VAR("WFU_WARNINGMESSAGECOLORS"),
|
1567 |
-
"mode" => "free",
|
1568 |
-
"category" => "colors",
|
1569 |
-
"subcategory" => "Upload Message Colors",
|
1570 |
-
"parent" => "",
|
1571 |
-
"dependencies" => null,
|
1572 |
-
"variables" => null,
|
1573 |
-
"help" => "It defines the text, background and border color of the warning message."
|
1574 |
-
),
|
1575 |
-
array(
|
1576 |
-
"name" => "Fail Message Colors",
|
1577 |
-
"attribute" => "failmessagecolors",
|
1578 |
-
"type" => "color-triplet",
|
1579 |
-
"validator" => "colors",
|
1580 |
-
"listitems" => null,
|
1581 |
-
"value" => WFU_VAR("WFU_FAILMESSAGECOLORS"),
|
1582 |
-
"mode" => "free",
|
1583 |
-
"category" => "colors",
|
1584 |
-
"subcategory" => "Upload Message Colors",
|
1585 |
-
"parent" => "",
|
1586 |
-
"dependencies" => null,
|
1587 |
-
"variables" => null,
|
1588 |
-
"help" => "It defines the text, background and border color of the fail (error) message."
|
1589 |
-
),
|
1590 |
-
array(
|
1591 |
-
"name" => "Wait Message Colors",
|
1592 |
-
"attribute" => "waitmessagecolors",
|
1593 |
-
"type" => "hidden",
|
1594 |
-
"validator" => "colors",
|
1595 |
-
"listitems" => null,
|
1596 |
-
"value" => WFU_VAR("WFU_WAITMESSAGECOLORS"),
|
1597 |
-
"mode" => "free",
|
1598 |
-
"category" => "colors",
|
1599 |
-
"subcategory" => "Upload Message Colors",
|
1600 |
-
"parent" => "",
|
1601 |
-
"dependencies" => null,
|
1602 |
-
"variables" => null,
|
1603 |
-
"help" => "It defines the text, background and border color of the wait message."
|
1604 |
-
),
|
1605 |
-
array(
|
1606 |
-
"name" => "Plugin Component Widths",
|
1607 |
-
"attribute" => "widths",
|
1608 |
-
"type" => "dimensions",
|
1609 |
-
"validator" => "text",
|
1610 |
-
"listitems" => null,
|
1611 |
-
"value" => WFU_VAR("WFU_WIDTHS"),
|
1612 |
-
"mode" => "free",
|
1613 |
-
"category" => "dimensions",
|
1614 |
-
"subcategory" => "Plugin Component Widths",
|
1615 |
-
"parent" => "",
|
1616 |
-
"dependencies" => null,
|
1617 |
-
"variables" => null,
|
1618 |
-
"help" => "It defines the widths of the selected plugin components."
|
1619 |
-
),
|
1620 |
-
array(
|
1621 |
-
"name" => "Plugin Component Heights",
|
1622 |
-
"attribute" => "heights",
|
1623 |
-
"type" => "dimensions",
|
1624 |
-
"validator" => "text",
|
1625 |
-
"listitems" => null,
|
1626 |
-
"value" => WFU_VAR("WFU_HEIGHTS"),
|
1627 |
-
"mode" => "free",
|
1628 |
-
"category" => "dimensions",
|
1629 |
-
"subcategory" => "Plugin Component Heights",
|
1630 |
-
"parent" => "",
|
1631 |
-
"dependencies" => null,
|
1632 |
-
"variables" => null,
|
1633 |
-
"help" => "It defines the heights of the selected plugin components."
|
1634 |
-
),
|
1635 |
-
array(
|
1636 |
-
"name" => "Include Additional Data Fields",
|
1637 |
-
"attribute" => "userdata",
|
1638 |
-
"type" => "onoff",
|
1639 |
-
"validator" => "text",
|
1640 |
-
"listitems" => null,
|
1641 |
-
"value" => WFU_VAR("WFU_USERDATA"),
|
1642 |
-
"mode" => "free",
|
1643 |
-
"category" => "userdata",
|
1644 |
-
"subcategory" => "Additional Data Fields",
|
1645 |
-
"parent" => "",
|
1646 |
-
"dependencies" => array("userdatalabel"),
|
1647 |
-
"variables" => null,
|
1648 |
-
"help" => "If enabled, then user can send additional information together with uploaded files (e.g. name, email etc), defined in userdatalabel attribute."
|
1649 |
-
),
|
1650 |
-
array(
|
1651 |
-
"name" => "Additional Data Fields",
|
1652 |
-
"attribute" => "userdatalabel",
|
1653 |
-
"type" => "formfields",
|
1654 |
-
"validator" => "text",
|
1655 |
-
"listitems" => wfu_formfield_definitions(),
|
1656 |
-
"value" => WFU_USERDATALABEL,
|
1657 |
-
"mode" => "free",
|
1658 |
-
"category" => "userdata",
|
1659 |
-
"subcategory" => "Additional Data Fields",
|
1660 |
-
"parent" => "userdata",
|
1661 |
-
"dependencies" => null,
|
1662 |
-
"variables" => null,
|
1663 |
-
"help" => "It defines the labels of the additional data fields and whether they are required or not."
|
1664 |
-
),
|
1665 |
-
array(
|
1666 |
-
"name" => "WP Filebase Plugin Connection",
|
1667 |
-
"attribute" => "filebaselink",
|
1668 |
-
"type" => "onoff",
|
1669 |
-
"validator" => "text",
|
1670 |
-
"listitems" => null,
|
1671 |
-
"value" => WFU_VAR("WFU_FILEBASELINK"),
|
1672 |
-
"mode" => "free",
|
1673 |
-
"category" => "interoperability",
|
1674 |
-
"subcategory" => "Connection With Other Plugins",
|
1675 |
-
"parent" => "",
|
1676 |
-
"dependencies" => null,
|
1677 |
-
"variables" => null,
|
1678 |
-
"help" => "If enabled then the WP Filebase Plugin will be informed about new file uploads."
|
1679 |
-
),
|
1680 |
-
array(
|
1681 |
-
"name" => "Add Uploaded Files To Media",
|
1682 |
-
"attribute" => "medialink",
|
1683 |
-
"type" => "onoff",
|
1684 |
-
"validator" => "text",
|
1685 |
-
"listitems" => null,
|
1686 |
-
"value" => WFU_VAR("WFU_MEDIALINK"),
|
1687 |
-
"mode" => "free",
|
1688 |
-
"category" => "interoperability",
|
1689 |
-
"subcategory" => "Connection With Other Wordpress Features",
|
1690 |
-
"parent" => "",
|
1691 |
-
"dependencies" => null,
|
1692 |
-
"variables" => null,
|
1693 |
-
"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)."
|
1694 |
-
),
|
1695 |
-
array(
|
1696 |
-
"name" => "Attach Uploaded Files To Post",
|
1697 |
-
"attribute" => "postlink",
|
1698 |
-
"type" => "onoff",
|
1699 |
-
"validator" => "text",
|
1700 |
-
"listitems" => null,
|
1701 |
-
"value" => WFU_VAR("WFU_POSTLINK"),
|
1702 |
-
"mode" => "free",
|
1703 |
-
"category" => "interoperability",
|
1704 |
-
"subcategory" => "Connection With Other Wordpress Features",
|
1705 |
-
"parent" => "",
|
1706 |
-
"dependencies" => null,
|
1707 |
-
"variables" => null,
|
1708 |
-
"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)."
|
1709 |
-
),
|
1710 |
-
array(
|
1711 |
-
"name" => "Enable Webcam",
|
1712 |
-
"attribute" => "webcam",
|
1713 |
-
"type" => "onoff",
|
1714 |
-
"validator" => "text",
|
1715 |
-
"listitems" => null,
|
1716 |
-
"value" => WFU_VAR("WFU_WEBCAM"),
|
1717 |
-
"mode" => "free",
|
1718 |
-
"category" => "webcam",
|
1719 |
-
"subcategory" => "Capture from Webcam (experimental)",
|
1720 |
-
"parent" => "",
|
1721 |
-
"dependencies" => array("webcammode", "audiocapture", "videowidth", "videoheight", "videoaspectratio", "videoframerate", "camerafacing", "maxrecordtime", "uploadmediabutton", "videoname", "imagename"),
|
1722 |
-
"variables" => null,
|
1723 |
-
"help" => "This enables capturing of video or still pictures from the computer's webcam. It is experimental because it is not supported by all browsers yet."
|
1724 |
-
),
|
1725 |
-
array(
|
1726 |
-
"name" => "Capture Mode",
|
1727 |
-
"attribute" => "webcammode",
|
1728 |
-
"type" => "radio",
|
1729 |
-
"validator" => "text",
|
1730 |
-
"listitems" => array("capture video", "take photos", "both"),
|
1731 |
-
"value" => WFU_VAR("WFU_WEBCAMMODE"),
|
1732 |
-
"mode" => "free",
|
1733 |
-
"category" => "webcam",
|
1734 |
-
"subcategory" => "Capture from Webcam (experimental)",
|
1735 |
-
"parent" => "webcam",
|
1736 |
-
"dependencies" => null,
|
1737 |
-
"variables" => null,
|
1738 |
-
"help" => "It defines the webcam capture mode. The webcam can either capture video, still photos or both."
|
1739 |
-
),
|
1740 |
-
array(
|
1741 |
-
"name" => "Capture Audio",
|
1742 |
-
"attribute" => "audiocapture",
|
1743 |
-
"type" => "onoff",
|
1744 |
-
"validator" => "text",
|
1745 |
-
"listitems" => null,
|
1746 |
-
"value" => WFU_VAR("WFU_AUDIOCAPTURE"),
|
1747 |
-
"mode" => "free",
|
1748 |
-
"category" => "webcam",
|
1749 |
-
"subcategory" => "Capture from Webcam (experimental)",
|
1750 |
-
"parent" => "webcam",
|
1751 |
-
"dependencies" => null,
|
1752 |
-
"variables" => null,
|
1753 |
-
"help" => "It defines whether audio will be captured together with video from the webcam."
|
1754 |
-
),
|
1755 |
-
array(
|
1756 |
-
"name" => "Video Width",
|
1757 |
-
"attribute" => "videowidth",
|
1758 |
-
"type" => "text",
|
1759 |
-
"validator" => "text",
|
1760 |
-
"listitems" => null,
|
1761 |
-
"value" => WFU_VAR("WFU_VIDEOWIDTH"),
|
1762 |
-
"mode" => "free",
|
1763 |
-
"category" => "webcam",
|
1764 |
-
"subcategory" => "Capture from Webcam (experimental)",
|
1765 |
-
"parent" => "webcam",
|
1766 |
-
"dependencies" => null,
|
1767 |
-
"variables" => null,
|
1768 |
-
"help" => "It requests a preferable video width for the webcam. The plugin will try to match this setting as close as possible depending on webcam capabilities."
|
1769 |
-
),
|
1770 |
-
array(
|
1771 |
-
"name" => "Video Height",
|
1772 |
-
"attribute" => "videoheight",
|
1773 |
-
"type" => "text",
|
1774 |
-
"validator" => "text",
|
1775 |
-
"listitems" => null,
|
1776 |
-
"value" => WFU_VAR("WFU_VIDEOHEIGHT"),
|
1777 |
-
"mode" => "free",
|
1778 |
-
"category" => "webcam",
|
1779 |
-
"subcategory" => "Capture from Webcam (experimental)",
|
1780 |
-
"parent" => "webcam",
|
1781 |
-
"dependencies" => null,
|
1782 |
-
"variables" => null,
|
1783 |
-
"help" => "It requests a preferable video height for the webcam. The plugin will try to match this setting as close as possible depending on webcam capabilities."
|
1784 |
-
),
|
1785 |
-
array(
|
1786 |
-
"name" => "Video Aspect Ratio",
|
1787 |
-
"attribute" => "videoaspectratio",
|
1788 |
-
"type" => "text",
|
1789 |
-
"validator" => "text",
|
1790 |
-
"listitems" => null,
|
1791 |
-
"value" => WFU_VAR("WFU_VIDEOASPECTRATIO"),
|
1792 |
-
"mode" => "free",
|
1793 |
-
"category" => "webcam",
|
1794 |
-
"subcategory" => "Capture from Webcam (experimental)",
|
1795 |
-
"parent" => "webcam",
|
1796 |
-
"dependencies" => null,
|
1797 |
-
"variables" => null,
|
1798 |
-
"help" => "It requests a preferable video aspect ratio for the webcam. The plugin will try to match this setting as close as possible depending on webcam capabilities."
|
1799 |
-
),
|
1800 |
-
array(
|
1801 |
-
"name" => "Video Frame Rate",
|
1802 |
-
"attribute" => "videoframerate",
|
1803 |
-
"type" => "text",
|
1804 |
-
"validator" => "text",
|
1805 |
-
"listitems" => null,
|
1806 |
-
"value" => WFU_VAR("WFU_VIDEOFRAMERATE"),
|
1807 |
-
"mode" => "free",
|
1808 |
-
"category" => "webcam",
|
1809 |
-
"subcategory" => "Capture from Webcam (experimental)",
|
1810 |
-
"parent" => "webcam",
|
1811 |
-
"dependencies" => null,
|
1812 |
-
"variables" => null,
|
1813 |
-
"help" => "It requests a preferable video frame rate for video recording. The plugin will try to match this setting as close as possible depending on webcam capabilities."
|
1814 |
-
),
|
1815 |
-
array(
|
1816 |
-
"name" => "Camera Facing Mode",
|
1817 |
-
"attribute" => "camerafacing",
|
1818 |
-
"type" => "radio",
|
1819 |
-
"validator" => "text",
|
1820 |
-
"listitems" => array("any", "front", "back"),
|
1821 |
-
"value" => WFU_VAR("WFU_CAMERAFACING"),
|
1822 |
-
"mode" => "free",
|
1823 |
-
"category" => "webcam",
|
1824 |
-
"subcategory" => "Capture from Webcam (experimental)",
|
1825 |
-
"parent" => "webcam",
|
1826 |
-
"dependencies" => null,
|
1827 |
-
"variables" => null,
|
1828 |
-
"help" => "It defines if the front or back camera will be preferred (for mobile devices with 2 cameras). The plugin will try to match this setting depending on webcam capabilities."
|
1829 |
-
),
|
1830 |
-
array(
|
1831 |
-
"name" => "Max Record Time",
|
1832 |
-
"attribute" => "maxrecordtime",
|
1833 |
-
"type" => "integer",
|
1834 |
-
"validator" => "integer",
|
1835 |
-
"listitems" => null,
|
1836 |
-
"value" => WFU_VAR("WFU_MAXRECORDTIME"),
|
1837 |
-
"mode" => "free",
|
1838 |
-
"category" => "webcam",
|
1839 |
-
"subcategory" => "Capture from Webcam (experimental)",
|
1840 |
-
"parent" => "webcam",
|
1841 |
-
"dependencies" => null,
|
1842 |
-
"variables" => null,
|
1843 |
-
"help" => "It defines the maximum time of video recording (in seconds). If it is set to -1, then there is no time limit."
|
1844 |
-
),
|
1845 |
-
null
|
1846 |
-
);
|
1847 |
-
|
1848 |
-
wfu_array_remove_nulls($defs);
|
1849 |
-
|
1850 |
-
|
1851 |
-
return $defs;
|
1852 |
-
}
|
1853 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Definition of Various Attributes of the Plugin
|
5 |
+
*
|
6 |
+
* This file contains definition of shortcode and formfield attributes of the
|
7 |
+
* plugin.
|
8 |
+
*
|
9 |
+
* @link /lib/wfu_attributes.php
|
10 |
+
*
|
11 |
+
* @package WordPress File Upload Plugin
|
12 |
+
* @subpackage Core Components
|
13 |
+
* @since 2.1.2
|
14 |
+
*/
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Definition of Uploader Form Elements
|
18 |
+
*
|
19 |
+
* This function defines the elements of the plugin upload form.
|
20 |
+
*
|
21 |
+
* @since 2.1.2
|
22 |
+
*
|
23 |
+
* @return array The list of uploader form elements (components).
|
24 |
+
*/
|
25 |
+
function wfu_component_definitions() {
|
26 |
+
$components = array(
|
27 |
+
array(
|
28 |
+
"id" => "title",
|
29 |
+
"name" => "Title",
|
30 |
+
"mode" => "free",
|
31 |
+
"dimensions" => array("plugin/Plugin", "title/Title"),
|
32 |
+
"multiplacements" => false,
|
33 |
+
"help" => "A title text for the plugin"
|
34 |
+
),
|
35 |
+
array(
|
36 |
+
"id" => "filename",
|
37 |
+
"name" => "Filename",
|
38 |
+
"mode" => "free",
|
39 |
+
"dimensions" => null,
|
40 |
+
"multiplacements" => false,
|
41 |
+
"help" => "It shows the name of the selected file (useful only for single file uploads)."
|
42 |
+
),
|
43 |
+
array(
|
44 |
+
"id" => "selectbutton",
|
45 |
+
"name" => "Select Button",
|
46 |
+
"mode" => "free",
|
47 |
+
"dimensions" => null,
|
48 |
+
"multiplacements" => false,
|
49 |
+
"help" => "Represents the button to select the files for upload."
|
50 |
+
),
|
51 |
+
array(
|
52 |
+
"id" => "uploadbutton",
|
53 |
+
"name" => "Upload Button",
|
54 |
+
"mode" => "free",
|
55 |
+
"dimensions" => null,
|
56 |
+
"multiplacements" => false,
|
57 |
+
"help" => "Represents the button to execute the upload after some files have been selected."
|
58 |
+
),
|
59 |
+
array(
|
60 |
+
"id" => "subfolders",
|
61 |
+
"name" => "Subfolders",
|
62 |
+
"mode" => "free",
|
63 |
+
"dimensions" => array("uploadfolder_label/Upload Folder Label", "subfolders/Subfolders", "subfolders_label/Subfolders Label", "subfolders_select/Subfolders List"),
|
64 |
+
"multiplacements" => false,
|
65 |
+
"help" => "Allows the user to select the upload folder from a dropdown list."
|
66 |
+
),
|
67 |
+
array(
|
68 |
+
"id" => "webcam",
|
69 |
+
"name" => "Webcam",
|
70 |
+
"mode" => "commercial",
|
71 |
+
"dimensions" => array("webcam/Webcam Box"),
|
72 |
+
"multiplacements" => false,
|
73 |
+
"help" => "Displays video from the device's webcam. The user can capture and upload screenshots or video streams."
|
74 |
+
),
|
75 |
+
array(
|
76 |
+
"id" => "progressbar",
|
77 |
+
"name" => "Progressbar",
|
78 |
+
"mode" => "free",
|
79 |
+
"dimensions" => null,
|
80 |
+
"multiplacements" => false,
|
81 |
+
"help" => "Displays a simple progress bar, showing total progress of upload."
|
82 |
+
),
|
83 |
+
array(
|
84 |
+
"id" => "userdata",
|
85 |
+
"name" => "User Fields",
|
86 |
+
"mode" => "free",
|
87 |
+
"dimensions" => array("userdata/User Fields", "userdata_label/User Fields Label", "userdata_value/User Fields Value"),
|
88 |
+
"multiplacements" => true,
|
89 |
+
"help" => "Displays additional fields that the user must fill-in together with the uploaded files."
|
90 |
+
),
|
91 |
+
array(
|
92 |
+
"id" => "consent",
|
93 |
+
"name" => "Consent",
|
94 |
+
"mode" => "free",
|
95 |
+
"dimensions" => array("consent/Consent Block"),
|
96 |
+
"multiplacements" => false,
|
97 |
+
"help" => "Displays a checkbox asking user's consent for storing personal data."
|
98 |
+
),
|
99 |
+
array(
|
100 |
+
"id" => "message",
|
101 |
+
"name" => "Message",
|
102 |
+
"mode" => "free",
|
103 |
+
"dimensions" => null,
|
104 |
+
"multiplacements" => false,
|
105 |
+
"help" => "Displays a message block with information about the upload, together with any warnings or errors."
|
106 |
+
)
|
107 |
+
);
|
108 |
+
|
109 |
+
wfu_array_remove_nulls($components);
|
110 |
+
|
111 |
+
return $components;
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* Definition of Uploader Form Attribute Categories
|
116 |
+
*
|
117 |
+
* This function defines the categories of the plugin uploader shortcode
|
118 |
+
* attributes. These categories show up as different tabs of the shortcode
|
119 |
+
* composer.
|
120 |
+
*
|
121 |
+
* @since 2.1.2
|
122 |
+
*
|
123 |
+
* @return array The list of uploader form attribute categories.
|
124 |
+
*/
|
125 |
+
function wfu_category_definitions() {
|
126 |
+
$cats = array(
|
127 |
+
"general" => "General",
|
128 |
+
"placements" => "Placements",
|
129 |
+
"labels" => "Labels",
|
130 |
+
"notifications" => "Notifications",
|
131 |
+
"personaldata" => "Personal Data",
|
132 |
+
"colors" => "Colors",
|
133 |
+
"dimensions" => "Dimensions",
|
134 |
+
"userdata" => "Additional Fields",
|
135 |
+
"interoperability" => "Interoperability",
|
136 |
+
"webcam" => "Webcam"
|
137 |
+
);
|
138 |
+
|
139 |
+
return $cats;
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* Definition of Uploader Form Custom Fields
|
144 |
+
*
|
145 |
+
* This function defines the plugin upload form custom fields and their
|
146 |
+
* attributes.
|
147 |
+
*
|
148 |
+
* @since 3.3.0
|
149 |
+
*
|
150 |
+
* @return array The list of upload form custom fields.
|
151 |
+
*/
|
152 |
+
function wfu_formfield_definitions() {
|
153 |
+
//field properties have 2 parts separated by "/"; the first part determines if the property will be shown to the user (show or hide); the second part determines default value)
|
154 |
+
//when making changes in the structure of formfield definitions, the following are affected:
|
155 |
+
// - wfu_admin_composer.php function wfu_shortcode_composer
|
156 |
+
// variable $fieldprops_basic
|
157 |
+
// variable $fieldprops_default
|
158 |
+
// variable $template
|
159 |
+
// variable wfu_attribute_..._typeprops
|
160 |
+
// variable $from_template
|
161 |
+
// - wfu_functions.php function wfu_parse_userdata_attribute
|
162 |
+
// variable $default
|
163 |
+
// variable $fieldprops
|
164 |
+
// - wfu_blocks.php function wfu_userdata_apply_template
|
165 |
+
// return variable
|
166 |
+
// - wordpress_file_upload_adminfuctions.js function wfu_formdata_type_changed
|
167 |
+
// variable field
|
168 |
+
// - wordpress_file_upload_adminfuctions.js function wfu_formdata_add_field
|
169 |
+
// variable field
|
170 |
+
// - wordpress_file_upload_adminfuctions.js function wfu_formdata_prepare_template
|
171 |
+
// variable fieldprops_basic
|
172 |
+
// variable template
|
173 |
+
// - wordpress_file_upload_adminfuctions.js function wfu_update_formfield_value
|
174 |
+
// variable part
|
175 |
+
// - wordpress_file_upload_adminfuctions.js function wfu_apply_value
|
176 |
+
// variable def
|
177 |
+
// variable fieldprops
|
178 |
+
$formfields = array(
|
179 |
+
array(
|
180 |
+
"type" => "text",
|
181 |
+
"type_description" => "Simple Text",
|
182 |
+
//label properties
|
183 |
+
"label" => "",
|
184 |
+
"label_label" => "Label",
|
185 |
+
"label_hint" => "enter the label that will be shown next to the field",
|
186 |
+
//checkbox properties
|
187 |
+
"required" => "show/false",
|
188 |
+
"required_hint" => "if checked, then this field must have a non-empty value for the file to be uploaded",
|
189 |
+
"donotautocomplete" => "show/false",
|
190 |
+
"donotautocomplete_hint" => "if checked, then the field will notify the browsers not to fill it with autocomplete data when the plugin is reloaded",
|
191 |
+
"validate" => "hide/false",
|
192 |
+
"validate_hint" => "if checked, then the field value entered by the user will be validated before file upload",
|
193 |
+
"typehook" => "hide/false",
|
194 |
+
"typehook_hint" => "if checked, then text suggestions will be shown below the field as the user types more text inside",
|
195 |
+
//dropdown properties
|
196 |
+
"labelposition" => "show/left",
|
197 |
+
"labelposition_hint" => "select the position of the field's label; the position is relative to the field",
|
198 |
+
"hintposition" => "show/right",
|
199 |
+
"hintposition_hint" => "select the position of the hint that will be shown to notify the user that something is wrong\\r\\nthe position is relative to the field",
|
200 |
+
//text properties
|
201 |
+
"default" => "show/",
|
202 |
+
"default_hint" => "enter a default value for the field or leave it empty if you do not want a default value",
|
203 |
+
"data" => "hide/",
|
204 |
+
"data_label" => "Data",
|
205 |
+
"data_hint" => "complete a list of values to be shown to the user",
|
206 |
+
"group" => "hide/",
|
207 |
+
"group_hint" => "if a value is set, then all fields having the same value will belong to the same group",
|
208 |
+
"format" => "hide/",
|
209 |
+
"format_hint" => "enter a format to format user selection"
|
210 |
+
),
|
211 |
+
array(
|
212 |
+
"type" => "multitext",
|
213 |
+
"type_description" => "Multiple Lines Text",
|
214 |
+
//label properties
|
215 |
+
"label" => "",
|
216 |
+
"label_label" => "Label",
|
217 |
+
"label_hint" => "enter the label that will be shown next to the field",
|
218 |
+
//checkbox properties
|
219 |
+
"required" => "show/false",
|
220 |
+
"required_hint" => "if checked, then this field must have a non-empty value for the file to be uploaded",
|
221 |
+
"donotautocomplete" => "hide/true",
|
222 |
+
"donotautocomplete_hint" => "if checked, then the field will notify the browsers not to fill it with autocomplete data when the plugin is reloaded",
|
223 |
+
"validate" => "hide/false",
|
224 |
+
"validate_hint" => "if checked, then the field value entered by the user will be validated before file upload",
|
225 |
+
"typehook" => "hide/false",
|
226 |
+
"typehook_hint" => "if checked, then text suggestions will be shown below the field as the user types more text inside",
|
227 |
+
//dropdown properties
|
228 |
+
"labelposition" => "show/left",
|
229 |
+
"labelposition_hint" => "select the position of the field's label; the position is relative to the field",
|
230 |
+
"hintposition" => "show/right",
|
231 |
+
"hintposition_hint" => "select the position of the hint that will be shown to notify the user that something is wrong\\r\\nthe position is relative to the field",
|
232 |
+
//text properties
|
233 |
+
"default" => "hide/",
|
234 |
+
"default_hint" => "enter a default value for the field or leave it empty if you do not want a default value",
|
235 |
+
"data" => "hide/",
|
236 |
+
"data_label" => "Data",
|
237 |
+
"data_hint" => "complete a list of values to be shown to the user",
|
238 |
+
"group" => "hide/",
|
239 |
+
"group_hint" => "if a value is set, then all fields having the same value will belong to the same group",
|
240 |
+
"format" => "hide/",
|
241 |
+
"format_hint" => "enter a format to format user selection"
|
242 |
+
),
|
243 |
+
array(
|
244 |
+
"type" => "number",
|
245 |
+
"type_description" => "Number",
|
246 |
+
//label properties
|
247 |
+
"label" => "",
|
248 |
+
"label_label" => "Label",
|
249 |
+
"label_hint" => "enter the label that will be shown next to the field",
|
250 |
+
//checkbox properties
|
251 |
+
"required" => "show/false",
|
252 |
+
"required_hint" => "if checked, then this field must have a non-empty value for the file to be uploaded",
|
253 |
+
"donotautocomplete" => "show/true",
|
254 |
+
"donotautocomplete_hint" => "if checked, then the field will notify the browsers not to fill it with autocomplete data when the plugin is reloaded",
|
255 |
+
"validate" => "show/true",
|
256 |
+
"validate_hint" => "if checked, then the number entered by the user will be checked if it is a valid number, based on the format defined, before file upload",
|
257 |
+
"typehook" => "show/false",
|
258 |
+
"typehook_hint" => "if checked, then only valid characters will be allowed during typing",
|
259 |
+
//dropdown properties
|
260 |
+
"labelposition" => "show/left",
|
261 |
+
"labelposition_hint" => "select the position of the field's label; the position is relative to the field",
|
262 |
+
"hintposition" => "show/right",
|
263 |
+
"hintposition_hint" => "select the position of the hint that will be shown to notify the user that something is wrong\\r\\nthe position is relative to the field",
|
264 |
+
//text properties
|
265 |
+
"default" => "show/",
|
266 |
+
"default_hint" => "enter a default value for the field or leave it empty if you do not want a default value",
|
267 |
+
"data" => "hide/",
|
268 |
+
"data_label" => "Data",
|
269 |
+
"data_hint" => "complete a list of values to be shown to the user",
|
270 |
+
"group" => "hide/",
|
271 |
+
"group_hint" => "if a non-empty group value is set, then another email confirmation field belonging to the same group must have the same email value",
|
272 |
+
"format" => "show/d",
|
273 |
+
"format_hint" => "enter a format for the number:\\r\\n d for integers\\r\\n f for floating point numbers\\r\\nthe dot (.) symbol is used as a decimal separator"
|
274 |
+
),
|
275 |
+
array(
|
276 |
+
"type" => "email",
|
277 |
+
"type_description" => "Email",
|
278 |
+
//label properties
|
279 |
+
"label" => "",
|
280 |
+
"label_label" => "Label",
|
281 |
+
"label_hint" => "enter the label that will be shown next to the field",
|
282 |
+
//checkbox properties
|
283 |
+
"required" => "show/false",
|
284 |
+
"required_hint" => "if checked, then this field must have a non-empty value for the file to be uploaded",
|
285 |
+
"donotautocomplete" => "show/true",
|
286 |
+
"donotautocomplete_hint" => "if checked, then the field will notify the browsers not to fill it with autocomplete data when the plugin is reloaded",
|
287 |
+
"validate" => "show/true",
|
288 |
+
"validate_hint" => "if checked, then the email entered by the user will be checked if it is valid before file upload",
|
289 |
+
"typehook" => "hide/false",
|
290 |
+
"typehook_hint" => "if checked, then text suggestions will be shown below the field as the user types more text inside",
|
291 |
+
//dropdown properties
|
292 |
+
"labelposition" => "show/left",
|
293 |
+
"labelposition_hint" => "select the position of the field's label; the position is relative to the field",
|
294 |
+
"hintposition" => "show/right",
|
295 |
+
"hintposition_hint" => "select the position of the hint that will be shown to notify the user that something is wrong\\r\\nthe position is relative to the field",
|
296 |
+
//text properties
|
297 |
+
"default" => "show/",
|
298 |
+
"default_hint" => "enter a default value for the field or leave it empty if you do not want a default value",
|
299 |
+
"data" => "hide/",
|
300 |
+
"data_label" => "Data",
|
301 |
+
"data_hint" => "complete a list of values to be shown to the user",
|
302 |
+
"group" => "show/0",
|
303 |
+
"group_hint" => "if a non-empty group value is set, then another email confirmation field belonging to the same group must have the same email value",
|
304 |
+
"format" => "hide/",
|
305 |
+
"format_hint" => "enter a format to format user selection"
|
306 |
+
),
|
307 |
+
array(
|
308 |
+
"type" => "confirmemail",
|
309 |
+
"type_description" => "Confirmation Email",
|
310 |
+
//label properties
|
311 |
+
"label" => "",
|
312 |
+
"label_label" => "Label",
|
313 |
+
"label_hint" => "enter the label that will be shown next to the field",
|
314 |
+
//checkbox properties
|
315 |
+
"required" => "show/true",
|
316 |
+
"required_hint" => "if checked, then this field must have a non-empty value for the file to be uploaded",
|
317 |
+
"donotautocomplete" => "show/true",
|
318 |
+
"donotautocomplete_hint" => "if checked, then the field will notify the browsers not to fill it with autocomplete data when the plugin is reloaded",
|
319 |
+
"validate" => "hide/true",
|
320 |
+
"validate_hint" => "if checked, then the confirmation email entered by the user will be checked if it is the same with the email belonging to the same group",
|
321 |
+
"typehook" => "hide/false",
|
322 |
+
"typehook_hint" => "if checked, then text suggestions will be shown below the field as the user types more text inside",
|
323 |
+
//dropdown properties
|
324 |
+
"labelposition" => "show/left",
|
325 |
+
"labelposition_hint" => "select the position of the field's label; the position is relative to the field",
|
326 |
+
"hintposition" => "show/right",
|
327 |
+
"hintposition_hint" => "select the position of the hint that will be shown to notify the user that something is wrong\\r\\nthe position is relative to the field",
|
328 |
+
//text properties
|
329 |
+
"default" => "hide/",
|
330 |
+
"default_hint" => "enter a default value for the field or leave it empty if you do not want a default value",
|
331 |
+
"data" => "hide/",
|
332 |
+
"data_label" => "Data",
|
333 |
+
"data_hint" => "complete a list of values to be shown to the user",
|
334 |
+
"group" => "show/0",
|
335 |
+
"group_hint" => "enter a non-empty value to match this email confirmation field with another email field",
|
336 |
+
"format" => "hide/",
|
337 |
+
"format_hint" => "enter a format to format user selection"
|
338 |
+
),
|
339 |
+
array(
|
340 |
+
"type" => "password",
|
341 |
+
"type_description" => "Password",
|
342 |
+
//label properties
|
343 |
+
"label" => "",
|
344 |
+
"label_label" => "Label",
|
345 |
+
"label_hint" => "enter the label that will be shown next to the field",
|
346 |
+
//checkbox properties
|
347 |
+
"required" => "show/true",
|
348 |
+
"required_hint" => "if checked, then this field must have a non-empty value for the file to be uploaded",
|
349 |
+
"donotautocomplete" => "false/true",
|
350 |
+
"donotautocomplete_hint" => "if checked, then the field will notify the browsers not to fill it with autocomplete data when the plugin is reloaded",
|
351 |
+
"validate" => "hide/false",
|
352 |
+
"validate_hint" => "if checked, then the value entered by the user will be validated",
|
353 |
+
"typehook" => "hide/false",
|
354 |
+
"typehook_hint" => "if checked, then text suggestions will be shown below the field as the user types more text inside",
|
355 |
+
//dropdown properties
|
356 |
+
"labelposition" => "show/left",
|
357 |
+
"labelposition_hint" => "select the position of the field's label; the position is relative to the field",
|
358 |
+
"hintposition" => "show/right",
|
359 |
+
"hintposition_hint" => "select the position of the hint that will be shown to notify the user that something is wrong\\r\\nthe position is relative to the field",
|
360 |
+
//text properties
|
361 |
+
"default" => "hide/",
|
362 |
+
"default_hint" => "enter a default value for the field or leave it empty if you do not want a default value",
|
363 |
+
"data" => "hide/",
|
364 |
+
"data_label" => "Data",
|
365 |
+
"data_hint" => "complete a list of values to be shown to the user",
|
366 |
+
"group" => "show/0",
|
367 |
+
"group_hint" => "if a non-empty group value is set, then another password confirmation field belonging to the same group must have the same password",
|
368 |
+
"format" => "hide/",
|
369 |
+
"format_hint" => "enter a format to format user selection"
|
370 |
+
),
|
371 |
+
array(
|
372 |
+
"type" => "confirmpassword",
|
373 |
+
"type_description" => "Confirmation Password",
|
374 |
+
//label properties
|
375 |
+
"label" => "",
|
376 |
+
"label_label" => "Label",
|
377 |
+
"label_hint" => "enter the label that will be shown next to the field",
|
378 |
+
//checkbox properties
|
379 |
+
"required" => "show/true",
|
380 |
+
"required_hint" => "if checked, then this field must have a non-empty value for the file to be uploaded",
|
381 |
+
"donotautocomplete" => "false/true",
|
382 |
+
"donotautocomplete_hint" => "if checked, then the field will notify the browsers not to fill it with autocomplete data when the plugin is reloaded",
|
383 |
+
"validate" => "hide/true",
|
384 |
+
"validate_hint" => "if checked, then the value entered by the user will be validated",
|
385 |
+
"typehook" => "hide/false",
|
386 |
+
"typehook_hint" => "if checked, then text suggestions will be shown below the field as the user types more text inside",
|
387 |
+
//dropdown properties
|
388 |
+
"labelposition" => "show/left",
|
389 |
+
"labelposition_hint" => "select the position of the field's label; the position is relative to the field",
|
390 |
+
"hintposition" => "show/right",
|
391 |
+
"hintposition_hint" => "select the position of the hint that will be shown to notify the user that something is wrong\\r\\nthe position is relative to the field",
|
392 |
+
//text properties
|
393 |
+
"default" => "hide/",
|
394 |
+
"default_hint" => "enter a default value for the field or leave it empty if you do not want a default value",
|
395 |
+
"data" => "hide/",
|
396 |
+
"data_label" => "Data",
|
397 |
+
"data_hint" => "complete a list of values to be shown to the user",
|
398 |
+
"group" => "show/0",
|
399 |
+
"group_hint" => "if a non-empty group value is set, then another password confirmation field belonging to the same group must have the same password",
|
400 |
+
"format" => "hide/",
|
401 |
+
"format_hint" => "enter a format to format user selection"
|
402 |
+
),
|
403 |
+
array(
|
404 |
+
"type" => "checkbox",
|
405 |
+
"type_description" => "Checkbox",
|
406 |
+
//label properties
|
407 |
+
"label" => "",
|
408 |
+
"label_label" => "Label",
|
409 |
+
"label_hint" => "enter the label that will be shown next to the field",
|
410 |
+
//checkbox properties
|
411 |
+
"required" => "show/false",
|
412 |
+
"required_hint" => "if checked, then this checkbox field must be checked before file upload",
|
413 |
+
"donotautocomplete" => "show/true",
|
414 |
+
"donotautocomplete_hint" => "if checked, then the field will not be autocompleted by browsers",
|
415 |
+
"validate" => "hide/false",
|
416 |
+
"validate_hint" => "if checked, then the field value entered by the user will be validated before file upload",
|
417 |
+
"typehook" => "hide/false",
|
418 |
+
"typehook_hint" => "if checked, then text suggestions will be shown below the field as the user types more text inside",
|
419 |
+
//dropdown properties
|
420 |
+
"labelposition" => "show/none",
|
421 |
+
"labelposition_hint" => "select the position of the field's label; the position is relative to the field",
|
422 |
+
"hintposition" => "show/right",
|
423 |
+
"hintposition_hint" => "select the position of the hint that will be shown to notify the user that something is wrong\\r\\nthe position is relative to the field",
|
424 |
+
//text properties
|
425 |
+
"default" => "show/false",
|
426 |
+
"default_hint" => "enter a default value (true or false) for the field or leave it empty if you do not want a default value",
|
427 |
+
"data" => "show/",
|
428 |
+
"data_label" => "Description",
|
429 |
+
"data_hint" => "enter a description for the checkbox",
|
430 |
+
"group" => "hide/",
|
431 |
+
"group_hint" => "if a value is set, then all fields having the same value will belong to the same group",
|
432 |
+
"format" => "show/right",
|
433 |
+
"format_hint" => "define the location of the description in relation to the check box\\r\\npossible values are: top, right, bottom, left"
|
434 |
+
),
|
435 |
+
array(
|
436 |
+
"type" => "radiobutton",
|
437 |
+
"type_description" => "Radio button",
|
438 |
+
//label properties
|
439 |
+
"label" => "",
|
440 |
+
"label_label" => "Label",
|
441 |
+
"label_hint" => "enter the label that will be shown next to the field",
|
442 |
+
//checkbox properties
|
443 |
+
"required" => "show/false",
|
444 |
+
"required_hint" => "if checked, then a radio button must be selected before file upload",
|
445 |
+
"donotautocomplete" => "show/true",
|
446 |
+
"donotautocomplete_hint" => "if checked, then the field will not be autocompleted by browsers",
|
447 |
+
"validate" => "hide/false",
|
448 |
+
"validate_hint" => "if checked, then the field value entered by the user will be validated before file upload",
|
449 |
+
"typehook" => "hide/false",
|
450 |
+
"typehook_hint" => "if checked, then text suggestions will be shown below the field as the user types more text inside",
|
451 |
+
//dropdown properties
|
452 |
+
"labelposition" => "show/left",
|
453 |
+
"labelposition_hint" => "select the position of the field's label; the position is relative to the field",
|
454 |
+
"hintposition" => "show/right",
|
455 |
+
"hintposition_hint" => "select the position of the hint that will be shown to notify the user that something is wrong\\r\\nthe position is relative to the field",
|
456 |
+
//text properties
|
457 |
+
"default" => "show/",
|
458 |
+
"default_hint" => "enter a default value for the field or leave it empty if you do not want a default value",
|
459 |
+
"data" => "show/",
|
460 |
+
"data_label" => "Items",
|
461 |
+
"data_hint" => "enter a comma delimited list of radio button items",
|
462 |
+
"group" => "show/0",
|
463 |
+
"group_hint" => "all radio buttons having the same group id belong to the same group",
|
464 |
+
"format" => "show/",
|
465 |
+
"format_hint" => "define the location of the radio labels in relation to their radio buttons (top, right, bottom, left)\\r\\nand the placement of the radio buttons (horizontal, vertical)"
|
466 |
+
),
|
467 |
+
array(
|
468 |
+
"type" => "date",
|
469 |
+
"type_description" => "Date",
|
470 |
+
//label properties
|
471 |
+
"label" => "",
|
472 |
+
"label_label" => "Label",
|
473 |
+
"label_hint" => "enter the label that will be shown next to the field",
|
474 |
+
//checkbox properties
|
475 |
+
"required" => "show/false",
|
476 |
+
"required_hint" => "if checked, then a date must be entered before file upload",
|
477 |
+
"donotautocomplete" => "show/true",
|
478 |
+
"donotautocomplete_hint" => "if checked, then the field will not be autocompleted by browsers",
|
479 |
+
"validate" => "hide/false",
|
480 |
+
"validate_hint" => "if checked, then the field value entered by the user will be validated before file upload",
|
481 |
+
"typehook" => "hide/false",
|
482 |
+
"typehook_hint" => "if checked, then text suggestions will be shown below the field as the user types more text inside",
|
483 |
+
//dropdown properties
|
484 |
+
"labelposition" => "show/left",
|
485 |
+
"labelposition_hint" => "select the position of the field's label; the position is relative to the field",
|
486 |
+
"hintposition" => "show/right",
|
487 |
+
"hintposition_hint" => "select the position of the hint that will be shown to notify the user that something is wrong\\r\\nthe position is relative to the field",
|
488 |
+
//text properties
|
489 |
+
"default" => "show/",
|
490 |
+
"default_hint" => "enter a default date for the field or leave it empty if you do not want a default value",
|
491 |
+
"data" => "hide/",
|
492 |
+
"data_label" => "Data",
|
493 |
+
"data_hint" => "enter data items",
|
494 |
+
"group" => "hide/",
|
495 |
+
"group_hint" => "enter a group value",
|
496 |
+
"format" => "show/",
|
497 |
+
"format_hint" => "define the format of the date field as follows:\\r\\n d - day of month (no leading zero)\\r\\n dd - day of month (two digit)\\r\\n o - day of the year (no leading zeros)\\r\\n oo - day of the year (three digit)\\r\\n D - day name short\\r\\n DD - day name long\\r\\n m - month of year (no leading zero)\\r\\n mm - month of year (two digit)\\r\\n M - month name short\\r\\n MM - month name long\\r\\n y - year (two digit)\\r\\n yy - year (four digit)\\r\\n @ - Unix timestamp (ms since 01/01/1970)\\r\\n ! - Windows ticks (100ns since 01/01/0001)\\r\\n '...' - literal text\\r\\n '' - single quote\\r\\n anything else - literal text\\r\\nthe format must be in parenthesis ()"
|
498 |
+
),
|
499 |
+
array(
|
500 |
+
"type" => "time",
|
501 |
+
"type_description" => "Time",
|
502 |
+
//label properties
|
503 |
+
"label" => "",
|
504 |
+
"label_label" => "Label",
|
505 |
+
"label_hint" => "enter the label that will be shown next to the field",
|
506 |
+
//checkbox properties
|
507 |
+
"required" => "show/false",
|
508 |
+
"required_hint" => "if checked, then a time must be entered before file upload",
|
509 |
+
"donotautocomplete" => "show/true",
|
510 |
+
"donotautocomplete_hint" => "if checked, then the field will not be autocompleted by browsers",
|
511 |
+
"validate" => "hide/false",
|
512 |
+
"validate_hint" => "if checked, then the field value entered by the user will be validated before file upload",
|
513 |
+
"typehook" => "hide/false",
|
514 |
+
"typehook_hint" => "if checked, then text suggestions will be shown below the field as the user types more text inside",
|
515 |
+
//dropdown properties
|
516 |
+
"labelposition" => "show/left",
|
517 |
+
"labelposition_hint" => "select the position of the field's label; the position is relative to the field",
|
518 |
+
"hintposition" => "show/right",
|
519 |
+
"hintposition_hint" => "select the position of the hint that will be shown to notify the user that something is wrong\\r\\nthe position is relative to the field",
|
520 |
+
//text properties
|
521 |
+
"default" => "show/",
|
522 |
+
"default_hint" => "enter a default time for the field or leave it empty if you do not want a default value",
|
523 |
+
"data" => "hide/",
|
524 |
+
"data_label" => "Data",
|
525 |
+
"data_hint" => "enter data items",
|
526 |
+
"group" => "hide/",
|
527 |
+
"group_hint" => "enter a group value",
|
528 |
+
"format" => "show/",
|
529 |
+
"format_hint" => "define the format of the time field as follows:\\r\\n H - hour with no leading 0 (24 hour)\\r\\n HH - hour with leading 0 (24 hour)\\r\\n h - hour with no leading 0 (12 hour)\\r\\n hh - hour with leading 0 (12 hour)\\r\\n m - minute with no leading 0\\r\\n mm - minute with leading 0\\r\\n s - second with no leading 0\\r\\n ss - second with leading 0\\r\\n l - milliseconds always with leading 0\\r\\n c - microseconds always with leading 0\\r\\n t - a or p for AM/PM\\r\\n T - A or P for AM/PM\\r\\n tt - am or pm for AM/PM\\r\\n TT - AM or PM for AM/PM\\r\\n z - timezone as defined by timezoneList\\r\\n Z - timezone in Iso 8601 format (+04:45)\\r\\n '...' - literal text\\r\\nthe format must be in parenthesis ()"
|
530 |
+
),
|
531 |
+
array(
|
532 |
+
"type" => "datetime",
|
533 |
+
"type_description" => "DateTime",
|
534 |
+
//label properties
|
535 |
+
"label" => "",
|
536 |
+
"label_label" => "Label",
|
537 |
+
"label_hint" => "enter the label that will be shown next to the field",
|
538 |
+
//checkbox properties
|
539 |
+
"required" => "show/false",
|
540 |
+
"required_hint" => "if checked, then a date and time must be entered before file upload",
|
541 |
+
"donotautocomplete" => "show/true",
|
542 |
+
"donotautocomplete_hint" => "if checked, then the field will not be autocompleted by browsers",
|
543 |
+
"validate" => "hide/false",
|
544 |
+
"validate_hint" => "if checked, then the field value entered by the user will be validated before file upload",
|
545 |
+
"typehook" => "hide/false",
|
546 |
+
"typehook_hint" => "if checked, then text suggestions will be shown below the field as the user types more text inside",
|
547 |
+
//dropdown properties
|
548 |
+
"labelposition" => "show/left",
|
549 |
+
"labelposition_hint" => "select the position of the field's label; the position is relative to the field",
|
550 |
+
"hintposition" => "show/right",
|
551 |
+
"hintposition_hint" => "select the position of the hint that will be shown to notify the user that something is wrong\\r\\nthe position is relative to the field",
|
552 |
+
//text properties
|
553 |
+
"default" => "show/",
|
554 |
+
"default_hint" => "enter a default date and time for the field or leave it empty if you do not want a default value",
|
555 |
+
"data" => "hide/",
|
556 |
+
"data_label" => "Data",
|
557 |
+
"data_hint" => "enter data items",
|
558 |
+
"group" => "hide/",
|
559 |
+
"group_hint" => "enter a group value",
|
560 |
+
"format" => "show/",
|
561 |
+
"format_hint" => "define the format of the datetime field as follows:\\r\\n date(dateformat) where dateformat is:\\r\\n d - day of month (no leading zero)\\r\\n dd - day of month (two digit)\\r\\n o - day of the year (no leading zeros)\\r\\n oo - day of the year (three digit)\\r\\n D - day name short\\r\\n DD - day name long\\r\\n m - month of year (no leading zero)\\r\\n mm - month of year (two digit)\\r\\n M - month name short\\r\\n MM - month name long\\r\\n y - year (two digit)\\r\\n yy - year (four digit)\\r\\n @ - Unix timestamp (ms since 01/01/1970)\\r\\n ! - Windows ticks (100ns since 01/01/0001)\\r\\n '...' - literal text\\r\\n '' - single quote\\r\\n anything else - literal text\\r\\n time(timeformat) where timeformat is:\\r\\n H - hour with no leading 0 (24 hour)\\r\\n HH - hour with leading 0 (24 hour)\\r\\n h - hour with no leading 0 (12 hour)\\r\\n hh - hour with leading 0 (12 hour)\\r\\n m - minute with no leading 0\\r\\n mm - minute with leading 0\\r\\n s - second with no leading 0\\r\\n ss - second with leading 0\\r\\n l - milliseconds always with leading 0\\r\\n c - microseconds always with leading 0\\r\\n t - a or p for AM/PM\\r\\n T - A or P for AM/PM\\r\\n tt - am or pm for AM/PM\\r\\n TT - AM or PM for AM/PM\\r\\n z - timezone as defined by timezoneList\\r\\n Z - timezone in Iso 8601 format (+04:45)\\r\\n '...' - literal text"
|
562 |
+
),
|
563 |
+
array(
|
564 |
+
"type" => "list",
|
565 |
+
"type_description" => "Listbox",
|
566 |
+
//label properties
|
567 |
+
"label" => "",
|
568 |
+
"label_label" => "Label",
|
569 |
+
"label_hint" => "enter the label that will be shown next to the field",
|
570 |
+
//checkbox properties
|
571 |
+
"required" => "show/false",
|
572 |
+
"required_hint" => "if checked, then a list item must be selected before file upload",
|
573 |
+
"donotautocomplete" => "show/true",
|
574 |
+
"donotautocomplete_hint" => "if checked, then the field will not be autocompleted by browsers",
|
575 |
+
"validate" => "hide/false",
|
576 |
+
"validate_hint" => "if checked, then the field value entered by the user will be validated before file upload",
|
577 |
+
"typehook" => "hide/false",
|
578 |
+
"typehook_hint" => "if checked, then text suggestions will be shown below the field as the user types more text inside",
|
579 |
+
//dropdown properties
|
580 |
+
"labelposition" => "show/left",
|
581 |
+
"labelposition_hint" => "select the position of the field's label; the position is relative to the field",
|
582 |
+
"hintposition" => "show/right",
|
583 |
+
"hintposition_hint" => "select the position of the hint that will be shown to notify the user that something is wrong\\r\\nthe position is relative to the field",
|
584 |
+
//text properties
|
585 |
+
"default" => "show/",
|
586 |
+
"default_hint" => "enter a default value for the field or leave it empty if you do not want a default value",
|
587 |
+
"data" => "show/",
|
588 |
+
"data_label" => "List Items",
|
589 |
+
"data_hint" => "enter a comma delimited list of items",
|
590 |
+
"group" => "hide/",
|
591 |
+
"group_hint" => "all items having the same group id belong to the same group",
|
592 |
+
"format" => "hide/",
|
593 |
+
"format_hint" => "enter the format of the list"
|
594 |
+
),
|
595 |
+
array(
|
596 |
+
"type" => "dropdown",
|
597 |
+
"type_description" => "Dropdown",
|
598 |
+
//label properties
|
599 |
+
"label" => "",
|
600 |
+
"label_label" => "Label",
|
601 |
+
"label_hint" => "enter the label that will be shown next to the field",
|
602 |
+
//checkbox properties
|
603 |
+
"required" => "show/false",
|
604 |
+
"required_hint" => "if checked, then an item from the dropdown list must be selected before file upload",
|
605 |
+
"donotautocomplete" => "show/true",
|
606 |
+
"donotautocomplete_hint" => "if checked, then the field will not be autocompleted by browsers",
|
607 |
+
"validate" => "hide/false",
|
608 |
+
"validate_hint" => "if checked, then the field value entered by the user will be validated before file upload",
|
609 |
+
"typehook" => "hide/false",
|
610 |
+
"typehook_hint" => "if checked, then text suggestions will be shown below the field as the user types more text inside",
|
611 |
+
//dropdown properties
|
612 |
+
"labelposition" => "show/left",
|
613 |
+
"labelposition_hint" => "select the position of the field's label; the position is relative to the field",
|
614 |
+
"hintposition" => "show/right",
|
615 |
+
"hintposition_hint" => "select the position of the hint that will be shown to notify the user that something is wrong\\r\\nthe position is relative to the field",
|
616 |
+
//text properties
|
617 |
+
"default" => "show/",
|
618 |
+
"default_hint" => "enter a default value for the field or leave it empty if you do not want a default value",
|
619 |
+
"data" => "show/",
|
620 |
+
"data_label" => "List Items",
|
621 |
+
"data_hint" => "enter a comma delimited list of items",
|
622 |
+
"group" => "hide/",
|
623 |
+
"group_hint" => "all items having the same group id belong to the same group",
|
624 |
+
"format" => "hide/",
|
625 |
+
"format_hint" => "enter the format of the list"
|
626 |
+
),
|
627 |
+
array(
|
628 |
+
"type" => "honeypot",
|
629 |
+
"type_description" => "Hidden Honeypot",
|
630 |
+
//label properties
|
631 |
+
"label" => "website",
|
632 |
+
"label_label" => "Name",
|
633 |
+
"label_hint" => "enter the name of the honeypot field; it must be a value that bots can easily recognize, like \'website\' or \'URL\'",
|
634 |
+
//checkbox properties
|
635 |
+
"required" => "hide/false",
|
636 |
+
"required_hint" => "if checked, then this field must have a non-empty value for the file to be uploaded",
|
637 |
+
"donotautocomplete" => "hide/true",
|
638 |
+
"donotautocomplete_hint" => "if checked, then the field will notify the browsers not to fill it with autocomplete data when the plugin is reloaded",
|
639 |
+
"validate" => "hide/false",
|
640 |
+
"validate_hint" => "if checked, then the field value entered by the user will be validated before file upload",
|
641 |
+
"typehook" => "hide/false",
|
642 |
+
"typehook_hint" => "if checked, then text suggestions will be shown below the field as the user types more text inside",
|
643 |
+
//dropdown properties
|
644 |
+
"labelposition" => "hide/none",
|
645 |
+
"labelposition_hint" => "select the position of the field's label; the position is relative to the field",
|
646 |
+
"hintposition" => "hide/none",
|
647 |
+
"hintposition_hint" => "select the position of the hint that will be shown to notify the user that something is wrong\\r\\nthe position is relative to the field",
|
648 |
+
//text properties
|
649 |
+
"default" => "hide/",
|
650 |
+
"default_hint" => "enter a default value for the field or leave it empty if you do not want a default value",
|
651 |
+
"data" => "hide/",
|
652 |
+
"data_label" => "Data",
|
653 |
+
"data_hint" => "complete a list of values to be shown to the user",
|
654 |
+
"group" => "hide/",
|
655 |
+
"group_hint" => "if a value is set, then all fields having the same value will belong to the same group",
|
656 |
+
"format" => "hide/",
|
657 |
+
"format_hint" => "enter a format to format user selection"
|
658 |
+
)
|
659 |
+
);
|
660 |
+
|
661 |
+
return $formfields;
|
662 |
+
}
|
663 |
+
|
664 |
+
/**
|
665 |
+
* Definition of Uploader Form Attributes
|
666 |
+
*
|
667 |
+
* This function defines the plugin uploader shortcode attributes.
|
668 |
+
*
|
669 |
+
* @since 2.1.2
|
670 |
+
*
|
671 |
+
* @return array The list of uploader form attributes.
|
672 |
+
*/
|
673 |
+
function wfu_attribute_definitions() {
|
674 |
+
$defs = array(
|
675 |
+
array(
|
676 |
+
"name" => "Widget ID",
|
677 |
+
"attribute" => "widgetid",
|
678 |
+
"type" => "hidden",
|
679 |
+
"validator" => "text",
|
680 |
+
"listitems" => null,
|
681 |
+
"value" => "",
|
682 |
+
"mode" => "free",
|
683 |
+
"category" => "",
|
684 |
+
"subcategory" => "Basic ",
|
685 |
+
"parent" => "",
|
686 |
+
"dependencies" => null,
|
687 |
+
"variables" => null,
|
688 |
+
"help" => ""
|
689 |
+
),
|
690 |
+
array(
|
691 |
+
"name" => "Plugin ID",
|
692 |
+
"attribute" => "uploadid",
|
693 |
+
"type" => "integer",
|
694 |
+
"validator" => "text",
|
695 |
+
"listitems" => null,
|
696 |
+
"value" => WFU_VAR("WFU_UPLOADID"),
|
697 |
+
"mode" => "free",
|
698 |
+
"category" => "general",
|
699 |
+
"subcategory" => "Basic Functionalities",
|
700 |
+
"parent" => "",
|
701 |
+
"dependencies" => null,
|
702 |
+
"variables" => null,
|
703 |
+
"help" => "The unique id of each shortcode. When you have many shortcodes of this plugin in the same page, then you must use different id for each one."
|
704 |
+
),
|
705 |
+
array(
|
706 |
+
"name" => "Single Button Operation",
|
707 |
+
"attribute" => "singlebutton",
|
708 |
+
"type" => "onoff",
|
709 |
+
"validator" => "text",
|
710 |
+
"listitems" => null,
|
711 |
+
"value" => WFU_VAR("WFU_SINGLEBUTTON"),
|
712 |
+
"mode" => "free",
|
713 |
+
"category" => "general",
|
714 |
+
"subcategory" => "Basic Functionalities",
|
715 |
+
"parent" => "",
|
716 |
+
"dependencies" => array("!uploadbutton"),
|
717 |
+
"variables" => null,
|
718 |
+
"help" => "When it is activated, no Upload button will be shown, but upload will start automatically as soon as files are selected."
|
719 |
+
),
|
720 |
+
array(
|
721 |
+
"name" => "Upload Path",
|
722 |
+
"attribute" => "uploadpath",
|
723 |
+
"type" => "ltext",
|
724 |
+
"validator" => "path",
|
725 |
+
"listitems" => null,
|
726 |
+
"value" => WFU_VAR("WFU_UPLOADPATH"),
|
727 |
+
"mode" => "free",
|
728 |
+
"category" => "general",
|
729 |
+
"subcategory" => "Basic Functionalities",
|
730 |
+
"parent" => "",
|
731 |
+
"dependencies" => null,
|
732 |
+
"variables" => array("%userid%", "%username%", "%blogid%", "%pageid%", "%pagetitle%", "%userdataXXX%"),
|
733 |
+
"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."
|
734 |
+
),
|
735 |
+
array(
|
736 |
+
"name" => "Plugin Fit Mode",
|
737 |
+
"attribute" => "fitmode",
|
738 |
+
"type" => "radio",
|
739 |
+
"validator" => "text",
|
740 |
+
"listitems" => array("fixed", "responsive"),
|
741 |
+
"value" => WFU_VAR("WFU_FITMODE"),
|
742 |
+
"mode" => "free",
|
743 |
+
"category" => "general",
|
744 |
+
"subcategory" => "Basic Functionalities",
|
745 |
+
"parent" => "",
|
746 |
+
"dependencies" => null,
|
747 |
+
"variables" => null,
|
748 |
+
"help" => "This defines how the plugin's elements will fit inside the page/post. If it is set to fixed, then the plugin's element positions will remain fixed no matter the width of the container page/post. If it is set to responsive, then the plugin's elements will wrap to fit the width of the container page/post."
|
749 |
+
),
|
750 |
+
array(
|
751 |
+
"name" => "Allow No File",
|
752 |
+
"attribute" => "allownofile",
|
753 |
+
"type" => "onoff",
|
754 |
+
"validator" => "text",
|
755 |
+
"listitems" => null,
|
756 |
+
"value" => WFU_VAR("WFU_ALLOWNOFILE"),
|
757 |
+
"mode" => "free",
|
758 |
+
"category" => "general",
|
759 |
+
"subcategory" => "Basic Functionalities",
|
760 |
+
"parent" => "",
|
761 |
+
"dependencies" => null,
|
762 |
+
"variables" => null,
|
763 |
+
"help" => "When it is activated a user can submit the upload form even if a file is not selected."
|
764 |
+
),
|
765 |
+
array(
|
766 |
+
"name" => "Reset Form Mode",
|
767 |
+
"attribute" => "resetmode",
|
768 |
+
"type" => "radio",
|
769 |
+
"validator" => "text",
|
770 |
+
"listitems" => array("always", "onsuccess", "never"),
|
771 |
+
"value" => WFU_VAR("WFU_RESETMODE"),
|
772 |
+
"mode" => "free",
|
773 |
+
"category" => "general",
|
774 |
+
"subcategory" => "Basic Functionalities",
|
775 |
+
"parent" => "",
|
776 |
+
"dependencies" => null,
|
777 |
+
"variables" => null,
|
778 |
+
"help" => "It defines whether the form will be reset after upload; 'always' means that it will be reset in any case, 'onsuccess' means that it will be reset only if upload was successful, 'never' means that it will never be reset."
|
779 |
+
),
|
780 |
+
array(
|
781 |
+
"name" => "Upload Roles",
|
782 |
+
"attribute" => "uploadrole",
|
783 |
+
"type" => "rolelist",
|
784 |
+
"validator" => "text",
|
785 |
+
"listitems" => array("default_administrator"),
|
786 |
+
"value" => WFU_VAR("WFU_UPLOADROLE"),
|
787 |
+
"mode" => "free",
|
788 |
+
"category" => "general",
|
789 |
+
"subcategory" => "Filters",
|
790 |
+
"parent" => "",
|
791 |
+
"dependencies" => null,
|
792 |
+
"variables" => null,
|
793 |
+
"help" => "Defines the categories (roles) of users allowed to upload files. Multiple selections can be made. If 'Select All' is checked, then all logged users can upload files. If 'Include Guests' is checked, then guests (not logged users) can also upload files. Default value is 'all,guests'."
|
794 |
+
),
|
795 |
+
array(
|
796 |
+
"name" => "Allowed File Extensions",
|
797 |
+
"attribute" => "uploadpatterns",
|
798 |
+
"type" => "text",
|
799 |
+
"validator" => "text",
|
800 |
+
"listitems" => null,
|
801 |
+
"value" => WFU_VAR("WFU_UPLOADPATTERNS"),
|
802 |
+
"mode" => "free",
|
803 |
+
"category" => "general",
|
804 |
+
"subcategory" => "Filters",
|
805 |
+
"parent" => "",
|
806 |
+
"dependencies" => null,
|
807 |
+
"variables" => null,
|
808 |
+
"help" => "Defines the allowed file extensions. Multiple extentions can be defined, separated with comma (,)."
|
809 |
+
),
|
810 |
+
array(
|
811 |
+
"name" => "Allowed File Size",
|
812 |
+
"attribute" => "maxsize",
|
813 |
+
"type" => "float",
|
814 |
+
"validator" => "float",
|
815 |
+
"listitems" => null,
|
816 |
+
"value" => WFU_VAR("WFU_MAXSIZE"),
|
817 |
+
"mode" => "free",
|
818 |
+
"category" => "general",
|
819 |
+
"subcategory" => "Filters",
|
820 |
+
"parent" => "",
|
821 |
+
"dependencies" => null,
|
822 |
+
"variables" => null,
|
823 |
+
"help" => "Defines the allowed file size in MBytes. Files larger than maxsize will not be uploaded. Floating point numbers can be used (e.g. '2.5')."
|
824 |
+
),
|
825 |
+
array(
|
826 |
+
"name" => "Create Upload Path",
|
827 |
+
"attribute" => "createpath",
|
828 |
+
"type" => "onoff",
|
829 |
+
"validator" => "text",
|
830 |
+
"listitems" => null,
|
831 |
+
"value" => WFU_VAR("WFU_CREATEPATH"),
|
832 |
+
"mode" => "free",
|
833 |
+
"category" => "general",
|
834 |
+
"subcategory" => "Upload Path and Files",
|
835 |
+
"parent" => "",
|
836 |
+
"dependencies" => null,
|
837 |
+
"variables" => null,
|
838 |
+
"help" => "If activated then the plugin will attempt to create the upload path, if it does not exist."
|
839 |
+
),
|
840 |
+
array(
|
841 |
+
"name" => "Do Not Change Filename",
|
842 |
+
"attribute" => "forcefilename",
|
843 |
+
"type" => "onoff",
|
844 |
+
"validator" => "text",
|
845 |
+
"listitems" => null,
|
846 |
+
"value" => WFU_VAR("WFU_FORCEFILENAME"),
|
847 |
+
"mode" => "free",
|
848 |
+
"category" => "general",
|
849 |
+
"subcategory" => "Upload Path and Files",
|
850 |
+
"parent" => "",
|
851 |
+
"dependencies" => null,
|
852 |
+
"variables" => null,
|
853 |
+
"help" => "The plugin by default will modify the filename if it contains invalid or non-english characters. By enabling this attribute the plugin will not change the filename."
|
854 |
+
),
|
855 |
+
array(
|
856 |
+
"name" => "Folder Access Method",
|
857 |
+
"attribute" => "accessmethod",
|
858 |
+
"type" => "radio",
|
859 |
+
"validator" => "text",
|
860 |
+
"listitems" => array("normal", "*ftp"),
|
861 |
+
"value" => WFU_VAR("WFU_ACCESSMETHOD"),
|
862 |
+
"mode" => "free",
|
863 |
+
"category" => "general",
|
864 |
+
"subcategory" => "Upload Path and Files",
|
865 |
+
"parent" => "",
|
866 |
+
"dependencies" => array("ftpinfo", "userftpdomain", "ftppassivemode", "ftpfilepermissions"),
|
867 |
+
"variables" => null,
|
868 |
+
"help" => "Some times files cannot be uploaded to the upload folder because of read/write permissions. A workaround is to use ftp to transfer the files, however ftp credentials must be declared, so use carefully and only if necessary."
|
869 |
+
),
|
870 |
+
array(
|
871 |
+
"name" => "FTP Access Credentials",
|
872 |
+
"attribute" => "ftpinfo",
|
873 |
+
"type" => "ftpinfo",
|
874 |
+
"validator" => "text",
|
875 |
+
"listitems" => null,
|
876 |
+
"value" => WFU_VAR("WFU_FTPINFO"),
|
877 |
+
"mode" => "free",
|
878 |
+
"category" => "general",
|
879 |
+
"subcategory" => "Upload Path and Files",
|
880 |
+
"parent" => "accessmethod",
|
881 |
+
"dependencies" => null,
|
882 |
+
"variables" => null,
|
883 |
+
"help" => "If FTP access method is selected, then FTP credentials must be declared here, in the form username:password@ftpdomain:port, e.g. myusername:mypass@ftpdomain.com:80. Port can be ommitted. The user can use Secure FTP (sftp) by putting the prefix 's' before the port number, e.g. myusername:mypass@ftpdomain.com:s22."
|
884 |
+
),
|
885 |
+
array(
|
886 |
+
"name" => "Use FTP Domain",
|
887 |
+
"attribute" => "useftpdomain",
|
888 |
+
"type" => "onoff",
|
889 |
+
"validator" => "text",
|
890 |
+
"listitems" => null,
|
891 |
+
"value" => WFU_VAR("WFU_USEFTPDOMAIN"),
|
892 |
+
"mode" => "free",
|
893 |
+
"category" => "general",
|
894 |
+
"subcategory" => "Upload Path and Files",
|
895 |
+
"parent" => "accessmethod",
|
896 |
+
"dependencies" => null,
|
897 |
+
"variables" => null,
|
898 |
+
"help" => "If FTP access method is selected, then sometimes the FTP domain is different than the domain of your Wordpress installation. In this case, enable this attribute if upload of files is not successful."
|
899 |
+
),
|
900 |
+
array(
|
901 |
+
"name" => "FTP Passive Mode",
|
902 |
+
"attribute" => "ftppassivemode",
|
903 |
+
"type" => "onoff",
|
904 |
+
"validator" => "text",
|
905 |
+
"listitems" => null,
|
906 |
+
"value" => WFU_VAR("WFU_FTPPASSIVEMODE"),
|
907 |
+
"mode" => "free",
|
908 |
+
"category" => "general",
|
909 |
+
"subcategory" => "Upload Path and Files",
|
910 |
+
"parent" => "accessmethod",
|
911 |
+
"dependencies" => null,
|
912 |
+
"variables" => null,
|
913 |
+
"help" => "If files fail to upload to the ftp domain then switching to passive FTP mode may solve the problem."
|
914 |
+
),
|
915 |
+
array(
|
916 |
+
"name" => "Permissions of Uploaded File",
|
917 |
+
"attribute" => "ftpfilepermissions",
|
918 |
+
"type" => "text",
|
919 |
+
"validator" => "integer",
|
920 |
+
"listitems" => null,
|
921 |
+
"value" => WFU_VAR("WFU_FTPFILEPERMISSIONS"),
|
922 |
+
"mode" => "free",
|
923 |
+
"category" => "general",
|
924 |
+
"subcategory" => "Upload Path and Files",
|
925 |
+
"parent" => "accessmethod",
|
926 |
+
"dependencies" => null,
|
927 |
+
"variables" => null,
|
928 |
+
"help" => "Force the uploaded files to have specific permissions. This is a 4-digit octal number, e.g. 0777. If left empty, then the ftp server will define the permissions."
|
929 |
+
),
|
930 |
+
array(
|
931 |
+
"name" => "Show Upload Folder Path",
|
932 |
+
"attribute" => "showtargetfolder",
|
933 |
+
"type" => "onoff",
|
934 |
+
"validator" => "text",
|
935 |
+
"listitems" => null,
|
936 |
+
"value" => WFU_VAR("WFU_SHOWTARGETFOLDER"),
|
937 |
+
"mode" => "free",
|
938 |
+
"category" => "general",
|
939 |
+
"subcategory" => "Upload Path and Files",
|
940 |
+
"parent" => "",
|
941 |
+
"dependencies" => array("targetfolderlabel"),
|
942 |
+
"variables" => null,
|
943 |
+
"help" => "It defines if a label with the upload directory will be shown."
|
944 |
+
),
|
945 |
+
array(
|
946 |
+
"name" => "Select Subfolder",
|
947 |
+
"attribute" => "askforsubfolders",
|
948 |
+
"type" => "onoff",
|
949 |
+
"validator" => "text",
|
950 |
+
"listitems" => null,
|
951 |
+
"value" => WFU_VAR("WFU_ASKFORSUBFOLDERS"),
|
952 |
+
"mode" => "free",
|
953 |
+
"category" => "general",
|
954 |
+
"subcategory" => "Upload Path and Files",
|
955 |
+
"parent" => "",
|
956 |
+
"dependencies" => array("subfoldertree", "subfolderlabel"),
|
957 |
+
"variables" => null,
|
958 |
+
"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."
|
959 |
+
),
|
960 |
+
array(
|
961 |
+
"name" => "List of Subfolders",
|
962 |
+
"attribute" => "subfoldertree",
|
963 |
+
"type" => "folderlist",
|
964 |
+
"validator" => "text",
|
965 |
+
"listitems" => null,
|
966 |
+
"value" => WFU_VAR("WFU_SUBFOLDERTREE"),
|
967 |
+
"mode" => "free",
|
968 |
+
"category" => "general",
|
969 |
+
"subcategory" => "Upload Path and Files",
|
970 |
+
"parent" => "askforsubfolders",
|
971 |
+
"dependencies" => null,
|
972 |
+
"variables" => null,
|
973 |
+
"help" => "The list of folders a user can select. Please see documentation on how to create the list of folders. If 'Auto-populate list' is selected, then the list will be filled automatically with the first-level subfolders inside the directory defined by uploadpath. If 'List is editable' is selected, then the user will have the capability to type the subfolder and filter the subfolder list and/or define a new subfolder."
|
974 |
+
),
|
975 |
+
array(
|
976 |
+
"name" => "File Duplicates Policy",
|
977 |
+
"attribute" => "duplicatespolicy",
|
978 |
+
"type" => "radio",
|
979 |
+
"validator" => "text",
|
980 |
+
"listitems" => array("overwrite", "reject", "*maintain both"),
|
981 |
+
"value" => WFU_VAR("WFU_DUBLICATESPOLICY"),
|
982 |
+
"mode" => "free",
|
983 |
+
"category" => "general",
|
984 |
+
"subcategory" => "Upload Path and Files",
|
985 |
+
"parent" => "",
|
986 |
+
"dependencies" => array("uniquepattern"),
|
987 |
+
"variables" => null,
|
988 |
+
"help" => "It determines what happens when an uploaded file has the same name with an existing file. The uploaded file can overwrite the existing one, be rejected or both can be kept by renaming the uploaded file according to a rule defined in uniquepattern attribute."
|
989 |
+
),
|
990 |
+
array(
|
991 |
+
"name" => "File Rename Rule",
|
992 |
+
"attribute" => "uniquepattern",
|
993 |
+
"type" => "radio",
|
994 |
+
"validator" => "text",
|
995 |
+
"listitems" => array("index", "datetimestamp"),
|
996 |
+
"value" => WFU_VAR("WFU_UNIQUEPATTERN"),
|
997 |
+
"mode" => "free",
|
998 |
+
"category" => "general",
|
999 |
+
"subcategory" => "Upload Path and Files",
|
1000 |
+
"parent" => "duplicatespolicy",
|
1001 |
+
"dependencies" => null,
|
1002 |
+
"variables" => null,
|
1003 |
+
"help" => "If duplicatespolicy is set to 'maintain both', then this rule defines how the uploaded file will be renamed, in order not to match an existing file. An incremental index number or a datetime stamp can be included in the uploaded file name to make it unique."
|
1004 |
+
),
|
1005 |
+
array(
|
1006 |
+
"name" => "Redirect after Upload",
|
1007 |
+
"attribute" => "redirect",
|
1008 |
+
"type" => "onoff",
|
1009 |
+
"validator" => "text",
|
1010 |
+
"listitems" => null,
|
1011 |
+
"value" => WFU_VAR("WFU_REDIRECT"),
|
1012 |
+
"mode" => "free",
|
1013 |
+
"category" => "general",
|
1014 |
+
"subcategory" => "Redirection",
|
1015 |
+
"parent" => "",
|
1016 |
+
"dependencies" => array("redirectlink"),
|
1017 |
+
"variables" => null,
|
1018 |
+
"help" => "If enabled, the user will be redirected to a url defined in redirectlink attribute upon successful upload of all the files."
|
1019 |
+
),
|
1020 |
+
array(
|
1021 |
+
"name" => "Redirection URL",
|
1022 |
+
"attribute" => "redirectlink",
|
1023 |
+
"type" => "ltext",
|
1024 |
+
"validator" => "link",
|
1025 |
+
"listitems" => null,
|
1026 |
+
"value" => WFU_VAR("WFU_REDIRECTLINK"),
|
1027 |
+
"mode" => "free",
|
1028 |
+
"category" => "general",
|
1029 |
+
"subcategory" => "Redirection",
|
1030 |
+
"parent" => "redirect",
|
1031 |
+
"dependencies" => null,
|
1032 |
+
"variables" => array("%filename%", "%username%"),
|
1033 |
+
"help" => "This is the redirect URL. The URL can be dynamic by using variables. Please see Documentation on how to use variables inside attributes."
|
1034 |
+
),
|
1035 |
+
array(
|
1036 |
+
"name" => "Show Detailed Admin Messages",
|
1037 |
+
"attribute" => "adminmessages",
|
1038 |
+
"type" => "onoff",
|
1039 |
+
"validator" => "text",
|
1040 |
+
"listitems" => null,
|
1041 |
+
"value" => WFU_VAR("WFU_ADMINMESSAGES"),
|
1042 |
+
"mode" => "free",
|
1043 |
+
"category" => "general",
|
1044 |
+
"subcategory" => "Other Administrator Options",
|
1045 |
+
"parent" => "",
|
1046 |
+
"dependencies" => null,
|
1047 |
+
"variables" => null,
|
1048 |
+
"help" => "If enabled then more detailed messages about upload operations will be shown to administrators for debugging or error detection."
|
1049 |
+
),
|
1050 |
+
array(
|
1051 |
+
"name" => "Disable AJAX",
|
1052 |
+
"attribute" => "forceclassic",
|
1053 |
+
"type" => "onoff",
|
1054 |
+
"validator" => "text",
|
1055 |
+
"listitems" => null,
|
1056 |
+
"value" => WFU_VAR("WFU_FORCECLASSIC"),
|
1057 |
+
"mode" => "free",
|
1058 |
+
"category" => "general",
|
1059 |
+
"subcategory" => "Other Administrator Options",
|
1060 |
+
"parent" => "",
|
1061 |
+
"dependencies" => null,
|
1062 |
+
"variables" => null,
|
1063 |
+
"help" => "If AJAX is disabled, then upload of files will be performed using HTML forms, meaning that page will refresh to complete the upload. Use it in case that AJAX is causing problems with your page (although the plugin has an auto-detection feature for checking if user's browser supports AJAX or not)."
|
1064 |
+
),
|
1065 |
+
array(
|
1066 |
+
"name" => "Test Mode",
|
1067 |
+
"attribute" => "testmode",
|
1068 |
+
"type" => "onoff",
|
1069 |
+
"validator" => "text",
|
1070 |
+
"listitems" => null,
|
1071 |
+
"value" => WFU_VAR("WFU_TESTMODE"),
|
1072 |
+
"mode" => "free",
|
1073 |
+
"category" => "general",
|
1074 |
+
"subcategory" => "Other Administrator Options",
|
1075 |
+
"parent" => "",
|
1076 |
+
"dependencies" => null,
|
1077 |
+
"variables" => null,
|
1078 |
+
"help" => "If enabled then the plugin will be shown in test mode, meaning that all selected features will be shown but no upload will be possible. Use it to review how the plugin looks like and style it according to your needs."
|
1079 |
+
),
|
1080 |
+
array(
|
1081 |
+
"name" => "Debug Mode",
|
1082 |
+
"attribute" => "debugmode",
|
1083 |
+
"type" => "onoff",
|
1084 |
+
"validator" => "text",
|
1085 |
+
"listitems" => null,
|
1086 |
+
"value" => WFU_VAR("WFU_DEBUGMODE"),
|
1087 |
+
"mode" => "free",
|
1088 |
+
"category" => "general",
|
1089 |
+
"subcategory" => "Other Administrator Options",
|
1090 |
+
"parent" => "",
|
1091 |
+
"dependencies" => null,
|
1092 |
+
"variables" => null,
|
1093 |
+
"help" => "If enabled then the plugin will show to administrators any internal PHP warnings and errors generated during the upload process inside the message box."
|
1094 |
+
),
|
1095 |
+
array(
|
1096 |
+
"name" => "Plugin Component Positions",
|
1097 |
+
"attribute" => "placements",
|
1098 |
+
"type" => "placements",
|
1099 |
+
"validator" => "text",
|
1100 |
+
"listitems" => null,
|
1101 |
+
"value" => WFU_VAR("WFU_PLACEMENTS"),
|
1102 |
+
"mode" => "free",
|
1103 |
+
"category" => "placements",
|
1104 |
+
"subcategory" => "Plugin Component Positions",
|
1105 |
+
"parent" => "",
|
1106 |
+
"dependencies" => null,
|
1107 |
+
"variables" => null,
|
1108 |
+
"help" => "It defines the positions of the selected plugin components. Drag the components from the right pane and drop them to the left one to define your own component positions."
|
1109 |
+
),
|
1110 |
+
array(
|
1111 |
+
"name" => "Plugin Title",
|
1112 |
+
"attribute" => "uploadtitle",
|
1113 |
+
"type" => "text",
|
1114 |
+
"validator" => "text",
|
1115 |
+
"listitems" => null,
|
1116 |
+
"value" => WFU_UPLOADTITLE,
|
1117 |
+
"mode" => "free",
|
1118 |
+
"category" => "labels",
|
1119 |
+
"subcategory" => "Title",
|
1120 |
+
"parent" => "",
|
1121 |
+
"dependencies" => null,
|
1122 |
+
"variables" => null,
|
1123 |
+
"help" => "A text representing the title of the plugin."
|
1124 |
+
),
|
1125 |
+
array(
|
1126 |
+
"name" => "Select Button Caption",
|
1127 |
+
"attribute" => "selectbutton",
|
1128 |
+
"type" => "text",
|
1129 |
+
"validator" => "text",
|
1130 |
+
"listitems" => null,
|
1131 |
+
"value" => WFU_SELECTBUTTON,
|
1132 |
+
"mode" => "free",
|
1133 |
+
"category" => "labels",
|
1134 |
+
"subcategory" => "Buttons",
|
1135 |
+
"parent" => "",
|
1136 |
+
"dependencies" => null,
|
1137 |
+
"variables" => null,
|
1138 |
+
"help" => "The caption of the button that selects the files for upload."
|
1139 |
+
),
|
1140 |
+
array(
|
1141 |
+
"name" => "Upload Button Caption",
|
1142 |
+
"attribute" => "uploadbutton",
|
1143 |
+
"type" => "text",
|
1144 |
+
"validator" => "text",
|
1145 |
+
"listitems" => null,
|
1146 |
+
"value" => WFU_UPLOADBUTTON,
|
1147 |
+
"mode" => "free",
|
1148 |
+
"category" => "labels",
|
1149 |
+
"subcategory" => "Buttons",
|
1150 |
+
"parent" => "",
|
1151 |
+
"dependencies" => null,
|
1152 |
+
"variables" => null,
|
1153 |
+
"help" => "The caption of the button that starts the upload."
|
1154 |
+
),
|
1155 |
+
array(
|
1156 |
+
"name" => "Upload Folder Label",
|
1157 |
+
"attribute" => "targetfolderlabel",
|
1158 |
+
"type" => "text",
|
1159 |
+
"validator" => "text",
|
1160 |
+
"listitems" => null,
|
1161 |
+
"value" => WFU_VAR("WFU_TARGETFOLDERLABEL"),
|
1162 |
+
"mode" => "free",
|
1163 |
+
"category" => "labels",
|
1164 |
+
"subcategory" => "Upload Folder",
|
1165 |
+
"parent" => "",
|
1166 |
+
"dependencies" => null,
|
1167 |
+
"variables" => null,
|
1168 |
+
"help" => "This is the label before the upload folder path, if the path is selected to be shown using the showtargetfolder attribute."
|
1169 |
+
),
|
1170 |
+
array(
|
1171 |
+
"name" => "Select Subfolder Label",
|
1172 |
+
"attribute" => "subfolderlabel",
|
1173 |
+
"type" => "text",
|
1174 |
+
"validator" => "text",
|
1175 |
+
"listitems" => null,
|
1176 |
+
"value" => WFU_VAR("WFU_SUBFOLDERLABEL"),
|
1177 |
+
"mode" => "free",
|
1178 |
+
"category" => "labels",
|
1179 |
+
"subcategory" => "Upload Folder",
|
1180 |
+
"parent" => "",
|
1181 |
+
"dependencies" => null,
|
1182 |
+
"variables" => null,
|
1183 |
+
"help" => "This is the label of the subfolder dropdown list. It is active when askforsubfolders attribute is on."
|
1184 |
+
),
|
1185 |
+
array(
|
1186 |
+
"name" => "Success Upload Message",
|
1187 |
+
"attribute" => "successmessage",
|
1188 |
+
"type" => "ltext",
|
1189 |
+
"validator" => "text",
|
1190 |
+
"listitems" => null,
|
1191 |
+
"value" => WFU_SUCCESSMESSAGE,
|
1192 |
+
"mode" => "free",
|
1193 |
+
"category" => "labels",
|
1194 |
+
"subcategory" => "Upload Messages",
|
1195 |
+
"parent" => "",
|
1196 |
+
"dependencies" => null,
|
1197 |
+
"variables" => array("%filename%", "%filepath%"),
|
1198 |
+
"help" => "This is the message that will be shown for every file that has been uploaded successfully."
|
1199 |
+
),
|
1200 |
+
array(
|
1201 |
+
"name" => "Warning Upload Message",
|
1202 |
+
"attribute" => "warningmessage",
|
1203 |
+
"type" => "ltext",
|
1204 |
+
"validator" => "text",
|
1205 |
+
"listitems" => null,
|
1206 |
+
"value" => WFU_WARNINGMESSAGE,
|
1207 |
+
"mode" => "free",
|
1208 |
+
"category" => "labels",
|
1209 |
+
"subcategory" => "Upload Messages",
|
1210 |
+
"parent" => "",
|
1211 |
+
"dependencies" => null,
|
1212 |
+
"variables" => array("%filename%", "%filepath%"),
|
1213 |
+
"help" => "This is the message that will be shown for every file that has been uploaded with warnings."
|
1214 |
+
),
|
1215 |
+
array(
|
1216 |
+
"name" => "Error Upload Message",
|
1217 |
+
"attribute" => "errormessage",
|
1218 |
+
"type" => "ltext",
|
1219 |
+
"validator" => "text",
|
1220 |
+
"listitems" => null,
|
1221 |
+
"value" => WFU_ERRORMESSAGE,
|
1222 |
+
"mode" => "free",
|
1223 |
+
"category" => "labels",
|
1224 |
+
"subcategory" => "Upload Messages",
|
1225 |
+
"parent" => "",
|
1226 |
+
"dependencies" => null,
|
1227 |
+
"variables" => array("%filename%", "%filepath%"),
|
1228 |
+
"help" => "This is the message that will be shown for every file that has failed to upload."
|
1229 |
+
),
|
1230 |
+
array(
|
1231 |
+
"name" => "Wait Upload Message",
|
1232 |
+
"attribute" => "waitmessage",
|
1233 |
+
"type" => "ltext",
|
1234 |
+
"validator" => "text",
|
1235 |
+
"listitems" => null,
|
1236 |
+
"value" => WFU_WAITMESSAGE,
|
1237 |
+
"mode" => "free",
|
1238 |
+
"category" => "labels",
|
1239 |
+
"subcategory" => "Upload Messages",
|
1240 |
+
"parent" => "",
|
1241 |
+
"dependencies" => null,
|
1242 |
+
"variables" => array("%filename%", "%filepath%"),
|
1243 |
+
"help" => "This is the message that will be shown while file is uploading."
|
1244 |
+
),
|
1245 |
+
array(
|
1246 |
+
"name" => "Upload Media Button Caption",
|
1247 |
+
"attribute" => "uploadmediabutton",
|
1248 |
+
"type" => "text",
|
1249 |
+
"validator" => "text",
|
1250 |
+
"listitems" => null,
|
1251 |
+
"value" => WFU_UPLOADMEDIABUTTON,
|
1252 |
+
"mode" => "free",
|
1253 |
+
"category" => "labels",
|
1254 |
+
"subcategory" => "Webcam Labels",
|
1255 |
+
"parent" => "",
|
1256 |
+
"dependencies" => null,
|
1257 |
+
"variables" => null,
|
1258 |
+
"help" => "The caption of the button that starts the upload when media capture from the webcam has been activated."
|
1259 |
+
),
|
1260 |
+
array(
|
1261 |
+
"name" => "Video Filename",
|
1262 |
+
"attribute" => "videoname",
|
1263 |
+
"type" => "text",
|
1264 |
+
"validator" => "text",
|
1265 |
+
"listitems" => null,
|
1266 |
+
"value" => WFU_VIDEONAME,
|
1267 |
+
"mode" => "free",
|
1268 |
+
"category" => "labels",
|
1269 |
+
"subcategory" => "Webcam Labels",
|
1270 |
+
"parent" => "",
|
1271 |
+
"dependencies" => null,
|
1272 |
+
"variables" => array("%userid%", "%username%", "%blogid%", "%pageid%", "%pagetitle%", "%userdataXXX%"),
|
1273 |
+
"help" => "This is the file name of the captured video file."
|
1274 |
+
),
|
1275 |
+
array(
|
1276 |
+
"name" => "Image Filename",
|
1277 |
+
"attribute" => "imagename",
|
1278 |
+
"type" => "text",
|
1279 |
+
"validator" => "text",
|
1280 |
+
"listitems" => null,
|
1281 |
+
"value" => WFU_IMAGENAME,
|
1282 |
+
"mode" => "free",
|
1283 |
+
"category" => "labels",
|
1284 |
+
"subcategory" => "Webcam Labels",
|
1285 |
+
"parent" => "",
|
1286 |
+
"dependencies" => null,
|
1287 |
+
"variables" => array("%userid%", "%username%", "%blogid%", "%pageid%", "%pagetitle%", "%userdataXXX%"),
|
1288 |
+
"help" => "This is the file name of the captured image file."
|
1289 |
+
),
|
1290 |
+
array(
|
1291 |
+
"name" => "Required Fields Suffix",
|
1292 |
+
"attribute" => "requiredlabel",
|
1293 |
+
"type" => "text",
|
1294 |
+
"validator" => "text",
|
1295 |
+
"listitems" => null,
|
1296 |
+
"value" => WFU_USERDATA_REQUIREDLABEL,
|
1297 |
+
"mode" => "free",
|
1298 |
+
"category" => "labels",
|
1299 |
+
"subcategory" => "Other Labels",
|
1300 |
+
"parent" => "",
|
1301 |
+
"dependencies" => null,
|
1302 |
+
"variables" => null,
|
1303 |
+
"help" => "This is the keyword that shows up next to user field labels in order to denote that they are required."
|
1304 |
+
),
|
1305 |
+
array(
|
1306 |
+
"name" => "Notify by Email",
|
1307 |
+
"attribute" => "notify",
|
1308 |
+
"type" => "onoff",
|
1309 |
+
"validator" => "text",
|
1310 |
+
"listitems" => null,
|
1311 |
+
"value" => WFU_VAR("WFU_NOTIFY"),
|
1312 |
+
"mode" => "free",
|
1313 |
+
"category" => "notifications",
|
1314 |
+
"subcategory" => "Email Notifications",
|
1315 |
+
"parent" => "",
|
1316 |
+
"dependencies" => array("notifyrecipients", "notifysubject", "notifymessage", "notifyheaders", "attachfile"),
|
1317 |
+
"variables" => null,
|
1318 |
+
"help" => "If activated then email will be sent to inform about successful file uploads."
|
1319 |
+
),
|
1320 |
+
array(
|
1321 |
+
"name" => "Email Recipients",
|
1322 |
+
"attribute" => "notifyrecipients",
|
1323 |
+
"type" => "mtext",
|
1324 |
+
"validator" => "text",
|
1325 |
+
"listitems" => null,
|
1326 |
+
"value" => WFU_VAR("WFU_NOTIFYRECIPIENTS"),
|
1327 |
+
"mode" => "free",
|
1328 |
+
"category" => "notifications",
|
1329 |
+
"subcategory" => "Email Notifications",
|
1330 |
+
"parent" => "notify",
|
1331 |
+
"dependencies" => null,
|
1332 |
+
"variables" => array("%useremail%", "%userdataXXX%", "%n%", "%dq%"),
|
1333 |
+
"help" => "Defines the recipients of the email notification. Can be dynamic by using variables. Please check Documentation on how to use variables in atributes."
|
1334 |
+
),
|
1335 |
+
array(
|
1336 |
+
"name" => "Email Headers",
|
1337 |
+
"attribute" => "notifyheaders",
|
1338 |
+
"type" => "mtext",
|
1339 |
+
"validator" => "emailheaders",
|
1340 |
+
"listitems" => null,
|
1341 |
+
"value" => WFU_VAR("WFU_NOTIFYHEADERS"),
|
1342 |
+
"mode" => "free",
|
1343 |
+
"category" => "notifications",
|
1344 |
+
"subcategory" => "Email Notifications",
|
1345 |
+
"parent" => "notify",
|
1346 |
+
"dependencies" => null,
|
1347 |
+
"variables" => array("%n%", "%dq%"),
|
1348 |
+
"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."
|
1349 |
+
),
|
1350 |
+
array(
|
1351 |
+
"name" => "Email Subject",
|
1352 |
+
"attribute" => "notifysubject",
|
1353 |
+
"type" => "ltext",
|
1354 |
+
"validator" => "emailsubject",
|
1355 |
+
"listitems" => null,
|
1356 |
+
"value" => WFU_NOTIFYSUBJECT,
|
1357 |
+
"mode" => "free",
|
1358 |
+
"category" => "notifications",
|
1359 |
+
"subcategory" => "Email Notifications",
|
1360 |
+
"parent" => "notify",
|
1361 |
+
"dependencies" => null,
|
1362 |
+
"variables" => array("%username%", "%useremail%", "%filename%", "%filepath%", "%blogid%", "%pageid%", "%pagetitle%", "%userdataXXX%", "%dq%"),
|
1363 |
+
"help" => "Defines the email subject. Can be dynamic by using variables. Please check Documentation on how to use variables in atributes."
|
1364 |
+
),
|
1365 |
+
array(
|
1366 |
+
"name" => "Email Body",
|
1367 |
+
"attribute" => "notifymessage",
|
1368 |
+
"type" => "mtext",
|
1369 |
+
"validator" => "emailbody",
|
1370 |
+
"listitems" => null,
|
1371 |
+
"value" => WFU_NOTIFYMESSAGE,
|
1372 |
+
"mode" => "free",
|
1373 |
+
"category" => "notifications",
|
1374 |
+
"subcategory" => "Email Notifications",
|
1375 |
+
"parent" => "notify",
|
1376 |
+
"dependencies" => null,
|
1377 |
+
"variables" => array("%username%", "%useremail%", "%filename%", "%filepath%", "%blogid%", "%pageid%", "%pagetitle%", "%userdataXXX%", "%n%", "%dq%"),
|
1378 |
+
"help" => "Defines the email body. Can be dynamic by using variables. Please check Documentation on how to use variables in atributes."
|
1379 |
+
),
|
1380 |
+
array(
|
1381 |
+
"name" => "Attach Uploaded Files",
|
1382 |
+
"attribute" => "attachfile",
|
1383 |
+
"type" => "onoff",
|
1384 |
+
"validator" => "text",
|
1385 |
+
"listitems" => null,
|
1386 |
+
"value" => WFU_VAR("WFU_ATTACHFILE"),
|
1387 |
+
"mode" => "free",
|
1388 |
+
"category" => "notifications",
|
1389 |
+
"subcategory" => "Email Notifications",
|
1390 |
+
"parent" => "notify",
|
1391 |
+
"dependencies" => null,
|
1392 |
+
"variables" => null,
|
1393 |
+
"help" => "If activated, then uploaded files will be included in the notification email as attachments. Please use carefully."
|
1394 |
+
),
|
1395 |
+
array(
|
1396 |
+
"name" => "Ask for Consent",
|
1397 |
+
"attribute" => "askconsent",
|
1398 |
+
"type" => "onoff",
|
1399 |
+
"validator" => "text",
|
1400 |
+
"listitems" => null,
|
1401 |
+
"value" => WFU_VAR("WFU_ASKCONSENT"),
|
1402 |
+
"mode" => "free",
|
1403 |
+
"category" => "personaldata",
|
1404 |
+
"subcategory" => "General Personal Data Options",
|
1405 |
+
"parent" => "",
|
1406 |
+
"dependencies" => array("personaldatatypes"),
|
1407 |
+
"variables" => null,
|
1408 |
+
"help" => "If activated, then consent from users will be asked for storing their personal data. If users do not give consent, then their data will not be stored in the database, they will only be included in the notification email, if email notifications are active."
|
1409 |
+
),
|
1410 |
+
array(
|
1411 |
+
"name" => "Personal Data Types",
|
1412 |
+
"attribute" => "personaldatatypes",
|
1413 |
+
"type" => "radio",
|
1414 |
+
"validator" => "text",
|
1415 |
+
"listitems" => array("userdata", "userdata and files"),
|
1416 |
+
"value" => WFU_VAR("WFU_PERSONALDATATYPES"),
|
1417 |
+
"mode" => "free",
|
1418 |
+
"category" => "personaldata",
|
1419 |
+
"subcategory" => "General Personal Data Options",
|
1420 |
+
"parent" => "askconsent",
|
1421 |
+
"dependencies" => null,
|
1422 |
+
"variables" => null,
|
1423 |
+
"help" => "Determines which data are considered as personal data. By default only userdata are considered as personal data. If the 2nd option is selected, then files will also be considered as personal data. This means that if the users do not give their consent, then the files will not be uploaded on the website, they will only be inluded in the notification email as attachments, if email notifications are active."
|
1424 |
+
),
|
1425 |
+
array(
|
1426 |
+
"name" => "Do Not Remember Consent Answer",
|
1427 |
+
"attribute" => "notrememberconsent",
|
1428 |
+
"type" => "onoff",
|
1429 |
+
"validator" => "text",
|
1430 |
+
"listitems" => null,
|
1431 |
+
"value" => WFU_VAR("WFU_NOTREMEMBERCONSENT"),
|
1432 |
+
"mode" => "free",
|
1433 |
+
"category" => "personaldata",
|
1434 |
+
"subcategory" => "Consent Behaviour",
|
1435 |
+
"parent" => "",
|
1436 |
+
"dependencies" => null,
|
1437 |
+
"variables" => null,
|
1438 |
+
"help" => "If activated the plugin will not remember the consent answer provided by the user and the consent question will always show."
|
1439 |
+
),
|
1440 |
+
array(
|
1441 |
+
"name" => "Consent Denial Rejects Upload",
|
1442 |
+
"attribute" => "consentrejectupload",
|
1443 |
+
"type" => "onoff",
|
1444 |
+
"validator" => "text",
|
1445 |
+
"listitems" => null,
|
1446 |
+
"value" => WFU_VAR("WFU_CONSENTREJECTUPLOAD"),
|
1447 |
+
"mode" => "free",
|
1448 |
+
"category" => "personaldata",
|
1449 |
+
"subcategory" => "Consent Behaviour",
|
1450 |
+
"parent" => "",
|
1451 |
+
"dependencies" => array("consentrejectmessage"),
|
1452 |
+
"variables" => null,
|
1453 |
+
"help" => "If activated and user has denied consent then the upload will be rejected. If deactivated, then the upload will continue regardless of consent answer."
|
1454 |
+
),
|
1455 |
+
array(
|
1456 |
+
"name" => "Reject Message",
|
1457 |
+
"attribute" => "consentrejectmessage",
|
1458 |
+
"type" => "ltext",
|
1459 |
+
"validator" => "text",
|
1460 |
+
"listitems" => null,
|
1461 |
+
"value" => WFU_CONSENTREJECTMESSAGE,
|
1462 |
+
"mode" => "free",
|
1463 |
+
"category" => "personaldata",
|
1464 |
+
"subcategory" => "Consent Behaviour",
|
1465 |
+
"parent" => "consentrejectupload",
|
1466 |
+
"dependencies" => null,
|
1467 |
+
"variables" => null,
|
1468 |
+
"help" => "It defines the message that will appear to the user if upload cannot continue due to consent denial."
|
1469 |
+
),
|
1470 |
+
array(
|
1471 |
+
"name" => "Consent Format",
|
1472 |
+
"attribute" => "consentformat",
|
1473 |
+
"type" => "radio",
|
1474 |
+
"validator" => "text",
|
1475 |
+
"listitems" => array("checkbox", "radio", "prompt"),
|
1476 |
+
"value" => WFU_VAR("WFU_CONSENTFORMAT"),
|
1477 |
+
"mode" => "free",
|
1478 |
+
"category" => "personaldata",
|
1479 |
+
"subcategory" => "Consent Appearance",
|
1480 |
+
"parent" => "",
|
1481 |
+
"dependencies" => null,
|
1482 |
+
"variables" => null,
|
1483 |
+
"help" => "Determines how consent question will appear to the user. If 'checkbox' is selected then a checkbox will appear inside the upload form which the user needs to tick. If 'radio' is selected then a radio button with 'Yes' and 'No' answers will appear inside the form (this makes sure that the user will select something after all. If 'prompt' is selected then a dialog will appear on the user when pressing the upload button asking for consent."
|
1484 |
+
),
|
1485 |
+
array(
|
1486 |
+
"name" => "Preselected Answer",
|
1487 |
+
"attribute" => "consentpreselect",
|
1488 |
+
"type" => "radio",
|
1489 |
+
"validator" => "text",
|
1490 |
+
"listitems" => array("none", "yes", "no"),
|
1491 |
+
"value" => WFU_VAR("WFU_CONSENTPRESELECT"),
|
1492 |
+
"mode" => "free",
|
1493 |
+
"category" => "personaldata",
|
1494 |
+
"subcategory" => "Consent Appearance",
|
1495 |
+
"parent" => "",
|
1496 |
+
"dependencies" => null,
|
1497 |
+
"variables" => null,
|
1498 |
+
"help" => "Determines whether a default answer will be selected."
|
1499 |
+
),
|
1500 |
+
array(
|
1501 |
+
"name" => "Consent Question for Checkbox",
|
1502 |
+
"attribute" => "consentquestion",
|
1503 |
+
"type" => "ltext",
|
1504 |
+
"validator" => "text",
|
1505 |
+
"listitems" => null,
|
1506 |
+
"value" => WFU_CONSENTQUESTION,
|
1507 |
+
"mode" => "free",
|
1508 |
+
"category" => "personaldata",
|
1509 |
+
"subcategory" => "Consent Appearance",
|
1510 |
+
"parent" => "",
|
1511 |
+
"dependencies" => null,
|
1512 |
+
"variables" => null,
|
1513 |
+
"help" => "Defines the question that will appear to the user next to the checkbox, or radio buttons or inside the prompt dialog. If a word starting and ending with semicolon (:) is added in the question, e.g. :link:, then it will be replaced by a link defined in 'Consent Disclaimer Link' attribute. This way a link to a disclaimer can be added."
|
1514 |
+
),
|
1515 |
+
array(
|
1516 |
+
"name" => "Consent Disclaimer Link",
|
1517 |
+
"attribute" => "consentdisclaimer",
|
1518 |
+
"type" => "ltext",
|
1519 |
+
"validator" => "text",
|
1520 |
+
"listitems" => null,
|
1521 |
+
"value" => WFU_VAR("WFU_CONSENTDISCLAIMER"),
|
1522 |
+
"mode" => "free",
|
1523 |
+
"category" => "personaldata",
|
1524 |
+
"subcategory" => "Consent Appearance",
|
1525 |
+
"parent" => "",
|
1526 |
+
"dependencies" => null,
|
1527 |
+
"variables" => null,
|
1528 |
+
"help" => "Defines a link that displays a disclaimer to the user if the user presses the relevant link that is included inside the consent question."
|
1529 |
+
),
|
1530 |
+
array(
|
1531 |
+
"name" => "Success Upload Message Color",
|
1532 |
+
"attribute" => "successmessagecolor",
|
1533 |
+
"type" => "hidden",
|
1534 |
+
"validator" => "colors",
|
1535 |
+
"listitems" => null,
|
1536 |
+
"value" => WFU_SUCCESSMESSAGECOLOR,
|
1537 |
+
"mode" => "free",
|
1538 |
+
"category" => "colors",
|
1539 |
+
"subcategory" => "Upload Message Colors",
|
1540 |
+
"parent" => "",
|
1541 |
+
"dependencies" => null,
|
1542 |
+
"variables" => null,
|
1543 |
+
"help" => "It defines the color of the success message. This attribute has been replaced by successmessagecolors, however it is kept here for backward compatibility."
|
1544 |
+
),
|
1545 |
+
array(
|
1546 |
+
"name" => "Success Message Colors",
|
1547 |
+
"attribute" => "successmessagecolors",
|
1548 |
+
"type" => "color-triplet",
|
1549 |
+
"validator" => "colors",
|
1550 |
+
"listitems" => null,
|
1551 |
+
"value" => WFU_VAR("WFU_SUCCESSMESSAGECOLORS"),
|
1552 |
+
"mode" => "free",
|
1553 |
+
"category" => "colors",
|
1554 |
+
"subcategory" => "Upload Message Colors",
|
1555 |
+
"parent" => "",
|
1556 |
+
"dependencies" => null,
|
1557 |
+
"variables" => null,
|
1558 |
+
"help" => "It defines the text, background and border color of the success message."
|
1559 |
+
),
|
1560 |
+
array(
|
1561 |
+
"name" => "Warning Message Colors",
|
1562 |
+
"attribute" => "warningmessagecolors",
|
1563 |
+
"type" => "color-triplet",
|
1564 |
+
"validator" => "colors",
|
1565 |
+
"listitems" => null,
|
1566 |
+
"value" => WFU_VAR("WFU_WARNINGMESSAGECOLORS"),
|
1567 |
+
"mode" => "free",
|
1568 |
+
"category" => "colors",
|
1569 |
+
"subcategory" => "Upload Message Colors",
|
1570 |
+
"parent" => "",
|
1571 |
+
"dependencies" => null,
|
1572 |
+
"variables" => null,
|
1573 |
+
"help" => "It defines the text, background and border color of the warning message."
|
1574 |
+
),
|
1575 |
+
array(
|
1576 |
+
"name" => "Fail Message Colors",
|
1577 |
+
"attribute" => "failmessagecolors",
|
1578 |
+
"type" => "color-triplet",
|
1579 |
+
"validator" => "colors",
|
1580 |
+
"listitems" => null,
|
1581 |
+
"value" => WFU_VAR("WFU_FAILMESSAGECOLORS"),
|
1582 |
+
"mode" => "free",
|
1583 |
+
"category" => "colors",
|
1584 |
+
"subcategory" => "Upload Message Colors",
|
1585 |
+
"parent" => "",
|
1586 |
+
"dependencies" => null,
|
1587 |
+
"variables" => null,
|
1588 |
+
"help" => "It defines the text, background and border color of the fail (error) message."
|
1589 |
+
),
|
1590 |
+
array(
|
1591 |
+
"name" => "Wait Message Colors",
|
1592 |
+
"attribute" => "waitmessagecolors",
|
1593 |
+
"type" => "hidden",
|
1594 |
+
"validator" => "colors",
|
1595 |
+
"listitems" => null,
|
1596 |
+
"value" => WFU_VAR("WFU_WAITMESSAGECOLORS"),
|
1597 |
+
"mode" => "free",
|
1598 |
+
"category" => "colors",
|
1599 |
+
"subcategory" => "Upload Message Colors",
|
1600 |
+
"parent" => "",
|
1601 |
+
"dependencies" => null,
|
1602 |
+
"variables" => null,
|
1603 |
+
"help" => "It defines the text, background and border color of the wait message."
|
1604 |
+
),
|
1605 |
+
array(
|
1606 |
+
"name" => "Plugin Component Widths",
|
1607 |
+
"attribute" => "widths",
|
1608 |
+
"type" => "dimensions",
|
1609 |
+
"validator" => "text",
|
1610 |
+
"listitems" => null,
|
1611 |
+
"value" => WFU_VAR("WFU_WIDTHS"),
|
1612 |
+
"mode" => "free",
|
1613 |
+
"category" => "dimensions",
|
1614 |
+
"subcategory" => "Plugin Component Widths",
|
1615 |
+
"parent" => "",
|
1616 |
+
"dependencies" => null,
|
1617 |
+
"variables" => null,
|
1618 |
+
"help" => "It defines the widths of the selected plugin components."
|
1619 |
+
),
|
1620 |
+
array(
|
1621 |
+
"name" => "Plugin Component Heights",
|
1622 |
+
"attribute" => "heights",
|
1623 |
+
"type" => "dimensions",
|
1624 |
+
"validator" => "text",
|
1625 |
+
"listitems" => null,
|
1626 |
+
"value" => WFU_VAR("WFU_HEIGHTS"),
|
1627 |
+
"mode" => "free",
|
1628 |
+
"category" => "dimensions",
|
1629 |
+
"subcategory" => "Plugin Component Heights",
|
1630 |
+
"parent" => "",
|
1631 |
+
"dependencies" => null,
|
1632 |
+
"variables" => null,
|
1633 |
+
"help" => "It defines the heights of the selected plugin components."
|
1634 |
+
),
|
1635 |
+
array(
|
1636 |
+
"name" => "Include Additional Data Fields",
|
1637 |
+
"attribute" => "userdata",
|
1638 |
+
"type" => "onoff",
|
1639 |
+
"validator" => "text",
|
1640 |
+
"listitems" => null,
|
1641 |
+
"value" => WFU_VAR("WFU_USERDATA"),
|
1642 |
+
"mode" => "free",
|
1643 |
+
"category" => "userdata",
|
1644 |
+
"subcategory" => "Additional Data Fields",
|
1645 |
+
"parent" => "",
|
1646 |
+
"dependencies" => array("userdatalabel"),
|
1647 |
+
"variables" => null,
|
1648 |
+
"help" => "If enabled, then user can send additional information together with uploaded files (e.g. name, email etc), defined in userdatalabel attribute."
|
1649 |
+
),
|
1650 |
+
array(
|
1651 |
+
"name" => "Additional Data Fields",
|
1652 |
+
"attribute" => "userdatalabel",
|
1653 |
+
"type" => "formfields",
|
1654 |
+
"validator" => "text",
|
1655 |
+
"listitems" => wfu_formfield_definitions(),
|
1656 |
+
"value" => WFU_USERDATALABEL,
|
1657 |
+
"mode" => "free",
|
1658 |
+
"category" => "userdata",
|
1659 |
+
"subcategory" => "Additional Data Fields",
|
1660 |
+
"parent" => "userdata",
|
1661 |
+
"dependencies" => null,
|
1662 |
+
"variables" => null,
|
1663 |
+
"help" => "It defines the labels of the additional data fields and whether they are required or not."
|
1664 |
+
),
|
1665 |
+
array(
|
1666 |
+
"name" => "WP Filebase Plugin Connection",
|
1667 |
+
"attribute" => "filebaselink",
|
1668 |
+
"type" => "onoff",
|
1669 |
+
"validator" => "text",
|
1670 |
+
"listitems" => null,
|
1671 |
+
"value" => WFU_VAR("WFU_FILEBASELINK"),
|
1672 |
+
"mode" => "free",
|
1673 |
+
"category" => "interoperability",
|
1674 |
+
"subcategory" => "Connection With Other Plugins",
|
1675 |
+
"parent" => "",
|
1676 |
+
"dependencies" => null,
|
1677 |
+
"variables" => null,
|
1678 |
+
"help" => "If enabled then the WP Filebase Plugin will be informed about new file uploads."
|
1679 |
+
),
|
1680 |
+
array(
|
1681 |
+
"name" => "Add Uploaded Files To Media",
|
1682 |
+
"attribute" => "medialink",
|
1683 |
+
"type" => "onoff",
|
1684 |
+
"validator" => "text",
|
1685 |
+
"listitems" => null,
|
1686 |
+
"value" => WFU_VAR("WFU_MEDIALINK"),
|
1687 |
+
"mode" => "free",
|
1688 |
+
"category" => "interoperability",
|
1689 |
+
"subcategory" => "Connection With Other Wordpress Features",
|
1690 |
+
"parent" => "",
|
1691 |
+
"dependencies" => null,
|
1692 |
+
"variables" => null,
|
1693 |
+
"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)."
|
1694 |
+
),
|
1695 |
+
array(
|
1696 |
+
"name" => "Attach Uploaded Files To Post",
|
1697 |
+
"attribute" => "postlink",
|
1698 |
+
"type" => "onoff",
|
1699 |
+
"validator" => "text",
|
1700 |
+
"listitems" => null,
|
1701 |
+
"value" => WFU_VAR("WFU_POSTLINK"),
|
1702 |
+
"mode" => "free",
|
1703 |
+
"category" => "interoperability",
|
1704 |
+
"subcategory" => "Connection With Other Wordpress Features",
|
1705 |
+
"parent" => "",
|
1706 |
+
"dependencies" => null,
|
1707 |
+
"variables" => null,
|
1708 |
+
"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)."
|
1709 |
+
),
|
1710 |
+
array(
|
1711 |
+
"name" => "Enable Webcam",
|
1712 |
+
"attribute" => "webcam",
|
1713 |
+
"type" => "onoff",
|
1714 |
+
"validator" => "text",
|
1715 |
+
"listitems" => null,
|
1716 |
+
"value" => WFU_VAR("WFU_WEBCAM"),
|
1717 |
+
"mode" => "free",
|
1718 |
+
"category" => "webcam",
|
1719 |
+
"subcategory" => "Capture from Webcam (experimental)",
|
1720 |
+
"parent" => "",
|
1721 |
+
"dependencies" => array("webcammode", "audiocapture", "videowidth", "videoheight", "videoaspectratio", "videoframerate", "camerafacing", "maxrecordtime", "uploadmediabutton", "videoname", "imagename"),
|
1722 |
+
"variables" => null,
|
1723 |
+
"help" => "This enables capturing of video or still pictures from the computer's webcam. It is experimental because it is not supported by all browsers yet."
|
1724 |
+
),
|
1725 |
+
array(
|
1726 |
+
"name" => "Capture Mode",
|
1727 |
+
"attribute" => "webcammode",
|
1728 |
+
"type" => "radio",
|
1729 |
+
"validator" => "text",
|
1730 |
+
"listitems" => array("capture video", "take photos", "both"),
|
1731 |
+
"value" => WFU_VAR("WFU_WEBCAMMODE"),
|
1732 |
+
"mode" => "free",
|
1733 |
+
"category" => "webcam",
|
1734 |
+
"subcategory" => "Capture from Webcam (experimental)",
|
1735 |
+
"parent" => "webcam",
|
1736 |
+
"dependencies" => null,
|
1737 |
+
"variables" => null,
|
1738 |
+
"help" => "It defines the webcam capture mode. The webcam can either capture video, still photos or both."
|
1739 |
+
),
|
1740 |
+
array(
|
1741 |
+
"name" => "Capture Audio",
|
1742 |
+
"attribute" => "audiocapture",
|
1743 |
+
"type" => "onoff",
|
1744 |
+
"validator" => "text",
|
1745 |
+
"listitems" => null,
|
1746 |
+
"value" => WFU_VAR("WFU_AUDIOCAPTURE"),
|
1747 |
+
"mode" => "free",
|
1748 |
+
"category" => "webcam",
|
1749 |
+
"subcategory" => "Capture from Webcam (experimental)",
|
1750 |
+
"parent" => "webcam",
|
1751 |
+
"dependencies" => null,
|
1752 |
+
"variables" => null,
|
1753 |
+
"help" => "It defines whether audio will be captured together with video from the webcam."
|
1754 |
+
),
|
1755 |
+
array(
|
1756 |
+
"name" => "Video Width",
|
1757 |
+
"attribute" => "videowidth",
|
1758 |
+
"type" => "text",
|
1759 |
+
"validator" => "text",
|
1760 |
+
"listitems" => null,
|
1761 |
+
"value" => WFU_VAR("WFU_VIDEOWIDTH"),
|
1762 |
+
"mode" => "free",
|
1763 |
+
"category" => "webcam",
|
1764 |
+
"subcategory" => "Capture from Webcam (experimental)",
|
1765 |
+
"parent" => "webcam",
|
1766 |
+
"dependencies" => null,
|
1767 |
+
"variables" => null,
|
1768 |
+
"help" => "It requests a preferable video width for the webcam. The plugin will try to match this setting as close as possible depending on webcam capabilities."
|
1769 |
+
),
|
1770 |
+
array(
|
1771 |
+
"name" => "Video Height",
|
1772 |
+
"attribute" => "videoheight",
|
1773 |
+
"type" => "text",
|
1774 |
+
"validator" => "text",
|
1775 |
+
"listitems" => null,
|
1776 |
+
"value" => WFU_VAR("WFU_VIDEOHEIGHT"),
|
1777 |
+
"mode" => "free",
|
1778 |
+
"category" => "webcam",
|
1779 |
+
"subcategory" => "Capture from Webcam (experimental)",
|
1780 |
+
"parent" => "webcam",
|
1781 |
+
"dependencies" => null,
|
1782 |
+
"variables" => null,
|
1783 |
+
"help" => "It requests a preferable video height for the webcam. The plugin will try to match this setting as close as possible depending on webcam capabilities."
|
1784 |
+
),
|
1785 |
+
array(
|
1786 |
+
"name" => "Video Aspect Ratio",
|
1787 |
+
"attribute" => "videoaspectratio",
|
1788 |
+
"type" => "text",
|
1789 |
+
"validator" => "text",
|
1790 |
+
"listitems" => null,
|
1791 |
+
"value" => WFU_VAR("WFU_VIDEOASPECTRATIO"),
|
1792 |
+
"mode" => "free",
|
1793 |
+
"category" => "webcam",
|
1794 |
+
"subcategory" => "Capture from Webcam (experimental)",
|
1795 |
+
"parent" => "webcam",
|
1796 |
+
"dependencies" => null,
|
1797 |
+
"variables" => null,
|
1798 |
+
"help" => "It requests a preferable video aspect ratio for the webcam. The plugin will try to match this setting as close as possible depending on webcam capabilities."
|
1799 |
+
),
|
1800 |
+
array(
|
1801 |
+
"name" => "Video Frame Rate",
|
1802 |
+
"attribute" => "videoframerate",
|
1803 |
+
"type" => "text",
|
1804 |
+
"validator" => "text",
|
1805 |
+
"listitems" => null,
|
1806 |
+
"value" => WFU_VAR("WFU_VIDEOFRAMERATE"),
|
1807 |
+
"mode" => "free",
|
1808 |
+
"category" => "webcam",
|
1809 |
+
"subcategory" => "Capture from Webcam (experimental)",
|
1810 |
+
"parent" => "webcam",
|
1811 |
+
"dependencies" => null,
|
1812 |
+
"variables" => null,
|
1813 |
+
"help" => "It requests a preferable video frame rate for video recording. The plugin will try to match this setting as close as possible depending on webcam capabilities."
|
1814 |
+
),
|
1815 |
+
array(
|
1816 |
+
"name" => "Camera Facing Mode",
|
1817 |
+
"attribute" => "camerafacing",
|
1818 |
+
"type" => "radio",
|
1819 |
+
"validator" => "text",
|
1820 |
+
"listitems" => array("any", "front", "back"),
|
1821 |
+
"value" => WFU_VAR("WFU_CAMERAFACING"),
|
1822 |
+
"mode" => "free",
|
1823 |
+
"category" => "webcam",
|
1824 |
+
"subcategory" => "Capture from Webcam (experimental)",
|
1825 |
+
"parent" => "webcam",
|
1826 |
+
"dependencies" => null,
|
1827 |
+
"variables" => null,
|
1828 |
+
"help" => "It defines if the front or back camera will be preferred (for mobile devices with 2 cameras). The plugin will try to match this setting depending on webcam capabilities."
|
1829 |
+
),
|
1830 |
+
array(
|
1831 |
+
"name" => "Max Record Time",
|
1832 |
+
"attribute" => "maxrecordtime",
|
1833 |
+
"type" => "integer",
|
1834 |
+
"validator" => "integer",
|
1835 |
+
"listitems" => null,
|
1836 |
+
"value" => WFU_VAR("WFU_MAXRECORDTIME"),
|
1837 |
+
"mode" => "free",
|
1838 |
+
"category" => "webcam",
|
1839 |
+
"subcategory" => "Capture from Webcam (experimental)",
|
1840 |
+
"parent" => "webcam",
|
1841 |
+
"dependencies" => null,
|
1842 |
+
"variables" => null,
|
1843 |
+
"help" => "It defines the maximum time of video recording (in seconds). If it is set to -1, then there is no time limit."
|
1844 |
+
),
|
1845 |
+
null
|
1846 |
+
);
|
1847 |
+
|
1848 |
+
wfu_array_remove_nulls($defs);
|
1849 |
+
|
1850 |
+
|
1851 |
+
return $defs;
|
1852 |
+
}
|
1853 |
+
|
lib/wfu_blocks.php
CHANGED
@@ -1,818 +1,818 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Plugin Upload Form Blocks
|
5 |
-
*
|
6 |
-
* This file contains functions related to preparation of the elements of the
|
7 |
-
* upload form of the plugin.
|
8 |
-
*
|
9 |
-
* @link /lib/wfu_blocks.php
|
10 |
-
*
|
11 |
-
* @package WordPress File Upload Plugin
|
12 |
-
* @subpackage Core Components
|
13 |
-
* @since 2.1.2
|
14 |
-
*/
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Prepare the Upload Form Generic Element.
|
18 |
-
*
|
19 |
-
* This function prepares the display properties of the generic top-level
|
20 |
-
* element of the plugin's upload form.
|
21 |
-
*
|
22 |
-
* @since 4.1.0
|
23 |
-
*
|
24 |
-
* @param array $params The uploader shortcode attributes.
|
25 |
-
* @param array $additional_params A list of additional parameters passed to the
|
26 |
-
* function.
|
27 |
-
* @param integer $occurrence_index The occurrence index of this element inside
|
28 |
-
* the upload form.
|
29 |
-
*
|
30 |
-
* @return array The display properties of the generic top-level element.
|
31 |
-
*/
|
32 |
-
function wfu_prepare_base_block($params, $additional_params, $occurrence_index) {
|
33 |
-
//prepare data for template
|
34 |
-
$data["ID"] = $params["uploadid"];
|
35 |
-
$data["responsive"] = ( $params["fitmode"] == "responsive" );
|
36 |
-
$data["testmode"] = ( $params["testmode"] == "true" );
|
37 |
-
$data["params"] = $params;
|
38 |
-
|
39 |
-
$base_item["title"] = '';
|
40 |
-
$base_item["hidden"] = false;
|
41 |
-
$base_item["width"] = "";
|
42 |
-
$base_item["object"] = "GlobalData.WFU[".$data["ID"]."].base";
|
43 |
-
//read html output from template
|
44 |
-
$base_item += wfu_read_template_output("base", $data);
|
45 |
-
|
46 |
-
return $base_item;
|
47 |
-
}
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Prepare the Upload Form Visual Editor Element.
|
51 |
-
*
|
52 |
-
* This function prepares the display properties of the visual editor element of
|
53 |
-
* the plugin's upload form.
|
54 |
-
*
|
55 |
-
* @since 4.0.0
|
56 |
-
*
|
57 |
-
* @param array $params The uploader shortcode attributes.
|
58 |
-
* @param array $additional_params A list of additional parameters passed to the
|
59 |
-
* function.
|
60 |
-
* @param integer $occurrence_index The occurrence index of this element inside
|
61 |
-
* the upload form.
|
62 |
-
*
|
63 |
-
* @return array The display properties of the visual editor element.
|
64 |
-
*/
|
65 |
-
function wfu_prepare_visualeditorbutton_block($params, $additional_params, $occurrence_index) {
|
66 |
-
if ( isset($params["uploadid"]) ) {
|
67 |
-
$ID = $params["uploadid"];
|
68 |
-
$JS_Object = "GlobalData.WFU[".$ID."].visualeditorbutton";
|
69 |
-
}
|
70 |
-
else {
|
71 |
-
$ID = $params["browserid"];
|
72 |
-
$JS_Object = "GlobalData.WFUB[".$ID."].visualeditorbutton";
|
73 |
-
}
|
74 |
-
//prepare data for template
|
75 |
-
$data["ID"] = $ID;
|
76 |
-
$data["shortcode_tag"] = $additional_params['shortcode_tag'];
|
77 |
-
$data["JS_Object"] = $JS_Object;
|
78 |
-
$data["params"] = $params;
|
79 |
-
|
80 |
-
$visualeditorbutton_item["title"] = '';
|
81 |
-
$visualeditorbutton_item["hidden"] = false;
|
82 |
-
$visualeditorbutton_item["width"] = "";
|
83 |
-
$visualeditorbutton_item["object"] = $JS_Object;
|
84 |
-
//read html output from template
|
85 |
-
$visualeditorbutton_item += wfu_read_template_output("visualeditorbutton", $data);
|
86 |
-
//initialize title object properties
|
87 |
-
$visualeditorbutton_item["js"] = $JS_Object." = { ".
|
88 |
-
"shortcode_tag: \"".$data["shortcode_tag"]."\", ".
|
89 |
-
"attachInvokeHandler: function(invoke_function) {}, ".
|
90 |
-
"onInvoke: function() {}, ".
|
91 |
-
"afterInvoke: function() {}".
|
92 |
-
"};\n\n".$visualeditorbutton_item["js"];
|
93 |
-
//append javascript variable that checks if title exists or not
|
94 |
-
$visualeditorbutton_item["js"] .= "\n\n".$JS_Object."_exist = true;";
|
95 |
-
|
96 |
-
return $visualeditorbutton_item;
|
97 |
-
}
|
98 |
-
|
99 |
-
|
100 |
-
/**
|
101 |
-
* Prepare the Upload Form Subfolders Element.
|
102 |
-
*
|
103 |
-
* This function prepares the display properties of the subfolders element of
|
104 |
-
* the plugin's upload form.
|
105 |
-
*
|
106 |
-
* @since 2.1.2
|
107 |
-
*
|
108 |
-
* @param array $params The uploader shortcode attributes.
|
109 |
-
* @param array $additional_params A list of additional parameters passed to the
|
110 |
-
* function.
|
111 |
-
* @param integer $occurrence_index The occurrence index of this element inside
|
112 |
-
* the upload form.
|
113 |
-
*
|
114 |
-
* @return array The display properties of the subfolders element.
|
115 |
-
*/
|
116 |
-
function wfu_prepare_subfolders_block($params, $additional_params, $occurrence_index) {
|
117 |
-
//prepare data for template
|
118 |
-
$data["ID"] = $params["uploadid"];
|
119 |
-
$data["widths"] = $additional_params['widths'];
|
120 |
-
$data["heights"] = $additional_params['heights'];
|
121 |
-
$data["responsive"] = ( $params["fitmode"] == "responsive" );
|
122 |
-
$data["testmode"] = ( $params["testmode"] == "true" );
|
123 |
-
$data["show_uploadfolder"] = ( $params["showtargetfolder"] == "true" );
|
124 |
-
$data["show_subfolders"] = ( $params["askforsubfolders"] == "true" );
|
125 |
-
$data["editable"] = ( substr($params["subfoldertree"], 0, 5) == "auto+" );
|
126 |
-
$data["uploadfolder"] = wfu_upload_plugin_directory($params["uploadpath"]);
|
127 |
-
$data["uploadfolder_title"] = $params["targetfolderlabel"];
|
128 |
-
$data["subfolders"] = array( 'path' => array(), 'label' => array(), 'level' => array(), 'default' => array() );
|
129 |
-
$data["subfolders_title"] = $params["subfolderlabel"];
|
130 |
-
$data["index"] = $occurrence_index;
|
131 |
-
$data["params"] = $params;
|
132 |
-
//prepare data of subfolders
|
133 |
-
if ( $data["show_subfolders"] && !$data["testmode"] ) {
|
134 |
-
if ( substr($params["subfoldertree"], 0, 4) == "auto" ) {
|
135 |
-
$upload_directory = wfu_upload_plugin_full_path($params);
|
136 |
-
$dirtree = wfu_getTree($upload_directory);
|
137 |
-
foreach ( $dirtree as &$dir ) $dir = '*'.$dir;
|
138 |
-
$params["subfoldertree"] = implode(',', $dirtree);
|
139 |
-
}
|
140 |
-
$subfolders = wfu_parse_folderlist($params["subfoldertree"]);
|
141 |
-
if ( count($subfolders['path']) == 0 ) {
|
142 |
-
array_push($subfolders['path'], "");
|
143 |
-
array_push($subfolders['label'], wfu_upload_plugin_directory($params["uploadpath"]));
|
144 |
-
array_push($subfolders['level'], 0);
|
145 |
-
array_push($subfolders['default'], false);
|
146 |
-
}
|
147 |
-
$data["subfolders"] = $subfolders;
|
148 |
-
}
|
149 |
-
|
150 |
-
$subfolders_item = null;
|
151 |
-
if ( $data["show_uploadfolder"] || $data["show_subfolders"] ) {
|
152 |
-
$subfolders_item["title"] = 'wordpress_file_upload_subfolders_'.$data["ID"];
|
153 |
-
$subfolders_item["hidden"] = false;
|
154 |
-
$subfolders_item["width"] = "";
|
155 |
-
$subfolders_item["object"] = "GlobalData.WFU[".$data["ID"]."].subfolders";
|
156 |
-
//for responsive plugin adjust width
|
157 |
-
if ( $data["responsive"] ) $subfolders_item["width"] = $data["width"];
|
158 |
-
//read html output from template
|
159 |
-
$subfolders_item += wfu_read_template_output("subfolders", $data);
|
160 |
-
//initialize subfolders object properties
|
161 |
-
$subfolders_item["js"] = "GlobalData.WFU[".$data["ID"]."].subfolders = { ".
|
162 |
-
"update_handler: function(new_value) { document.getElementById('hiddeninput_".$data["ID"]."').value = new_value; }, ".
|
163 |
-
"check: function() { return true; }, ".
|
164 |
-
"index: function() { return -1; }, ".
|
165 |
-
"reset: function() {}, ".
|
166 |
-
"toggle: function(enabled) {}".
|
167 |
-
"};\n\n".$subfolders_item["js"];
|
168 |
-
//append javascript variable that checks if subfolders element exists or not
|
169 |
-
if ( $data["show_subfolders"] ) $subfolders_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].subfolders_exist = true;";
|
170 |
-
}
|
171 |
-
|
172 |
-
return $subfolders_item;
|
173 |
-
}
|
174 |
-
|
175 |
-
/**
|
176 |
-
* Prepare the Upload Form Title Element.
|
177 |
-
*
|
178 |
-
* This function prepares the display properties of the title element of the
|
179 |
-
* plugin's upload form.
|
180 |
-
*
|
181 |
-
* @since 2.1.2
|
182 |
-
*
|
183 |
-
* @param array $params The uploader shortcode attributes.
|
184 |
-
* @param array $additional_params A list of additional parameters passed to the
|
185 |
-
* function.
|
186 |
-
* @param integer $occurrence_index The occurrence index of this element inside
|
187 |
-
* the upload form.
|
188 |
-
*
|
189 |
-
* @return array The display properties of the title element.
|
190 |
-
*/
|
191 |
-
function wfu_prepare_title_block($params, $additional_params, $occurrence_index) {
|
192 |
-
//prepare data for template
|
193 |
-
$data["ID"] = $params["uploadid"];
|
194 |
-
$data["width"] = $additional_params['widths']['title'];
|
195 |
-
$data["height"] = $additional_params['heights']['title'];
|
196 |
-
$data["responsive"] = ( $params["fitmode"] == "responsive" );
|
197 |
-
$data["testmode"] = ( $params["testmode"] == "true" );
|
198 |
-
$data["title"] = $params["uploadtitle"];
|
199 |
-
$data["index"] = $occurrence_index;
|
200 |
-
$data["params"] = $params;
|
201 |
-
|
202 |
-
$title_item["title"] = 'wordpress_file_upload_title_'.$data["ID"];
|
203 |
-
$title_item["hidden"] = false;
|
204 |
-
$title_item["width"] = "";
|
205 |
-
$title_item["object"] = "GlobalData.WFU[".$data["ID"]."].title";
|
206 |
-
//for responsive plugin adjust container and container's parent widths if a % width has been defined
|
207 |
-
if ( $data["responsive"] && strlen($data["width"]) > 1 && substr($data["width"], -1, 1) == "%" ) $title_item["width"] = $data["width"];
|
208 |
-
//read html output from template
|
209 |
-
$title_item += wfu_read_template_output("title", $data);
|
210 |
-
//initialize title object properties
|
211 |
-
$title_item["js"] = "GlobalData.WFU[".$data["ID"]."].title = {};\n\n".$title_item["js"];
|
212 |
-
//append javascript variable that checks if title exists or not
|
213 |
-
$title_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].title_exist = true;";
|
214 |
-
|
215 |
-
return $title_item;
|
216 |
-
}
|
217 |
-
|
218 |
-
/**
|
219 |
-
* Prepare the Upload Form Filename Element.
|
220 |
-
*
|
221 |
-
* This function prepares the display properties of the filename (textbox)
|
222 |
-
* element of the plugin's upload form.
|
223 |
-
*
|
224 |
-
* @since 2.1.2
|
225 |
-
*
|
226 |
-
* @param array $params The uploader shortcode attributes.
|
227 |
-
* @param array $additional_params A list of additional parameters passed to the
|
228 |
-
* function.
|
229 |
-
* @param integer $occurrence_index The occurrence index of this element inside
|
230 |
-
* the upload form.
|
231 |
-
*
|
232 |
-
* @return array The display properties of the filename element.
|
233 |
-
*/
|
234 |
-
function wfu_prepare_textbox_block($params, $additional_params, $occurrence_index) {
|
235 |
-
//prepare data for template
|
236 |
-
$data["ID"] = $params["uploadid"];
|
237 |
-
$data["width"] = $additional_params['widths']['filename'];
|
238 |
-
$data["height"] = $additional_params['heights']['filename'];
|
239 |
-
$data["responsive"] = ( $params["fitmode"] == "responsive" );
|
240 |
-
$data["testmode"] = ( $params["testmode"] == "true" );
|
241 |
-
$data["index"] = $occurrence_index;
|
242 |
-
$data["params"] = $params;
|
243 |
-
|
244 |
-
|
245 |
-
$textbox_item["title"] = 'wordpress_file_upload_textbox_'.$data["ID"];
|
246 |
-
$textbox_item["hidden"] = false;
|
247 |
-
$textbox_item["width"] = "";
|
248 |
-
$textbox_item["object"] = "GlobalData.WFU[".$data["ID"]."].textbox";
|
249 |
-
//for responsive plugin adjust container and container's parent widths if a % width has been defined
|
250 |
-
if ( $data["responsive"] && strlen($data["width"]) > 1 && substr($data["width"], -1, 1) == "%" ) $textbox_item["width"] = $data["width"];
|
251 |
-
//read html output from template
|
252 |
-
$textbox_item += wfu_read_template_output("textbox", $data);
|
253 |
-
//initialize textbox object properties
|
254 |
-
$textbox_item["js"] = "GlobalData.WFU[".$data["ID"]."].textbox = { ".
|
255 |
-
"attachCancelHandler: function(cancel_function) {}, ".
|
256 |
-
"dettachCancelHandler: function() {}, ".
|
257 |
-
"update: function(action, filenames) {} ".
|
258 |
-
"};\n\n".$textbox_item["js"];
|
259 |
-
//append javascript variable that checks if textbox exists or not
|
260 |
-
$textbox_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].textbox_exist = true;";
|
261 |
-
|
262 |
-
return $textbox_item;
|
263 |
-
}
|
264 |
-
|
265 |
-
/**
|
266 |
-
* Prepare the Upload Form Main Form Element.
|
267 |
-
*
|
268 |
-
* This function prepares the display properties of the form element of the
|
269 |
-
* plugin's upload form. This element also contains the select button element.
|
270 |
-
*
|
271 |
-
* @since 2.1.2
|
272 |
-
*
|
273 |
-
* @param array $params The uploader shortcode attributes.
|
274 |
-
* @param array $additional_params A list of additional parameters passed to the
|
275 |
-
* function.
|
276 |
-
* @param integer $occurrence_index The occurrence index of this element inside
|
277 |
-
* the upload form.
|
278 |
-
*
|
279 |
-
* @return array The display properties of the main form element.
|
280 |
-
*/
|
281 |
-
function wfu_prepare_uploadform_block($params, $additional_params, $occurrence_index) {
|
282 |
-
//prepare data for template
|
283 |
-
$data["ID"] = $params["uploadid"];
|
284 |
-
$data["width"] = $additional_params['widths']['selectbutton'];
|
285 |
-
$data["height"] = $additional_params['heights']['selectbutton'];
|
286 |
-
$data["responsive"] = ( $params["fitmode"] == "responsive" );
|
287 |
-
$data["testmode"] = ( $params["testmode"] == "true" );
|
288 |
-
$data["label"] = $params["selectbutton"];
|
289 |
-
$data["filename"] = "uploadedfile_".$data["ID"];
|
290 |
-
$data["hidden_elements"] = array(
|
291 |
-
array( "id" => "wfu_uploader_nonce_".$data["ID"], "name" => "wfu_uploader_nonce", "value" => wp_create_nonce("wfu-uploader-nonce") ),
|
292 |
-
array( "id" => "hiddeninput_".$data["ID"], "name" => "hiddeninput_".$data["ID"], "value" => "" ),
|
293 |
-
array( "id" => "uniqueuploadid_".$data["ID"], "name" => "uniqueuploadid_".$data["ID"], "value" => "" ),
|
294 |
-
array( "id" => "nofileupload_".$data["ID"], "name" => "nofileupload_".$data["ID"], "value" => "0" ),
|
295 |
-
array( "id" => "uploadedfile_".$data["ID"]."_name", "name" => "uploadedfile_".$data["ID"]."_name", "value" => wfu_plugin_encode_string("dummy.txt") ),
|
296 |
-
array( "id" => "uploadedfile_".$data["ID"]."_size", "name" => "uploadedfile_".$data["ID"]."_size", "value" => "0" ),
|
297 |
-
array( "id" => "adminerrorcodes_".$data["ID"], "name" => "adminerrorcodes_".$data["ID"], "value" => "" )
|
298 |
-
);
|
299 |
-
if ( $additional_params["require_consent"] ) array_push( $data["hidden_elements"],
|
300 |
-
array( "id" => "consentresult_".$data["ID"], "name" => "consentresult_".$data["ID"], "value" => "" )
|
301 |
-
);
|
302 |
-
foreach ($params["userdata_fields"] as $userdata_key => $userdata_field)
|
303 |
-
array_push($data["hidden_elements"], array( "id" => "hiddeninput_".$data["ID"]."_userdata_".$userdata_key, "name" => "hiddeninput_".$data["ID"]."_userdata_".$userdata_key, "value" => "" ));
|
304 |
-
$data["index"] = $occurrence_index;
|
305 |
-
$data["params"] = $params;
|
306 |
-
|
307 |
-
$uploadform_item["title"] = 'wordpress_file_upload_form_'.$data["ID"];
|
308 |
-
// selectbutton block is mandatory because it contains the upload form element, so in case it is not included in the placements
|
309 |
-
// attribute then we set its visibility to hidden
|
310 |
-
$uploadform_item["hidden"] = ( strpos($params["placements"], "selectbutton") === false );
|
311 |
-
$uploadform_item["width"] = "";
|
312 |
-
$uploadform_item["object"] = "GlobalData.WFU[".$data["ID"]."].uploadform";
|
313 |
-
//for responsive plugin adjust container and container's parent widths if a % width has been defined
|
314 |
-
if ( $data["responsive"] && strlen($data["width"]) > 1 && substr($data["width"], -1, 1) == "%" ) $uploadform_item["width"] = $data["width"];
|
315 |
-
|
316 |
-
//read html output from template
|
317 |
-
$uploadform_item += wfu_read_template_output("uploadform", $data);
|
318 |
-
//initialize uploadform object properties
|
319 |
-
$uploadform_item["js"] = "GlobalData.WFU[".$data["ID"]."].uploadform = { ".
|
320 |
-
"attachActions: function(clickaction, changeaction) {}, ".
|
321 |
-
"reset: function() {}, ".
|
322 |
-
"resetDummy: function() {}, ".
|
323 |
-
"submit: function() {}, ".
|
324 |
-
"lock: function() {}, ".
|
325 |
-
"unlock: function() {}, ".
|
326 |
-
"changeFileName: function(new_filename) {}, ".
|
327 |
-
"files: function() { return []; } ".
|
328 |
-
"};\n\n".$uploadform_item["js"];
|
329 |
-
//append javascript variable that checks if uploadform element exists or not
|
330 |
-
$uploadform_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].uploadform_exist = true;";
|
331 |
-
|
332 |
-
return $uploadform_item;
|
333 |
-
}
|
334 |
-
|
335 |
-
/**
|
336 |
-
* Prepare the Upload Form Submit Button Element.
|
337 |
-
*
|
338 |
-
* This function prepares the display properties of the submit button element of
|
339 |
-
* the plugin's upload form.
|
340 |
-
*
|
341 |
-
* @since 2.1.2
|
342 |
-
*
|
343 |
-
* @param array $params The uploader shortcode attributes.
|
344 |
-
* @param array $additional_params A list of additional parameters passed to the
|
345 |
-
* function.
|
346 |
-
* @param integer $occurrence_index The occurrence index of this element inside
|
347 |
-
* the upload form.
|
348 |
-
*
|
349 |
-
* @return array The display properties of the submit button element.
|
350 |
-
*/
|
351 |
-
function wfu_prepare_submit_block($params, $additional_params, $occurrence_index) {
|
352 |
-
//prepare data for template
|
353 |
-
$data["ID"] = $params["uploadid"];
|
354 |
-
$data["width"] = $additional_params['widths']['uploadbutton'];
|
355 |
-
$data["height"] = $additional_params['heights']['uploadbutton'];
|
356 |
-
$data["responsive"] = ( $params["fitmode"] == "responsive" );
|
357 |
-
$data["testmode"] = ( $params["testmode"] == "true" );
|
358 |
-
$data["allownofile"] = ( $params["allownofile"] == "true" );
|
359 |
-
$data["label"] = $params["uploadbutton"];
|
360 |
-
$data["index"] = $occurrence_index;
|
361 |
-
$data["params"] = $params;
|
362 |
-
|
363 |
-
$submit_item["title"] = 'wordpress_file_upload_submit_'.$data["ID"];
|
364 |
-
$submit_item["hidden"] = false;
|
365 |
-
$submit_item["width"] = "";
|
366 |
-
$submit_item["object"] = "GlobalData.WFU[".$data["ID"]."].submit";
|
367 |
-
//for responsive plugin adjust container and container's parent widths if a % width has been defined
|
368 |
-
if ( $data["responsive"] && strlen($data["width"]) > 1 && substr($data["width"], -1, 1) == "%" ) $submit_item["width"] = $data["width"];
|
369 |
-
|
370 |
-
//read html output from template
|
371 |
-
$submit_item += wfu_read_template_output("submit", $data);
|
372 |
-
//initialize submit element (upload button) object properties
|
373 |
-
$submit_item["js"] = "GlobalData.WFU[".$data["ID"]."].submit = { ".
|
374 |
-
"label_default: '".$data["label"]."', ".
|
375 |
-
"attachClickAction: function(clickaction) { }, ".
|
376 |
-
"updateLabel: function(new_label) { }, ".
|
377 |
-
"toggle: function(status) { } ".
|
378 |
-
"};\n\n".$submit_item["js"];
|
379 |
-
//append javascript variable that checks if upload button element exists
|
380 |
-
$submit_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].submit_exist = true;";
|
381 |
-
|
382 |
-
return $submit_item;
|
383 |
-
}
|
384 |
-
|
385 |
-
|
386 |
-
/**
|
387 |
-
* Prepare the Upload Form Webcam Element.
|
388 |
-
*
|
389 |
-
* This function prepares the display properties of the webcam element of the
|
390 |
-
* plugin's upload form.
|
391 |
-
*
|
392 |
-
* @since 3.8.0
|
393 |
-
*
|
394 |
-
* @param array $params The uploader shortcode attributes.
|
395 |
-
* @param array $additional_params A list of additional parameters passed to the
|
396 |
-
* function.
|
397 |
-
* @param integer $occurrence_index The occurrence index of this element inside
|
398 |
-
* the upload form.
|
399 |
-
*
|
400 |
-
* @return array The display properties of the webcam element.
|
401 |
-
*/
|
402 |
-
function wfu_prepare_webcam_block($params, $additional_params, $occurrence_index) {
|
403 |
-
//prepare data for template
|
404 |
-
$data["ID"] = $params["uploadid"];
|
405 |
-
$data["width"] = $additional_params['widths']['webcam'];
|
406 |
-
$data["height"] = $additional_params['heights']['webcam'];
|
407 |
-
$data["responsive"] = ( $params["fitmode"] == "responsive" );
|
408 |
-
$data["testmode"] = ( $params["testmode"] == "true" );
|
409 |
-
$data["index"] = $occurrence_index;
|
410 |
-
$data["params"] = $params;
|
411 |
-
|
412 |
-
$webcam_item["title"] = 'wordpress_file_upload_webcam_'.$data["ID"];
|
413 |
-
$webcam_item["hidden"] = false;
|
414 |
-
$webcam_item["width"] = "";
|
415 |
-
$webcam_item["object"] = "GlobalData.WFU[".$data["ID"]."].webcam";
|
416 |
-
|
417 |
-
$webcam_init = "\n".'var wfu_webrtc_ref = document.createElement("SCRIPT");';
|
418 |
-
$webcam_init .= "\n".'wfu_webrtc_ref.setAttribute("type", "text/javascript");';
|
419 |
-
$webcam_init .= "\n".'wfu_webrtc_ref.setAttribute("src", "https://webrtc.github.io/adapter/adapter-latest.js");';
|
420 |
-
$webcam_init .= "\n".'document.getElementById(GlobalData.WFU['.$data["ID"].'].container_id).appendChild(wfu_webrtc_ref);';
|
421 |
-
$webcam_init .= "\n".'var wfu_initialize_webcam_loader_'.$data["ID"].' = function() { wfu_initialize_webcam('.$data["ID"].', "'.$params["webcammode"].'", "'.$params["audiocapture"].'", "'.$params["videowidth"].'", "'.$params["videoheight"].'", "'.$params["videoaspectratio"].'", "'.$params["videoframerate"].'", "'.$params["camerafacing"].'", '.$params["maxrecordtime"].'); }';
|
422 |
-
$webcam_init .= "\n".'if(window.addEventListener) { window.addEventListener("load", wfu_initialize_webcam_loader_'.$data["ID"].', false); } else if(window.attachEvent) { window.attachEvent("onload", wfu_initialize_webcam_loader_'.$data["ID"].'); } else { window["onload"] = wfu_initialize_webcam_loader_'.$data["ID"].'; }';
|
423 |
-
|
424 |
-
//read html output from template
|
425 |
-
$webcam_item += wfu_read_template_output("webcam", $data);
|
426 |
-
//initialize captcha object properties
|
427 |
-
$webcam_item["js"] = "GlobalData.WFU[".$data["ID"]."].webcam = { ".
|
428 |
-
"initCallback: function() {},".
|
429 |
-
"initButtons: function(mode) {},".
|
430 |
-
"updateStatus: function(status) {},".
|
431 |
-
"updateButtonStatus: function(status) {},".
|
432 |
-
"updateTimer: function(time) {},".
|
433 |
-
"updatePlayProgress: function(duration) {},".
|
434 |
-
"setVideoProperties: function(props) {},".
|
435 |
-
"videoSize: function() { return null; },".
|
436 |
-
"readyState: function() { return -1; },".
|
437 |
-
"screenshot: function(savefunc, image_type) {},".
|
438 |
-
"play: function() {},".
|
439 |
-
"pause: function() {},".
|
440 |
-
"back: function() {},".
|
441 |
-
"fwd: function(duration) {},".
|
442 |
-
"ended: function() {}".
|
443 |
-
"};\n\n".$webcam_item["js"].$webcam_init;
|
444 |
-
//append javascript variable that checks if webcam element exists or not
|
445 |
-
$webcam_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].webcam_exist = true;";
|
446 |
-
|
447 |
-
return $webcam_item;
|
448 |
-
}
|
449 |
-
|
450 |
-
/**
|
451 |
-
* Prepare the Upload Form Progress Bar Element.
|
452 |
-
*
|
453 |
-
* This function prepares the display properties of the progress bar element of
|
454 |
-
* the plugin's upload form.
|
455 |
-
*
|
456 |
-
* @since 3.8.0
|
457 |
-
*
|
458 |
-
* @param array $params The uploader shortcode attributes.
|
459 |
-
* @param array $additional_params A list of additional parameters passed to the
|
460 |
-
* function.
|
461 |
-
* @param integer $occurrence_index The occurrence index of this element inside
|
462 |
-
* the upload form.
|
463 |
-
*
|
464 |
-
* @return array The display properties of the progress bar element.
|
465 |
-
*/
|
466 |
-
function wfu_prepare_progressbar_block($params, $additional_params, $occurrence_index) {
|
467 |
-
//prepare data for template
|
468 |
-
$data["ID"] = $params["uploadid"];
|
469 |
-
$data["width"] = $additional_params['widths']['progressbar'];
|
470 |
-
$data["height"] = $additional_params['heights']['progressbar'];
|
471 |
-
$data["responsive"] = ( $params["fitmode"] == "responsive" );
|
472 |
-
$data["testmode"] = ( $params["testmode"] == "true" );
|
473 |
-
$data["index"] = $occurrence_index;
|
474 |
-
$data["params"] = $params;
|
475 |
-
|
476 |
-
$progressbar_item["title"] = 'wordpress_file_upload_progressbar_'.$data["ID"];
|
477 |
-
$progressbar_item["hidden"] = ( $params["testmode"] != "true" );
|
478 |
-
$progressbar_item["width"] = "";
|
479 |
-
$progressbar_item["object"] = "GlobalData.WFU[".$data["ID"]."].progressbar";
|
480 |
-
//for responsive plugin adjust container's parent width if a % width has been defined
|
481 |
-
if ( $data["responsive"] && strlen($data["width"]) > 1 && substr($data["width"], -1, 1) == "%" ) $progressbar_item["width"] = $data["width"];
|
482 |
-
//read html output from template
|
483 |
-
$progressbar_item += wfu_read_template_output("progressbar", $data);
|
484 |
-
//initialize progressbar object properties
|
485 |
-
$progressbar_item["js"] = "GlobalData.WFU[".$data["ID"]."].progressbar = { ".
|
486 |
-
"show: function(mode) {}, ".
|
487 |
-
"hide: function() {}, ".
|
488 |
-
"update: function(progress) {} ".
|
489 |
-
"};\n\n".$progressbar_item["js"];
|
490 |
-
//append javascript variable that checks if progress bar exists or not
|
491 |
-
$progressbar_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].progressbar_exist = true;";
|
492 |
-
|
493 |
-
return $progressbar_item;
|
494 |
-
}
|
495 |
-
|
496 |
-
/**
|
497 |
-
* Prepare the Upload Form Message Element.
|
498 |
-
*
|
499 |
-
* This function prepares the display properties of the message element of the
|
500 |
-
* plugin's upload form.
|
501 |
-
*
|
502 |
-
* @since 2.1.2
|
503 |
-
*
|
504 |
-
* @param array $params The uploader shortcode attributes.
|
505 |
-
* @param array $additional_params A list of additional parameters passed to the
|
506 |
-
* function.
|
507 |
-
* @param integer $occurrence_index The occurrence index of this element inside
|
508 |
-
* the upload form.
|
509 |
-
*
|
510 |
-
* @return array The display properties of the message element.
|
511 |
-
*/
|
512 |
-
function wfu_prepare_message_block($params, $additional_params, $occurrence_index) {
|
513 |
-
//prepare data for template
|
514 |
-
$data["ID"] = $params["uploadid"];
|
515 |
-
$data["width"] = $additional_params['widths']['message'];
|
516 |
-
$data["height"] = $additional_params['heights']['message'];
|
517 |
-
$data["responsive"] = ( $params["fitmode"] == "responsive" );
|
518 |
-
$data["testmode"] = ( $params["testmode"] == "true" );
|
519 |
-
$data["index"] = $occurrence_index;
|
520 |
-
$data["params"] = $params;
|
521 |
-
|
522 |
-
$header_styles["State0"] = wfu_prepare_message_colors(WFU_VAR("WFU_HEADERMESSAGECOLORS_STATE0"));
|
523 |
-
$header_styles["State0"]['message'] = WFU_UPLOAD_STATE0;
|
524 |
-
$header_styles["State1"] = wfu_prepare_message_colors($params["warningmessagecolors"]);
|
525 |
-
$header_styles["State1"]['message'] = WFU_UPLOAD_STATE1;
|
526 |
-
$header_styles["State2"] = wfu_prepare_message_colors($params["warningmessagecolors"]);
|
527 |
-
$header_styles["State2"]['message'] = WFU_UPLOAD_STATE2;
|
528 |
-
$header_styles["State3"] = wfu_prepare_message_colors($params["warningmessagecolors"]);
|
529 |
-
$header_styles["State3"]['message'] = WFU_UPLOAD_STATE3;
|
530 |
-
$header_styles["State4"] = wfu_prepare_message_colors($params["successmessagecolors"]);
|
531 |
-
$header_styles["State4"]['message'] = WFU_UPLOAD_STATE4;
|
532 |
-
$header_styles["State5"] = wfu_prepare_message_colors($params["warningmessagecolors"]);
|
533 |
-
$header_styles["State5"]['message'] = WFU_UPLOAD_STATE5;
|
534 |
-
$header_styles["State5_singlefile"] = wfu_prepare_message_colors(WFU_VAR("WFU_HEADERMESSAGECOLORS_STATE5"));
|
535 |
-
$header_styles["State5_singlefile"]['message'] = WFU_UPLOAD_STATE5_SINGLEFILE;
|
536 |
-
$header_styles["State6"] = wfu_prepare_message_colors($params["warningmessagecolors"]);
|
537 |
-
$header_styles["State6"]['message'] = WFU_UPLOAD_STATE6;
|
538 |
-
$header_styles["State7"] = wfu_prepare_message_colors($params["failmessagecolors"]);
|
539 |
-
$header_styles["State7"]['message'] = WFU_UPLOAD_STATE7;
|
540 |
-
$header_styles["State7_singlefile"] = wfu_prepare_message_colors(WFU_VAR("WFU_HEADERMESSAGECOLORS_STATE7"));
|
541 |
-
$header_styles["State7_singlefile"]['message'] = WFU_UPLOAD_STATE7_SINGLEFILE;
|
542 |
-
$header_styles["State8"] = wfu_prepare_message_colors($params["failmessagecolors"]);
|
543 |
-
$header_styles["State8"]['message'] = WFU_UPLOAD_STATE8;
|
544 |
-
$header_styles["State9"] = wfu_prepare_message_colors(WFU_VAR("WFU_HEADERMESSAGECOLORS_STATE9"));
|
545 |
-
$header_styles["State9"]['message'] = WFU_UPLOAD_STATE9;
|
546 |
-
$header_styles["State10"] = wfu_prepare_message_colors($params["failmessagecolors"]);
|
547 |
-
$header_styles["State10"]['message'] = WFU_UPLOAD_STATE10;
|
548 |
-
$header_styles["State11"] = wfu_prepare_message_colors(WFU_VAR("WFU_HEADERMESSAGECOLORS_STATE11"));
|
549 |
-
$header_styles["State11"]['message'] = WFU_UPLOAD_STATE11;
|
550 |
-
$header_styles["State12"] = wfu_prepare_message_colors($params["failmessagecolors"]);
|
551 |
-
$header_styles["State12"]['message'] = WFU_UPLOAD_STATE12;
|
552 |
-
$header_styles["State13"] = wfu_prepare_message_colors(WFU_VAR("WFU_HEADERMESSAGECOLORS_STATE13"));
|
553 |
-
$header_styles["State13"]['message'] = WFU_UPLOAD_STATE13;
|
554 |
-
$header_styles["State14"] = wfu_prepare_message_colors($params["successmessagecolors"]);
|
555 |
-
$header_styles["State14"]['message'] = WFU_UPLOAD_STATE14;
|
556 |
-
$header_styles["State15"] = wfu_prepare_message_colors($params["failmessagecolors"]);
|
557 |
-
$header_styles["State15"]['message'] = WFU_UPLOAD_STATE15;
|
558 |
-
$header_styles["State16"] = wfu_prepare_message_colors(WFU_VAR("WFU_HEADERMESSAGECOLORS_STATE16"));
|
559 |
-
$header_styles["State16"]['message'] = WFU_UPLOAD_STATE16;
|
560 |
-
$header_styles["State17"] = wfu_prepare_message_colors($params["failmessagecolors"]);
|
561 |
-
$header_styles["State17"]['message'] = WFU_UPLOAD_STATE17;
|
562 |
-
$header_styles["State18"] = wfu_prepare_message_colors($params["successmessagecolors"]);
|
563 |
-
$header_styles["State18"]['message'] = WFU_UPLOAD_STATE18;
|
564 |
-
$header_styles["State19"] = wfu_prepare_message_colors($params["warningmessagecolors"]);
|
565 |
-
$header_styles["State19"]['message'] = WFU_UPLOAD_STATE19;
|
566 |
-
$data["header_styles"] = $header_styles;
|
567 |
-
|
568 |
-
$message_item["title"] = 'wordpress_file_upload_message_'.$data["ID"];
|
569 |
-
$message_item["hidden"] = false;
|
570 |
-
$message_item["width"] = "";
|
571 |
-
$message_item["object"] = "GlobalData.WFU[".$data["ID"]."].message";
|
572 |
-
//for responsive plugin adjust container and container's parent widths if a % width has been defined
|
573 |
-
if ( $data["responsive"] && strlen($data["width"]) > 1 && substr($data["width"], -1, 1) == "%" ) $message_item["width"] = $data["width"];
|
574 |
-
|
575 |
-
// $message_block = wfu_prepare_message_block_skeleton($sid, $styles, ( $params["testmode"] == "true" ));
|
576 |
-
// $message_item = $message_block["msgblock"];
|
577 |
-
|
578 |
-
$message_init = "\n".'if (!GlobalData.States) {';
|
579 |
-
$message_init .= "\n\t".'GlobalData.States = {};';
|
580 |
-
foreach ( $data["header_styles"] as $state => $statedata )
|
581 |
-
$message_init .= "\n\t\t".'GlobalData.States.'.$state.' = { color:"'.$statedata["color"].'", bgcolor:"'.$statedata["bgcolor"].'", borcolor:"'.$statedata["borcolor"].'", message:"'.$statedata["message"].'" };';
|
582 |
-
$message_init .= "\n\t".'GlobalData.Colors = {';
|
583 |
-
$message_init .= "\n\t\t".'default: "'.WFU_VAR("WFU_DEFAULTMESSAGECOLORS").'".split(","),';
|
584 |
-
$message_init .= "\n\t\t".'success: "'.$params['successmessagecolors'].'".split(","),';
|
585 |
-
$message_init .= "\n\t\t".'warning: "'.$params['warningmessagecolors'].'".split(","),';
|
586 |
-
$message_init .= "\n\t\t".'error: "'.$params['failmessagecolors'].'".split(",")';
|
587 |
-
$message_init .= "\n\t".'};';
|
588 |
-
$message_init .= "\n".'}';
|
589 |
-
|
590 |
-
//read html output from template
|
591 |
-
$message_item += wfu_read_template_output("message", $data);
|
592 |
-
//extract header_template and file_template
|
593 |
-
$header_template = "";
|
594 |
-
$header_template_line = "";
|
595 |
-
$in_header_template_block = false;
|
596 |
-
$file_template = "";
|
597 |
-
$file_template_line = "";
|
598 |
-
$in_file_template_block = false;
|
599 |
-
foreach ( $message_item as $key => $item ) {
|
600 |
-
if ( $in_header_template_block ) {
|
601 |
-
unset($message_item[$key]);
|
602 |
-
if ( $item != "</header_template><file_template>" ) $header_template .= $item."\n";
|
603 |
-
else {
|
604 |
-
$in_header_template_block = false;
|
605 |
-
$in_file_template_block = true;
|
606 |
-
}
|
607 |
-
}
|
608 |
-
elseif ( $in_file_template_block ) {
|
609 |
-
unset($message_item[$key]);
|
610 |
-
if ( $item != "</file_template>" ) $file_template .= $item."\n";
|
611 |
-
else $in_file_template_block = false;
|
612 |
-
}
|
613 |
-
elseif ( substr($key, 0, 4) == "line" ) {
|
614 |
-
if ( $item == "<header_template>" ) {
|
615 |
-
unset($message_item[$key]);
|
616 |
-
$in_header_template_block = true;
|
617 |
-
}
|
618 |
-
elseif ( strpos($item, "[header_template]") !== false ) $header_template_line = $key;
|
619 |
-
elseif ( strpos($item, "[file_template]") !== false ) $file_template_line = $key;
|
620 |
-
}
|
621 |
-
}
|
622 |
-
if ( $header_template_line != "" )
|
623 |
-
$message_item[$header_template_line] = str_replace("[header_template]", wfu_plugin_encode_string(trim($header_template)), $message_item[$header_template_line]);
|
624 |
-
if ( $file_template_line != "" )
|
625 |
-
$message_item[$file_template_line] = str_replace("[file_template]", wfu_plugin_encode_string(trim($file_template)), $message_item[$file_template_line]);
|
626 |
-
//initialize message object properties
|
627 |
-
$message_item["js"] = "GlobalData.WFU[".$data["ID"]."].message = { ".
|
628 |
-
"update: function(data) {},".
|
629 |
-
"reset: function() {}".
|
630 |
-
"};\n\n".$message_item["js"].$message_init;
|
631 |
-
//append javascript variable that checks if message block exists or not
|
632 |
-
$message_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].message_exist = true;";
|
633 |
-
|
634 |
-
return $message_item;
|
635 |
-
}
|
636 |
-
|
637 |
-
/**
|
638 |
-
* Prepare the Upload Form User Data Element.
|
639 |
-
*
|
640 |
-
* This function prepares the display properties of the user data element of the
|
641 |
-
* plugin's upload form.
|
642 |
-
*
|
643 |
-
* @since 2.1.2
|
644 |
-
*
|
645 |
-
* @param array $params The uploader shortcode attributes.
|
646 |
-
* @param array $additional_params A list of additional parameters passed to the
|
647 |
-
* function.
|
648 |
-
* @param integer $occurrence_index The occurrence index of this element inside
|
649 |
-
* the upload form.
|
650 |
-
*
|
651 |
-
* @return array The display properties of the user data element.
|
652 |
-
*/
|
653 |
-
function wfu_prepare_userdata_block($params, $additional_params, $occurrence_index) {
|
654 |
-
$data["ID"] = $params["uploadid"];
|
655 |
-
$data["width"] = $additional_params['widths']['userdata'];
|
656 |
-
$data["height"] = $additional_params['heights']['userdata'];
|
657 |
-
$data["width_label"] = $additional_params['widths']['userdata_label'];
|
658 |
-
$data["height_label"] = $additional_params['heights']['userdata_label'];
|
659 |
-
$data["width_value"] = $additional_params['widths']['userdata_value'];
|
660 |
-
$data["height_value"] = $additional_params['heights']['userdata_value'];
|
661 |
-
$data["responsive"] = ( $params["fitmode"] == "responsive" );
|
662 |
-
$data["testmode"] = ( $params["testmode"] == "true" );
|
663 |
-
$data["props"] = array();
|
664 |
-
$data["index"] = $occurrence_index;
|
665 |
-
$data["params"] = $params;
|
666 |
-
//fill $data["props"] variable with properties of existing userdata fields
|
667 |
-
foreach ($params["userdata_fields"] as $userdata_key => $userdata_field) {
|
668 |
-
//use only fields belonging to $occurrence_index
|
669 |
-
if ( $occurrence_index == 0 || $userdata_field["occurrence"] == $occurrence_index ) {
|
670 |
-
$props = $userdata_field;
|
671 |
-
$props["key"] = $userdata_key;
|
672 |
-
array_push($data["props"], $props);
|
673 |
-
}
|
674 |
-
}
|
675 |
-
|
676 |
-
$userdata_item["title"] = 'wordpress_file_upload_userdata_'.$data["ID"].( $occurrence_index == 0 ? "" : "_".($occurrence_index - 1) );
|
677 |
-
$userdata_item["hidden"] = false;
|
678 |
-
$userdata_item["width"] = "";
|
679 |
-
$userdata_item["object"] = "GlobalData.WFU[".$data["ID"]."].userdata";
|
680 |
-
//for responsive plugin adjust container and container's parent widths if a % width has been defined
|
681 |
-
if ( $data["responsive"] && strlen($data["width"]) > 1 && substr($data["width"], -1, 1) == "%" ) $userdata_item["width"] = $data["width"];
|
682 |
-
$userdata_item += wfu_read_template_output("userdata", $data);
|
683 |
-
//extract templates of field types
|
684 |
-
$templates_html = "";
|
685 |
-
foreach ( $userdata_item as $key => $item ) {
|
686 |
-
if ( substr($key, 0, 4) == "line" ) {
|
687 |
-
$templates_html .= ( $templates_html == "" ? "" : "\r\n" ).$item;
|
688 |
-
unset($userdata_item[$key]);
|
689 |
-
}
|
690 |
-
}
|
691 |
-
//subclass init() function of userdata object so that it fills WFU.userdata
|
692 |
-
//object with properties and code handlers of the userdata fields;
|
693 |
-
//the subclassed init() function is carefully written because userdata is a
|
694 |
-
//multiplacements component, so init() function will run more than once
|
695 |
-
//and every time it runs we need to make sure that only the elements
|
696 |
-
//corresponding to the specific $occurrence_index will be initialized
|
697 |
-
$init_index = ( $occurrence_index <= 1 ? 0 : $occurrence_index - 1 );
|
698 |
-
$userdata_init = "";
|
699 |
-
$userdata_init .= "\n".'GlobalData.WFU['.$data["ID"].'].userdata._init'.$init_index.' = GlobalData.WFU['.$data["ID"].'].userdata.init;';
|
700 |
-
$userdata_init .= "\n".'GlobalData.WFU['.$data["ID"].'].userdata.init = function() {';
|
701 |
-
$userdata_init .= "\n\t".'GlobalData.WFU['.$data["ID"].'].userdata._init'.$init_index.'();';
|
702 |
-
$userdata_init .= "\n\t".'var WFU = GlobalData.WFU['.$data["ID"].'];';
|
703 |
-
if ( $init_index == 0 ) {
|
704 |
-
$userdata_init .= "\n\t".'if (typeof WFU.userdata.init_count == "undefined") {';
|
705 |
-
$userdata_init .= "\n\t\t".'WFU.userdata.init_count = 0;';
|
706 |
-
$userdata_init .= "\n\t\t".'WFU.userdata.codes = [];';
|
707 |
-
$userdata_init .= "\n\t\t".'WFU.userdata.props = [];';
|
708 |
-
$userdata_init .= "\n\t".'}';
|
709 |
-
$userdata_init .= "\n\t".'else WFU.userdata.init_count ++;';
|
710 |
-
}
|
711 |
-
$userdata_init .= "\n\t".'if (WFU.userdata.init_count == '.$init_index.') {';
|
712 |
-
$i = 1;
|
713 |
-
foreach ($params["userdata_fields"] as $userdata_key => $userdata_field) {
|
714 |
-
//show only fields belonging to $occurrence_index
|
715 |
-
if ( $occurrence_index == 0 || $userdata_field["occurrence"] == $occurrence_index ) {
|
716 |
-
$userdata_field["key"] = $userdata_key;
|
717 |
-
//get field template
|
718 |
-
$template = "";
|
719 |
-
$matches = array();
|
720 |
-
preg_match("/<userdata_".$userdata_field["key"]."_template>(.*?)<\/userdata_".$userdata_field["key"]."_template>/s", $templates_html, $matches);
|
721 |
-
if ( isset($matches[1]) ) $template = $matches[1];
|
722 |
-
//generate html code
|
723 |
-
foreach ( explode("\r\n", $template) as $line ) $userdata_item["line".$i++] = $line;
|
724 |
-
//generate javascript code
|
725 |
-
$userdata_init .= "\n\t\t".'WFU.userdata.codes['.$userdata_field["key"].'] = {};';
|
726 |
-
$userdata_init .= "\n\t\t".'WFU.userdata.props['.$userdata_field["key"].'] = '.wfu_PHP_array_to_JS_object($userdata_field).';';
|
727 |
-
$userdata_init .= "\n\t\t".'WFU.userdata.props['.$userdata_field["key"].'].store = function() { document.getElementById("hiddeninput_'.$data["ID"].'_userdata_'.$userdata_field["key"].'").value = WFU.userdata.codes['.$userdata_field["key"].'].value(); };';
|
728 |
-
$userdata_init .= "\n\t\t".'WFU.userdata.props['.$userdata_field["key"].'].getstored = function() { return document.getElementById("hiddeninput_'.$data["ID"].'_userdata_'.$userdata_field["key"].'").value; };';
|
729 |
-
$userdata_init .= "\n\t\t".'wfu_init_userdata_handlers('.$data["ID"].', '.$userdata_field["key"].');';
|
730 |
-
}
|
731 |
-
}
|
732 |
-
$userdata_init .= "\n\t".'}';
|
733 |
-
$userdata_init .= "\n".'}';
|
734 |
-
//initialize userdata object properties only for the first $occurrence_index
|
735 |
-
if ( $init_index == 0 ) {
|
736 |
-
$userdata_item["js"] = "GlobalData.WFU[".$data["ID"]."].userdata = { ".
|
737 |
-
"initField: function(props) {}, ".
|
738 |
-
"attachHandlers: function(props, handlerfunc) {}, ".
|
739 |
-
"getValue: function(props) { return ''; }, ".
|
740 |
-
"setValue: function(props, value) {}, ".
|
741 |
-
"enable: function(props) {}, ".
|
742 |
-
"disable: function(props) {}, ".
|
743 |
-
"prompt: function(props, message) {}".
|
744 |
-
"};\n\n".$userdata_item["js"];
|
745 |
-
}
|
746 |
-
else $userdata_item["js"] = "";
|
747 |
-
$userdata_item["js"] .= $userdata_init;
|
748 |
-
//append javascript additional userdata variables only for the first
|
749 |
-
//$occurrence_index
|
750 |
-
if ( $init_index == 0 ) {
|
751 |
-
$userdata_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].userdata_exist = true;";
|
752 |
-
$userdata_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].userdata.error_empty = \"".WFU_ERROR_USERDATA_EMPTY."\";";
|
753 |
-
$userdata_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].userdata.error_invalid_number = \"".WFU_ERROR_USERDATANUMBER_INVALID."\";";
|
754 |
-
$userdata_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].userdata.error_invalid_email = \"".WFU_ERROR_USERDATAEMAIL_INVALID."\";";
|
755 |
-
$userdata_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].userdata.error_confirm_email_nomatch = \"".WFU_ERROR_USERDATACONFIRMEMAIL_NOMATCH."\";";
|
756 |
-
$userdata_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].userdata.error_confirm_email_nobase = \"".WFU_ERROR_USERDATACONFIRMEMAIL_NOBASE."\";";
|
757 |
-
$userdata_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].userdata.error_confirm_password_nomatch = \"".WFU_ERROR_USERDATACONFIRMPASSWORD_NOMATCH."\";";
|
758 |
-
$userdata_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].userdata.error_confirm_password_nobase = \"".WFU_ERROR_USERDATACONFIRMPASSWORD_NOBASE."\";";
|
759 |
-
$userdata_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].userdata.error_checkbox_notchecked = \"".WFU_ERROR_USERDATACHECKBOX_NOTCHECKED."\";";
|
760 |
-
$userdata_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].userdata.error_radio_notselected = \"".WFU_ERROR_USERDATARADIO_NOTSELECTED."\";";
|
761 |
-
}
|
762 |
-
|
763 |
-
return $userdata_item;
|
764 |
-
}
|
765 |
-
|
766 |
-
/**
|
767 |
-
* Prepare the Upload Form Consent Element.
|
768 |
-
*
|
769 |
-
* This function prepares the display properties of the consent element of the
|
770 |
-
* plugin's upload form.
|
771 |
-
*
|
772 |
-
* @since 4.5.0
|
773 |
-
*
|
774 |
-
* @param array $params The uploader shortcode attributes.
|
775 |
-
* @param array $additional_params A list of additional parameters passed to the
|
776 |
-
* function.
|
777 |
-
* @param integer $occurrence_index The occurrence index of this element inside
|
778 |
-
* the upload form.
|
779 |
-
*
|
780 |
-
* @return array The display properties of the consent element.
|
781 |
-
*/
|
782 |
-
function wfu_prepare_consent_block($params, $additional_params, $occurrence_index) {
|
783 |
-
//prepare data for template
|
784 |
-
$data["ID"] = $params["uploadid"];
|
785 |
-
$data["width"] = $additional_params['widths']['consent'];
|
786 |
-
$data["height"] = $additional_params['heights']['consent'];
|
787 |
-
$data["responsive"] = ( $params["fitmode"] == "responsive" );
|
788 |
-
$data["testmode"] = ( $params["testmode"] == "true" );
|
789 |
-
$data["index"] = $occurrence_index;
|
790 |
-
$data["format"] = $params["consentformat"];
|
791 |
-
$data["preselected"] = $params["consentpreselect"];
|
792 |
-
$data["question"] = preg_replace("/:(\w*):/", "<a href=\"".$params["consentdisclaimer"]."\">$1</a>", $params["consentquestion"]);
|
793 |
-
$data["params"] = $params;
|
794 |
-
|
795 |
-
$consent_item["title"] = 'wordpress_file_upload_consent_'.$data["ID"];
|
796 |
-
$consent_item["hidden"] = ( $params["consentformat"] == "prompt" );
|
797 |
-
$consent_item["width"] = "";
|
798 |
-
$consent_item["object"] = "GlobalData.WFU[".$data["ID"]."].consent";
|
799 |
-
//for responsive plugin adjust container and container's parent widths if a % width has been defined
|
800 |
-
if ( $data["responsive"] && strlen($data["width"]) > 1 && substr($data["width"], -1, 1) == "%" ) $consent_item["width"] = $data["width"];
|
801 |
-
//read html output from template
|
802 |
-
$consent_item += wfu_read_template_output("consent", $data);
|
803 |
-
//initialize consent object properties
|
804 |
-
$consent_item["js"] = "GlobalData.WFU[".$data["ID"]."].consent = { ".
|
805 |
-
"consentCompleted: function() { return false; }, ".
|
806 |
-
"attachActions: function(completeaction) {}, ".
|
807 |
-
"update: function(action) {} ".
|
808 |
-
"};\n\n".$consent_item["js"];
|
809 |
-
//append javascript variable that checks if consent exists or not
|
810 |
-
$consent_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].consent_exist = true;";
|
811 |
-
//append additional consent parameters
|
812 |
-
$consent_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].consent.remember_consent = ".( $params["notrememberconsent"] != "true" ? "true" : "false" ).";";
|
813 |
-
$consent_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].consent.no_rejects_upload = ".( $params["consentrejectupload"] == "true" ? "true" : "false" ).";";
|
814 |
-
$consent_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].consent.consent_format = '".$params["consentformat"]."';";
|
815 |
-
$consent_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].consent.consent_question = '".preg_replace("/:(\w):/", "<a href=\"".$params["consentdisclaimer"]."\">$1</a>", $params["consentquestion"])."';";
|
816 |
-
|
817 |
-
return $consent_item;
|
818 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Plugin Upload Form Blocks
|
5 |
+
*
|
6 |
+
* This file contains functions related to preparation of the elements of the
|
7 |
+
* upload form of the plugin.
|
8 |
+
*
|
9 |
+
* @link /lib/wfu_blocks.php
|
10 |
+
*
|
11 |
+
* @package WordPress File Upload Plugin
|
12 |
+
* @subpackage Core Components
|
13 |
+
* @since 2.1.2
|
14 |
+
*/
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Prepare the Upload Form Generic Element.
|
18 |
+
*
|
19 |
+
* This function prepares the display properties of the generic top-level
|
20 |
+
* element of the plugin's upload form.
|
21 |
+
*
|
22 |
+
* @since 4.1.0
|
23 |
+
*
|
24 |
+
* @param array $params The uploader shortcode attributes.
|
25 |
+
* @param array $additional_params A list of additional parameters passed to the
|
26 |
+
* function.
|
27 |
+
* @param integer $occurrence_index The occurrence index of this element inside
|
28 |
+
* the upload form.
|
29 |
+
*
|
30 |
+
* @return array The display properties of the generic top-level element.
|
31 |
+
*/
|
32 |
+
function wfu_prepare_base_block($params, $additional_params, $occurrence_index) {
|
33 |
+
//prepare data for template
|
34 |
+
$data["ID"] = $params["uploadid"];
|
35 |
+
$data["responsive"] = ( $params["fitmode"] == "responsive" );
|
36 |
+
$data["testmode"] = ( $params["testmode"] == "true" );
|
37 |
+
$data["params"] = $params;
|
38 |
+
|
39 |
+
$base_item["title"] = '';
|
40 |
+
$base_item["hidden"] = false;
|
41 |
+
$base_item["width"] = "";
|
42 |
+
$base_item["object"] = "GlobalData.WFU[".$data["ID"]."].base";
|
43 |
+
//read html output from template
|
44 |
+
$base_item += wfu_read_template_output("base", $data);
|
45 |
+
|
46 |
+
return $base_item;
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Prepare the Upload Form Visual Editor Element.
|
51 |
+
*
|
52 |
+
* This function prepares the display properties of the visual editor element of
|
53 |
+
* the plugin's upload form.
|
54 |
+
*
|
55 |
+
* @since 4.0.0
|
56 |
+
*
|
57 |
+
* @param array $params The uploader shortcode attributes.
|
58 |
+
* @param array $additional_params A list of additional parameters passed to the
|
59 |
+
* function.
|
60 |
+
* @param integer $occurrence_index The occurrence index of this element inside
|
61 |
+
* the upload form.
|
62 |
+
*
|
63 |
+
* @return array The display properties of the visual editor element.
|
64 |
+
*/
|
65 |
+
function wfu_prepare_visualeditorbutton_block($params, $additional_params, $occurrence_index) {
|
66 |
+
if ( isset($params["uploadid"]) ) {
|
67 |
+
$ID = $params["uploadid"];
|
68 |
+
$JS_Object = "GlobalData.WFU[".$ID."].visualeditorbutton";
|
69 |
+
}
|
70 |
+
else {
|
71 |
+
$ID = $params["browserid"];
|
72 |
+
$JS_Object = "GlobalData.WFUB[".$ID."].visualeditorbutton";
|
73 |
+
}
|
74 |
+
//prepare data for template
|
75 |
+
$data["ID"] = $ID;
|
76 |
+
$data["shortcode_tag"] = $additional_params['shortcode_tag'];
|
77 |
+
$data["JS_Object"] = $JS_Object;
|
78 |
+
$data["params"] = $params;
|
79 |
+
|
80 |
+
$visualeditorbutton_item["title"] = '';
|
81 |
+
$visualeditorbutton_item["hidden"] = false;
|
82 |
+
$visualeditorbutton_item["width"] = "";
|
83 |
+
$visualeditorbutton_item["object"] = $JS_Object;
|
84 |
+
//read html output from template
|
85 |
+
$visualeditorbutton_item += wfu_read_template_output("visualeditorbutton", $data);
|
86 |
+
//initialize title object properties
|
87 |
+
$visualeditorbutton_item["js"] = $JS_Object." = { ".
|
88 |
+
"shortcode_tag: \"".$data["shortcode_tag"]."\", ".
|
89 |
+
"attachInvokeHandler: function(invoke_function) {}, ".
|
90 |
+
"onInvoke: function() {}, ".
|
91 |
+
"afterInvoke: function() {}".
|
92 |
+
"};\n\n".$visualeditorbutton_item["js"];
|
93 |
+
//append javascript variable that checks if title exists or not
|
94 |
+
$visualeditorbutton_item["js"] .= "\n\n".$JS_Object."_exist = true;";
|
95 |
+
|
96 |
+
return $visualeditorbutton_item;
|
97 |
+
}
|
98 |
+
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Prepare the Upload Form Subfolders Element.
|
102 |
+
*
|
103 |
+
* This function prepares the display properties of the subfolders element of
|
104 |
+
* the plugin's upload form.
|
105 |
+
*
|
106 |
+
* @since 2.1.2
|
107 |
+
*
|
108 |
+
* @param array $params The uploader shortcode attributes.
|
109 |
+
* @param array $additional_params A list of additional parameters passed to the
|
110 |
+
* function.
|
111 |
+
* @param integer $occurrence_index The occurrence index of this element inside
|
112 |
+
* the upload form.
|
113 |
+
*
|
114 |
+
* @return array The display properties of the subfolders element.
|
115 |
+
*/
|
116 |
+
function wfu_prepare_subfolders_block($params, $additional_params, $occurrence_index) {
|
117 |
+
//prepare data for template
|
118 |
+
$data["ID"] = $params["uploadid"];
|
119 |
+
$data["widths"] = $additional_params['widths'];
|
120 |
+
$data["heights"] = $additional_params['heights'];
|
121 |
+
$data["responsive"] = ( $params["fitmode"] == "responsive" );
|
122 |
+
$data["testmode"] = ( $params["testmode"] == "true" );
|
123 |
+
$data["show_uploadfolder"] = ( $params["showtargetfolder"] == "true" );
|
124 |
+
$data["show_subfolders"] = ( $params["askforsubfolders"] == "true" );
|
125 |
+
$data["editable"] = ( substr($params["subfoldertree"], 0, 5) == "auto+" );
|
126 |
+
$data["uploadfolder"] = wfu_upload_plugin_directory($params["uploadpath"]);
|
127 |
+
$data["uploadfolder_title"] = $params["targetfolderlabel"];
|
128 |
+
$data["subfolders"] = array( 'path' => array(), 'label' => array(), 'level' => array(), 'default' => array() );
|
129 |
+
$data["subfolders_title"] = $params["subfolderlabel"];
|
130 |
+
$data["index"] = $occurrence_index;
|
131 |
+
$data["params"] = $params;
|
132 |
+
//prepare data of subfolders
|
133 |
+
if ( $data["show_subfolders"] && !$data["testmode"] ) {
|
134 |
+
if ( substr($params["subfoldertree"], 0, 4) == "auto" ) {
|
135 |
+
$upload_directory = wfu_upload_plugin_full_path($params);
|
136 |
+
$dirtree = wfu_getTree($upload_directory);
|
137 |
+
foreach ( $dirtree as &$dir ) $dir = '*'.$dir;
|
138 |
+
$params["subfoldertree"] = implode(',', $dirtree);
|
139 |
+
}
|
140 |
+
$subfolders = wfu_parse_folderlist($params["subfoldertree"]);
|
141 |
+
if ( count($subfolders['path']) == 0 ) {
|
142 |
+
array_push($subfolders['path'], "");
|
143 |
+
array_push($subfolders['label'], wfu_upload_plugin_directory($params["uploadpath"]));
|
144 |
+
array_push($subfolders['level'], 0);
|
145 |
+
array_push($subfolders['default'], false);
|
146 |
+
}
|
147 |
+
$data["subfolders"] = $subfolders;
|
148 |
+
}
|
149 |
+
|
150 |
+
$subfolders_item = null;
|
151 |
+
if ( $data["show_uploadfolder"] || $data["show_subfolders"] ) {
|
152 |
+
$subfolders_item["title"] = 'wordpress_file_upload_subfolders_'.$data["ID"];
|
153 |
+
$subfolders_item["hidden"] = false;
|
154 |
+
$subfolders_item["width"] = "";
|
155 |
+
$subfolders_item["object"] = "GlobalData.WFU[".$data["ID"]."].subfolders";
|
156 |
+
//for responsive plugin adjust width
|
157 |
+
if ( $data["responsive"] ) $subfolders_item["width"] = $data["width"];
|
158 |
+
//read html output from template
|
159 |
+
$subfolders_item += wfu_read_template_output("subfolders", $data);
|
160 |
+
//initialize subfolders object properties
|
161 |
+
$subfolders_item["js"] = "GlobalData.WFU[".$data["ID"]."].subfolders = { ".
|
162 |
+
"update_handler: function(new_value) { document.getElementById('hiddeninput_".$data["ID"]."').value = new_value; }, ".
|
163 |
+
"check: function() { return true; }, ".
|
164 |
+
"index: function() { return -1; }, ".
|
165 |
+
"reset: function() {}, ".
|
166 |
+
"toggle: function(enabled) {}".
|
167 |
+
"};\n\n".$subfolders_item["js"];
|
168 |
+
//append javascript variable that checks if subfolders element exists or not
|
169 |
+
if ( $data["show_subfolders"] ) $subfolders_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].subfolders_exist = true;";
|
170 |
+
}
|
171 |
+
|
172 |
+
return $subfolders_item;
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Prepare the Upload Form Title Element.
|
177 |
+
*
|
178 |
+
* This function prepares the display properties of the title element of the
|
179 |
+
* plugin's upload form.
|
180 |
+
*
|
181 |
+
* @since 2.1.2
|
182 |
+
*
|
183 |
+
* @param array $params The uploader shortcode attributes.
|
184 |
+
* @param array $additional_params A list of additional parameters passed to the
|
185 |
+
* function.
|
186 |
+
* @param integer $occurrence_index The occurrence index of this element inside
|
187 |
+
* the upload form.
|
188 |
+
*
|
189 |
+
* @return array The display properties of the title element.
|
190 |
+
*/
|
191 |
+
function wfu_prepare_title_block($params, $additional_params, $occurrence_index) {
|
192 |
+
//prepare data for template
|
193 |
+
$data["ID"] = $params["uploadid"];
|
194 |
+
$data["width"] = $additional_params['widths']['title'];
|
195 |
+
$data["height"] = $additional_params['heights']['title'];
|
196 |
+
$data["responsive"] = ( $params["fitmode"] == "responsive" );
|
197 |
+
$data["testmode"] = ( $params["testmode"] == "true" );
|
198 |
+
$data["title"] = $params["uploadtitle"];
|
199 |
+
$data["index"] = $occurrence_index;
|
200 |
+
$data["params"] = $params;
|
201 |
+
|
202 |
+
$title_item["title"] = 'wordpress_file_upload_title_'.$data["ID"];
|
203 |
+
$title_item["hidden"] = false;
|
204 |
+
$title_item["width"] = "";
|
205 |
+
$title_item["object"] = "GlobalData.WFU[".$data["ID"]."].title";
|
206 |
+
//for responsive plugin adjust container and container's parent widths if a % width has been defined
|
207 |
+
if ( $data["responsive"] && strlen($data["width"]) > 1 && substr($data["width"], -1, 1) == "%" ) $title_item["width"] = $data["width"];
|
208 |
+
//read html output from template
|
209 |
+
$title_item += wfu_read_template_output("title", $data);
|
210 |
+
//initialize title object properties
|
211 |
+
$title_item["js"] = "GlobalData.WFU[".$data["ID"]."].title = {};\n\n".$title_item["js"];
|
212 |
+
//append javascript variable that checks if title exists or not
|
213 |
+
$title_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].title_exist = true;";
|
214 |
+
|
215 |
+
return $title_item;
|
216 |
+
}
|
217 |
+
|
218 |
+
/**
|
219 |
+
* Prepare the Upload Form Filename Element.
|
220 |
+
*
|
221 |
+
* This function prepares the display properties of the filename (textbox)
|
222 |
+
* element of the plugin's upload form.
|
223 |
+
*
|
224 |
+
* @since 2.1.2
|
225 |
+
*
|
226 |
+
* @param array $params The uploader shortcode attributes.
|
227 |
+
* @param array $additional_params A list of additional parameters passed to the
|
228 |
+
* function.
|
229 |
+
* @param integer $occurrence_index The occurrence index of this element inside
|
230 |
+
* the upload form.
|
231 |
+
*
|
232 |
+
* @return array The display properties of the filename element.
|
233 |
+
*/
|
234 |
+
function wfu_prepare_textbox_block($params, $additional_params, $occurrence_index) {
|
235 |
+
//prepare data for template
|
236 |
+
$data["ID"] = $params["uploadid"];
|
237 |
+
$data["width"] = $additional_params['widths']['filename'];
|
238 |
+
$data["height"] = $additional_params['heights']['filename'];
|
239 |
+
$data["responsive"] = ( $params["fitmode"] == "responsive" );
|
240 |
+
$data["testmode"] = ( $params["testmode"] == "true" );
|
241 |
+
$data["index"] = $occurrence_index;
|
242 |
+
$data["params"] = $params;
|
243 |
+
|
244 |
+
|
245 |
+
$textbox_item["title"] = 'wordpress_file_upload_textbox_'.$data["ID"];
|
246 |
+
$textbox_item["hidden"] = false;
|
247 |
+
$textbox_item["width"] = "";
|
248 |
+
$textbox_item["object"] = "GlobalData.WFU[".$data["ID"]."].textbox";
|
249 |
+
//for responsive plugin adjust container and container's parent widths if a % width has been defined
|
250 |
+
if ( $data["responsive"] && strlen($data["width"]) > 1 && substr($data["width"], -1, 1) == "%" ) $textbox_item["width"] = $data["width"];
|
251 |
+
//read html output from template
|
252 |
+
$textbox_item += wfu_read_template_output("textbox", $data);
|
253 |
+
//initialize textbox object properties
|
254 |
+
$textbox_item["js"] = "GlobalData.WFU[".$data["ID"]."].textbox = { ".
|
255 |
+
"attachCancelHandler: function(cancel_function) {}, ".
|
256 |
+
"dettachCancelHandler: function() {}, ".
|
257 |
+
"update: function(action, filenames) {} ".
|
258 |
+
"};\n\n".$textbox_item["js"];
|
259 |
+
//append javascript variable that checks if textbox exists or not
|
260 |
+
$textbox_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].textbox_exist = true;";
|
261 |
+
|
262 |
+
return $textbox_item;
|
263 |
+
}
|
264 |
+
|
265 |
+
/**
|
266 |
+
* Prepare the Upload Form Main Form Element.
|
267 |
+
*
|
268 |
+
* This function prepares the display properties of the form element of the
|
269 |
+
* plugin's upload form. This element also contains the select button element.
|
270 |
+
*
|
271 |
+
* @since 2.1.2
|
272 |
+
*
|
273 |
+
* @param array $params The uploader shortcode attributes.
|
274 |
+
* @param array $additional_params A list of additional parameters passed to the
|
275 |
+
* function.
|
276 |
+
* @param integer $occurrence_index The occurrence index of this element inside
|
277 |
+
* the upload form.
|
278 |
+
*
|
279 |
+
* @return array The display properties of the main form element.
|
280 |
+
*/
|
281 |
+
function wfu_prepare_uploadform_block($params, $additional_params, $occurrence_index) {
|
282 |
+
//prepare data for template
|
283 |
+
$data["ID"] = $params["uploadid"];
|
284 |
+
$data["width"] = $additional_params['widths']['selectbutton'];
|
285 |
+
$data["height"] = $additional_params['heights']['selectbutton'];
|
286 |
+
$data["responsive"] = ( $params["fitmode"] == "responsive" );
|
287 |
+
$data["testmode"] = ( $params["testmode"] == "true" );
|
288 |
+
$data["label"] = $params["selectbutton"];
|
289 |
+
$data["filename"] = "uploadedfile_".$data["ID"];
|
290 |
+
$data["hidden_elements"] = array(
|
291 |
+
array( "id" => "wfu_uploader_nonce_".$data["ID"], "name" => "wfu_uploader_nonce", "value" => wp_create_nonce("wfu-uploader-nonce") ),
|
292 |
+
array( "id" => "hiddeninput_".$data["ID"], "name" => "hiddeninput_".$data["ID"], "value" => "" ),
|
293 |
+
array( "id" => "uniqueuploadid_".$data["ID"], "name" => "uniqueuploadid_".$data["ID"], "value" => "" ),
|
294 |
+
array( "id" => "nofileupload_".$data["ID"], "name" => "nofileupload_".$data["ID"], "value" => "0" ),
|
295 |
+
array( "id" => "uploadedfile_".$data["ID"]."_name", "name" => "uploadedfile_".$data["ID"]."_name", "value" => wfu_plugin_encode_string("dummy.txt") ),
|
296 |
+
array( "id" => "uploadedfile_".$data["ID"]."_size", "name" => "uploadedfile_".$data["ID"]."_size", "value" => "0" ),
|
297 |
+
array( "id" => "adminerrorcodes_".$data["ID"], "name" => "adminerrorcodes_".$data["ID"], "value" => "" )
|
298 |
+
);
|
299 |
+
if ( $additional_params["require_consent"] ) array_push( $data["hidden_elements"],
|
300 |
+
array( "id" => "consentresult_".$data["ID"], "name" => "consentresult_".$data["ID"], "value" => "" )
|
301 |
+
);
|
302 |
+
foreach ($params["userdata_fields"] as $userdata_key => $userdata_field)
|
303 |
+
array_push($data["hidden_elements"], array( "id" => "hiddeninput_".$data["ID"]."_userdata_".$userdata_key, "name" => "hiddeninput_".$data["ID"]."_userdata_".$userdata_key, "value" => "" ));
|
304 |
+
$data["index"] = $occurrence_index;
|
305 |
+
$data["params"] = $params;
|
306 |
+
|
307 |
+
$uploadform_item["title"] = 'wordpress_file_upload_form_'.$data["ID"];
|
308 |
+
// selectbutton block is mandatory because it contains the upload form element, so in case it is not included in the placements
|
309 |
+
// attribute then we set its visibility to hidden
|
310 |
+
$uploadform_item["hidden"] = ( strpos($params["placements"], "selectbutton") === false );
|
311 |
+
$uploadform_item["width"] = "";
|
312 |
+
$uploadform_item["object"] = "GlobalData.WFU[".$data["ID"]."].uploadform";
|
313 |
+
//for responsive plugin adjust container and container's parent widths if a % width has been defined
|
314 |
+
if ( $data["responsive"] && strlen($data["width"]) > 1 && substr($data["width"], -1, 1) == "%" ) $uploadform_item["width"] = $data["width"];
|
315 |
+
|
316 |
+
//read html output from template
|
317 |
+
$uploadform_item += wfu_read_template_output("uploadform", $data);
|
318 |
+
//initialize uploadform object properties
|
319 |
+
$uploadform_item["js"] = "GlobalData.WFU[".$data["ID"]."].uploadform = { ".
|
320 |
+
"attachActions: function(clickaction, changeaction) {}, ".
|
321 |
+
"reset: function() {}, ".
|
322 |
+
"resetDummy: function() {}, ".
|
323 |
+
"submit: function() {}, ".
|
324 |
+
"lock: function() {}, ".
|
325 |
+
"unlock: function() {}, ".
|
326 |
+
"changeFileName: function(new_filename) {}, ".
|
327 |
+
"files: function() { return []; } ".
|
328 |
+
"};\n\n".$uploadform_item["js"];
|
329 |
+
//append javascript variable that checks if uploadform element exists or not
|
330 |
+
$uploadform_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].uploadform_exist = true;";
|
331 |
+
|
332 |
+
return $uploadform_item;
|
333 |
+
}
|
334 |
+
|
335 |
+
/**
|
336 |
+
* Prepare the Upload Form Submit Button Element.
|
337 |
+
*
|
338 |
+
* This function prepares the display properties of the submit button element of
|
339 |
+
* the plugin's upload form.
|
340 |
+
*
|
341 |
+
* @since 2.1.2
|
342 |
+
*
|
343 |
+
* @param array $params The uploader shortcode attributes.
|
344 |
+
* @param array $additional_params A list of additional parameters passed to the
|
345 |
+
* function.
|
346 |
+
* @param integer $occurrence_index The occurrence index of this element inside
|
347 |
+
* the upload form.
|
348 |
+
*
|
349 |
+
* @return array The display properties of the submit button element.
|
350 |
+
*/
|
351 |
+
function wfu_prepare_submit_block($params, $additional_params, $occurrence_index) {
|
352 |
+
//prepare data for template
|
353 |
+
$data["ID"] = $params["uploadid"];
|
354 |
+
$data["width"] = $additional_params['widths']['uploadbutton'];
|
355 |
+
$data["height"] = $additional_params['heights']['uploadbutton'];
|
356 |
+
$data["responsive"] = ( $params["fitmode"] == "responsive" );
|
357 |
+
$data["testmode"] = ( $params["testmode"] == "true" );
|
358 |
+
$data["allownofile"] = ( $params["allownofile"] == "true" );
|
359 |
+
$data["label"] = $params["uploadbutton"];
|
360 |
+
$data["index"] = $occurrence_index;
|
361 |
+
$data["params"] = $params;
|
362 |
+
|
363 |
+
$submit_item["title"] = 'wordpress_file_upload_submit_'.$data["ID"];
|
364 |
+
$submit_item["hidden"] = false;
|
365 |
+
$submit_item["width"] = "";
|
366 |
+
$submit_item["object"] = "GlobalData.WFU[".$data["ID"]."].submit";
|
367 |
+
//for responsive plugin adjust container and container's parent widths if a % width has been defined
|
368 |
+
if ( $data["responsive"] && strlen($data["width"]) > 1 && substr($data["width"], -1, 1) == "%" ) $submit_item["width"] = $data["width"];
|
369 |
+
|
370 |
+
//read html output from template
|
371 |
+
$submit_item += wfu_read_template_output("submit", $data);
|
372 |
+
//initialize submit element (upload button) object properties
|
373 |
+
$submit_item["js"] = "GlobalData.WFU[".$data["ID"]."].submit = { ".
|
374 |
+
"label_default: '".$data["label"]."', ".
|
375 |
+
"attachClickAction: function(clickaction) { }, ".
|
376 |
+
"updateLabel: function(new_label) { }, ".
|
377 |
+
"toggle: function(status) { } ".
|
378 |
+
"};\n\n".$submit_item["js"];
|
379 |
+
//append javascript variable that checks if upload button element exists
|
380 |
+
$submit_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].submit_exist = true;";
|
381 |
+
|
382 |
+
return $submit_item;
|
383 |
+
}
|
384 |
+
|
385 |
+
|
386 |
+
/**
|
387 |
+
* Prepare the Upload Form Webcam Element.
|
388 |
+
*
|
389 |
+
* This function prepares the display properties of the webcam element of the
|
390 |
+
* plugin's upload form.
|
391 |
+
*
|
392 |
+
* @since 3.8.0
|
393 |
+
*
|
394 |
+
* @param array $params The uploader shortcode attributes.
|
395 |
+
* @param array $additional_params A list of additional parameters passed to the
|
396 |
+
* function.
|
397 |
+
* @param integer $occurrence_index The occurrence index of this element inside
|
398 |
+
* the upload form.
|
399 |
+
*
|
400 |
+
* @return array The display properties of the webcam element.
|
401 |
+
*/
|
402 |
+
function wfu_prepare_webcam_block($params, $additional_params, $occurrence_index) {
|
403 |
+
//prepare data for template
|
404 |
+
$data["ID"] = $params["uploadid"];
|
405 |
+
$data["width"] = $additional_params['widths']['webcam'];
|
406 |
+
$data["height"] = $additional_params['heights']['webcam'];
|
407 |
+
$data["responsive"] = ( $params["fitmode"] == "responsive" );
|
408 |
+
$data["testmode"] = ( $params["testmode"] == "true" );
|
409 |
+
$data["index"] = $occurrence_index;
|
410 |
+
$data["params"] = $params;
|
411 |
+
|
412 |
+
$webcam_item["title"] = 'wordpress_file_upload_webcam_'.$data["ID"];
|
413 |
+
$webcam_item["hidden"] = false;
|
414 |
+
$webcam_item["width"] = "";
|
415 |
+
$webcam_item["object"] = "GlobalData.WFU[".$data["ID"]."].webcam";
|
416 |
+
|
417 |
+
$webcam_init = "\n".'var wfu_webrtc_ref = document.createElement("SCRIPT");';
|
418 |
+
$webcam_init .= "\n".'wfu_webrtc_ref.setAttribute("type", "text/javascript");';
|
419 |
+
$webcam_init .= "\n".'wfu_webrtc_ref.setAttribute("src", "https://webrtc.github.io/adapter/adapter-latest.js");';
|
420 |
+
$webcam_init .= "\n".'document.getElementById(GlobalData.WFU['.$data["ID"].'].container_id).appendChild(wfu_webrtc_ref);';
|
421 |
+
$webcam_init .= "\n".'var wfu_initialize_webcam_loader_'.$data["ID"].' = function() { wfu_initialize_webcam('.$data["ID"].', "'.$params["webcammode"].'", "'.$params["audiocapture"].'", "'.$params["videowidth"].'", "'.$params["videoheight"].'", "'.$params["videoaspectratio"].'", "'.$params["videoframerate"].'", "'.$params["camerafacing"].'", '.$params["maxrecordtime"].'); }';
|
422 |
+
$webcam_init .= "\n".'if(window.addEventListener) { window.addEventListener("load", wfu_initialize_webcam_loader_'.$data["ID"].', false); } else if(window.attachEvent) { window.attachEvent("onload", wfu_initialize_webcam_loader_'.$data["ID"].'); } else { window["onload"] = wfu_initialize_webcam_loader_'.$data["ID"].'; }';
|
423 |
+
|
424 |
+
//read html output from template
|
425 |
+
$webcam_item += wfu_read_template_output("webcam", $data);
|
426 |
+
//initialize captcha object properties
|
427 |
+
$webcam_item["js"] = "GlobalData.WFU[".$data["ID"]."].webcam = { ".
|
428 |
+
"initCallback: function() {},".
|
429 |
+
"initButtons: function(mode) {},".
|
430 |
+
"updateStatus: function(status) {},".
|
431 |
+
"updateButtonStatus: function(status) {},".
|
432 |
+
"updateTimer: function(time) {},".
|
433 |
+
"updatePlayProgress: function(duration) {},".
|
434 |
+
"setVideoProperties: function(props) {},".
|
435 |
+
"videoSize: function() { return null; },".
|
436 |
+
"readyState: function() { return -1; },".
|
437 |
+
"screenshot: function(savefunc, image_type) {},".
|
438 |
+
"play: function() {},".
|
439 |
+
"pause: function() {},".
|
440 |
+
"back: function() {},".
|
441 |
+
"fwd: function(duration) {},".
|
442 |
+
"ended: function() {}".
|
443 |
+
"};\n\n".$webcam_item["js"].$webcam_init;
|
444 |
+
//append javascript variable that checks if webcam element exists or not
|
445 |
+
$webcam_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].webcam_exist = true;";
|
446 |
+
|
447 |
+
return $webcam_item;
|
448 |
+
}
|
449 |
+
|
450 |
+
/**
|
451 |
+
* Prepare the Upload Form Progress Bar Element.
|
452 |
+
*
|
453 |
+
* This function prepares the display properties of the progress bar element of
|
454 |
+
* the plugin's upload form.
|
455 |
+
*
|
456 |
+
* @since 3.8.0
|
457 |
+
*
|
458 |
+
* @param array $params The uploader shortcode attributes.
|
459 |
+
* @param array $additional_params A list of additional parameters passed to the
|
460 |
+
* function.
|
461 |
+
* @param integer $occurrence_index The occurrence index of this element inside
|
462 |
+
* the upload form.
|
463 |
+
*
|
464 |
+
* @return array The display properties of the progress bar element.
|
465 |
+
*/
|
466 |
+
function wfu_prepare_progressbar_block($params, $additional_params, $occurrence_index) {
|
467 |
+
//prepare data for template
|
468 |
+
$data["ID"] = $params["uploadid"];
|
469 |
+
$data["width"] = $additional_params['widths']['progressbar'];
|
470 |
+
$data["height"] = $additional_params['heights']['progressbar'];
|
471 |
+
$data["responsive"] = ( $params["fitmode"] == "responsive" );
|
472 |
+
$data["testmode"] = ( $params["testmode"] == "true" );
|
473 |
+
$data["index"] = $occurrence_index;
|
474 |
+
$data["params"] = $params;
|
475 |
+
|
476 |
+
$progressbar_item["title"] = 'wordpress_file_upload_progressbar_'.$data["ID"];
|
477 |
+
$progressbar_item["hidden"] = ( $params["testmode"] != "true" );
|
478 |
+
$progressbar_item["width"] = "";
|
479 |
+
$progressbar_item["object"] = "GlobalData.WFU[".$data["ID"]."].progressbar";
|
480 |
+
//for responsive plugin adjust container's parent width if a % width has been defined
|
481 |
+
if ( $data["responsive"] && strlen($data["width"]) > 1 && substr($data["width"], -1, 1) == "%" ) $progressbar_item["width"] = $data["width"];
|
482 |
+
//read html output from template
|
483 |
+
$progressbar_item += wfu_read_template_output("progressbar", $data);
|
484 |
+
//initialize progressbar object properties
|
485 |
+
$progressbar_item["js"] = "GlobalData.WFU[".$data["ID"]."].progressbar = { ".
|
486 |
+
"show: function(mode) {}, ".
|
487 |
+
"hide: function() {}, ".
|
488 |
+
"update: function(progress) {} ".
|
489 |
+
"};\n\n".$progressbar_item["js"];
|
490 |
+
//append javascript variable that checks if progress bar exists or not
|
491 |
+
$progressbar_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].progressbar_exist = true;";
|
492 |
+
|
493 |
+
return $progressbar_item;
|
494 |
+
}
|
495 |
+
|
496 |
+
/**
|
497 |
+
* Prepare the Upload Form Message Element.
|
498 |
+
*
|
499 |
+
* This function prepares the display properties of the message element of the
|
500 |
+
* plugin's upload form.
|
501 |
+
*
|
502 |
+
* @since 2.1.2
|
503 |
+
*
|
504 |
+
* @param array $params The uploader shortcode attributes.
|
505 |
+
* @param array $additional_params A list of additional parameters passed to the
|
506 |
+
* function.
|
507 |
+
* @param integer $occurrence_index The occurrence index of this element inside
|
508 |
+
* the upload form.
|
509 |
+
*
|
510 |
+
* @return array The display properties of the message element.
|
511 |
+
*/
|
512 |
+
function wfu_prepare_message_block($params, $additional_params, $occurrence_index) {
|
513 |
+
//prepare data for template
|
514 |
+
$data["ID"] = $params["uploadid"];
|
515 |
+
$data["width"] = $additional_params['widths']['message'];
|
516 |
+
$data["height"] = $additional_params['heights']['message'];
|
517 |
+
$data["responsive"] = ( $params["fitmode"] == "responsive" );
|
518 |
+
$data["testmode"] = ( $params["testmode"] == "true" );
|
519 |
+
$data["index"] = $occurrence_index;
|
520 |
+
$data["params"] = $params;
|
521 |
+
|
522 |
+
$header_styles["State0"] = wfu_prepare_message_colors(WFU_VAR("WFU_HEADERMESSAGECOLORS_STATE0"));
|
523 |
+
$header_styles["State0"]['message'] = WFU_UPLOAD_STATE0;
|
524 |
+
$header_styles["State1"] = wfu_prepare_message_colors($params["warningmessagecolors"]);
|
525 |
+
$header_styles["State1"]['message'] = WFU_UPLOAD_STATE1;
|
526 |
+
$header_styles["State2"] = wfu_prepare_message_colors($params["warningmessagecolors"]);
|
527 |
+
$header_styles["State2"]['message'] = WFU_UPLOAD_STATE2;
|
528 |
+
$header_styles["State3"] = wfu_prepare_message_colors($params["warningmessagecolors"]);
|
529 |
+
$header_styles["State3"]['message'] = WFU_UPLOAD_STATE3;
|
530 |
+
$header_styles["State4"] = wfu_prepare_message_colors($params["successmessagecolors"]);
|
531 |
+
$header_styles["State4"]['message'] = WFU_UPLOAD_STATE4;
|
532 |
+
$header_styles["State5"] = wfu_prepare_message_colors($params["warningmessagecolors"]);
|
533 |
+
$header_styles["State5"]['message'] = WFU_UPLOAD_STATE5;
|
534 |
+
$header_styles["State5_singlefile"] = wfu_prepare_message_colors(WFU_VAR("WFU_HEADERMESSAGECOLORS_STATE5"));
|
535 |
+
$header_styles["State5_singlefile"]['message'] = WFU_UPLOAD_STATE5_SINGLEFILE;
|
536 |
+
$header_styles["State6"] = wfu_prepare_message_colors($params["warningmessagecolors"]);
|
537 |
+
$header_styles["State6"]['message'] = WFU_UPLOAD_STATE6;
|
538 |
+
$header_styles["State7"] = wfu_prepare_message_colors($params["failmessagecolors"]);
|
539 |
+
$header_styles["State7"]['message'] = WFU_UPLOAD_STATE7;
|
540 |
+
$header_styles["State7_singlefile"] = wfu_prepare_message_colors(WFU_VAR("WFU_HEADERMESSAGECOLORS_STATE7"));
|
541 |
+
$header_styles["State7_singlefile"]['message'] = WFU_UPLOAD_STATE7_SINGLEFILE;
|
542 |
+
$header_styles["State8"] = wfu_prepare_message_colors($params["failmessagecolors"]);
|
543 |
+
$header_styles["State8"]['message'] = WFU_UPLOAD_STATE8;
|
544 |
+
$header_styles["State9"] = wfu_prepare_message_colors(WFU_VAR("WFU_HEADERMESSAGECOLORS_STATE9"));
|
545 |
+
$header_styles["State9"]['message'] = WFU_UPLOAD_STATE9;
|
546 |
+
$header_styles["State10"] = wfu_prepare_message_colors($params["failmessagecolors"]);
|
547 |
+
$header_styles["State10"]['message'] = WFU_UPLOAD_STATE10;
|
548 |
+
$header_styles["State11"] = wfu_prepare_message_colors(WFU_VAR("WFU_HEADERMESSAGECOLORS_STATE11"));
|
549 |
+
$header_styles["State11"]['message'] = WFU_UPLOAD_STATE11;
|
550 |
+
$header_styles["State12"] = wfu_prepare_message_colors($params["failmessagecolors"]);
|
551 |
+
$header_styles["State12"]['message'] = WFU_UPLOAD_STATE12;
|
552 |
+
$header_styles["State13"] = wfu_prepare_message_colors(WFU_VAR("WFU_HEADERMESSAGECOLORS_STATE13"));
|
553 |
+
$header_styles["State13"]['message'] = WFU_UPLOAD_STATE13;
|
554 |
+
$header_styles["State14"] = wfu_prepare_message_colors($params["successmessagecolors"]);
|
555 |
+
$header_styles["State14"]['message'] = WFU_UPLOAD_STATE14;
|
556 |
+
$header_styles["State15"] = wfu_prepare_message_colors($params["failmessagecolors"]);
|
557 |
+
$header_styles["State15"]['message'] = WFU_UPLOAD_STATE15;
|
558 |
+
$header_styles["State16"] = wfu_prepare_message_colors(WFU_VAR("WFU_HEADERMESSAGECOLORS_STATE16"));
|
559 |
+
$header_styles["State16"]['message'] = WFU_UPLOAD_STATE16;
|
560 |
+
$header_styles["State17"] = wfu_prepare_message_colors($params["failmessagecolors"]);
|
561 |
+
$header_styles["State17"]['message'] = WFU_UPLOAD_STATE17;
|
562 |
+
$header_styles["State18"] = wfu_prepare_message_colors($params["successmessagecolors"]);
|
563 |
+
$header_styles["State18"]['message'] = WFU_UPLOAD_STATE18;
|
564 |
+
$header_styles["State19"] = wfu_prepare_message_colors($params["warningmessagecolors"]);
|
565 |
+
$header_styles["State19"]['message'] = WFU_UPLOAD_STATE19;
|
566 |
+
$data["header_styles"] = $header_styles;
|
567 |
+
|
568 |
+
$message_item["title"] = 'wordpress_file_upload_message_'.$data["ID"];
|
569 |
+
$message_item["hidden"] = false;
|
570 |
+
$message_item["width"] = "";
|
571 |
+
$message_item["object"] = "GlobalData.WFU[".$data["ID"]."].message";
|
572 |
+
//for responsive plugin adjust container and container's parent widths if a % width has been defined
|
573 |
+
if ( $data["responsive"] && strlen($data["width"]) > 1 && substr($data["width"], -1, 1) == "%" ) $message_item["width"] = $data["width"];
|
574 |
+
|
575 |
+
// $message_block = wfu_prepare_message_block_skeleton($sid, $styles, ( $params["testmode"] == "true" ));
|
576 |
+
// $message_item = $message_block["msgblock"];
|
577 |
+
|
578 |
+
$message_init = "\n".'if (!GlobalData.States) {';
|
579 |
+
$message_init .= "\n\t".'GlobalData.States = {};';
|
580 |
+
foreach ( $data["header_styles"] as $state => $statedata )
|
581 |
+
$message_init .= "\n\t\t".'GlobalData.States.'.$state.' = { color:"'.$statedata["color"].'", bgcolor:"'.$statedata["bgcolor"].'", borcolor:"'.$statedata["borcolor"].'", message:"'.$statedata["message"].'" };';
|
582 |
+
$message_init .= "\n\t".'GlobalData.Colors = {';
|
583 |
+
$message_init .= "\n\t\t".'default: "'.WFU_VAR("WFU_DEFAULTMESSAGECOLORS").'".split(","),';
|
584 |
+
$message_init .= "\n\t\t".'success: "'.$params['successmessagecolors'].'".split(","),';
|
585 |
+
$message_init .= "\n\t\t".'warning: "'.$params['warningmessagecolors'].'".split(","),';
|
586 |
+
$message_init .= "\n\t\t".'error: "'.$params['failmessagecolors'].'".split(",")';
|
587 |
+
$message_init .= "\n\t".'};';
|
588 |
+
$message_init .= "\n".'}';
|
589 |
+
|
590 |
+
//read html output from template
|
591 |
+
$message_item += wfu_read_template_output("message", $data);
|
592 |
+
//extract header_template and file_template
|
593 |
+
$header_template = "";
|
594 |
+
$header_template_line = "";
|
595 |
+
$in_header_template_block = false;
|
596 |
+
$file_template = "";
|
597 |
+
$file_template_line = "";
|
598 |
+
$in_file_template_block = false;
|
599 |
+
foreach ( $message_item as $key => $item ) {
|
600 |
+
if ( $in_header_template_block ) {
|
601 |
+
unset($message_item[$key]);
|
602 |
+
if ( $item != "</header_template><file_template>" ) $header_template .= $item."\n";
|
603 |
+
else {
|
604 |
+
$in_header_template_block = false;
|
605 |
+
$in_file_template_block = true;
|
606 |
+
}
|
607 |
+
}
|
608 |
+
elseif ( $in_file_template_block ) {
|
609 |
+
unset($message_item[$key]);
|
610 |
+
if ( $item != "</file_template>" ) $file_template .= $item."\n";
|
611 |
+
else $in_file_template_block = false;
|
612 |
+
}
|
613 |
+
elseif ( substr($key, 0, 4) == "line" ) {
|
614 |
+
if ( $item == "<header_template>" ) {
|
615 |
+
unset($message_item[$key]);
|
616 |
+
$in_header_template_block = true;
|
617 |
+
}
|
618 |
+
elseif ( strpos($item, "[header_template]") !== false ) $header_template_line = $key;
|
619 |
+
elseif ( strpos($item, "[file_template]") !== false ) $file_template_line = $key;
|
620 |
+
}
|
621 |
+
}
|
622 |
+
if ( $header_template_line != "" )
|
623 |
+
$message_item[$header_template_line] = str_replace("[header_template]", wfu_plugin_encode_string(trim($header_template)), $message_item[$header_template_line]);
|
624 |
+
if ( $file_template_line != "" )
|
625 |
+
$message_item[$file_template_line] = str_replace("[file_template]", wfu_plugin_encode_string(trim($file_template)), $message_item[$file_template_line]);
|
626 |
+
//initialize message object properties
|
627 |
+
$message_item["js"] = "GlobalData.WFU[".$data["ID"]."].message = { ".
|
628 |
+
"update: function(data) {},".
|
629 |
+
"reset: function() {}".
|
630 |
+
"};\n\n".$message_item["js"].$message_init;
|
631 |
+
//append javascript variable that checks if message block exists or not
|
632 |
+
$message_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].message_exist = true;";
|
633 |
+
|
634 |
+
return $message_item;
|
635 |
+
}
|
636 |
+
|
637 |
+
/**
|
638 |
+
* Prepare the Upload Form User Data Element.
|
639 |
+
*
|
640 |
+
* This function prepares the display properties of the user data element of the
|
641 |
+
* plugin's upload form.
|
642 |
+
*
|
643 |
+
* @since 2.1.2
|
644 |
+
*
|
645 |
+
* @param array $params The uploader shortcode attributes.
|
646 |
+
* @param array $additional_params A list of additional parameters passed to the
|
647 |
+
* function.
|
648 |
+
* @param integer $occurrence_index The occurrence index of this element inside
|
649 |
+
* the upload form.
|
650 |
+
*
|
651 |
+
* @return array The display properties of the user data element.
|
652 |
+
*/
|
653 |
+
function wfu_prepare_userdata_block($params, $additional_params, $occurrence_index) {
|
654 |
+
$data["ID"] = $params["uploadid"];
|
655 |
+
$data["width"] = $additional_params['widths']['userdata'];
|
656 |
+
$data["height"] = $additional_params['heights']['userdata'];
|
657 |
+
$data["width_label"] = $additional_params['widths']['userdata_label'];
|
658 |
+
$data["height_label"] = $additional_params['heights']['userdata_label'];
|
659 |
+
$data["width_value"] = $additional_params['widths']['userdata_value'];
|
660 |
+
$data["height_value"] = $additional_params['heights']['userdata_value'];
|
661 |
+
$data["responsive"] = ( $params["fitmode"] == "responsive" );
|
662 |
+
$data["testmode"] = ( $params["testmode"] == "true" );
|
663 |
+
$data["props"] = array();
|
664 |
+
$data["index"] = $occurrence_index;
|
665 |
+
$data["params"] = $params;
|
666 |
+
//fill $data["props"] variable with properties of existing userdata fields
|
667 |
+
foreach ($params["userdata_fields"] as $userdata_key => $userdata_field) {
|
668 |
+
//use only fields belonging to $occurrence_index
|
669 |
+
if ( $occurrence_index == 0 || $userdata_field["occurrence"] == $occurrence_index ) {
|
670 |
+
$props = $userdata_field;
|
671 |
+
$props["key"] = $userdata_key;
|
672 |
+
array_push($data["props"], $props);
|
673 |
+
}
|
674 |
+
}
|
675 |
+
|
676 |
+
$userdata_item["title"] = 'wordpress_file_upload_userdata_'.$data["ID"].( $occurrence_index == 0 ? "" : "_".($occurrence_index - 1) );
|
677 |
+
$userdata_item["hidden"] = false;
|
678 |
+
$userdata_item["width"] = "";
|
679 |
+
$userdata_item["object"] = "GlobalData.WFU[".$data["ID"]."].userdata";
|
680 |
+
//for responsive plugin adjust container and container's parent widths if a % width has been defined
|
681 |
+
if ( $data["responsive"] && strlen($data["width"]) > 1 && substr($data["width"], -1, 1) == "%" ) $userdata_item["width"] = $data["width"];
|
682 |
+
$userdata_item += wfu_read_template_output("userdata", $data);
|
683 |
+
//extract templates of field types
|
684 |
+
$templates_html = "";
|
685 |
+
foreach ( $userdata_item as $key => $item ) {
|
686 |
+
if ( substr($key, 0, 4) == "line" ) {
|
687 |
+
$templates_html .= ( $templates_html == "" ? "" : "\r\n" ).$item;
|
688 |
+
unset($userdata_item[$key]);
|
689 |
+
}
|
690 |
+
}
|
691 |
+
//subclass init() function of userdata object so that it fills WFU.userdata
|
692 |
+
//object with properties and code handlers of the userdata fields;
|
693 |
+
//the subclassed init() function is carefully written because userdata is a
|
694 |
+
//multiplacements component, so init() function will run more than once
|
695 |
+
//and every time it runs we need to make sure that only the elements
|
696 |
+
//corresponding to the specific $occurrence_index will be initialized
|
697 |
+
$init_index = ( $occurrence_index <= 1 ? 0 : $occurrence_index - 1 );
|
698 |
+
$userdata_init = "";
|
699 |
+
$userdata_init .= "\n".'GlobalData.WFU['.$data["ID"].'].userdata._init'.$init_index.' = GlobalData.WFU['.$data["ID"].'].userdata.init;';
|
700 |
+
$userdata_init .= "\n".'GlobalData.WFU['.$data["ID"].'].userdata.init = function() {';
|
701 |
+
$userdata_init .= "\n\t".'GlobalData.WFU['.$data["ID"].'].userdata._init'.$init_index.'();';
|
702 |
+
$userdata_init .= "\n\t".'var WFU = GlobalData.WFU['.$data["ID"].'];';
|
703 |
+
if ( $init_index == 0 ) {
|
704 |
+
$userdata_init .= "\n\t".'if (typeof WFU.userdata.init_count == "undefined") {';
|
705 |
+
$userdata_init .= "\n\t\t".'WFU.userdata.init_count = 0;';
|
706 |
+
$userdata_init .= "\n\t\t".'WFU.userdata.codes = [];';
|
707 |
+
$userdata_init .= "\n\t\t".'WFU.userdata.props = [];';
|
708 |
+
$userdata_init .= "\n\t".'}';
|
709 |
+
$userdata_init .= "\n\t".'else WFU.userdata.init_count ++;';
|
710 |
+
}
|
711 |
+
$userdata_init .= "\n\t".'if (WFU.userdata.init_count == '.$init_index.') {';
|
712 |
+
$i = 1;
|
713 |
+
foreach ($params["userdata_fields"] as $userdata_key => $userdata_field) {
|
714 |
+
//show only fields belonging to $occurrence_index
|
715 |
+
if ( $occurrence_index == 0 || $userdata_field["occurrence"] == $occurrence_index ) {
|
716 |
+
$userdata_field["key"] = $userdata_key;
|
717 |
+
//get field template
|
718 |
+
$template = "";
|
719 |
+
$matches = array();
|
720 |
+
preg_match("/<userdata_".$userdata_field["key"]."_template>(.*?)<\/userdata_".$userdata_field["key"]."_template>/s", $templates_html, $matches);
|
721 |
+
if ( isset($matches[1]) ) $template = $matches[1];
|
722 |
+
//generate html code
|
723 |
+
foreach ( explode("\r\n", $template) as $line ) $userdata_item["line".$i++] = $line;
|
724 |
+
//generate javascript code
|
725 |
+
$userdata_init .= "\n\t\t".'WFU.userdata.codes['.$userdata_field["key"].'] = {};';
|
726 |
+
$userdata_init .= "\n\t\t".'WFU.userdata.props['.$userdata_field["key"].'] = '.wfu_PHP_array_to_JS_object($userdata_field).';';
|
727 |
+
$userdata_init .= "\n\t\t".'WFU.userdata.props['.$userdata_field["key"].'].store = function() { document.getElementById("hiddeninput_'.$data["ID"].'_userdata_'.$userdata_field["key"].'").value = WFU.userdata.codes['.$userdata_field["key"].'].value(); };';
|
728 |
+
$userdata_init .= "\n\t\t".'WFU.userdata.props['.$userdata_field["key"].'].getstored = function() { return document.getElementById("hiddeninput_'.$data["ID"].'_userdata_'.$userdata_field["key"].'").value; };';
|
729 |
+
$userdata_init .= "\n\t\t".'wfu_init_userdata_handlers('.$data["ID"].', '.$userdata_field["key"].');';
|
730 |
+
}
|
731 |
+
}
|
732 |
+
$userdata_init .= "\n\t".'}';
|
733 |
+
$userdata_init .= "\n".'}';
|
734 |
+
//initialize userdata object properties only for the first $occurrence_index
|
735 |
+
if ( $init_index == 0 ) {
|
736 |
+
$userdata_item["js"] = "GlobalData.WFU[".$data["ID"]."].userdata = { ".
|
737 |
+
"initField: function(props) {}, ".
|
738 |
+
"attachHandlers: function(props, handlerfunc) {}, ".
|
739 |
+
"getValue: function(props) { return ''; }, ".
|
740 |
+
"setValue: function(props, value) {}, ".
|
741 |
+
"enable: function(props) {}, ".
|
742 |
+
"disable: function(props) {}, ".
|
743 |
+
"prompt: function(props, message) {}".
|
744 |
+
"};\n\n".$userdata_item["js"];
|
745 |
+
}
|
746 |
+
else $userdata_item["js"] = "";
|
747 |
+
$userdata_item["js"] .= $userdata_init;
|
748 |
+
//append javascript additional userdata variables only for the first
|
749 |
+
//$occurrence_index
|
750 |
+
if ( $init_index == 0 ) {
|
751 |
+
$userdata_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].userdata_exist = true;";
|
752 |
+
$userdata_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].userdata.error_empty = \"".WFU_ERROR_USERDATA_EMPTY."\";";
|
753 |
+
$userdata_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].userdata.error_invalid_number = \"".WFU_ERROR_USERDATANUMBER_INVALID."\";";
|
754 |
+
$userdata_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].userdata.error_invalid_email = \"".WFU_ERROR_USERDATAEMAIL_INVALID."\";";
|
755 |
+
$userdata_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].userdata.error_confirm_email_nomatch = \"".WFU_ERROR_USERDATACONFIRMEMAIL_NOMATCH."\";";
|
756 |
+
$userdata_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].userdata.error_confirm_email_nobase = \"".WFU_ERROR_USERDATACONFIRMEMAIL_NOBASE."\";";
|
757 |
+
$userdata_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].userdata.error_confirm_password_nomatch = \"".WFU_ERROR_USERDATACONFIRMPASSWORD_NOMATCH."\";";
|
758 |
+
$userdata_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].userdata.error_confirm_password_nobase = \"".WFU_ERROR_USERDATACONFIRMPASSWORD_NOBASE."\";";
|
759 |
+
$userdata_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].userdata.error_checkbox_notchecked = \"".WFU_ERROR_USERDATACHECKBOX_NOTCHECKED."\";";
|
760 |
+
$userdata_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].userdata.error_radio_notselected = \"".WFU_ERROR_USERDATARADIO_NOTSELECTED."\";";
|
761 |
+
}
|
762 |
+
|
763 |
+
return $userdata_item;
|
764 |
+
}
|
765 |
+
|
766 |
+
/**
|
767 |
+
* Prepare the Upload Form Consent Element.
|
768 |
+
*
|
769 |
+
* This function prepares the display properties of the consent element of the
|
770 |
+
* plugin's upload form.
|
771 |
+
*
|
772 |
+
* @since 4.5.0
|
773 |
+
*
|
774 |
+
* @param array $params The uploader shortcode attributes.
|
775 |
+
* @param array $additional_params A list of additional parameters passed to the
|
776 |
+
* function.
|
777 |
+
* @param integer $occurrence_index The occurrence index of this element inside
|
778 |
+
* the upload form.
|
779 |
+
*
|
780 |
+
* @return array The display properties of the consent element.
|
781 |
+
*/
|
782 |
+
function wfu_prepare_consent_block($params, $additional_params, $occurrence_index) {
|
783 |
+
//prepare data for template
|
784 |
+
$data["ID"] = $params["uploadid"];
|
785 |
+
$data["width"] = $additional_params['widths']['consent'];
|
786 |
+
$data["height"] = $additional_params['heights']['consent'];
|
787 |
+
$data["responsive"] = ( $params["fitmode"] == "responsive" );
|
788 |
+
$data["testmode"] = ( $params["testmode"] == "true" );
|
789 |
+
$data["index"] = $occurrence_index;
|
790 |
+
$data["format"] = $params["consentformat"];
|
791 |
+
$data["preselected"] = $params["consentpreselect"];
|
792 |
+
$data["question"] = preg_replace("/:(\w*):/", "<a href=\"".$params["consentdisclaimer"]."\">$1</a>", $params["consentquestion"]);
|
793 |
+
$data["params"] = $params;
|
794 |
+
|
795 |
+
$consent_item["title"] = 'wordpress_file_upload_consent_'.$data["ID"];
|
796 |
+
$consent_item["hidden"] = ( $params["consentformat"] == "prompt" );
|
797 |
+
$consent_item["width"] = "";
|
798 |
+
$consent_item["object"] = "GlobalData.WFU[".$data["ID"]."].consent";
|
799 |
+
//for responsive plugin adjust container and container's parent widths if a % width has been defined
|
800 |
+
if ( $data["responsive"] && strlen($data["width"]) > 1 && substr($data["width"], -1, 1) == "%" ) $consent_item["width"] = $data["width"];
|
801 |
+
//read html output from template
|
802 |
+
$consent_item += wfu_read_template_output("consent", $data);
|
803 |
+
//initialize consent object properties
|
804 |
+
$consent_item["js"] = "GlobalData.WFU[".$data["ID"]."].consent = { ".
|
805 |
+
"consentCompleted: function() { return false; }, ".
|
806 |
+
"attachActions: function(completeaction) {}, ".
|
807 |
+
"update: function(action) {} ".
|
808 |
+
"};\n\n".$consent_item["js"];
|
809 |
+
//append javascript variable that checks if consent exists or not
|
810 |
+
$consent_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].consent_exist = true;";
|
811 |
+
//append additional consent parameters
|
812 |
+
$consent_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].consent.remember_consent = ".( $params["notrememberconsent"] != "true" ? "true" : "false" ).";";
|
813 |
+
$consent_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].consent.no_rejects_upload = ".( $params["consentrejectupload"] == "true" ? "true" : "false" ).";";
|
814 |
+
$consent_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].consent.consent_format = '".$params["consentformat"]."';";
|
815 |
+
$consent_item["js"] .= "\n\nGlobalData.WFU[".$data["ID"]."].consent.consent_question = '".preg_replace("/:(\w):/", "<a href=\"".$params["consentdisclaimer"]."\">$1</a>", $params["consentquestion"])."';";
|
816 |
+
|
817 |
+
return $consent_item;
|
818 |
}
|
lib/wfu_constants.php
CHANGED
@@ -1,505 +1,522 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Constants and Strings of Plugin
|
5 |
-
*
|
6 |
-
* This file initializes all constants and translatable strings of the plugin.
|
7 |
-
*
|
8 |
-
* @link /lib/wfu_constants.php
|
9 |
-
*
|
10 |
-
* @package WordPress File Upload Plugin
|
11 |
-
* @subpackage Core Components
|
12 |
-
* @since 2.1.2
|
13 |
-
*/
|
14 |
-
|
15 |
-
$siteurl = site_url();
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Translatable Strings Initialization.
|
19 |
-
*
|
20 |
-
* This function initializes all translatable strings of the plugin.
|
21 |
-
*
|
22 |
-
* @since 4.7.0
|
23 |
-
*/
|
24 |
-
function wfu_initialize_i18n_strings() {
|
25 |
-
if ( defined("WFU_I18_LOADED") ) return;
|
26 |
-
DEFINE("WFU_I18_LOADED", 1);
|
27 |
-
//plugin default values
|
28 |
-
DEFINE("WFU_UPLOADTITLE", __('Upload files', 'wp-file-upload'));
|
29 |
-
DEFINE("WFU_SELECTBUTTON", __('Select File', 'wp-file-upload'));
|
30 |
-
DEFINE("WFU_UPLOADBUTTON", __('Upload File', 'wp-file-upload'));
|
31 |
-
DEFINE("WFU_NOTIFYSUBJECT", __('File Upload Notification', 'wp-file-upload'));
|
32 |
-
DEFINE("WFU_NOTIFYMESSAGE", __("Dear Recipient,%n%%n% This is an automatic delivery message to notify you that a new file has been uploaded.%n%%n%Best Regards", 'wp-file-upload'));
|
33 |
-
DEFINE("WFU_SUCCESSMESSAGE", __('File %filename% uploaded successfully', 'wp-file-upload'));
|
34 |
-
DEFINE("WFU_WARNINGMESSAGE", __('File %filename% uploaded successfully but with warnings', 'wp-file-upload'));
|
35 |
-
DEFINE("WFU_ERRORMESSAGE", __('File %filename% not uploaded', 'wp-file-upload'));
|
36 |
-
DEFINE("WFU_WAITMESSAGE", __('File %filename% is being uploaded', 'wp-file-upload'));
|
37 |
-
DEFINE("WFU_USERDATALABEL", __('Your message', 'wp-file-upload')."|t:text|s:left|r:0|a:0|p:inline|d:");
|
38 |
-
DEFINE("WFU_CAPTCHAPROMPT", __('Please fill in the above words: ', 'wp-file-upload'));
|
39 |
-
DEFINE("WFU_UPLOADMEDIABUTTON", __('Upload Media', 'wp-file-upload'));
|
40 |
-
DEFINE("WFU_VIDEONAME", __('videostream', 'wp-file-upload'));
|
41 |
-
DEFINE("WFU_IMAGENAME", __('screenshot', 'wp-file-upload'));
|
42 |
-
DEFINE("WFU_CONSENTQUESTION", __('By activating this option I agree to let the website keep my personal data', 'wp-file-upload'));
|
43 |
-
DEFINE("WFU_CONSENTREJECTMESSAGE", __('You have denied to let the website keep your personal data. Upload cannot continue!', 'wp-file-upload'));
|
44 |
-
DEFINE("WFU_CONSENTYES", __('Yes', 'wp-file-upload'));
|
45 |
-
DEFINE("WFU_CONSENTNO", __('No', 'wp-file-upload'));
|
46 |
-
//browser default values
|
47 |
-
DEFINE("WFU_FILETITLE", __('File', 'wp-file-upload'));
|
48 |
-
DEFINE("WFU_DATETITLE", __('Date', 'wp-file-upload'));
|
49 |
-
DEFINE("WFU_SIZETITLE", __('Size', 'wp-file-upload'));
|
50 |
-
DEFINE("WFU_USERTITLE", __('User', 'wp-file-upload'));
|
51 |
-
DEFINE("WFU_POSTTITLE", __('Page', 'wp-file-upload'));
|
52 |
-
DEFINE("WFU_FIELDSTITLE", __('User Fields', 'wp-file-upload'));
|
53 |
-
DEFINE("WFU_DOWNLOADLABEL", __('Download', 'wp-file-upload'));
|
54 |
-
DEFINE("WFU_DOWNLOADTITLE", __('Download this file', 'wp-file-upload'));
|
55 |
-
DEFINE("WFU_DELETELABEL", __('Delete', 'wp-file-upload'));
|
56 |
-
DEFINE("WFU_DELETETITLE", __('Delete this file', 'wp-file-upload'));
|
57 |
-
DEFINE("WFU_REMOVEREMOTELABEL", __('Remove Remote', 'wp-file-upload'));
|
58 |
-
DEFINE("WFU_REMOVEREMOTETITLE", __('Remove this remote file', 'wp-file-upload'));
|
59 |
-
DEFINE("WFU_SORTTITLE", __('Sort list based on this column', 'wp-file-upload'));
|
60 |
-
DEFINE("WFU_GUESTTITLE", __('guest', 'wp-file-upload'));
|
61 |
-
DEFINE("WFU_UNKNOWNTITLE", __('unknown', 'wp-file-upload'));
|
62 |
-
//error messages
|
63 |
-
DEFINE("WFU_ERROR_ADMIN_FTPDIR_RESOLVE", __("Error. Could not resolve ftp target filedir. Check the domain in 'ftpinfo' attribute.", "wp-file-upload"));
|
64 |
-
DEFINE("WFU_ERROR_ADMIN_FTPINFO_INVALID", __("Error. Invalid ftp information. Check 'ftpinfo' attribute.", "wp-file-upload"));
|
65 |
-
DEFINE("WFU_ERROR_ADMIN_FTPINFO_EXTRACT", __("Error. Could not extract ftp information from 'ftpinfo' attribute. Check its syntax.", "wp-file-upload"));
|
66 |
-
DEFINE("WFU_ERROR_ADMIN_FTPFILE_RESOLVE", __("Error. Could not resolve ftp target filename. Check the domain in 'ftpinfo' attribute.", "wp-file-upload"));
|
67 |
-
DEFINE("WFU_ERROR_ADMIN_FTPSOURCE_FAIL", __("Error. Could not open source file for ftp upload. Check if file is accessible.", "wp-file-upload"));
|
68 |
-
DEFINE("WFU_ERROR_ADMIN_FTPTRANSFER_FAIL", __("Error. Could not send data to ftp target file.", "wp-file-upload"));
|
69 |
-
DEFINE("WFU_ERROR_ADMIN_FTPHOST_FAIL", __("Error. Could not connect to ftp host. Check the domain in 'ftpinfo' attribute.", "wp-file-upload"));
|
70 |
-
DEFINE("WFU_ERROR_ADMIN_FTPLOGIN_FAIL", __("Error. Could not authenticate to ftp host. Check username and password in 'ftpinfo' attribute.", "wp-file-upload"));
|
71 |
-
DEFINE("WFU_ERROR_ADMIN_SFTPINIT_FAIL", __("Error. Could not initialize sftp subsystem. Please check if the server supports sftp.", "wp-file-upload"));
|
72 |
-
DEFINE("WFU_ERROR_ADMIN_SFTP_UNSUPPORTED", __("Error. The web server does not support sftp.", "wp-file-upload"));
|
73 |
-
DEFINE("WFU_ERROR_ADMIN_FILE_PHP_SIZE", __("Error. The upload size limit of PHP directive upload_max_filesize is preventing the upload of big files.\nPHP directive upload_max_filesize limit is: ".ini_get("upload_max_filesize").".\nTo increase the limit change the value of the directive from php.ini.\nIf you don't have access to php.ini, then try adding the following line to your .htaccess file:\n\nphp_value upload_max_filesize 10M\n\n(adjust the size according to your needs)\n\nThe file .htaccess is found in your website root directory (where index.php is found).\nIf your don't have this file, then create it.\nIf this does not work either, then contact your domain provider.", "wp-file-upload"));
|
74 |
-
DEFINE("WFU_ERROR_ADMIN_FILE_PHP_TIME", __("The upload time limit of PHP directive max_input_time is preventing the upload of big files.\nPHP directive max_input_time limit is: ".ini_get("max_input_time")." seconds.\nTo increase the limit change the value of the directive from php.ini.\nIf you don't have access to php.ini, then add the following line to your .htaccess file:\n\nphp_value max_input_time 500\n\n(adjust the time according to your needs)\n\nThe file .htaccess is found in your website root directory (where index.php is found).\nIf your don't have this file, then create it.\nIf this does not work either, then contact your domain provider.", "wp-file-upload"));
|
75 |
-
DEFINE("WFU_ERROR_ADMIN_DIR_PERMISSION", __("Error. Permission denied to write to target folder.\nCheck and correct read/write permissions of target folder.", "wp-file-upload"));
|
76 |
-
DEFINE("WFU_ERROR_ADMIN_FILE_WRONGEXT", __("Error. This file was rejected because its extension is not correct. Its proper filename is: ", "wp-file-upload"));
|
77 |
-
DEFINE("
|
78 |
-
DEFINE("
|
79 |
-
DEFINE("
|
80 |
-
DEFINE("
|
81 |
-
DEFINE("
|
82 |
-
DEFINE("
|
83 |
-
DEFINE("
|
84 |
-
DEFINE("
|
85 |
-
DEFINE("
|
86 |
-
DEFINE("
|
87 |
-
DEFINE("
|
88 |
-
DEFINE("
|
89 |
-
DEFINE("
|
90 |
-
DEFINE("
|
91 |
-
DEFINE("
|
92 |
-
DEFINE("
|
93 |
-
DEFINE("
|
94 |
-
DEFINE("
|
95 |
-
DEFINE("
|
96 |
-
DEFINE("
|
97 |
-
DEFINE("
|
98 |
-
DEFINE("
|
99 |
-
DEFINE("
|
100 |
-
DEFINE("
|
101 |
-
DEFINE("
|
102 |
-
DEFINE("
|
103 |
-
DEFINE("
|
104 |
-
DEFINE("
|
105 |
-
DEFINE("
|
106 |
-
DEFINE("
|
107 |
-
DEFINE("
|
108 |
-
DEFINE("
|
109 |
-
DEFINE("
|
110 |
-
DEFINE("
|
111 |
-
DEFINE("
|
112 |
-
DEFINE("
|
113 |
-
DEFINE("
|
114 |
-
DEFINE("
|
115 |
-
DEFINE("
|
116 |
-
DEFINE("
|
117 |
-
DEFINE("
|
118 |
-
DEFINE("
|
119 |
-
DEFINE("
|
120 |
-
DEFINE("
|
121 |
-
DEFINE("
|
122 |
-
DEFINE("
|
123 |
-
DEFINE("
|
124 |
-
DEFINE("
|
125 |
-
DEFINE("
|
126 |
-
DEFINE("
|
127 |
-
DEFINE("
|
128 |
-
DEFINE("
|
129 |
-
DEFINE("
|
130 |
-
DEFINE("
|
131 |
-
DEFINE("
|
132 |
-
DEFINE("
|
133 |
-
DEFINE("
|
134 |
-
DEFINE("
|
135 |
-
DEFINE("
|
136 |
-
DEFINE("
|
137 |
-
DEFINE("
|
138 |
-
DEFINE("
|
139 |
-
DEFINE("
|
140 |
-
DEFINE("
|
141 |
-
DEFINE("
|
142 |
-
DEFINE("
|
143 |
-
DEFINE("
|
144 |
-
DEFINE("
|
145 |
-
DEFINE("
|
146 |
-
DEFINE("
|
147 |
-
DEFINE("
|
148 |
-
DEFINE("
|
149 |
-
DEFINE("
|
150 |
-
DEFINE("
|
151 |
-
DEFINE("
|
152 |
-
DEFINE("
|
153 |
-
DEFINE("
|
154 |
-
DEFINE("
|
155 |
-
DEFINE("
|
156 |
-
DEFINE("
|
157 |
-
DEFINE("
|
158 |
-
|
159 |
-
|
160 |
-
DEFINE("
|
161 |
-
DEFINE("
|
162 |
-
DEFINE("
|
163 |
-
DEFINE("
|
164 |
-
DEFINE("
|
165 |
-
DEFINE("
|
166 |
-
DEFINE("
|
167 |
-
DEFINE("
|
168 |
-
DEFINE("
|
169 |
-
DEFINE("
|
170 |
-
DEFINE("
|
171 |
-
DEFINE("
|
172 |
-
DEFINE("
|
173 |
-
DEFINE("
|
174 |
-
|
175 |
-
|
176 |
-
DEFINE("
|
177 |
-
DEFINE("
|
178 |
-
DEFINE("
|
179 |
-
DEFINE("
|
180 |
-
DEFINE("
|
181 |
-
|
182 |
-
|
183 |
-
DEFINE("
|
184 |
-
DEFINE("
|
185 |
-
DEFINE("
|
186 |
-
DEFINE("
|
187 |
-
DEFINE("
|
188 |
-
DEFINE("
|
189 |
-
DEFINE("
|
190 |
-
|
191 |
-
|
192 |
-
DEFINE("
|
193 |
-
DEFINE("
|
194 |
-
DEFINE("
|
195 |
-
DEFINE("
|
196 |
-
DEFINE("
|
197 |
-
DEFINE("
|
198 |
-
DEFINE("
|
199 |
-
DEFINE("
|
200 |
-
DEFINE("
|
201 |
-
|
202 |
-
|
203 |
-
DEFINE("
|
204 |
-
DEFINE("
|
205 |
-
DEFINE("
|
206 |
-
DEFINE("
|
207 |
-
DEFINE("
|
208 |
-
DEFINE("
|
209 |
-
DEFINE("
|
210 |
-
DEFINE("
|
211 |
-
DEFINE("
|
212 |
-
DEFINE("
|
213 |
-
DEFINE("
|
214 |
-
DEFINE("
|
215 |
-
DEFINE("
|
216 |
-
DEFINE("
|
217 |
-
DEFINE("
|
218 |
-
DEFINE("
|
219 |
-
DEFINE("
|
220 |
-
DEFINE("
|
221 |
-
DEFINE("
|
222 |
-
DEFINE("
|
223 |
-
DEFINE("
|
224 |
-
DEFINE("
|
225 |
-
DEFINE("
|
226 |
-
DEFINE("
|
227 |
-
DEFINE("
|
228 |
-
DEFINE("
|
229 |
-
DEFINE("
|
230 |
-
DEFINE("
|
231 |
-
DEFINE("
|
232 |
-
DEFINE("
|
233 |
-
DEFINE("
|
234 |
-
DEFINE("
|
235 |
-
DEFINE("
|
236 |
-
DEFINE("
|
237 |
-
DEFINE("
|
238 |
-
DEFINE("
|
239 |
-
DEFINE("
|
240 |
-
DEFINE("
|
241 |
-
DEFINE("
|
242 |
-
DEFINE("
|
243 |
-
DEFINE("
|
244 |
-
DEFINE("
|
245 |
-
DEFINE("
|
246 |
-
DEFINE("
|
247 |
-
DEFINE("
|
248 |
-
DEFINE("
|
249 |
-
|
250 |
-
|
251 |
-
DEFINE("
|
252 |
-
DEFINE("
|
253 |
-
DEFINE("
|
254 |
-
DEFINE("
|
255 |
-
DEFINE("
|
256 |
-
DEFINE("
|
257 |
-
DEFINE("
|
258 |
-
DEFINE("
|
259 |
-
|
260 |
-
|
261 |
-
DEFINE("
|
262 |
-
DEFINE("
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
"
|
270 |
-
"
|
271 |
-
"
|
272 |
-
"
|
273 |
-
"
|
274 |
-
"WFU_ALLOWNOFILE" => array( "Default Allow No File Mode", "string", "false", "The default mode for allowing no file uploads. If it is set to 'true' then an upload form can be submitted even if a file has not been selected. It can be 'true' or 'false'." ),
|
275 |
-
"
|
276 |
-
"
|
277 |
-
"
|
278 |
-
"
|
279 |
-
"
|
280 |
-
"
|
281 |
-
"
|
282 |
-
"
|
283 |
-
"
|
284 |
-
"
|
285 |
-
"
|
286 |
-
"
|
287 |
-
"
|
288 |
-
"
|
289 |
-
"
|
290 |
-
"
|
291 |
-
"
|
292 |
-
"
|
293 |
-
"
|
294 |
-
"
|
295 |
-
"
|
296 |
-
"
|
297 |
-
"
|
298 |
-
"
|
299 |
-
"
|
300 |
-
"
|
301 |
-
"
|
302 |
-
"
|
303 |
-
"
|
304 |
-
"
|
305 |
-
"
|
306 |
-
"
|
307 |
-
"
|
308 |
-
"
|
309 |
-
"
|
310 |
-
"
|
311 |
-
"
|
312 |
-
"
|
313 |
-
"
|
314 |
-
"
|
315 |
-
"
|
316 |
-
"
|
317 |
-
"
|
318 |
-
"
|
319 |
-
"
|
320 |
-
"
|
321 |
-
"
|
322 |
-
"
|
323 |
-
"
|
324 |
-
"
|
325 |
-
"
|
326 |
-
"
|
327 |
-
)
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
"
|
332 |
-
"
|
333 |
-
"
|
334 |
-
"
|
335 |
-
"
|
336 |
-
"
|
337 |
-
"
|
338 |
-
"
|
339 |
-
"
|
340 |
-
"
|
341 |
-
"
|
342 |
-
"
|
343 |
-
"
|
344 |
-
"
|
345 |
-
"
|
346 |
-
"
|
347 |
-
"
|
348 |
-
"
|
349 |
-
"
|
350 |
-
"
|
351 |
-
"
|
352 |
-
"
|
353 |
-
"
|
354 |
-
"
|
355 |
-
"
|
356 |
-
"
|
357 |
-
"
|
358 |
-
"
|
359 |
-
"
|
360 |
-
"
|
361 |
-
"
|
362 |
-
"
|
363 |
-
"
|
364 |
-
"
|
365 |
-
"
|
366 |
-
"
|
367 |
-
"
|
368 |
-
"
|
369 |
-
"
|
370 |
-
"
|
371 |
-
"
|
372 |
-
"
|
373 |
-
"
|
374 |
-
"
|
375 |
-
"
|
376 |
-
"
|
377 |
-
"
|
378 |
-
"
|
379 |
-
"
|
380 |
-
"
|
381 |
-
"
|
382 |
-
"
|
383 |
-
"
|
384 |
-
)
|
385 |
-
|
386 |
-
|
387 |
-
"
|
388 |
-
"
|
389 |
-
"
|
390 |
-
"
|
391 |
-
"
|
392 |
-
"
|
393 |
-
"
|
394 |
-
"
|
395 |
-
"
|
396 |
-
"
|
397 |
-
"
|
398 |
-
"
|
399 |
-
"
|
400 |
-
"
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
"
|
405 |
-
"
|
406 |
-
"
|
407 |
-
"
|
408 |
-
"
|
409 |
-
)
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
DEFINE("
|
447 |
-
DEFINE("
|
448 |
-
DEFINE("
|
449 |
-
DEFINE("
|
450 |
-
DEFINE("
|
451 |
-
DEFINE("
|
452 |
-
DEFINE("
|
453 |
-
DEFINE("
|
454 |
-
|
455 |
-
DEFINE("
|
456 |
-
DEFINE("
|
457 |
-
DEFINE("
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
"
|
487 |
-
"
|
488 |
-
"
|
489 |
-
"
|
490 |
-
"
|
491 |
-
"
|
492 |
-
"
|
493 |
-
"
|
494 |
-
"
|
495 |
-
"
|
496 |
-
"
|
497 |
-
"
|
498 |
-
"
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
505 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Constants and Strings of Plugin
|
5 |
+
*
|
6 |
+
* This file initializes all constants and translatable strings of the plugin.
|
7 |
+
*
|
8 |
+
* @link /lib/wfu_constants.php
|
9 |
+
*
|
10 |
+
* @package WordPress File Upload Plugin
|
11 |
+
* @subpackage Core Components
|
12 |
+
* @since 2.1.2
|
13 |
+
*/
|
14 |
+
|
15 |
+
$siteurl = site_url();
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Translatable Strings Initialization.
|
19 |
+
*
|
20 |
+
* This function initializes all translatable strings of the plugin.
|
21 |
+
*
|
22 |
+
* @since 4.7.0
|
23 |
+
*/
|
24 |
+
function wfu_initialize_i18n_strings() {
|
25 |
+
if ( defined("WFU_I18_LOADED") ) return;
|
26 |
+
DEFINE("WFU_I18_LOADED", 1);
|
27 |
+
//plugin default values
|
28 |
+
DEFINE("WFU_UPLOADTITLE", __('Upload files', 'wp-file-upload'));
|
29 |
+
DEFINE("WFU_SELECTBUTTON", __('Select File', 'wp-file-upload'));
|
30 |
+
DEFINE("WFU_UPLOADBUTTON", __('Upload File', 'wp-file-upload'));
|
31 |
+
DEFINE("WFU_NOTIFYSUBJECT", __('File Upload Notification', 'wp-file-upload'));
|
32 |
+
DEFINE("WFU_NOTIFYMESSAGE", __("Dear Recipient,%n%%n% This is an automatic delivery message to notify you that a new file has been uploaded.%n%%n%Best Regards", 'wp-file-upload'));
|
33 |
+
DEFINE("WFU_SUCCESSMESSAGE", __('File %filename% uploaded successfully', 'wp-file-upload'));
|
34 |
+
DEFINE("WFU_WARNINGMESSAGE", __('File %filename% uploaded successfully but with warnings', 'wp-file-upload'));
|
35 |
+
DEFINE("WFU_ERRORMESSAGE", __('File %filename% not uploaded', 'wp-file-upload'));
|
36 |
+
DEFINE("WFU_WAITMESSAGE", __('File %filename% is being uploaded', 'wp-file-upload'));
|
37 |
+
DEFINE("WFU_USERDATALABEL", __('Your message', 'wp-file-upload')."|t:text|s:left|r:0|a:0|p:inline|d:");
|
38 |
+
DEFINE("WFU_CAPTCHAPROMPT", __('Please fill in the above words: ', 'wp-file-upload'));
|
39 |
+
DEFINE("WFU_UPLOADMEDIABUTTON", __('Upload Media', 'wp-file-upload'));
|
40 |
+
DEFINE("WFU_VIDEONAME", __('videostream', 'wp-file-upload'));
|
41 |
+
DEFINE("WFU_IMAGENAME", __('screenshot', 'wp-file-upload'));
|
42 |
+
DEFINE("WFU_CONSENTQUESTION", __('By activating this option I agree to let the website keep my personal data', 'wp-file-upload'));
|
43 |
+
DEFINE("WFU_CONSENTREJECTMESSAGE", __('You have denied to let the website keep your personal data. Upload cannot continue!', 'wp-file-upload'));
|
44 |
+
DEFINE("WFU_CONSENTYES", __('Yes', 'wp-file-upload'));
|
45 |
+
DEFINE("WFU_CONSENTNO", __('No', 'wp-file-upload'));
|
46 |
+
//browser default values
|
47 |
+
DEFINE("WFU_FILETITLE", __('File', 'wp-file-upload'));
|
48 |
+
DEFINE("WFU_DATETITLE", __('Date', 'wp-file-upload'));
|
49 |
+
DEFINE("WFU_SIZETITLE", __('Size', 'wp-file-upload'));
|
50 |
+
DEFINE("WFU_USERTITLE", __('User', 'wp-file-upload'));
|
51 |
+
DEFINE("WFU_POSTTITLE", __('Page', 'wp-file-upload'));
|
52 |
+
DEFINE("WFU_FIELDSTITLE", __('User Fields', 'wp-file-upload'));
|
53 |
+
DEFINE("WFU_DOWNLOADLABEL", __('Download', 'wp-file-upload'));
|
54 |
+
DEFINE("WFU_DOWNLOADTITLE", __('Download this file', 'wp-file-upload'));
|
55 |
+
DEFINE("WFU_DELETELABEL", __('Delete', 'wp-file-upload'));
|
56 |
+
DEFINE("WFU_DELETETITLE", __('Delete this file', 'wp-file-upload'));
|
57 |
+
DEFINE("WFU_REMOVEREMOTELABEL", __('Remove Remote', 'wp-file-upload'));
|
58 |
+
DEFINE("WFU_REMOVEREMOTETITLE", __('Remove this remote file', 'wp-file-upload'));
|
59 |
+
DEFINE("WFU_SORTTITLE", __('Sort list based on this column', 'wp-file-upload'));
|
60 |
+
DEFINE("WFU_GUESTTITLE", __('guest', 'wp-file-upload'));
|
61 |
+
DEFINE("WFU_UNKNOWNTITLE", __('unknown', 'wp-file-upload'));
|
62 |
+
//error messages
|
63 |
+
DEFINE("WFU_ERROR_ADMIN_FTPDIR_RESOLVE", __("Error. Could not resolve ftp target filedir. Check the domain in 'ftpinfo' attribute.", "wp-file-upload"));
|
64 |
+
DEFINE("WFU_ERROR_ADMIN_FTPINFO_INVALID", __("Error. Invalid ftp information. Check 'ftpinfo' attribute.", "wp-file-upload"));
|
65 |
+
DEFINE("WFU_ERROR_ADMIN_FTPINFO_EXTRACT", __("Error. Could not extract ftp information from 'ftpinfo' attribute. Check its syntax.", "wp-file-upload"));
|
66 |
+
DEFINE("WFU_ERROR_ADMIN_FTPFILE_RESOLVE", __("Error. Could not resolve ftp target filename. Check the domain in 'ftpinfo' attribute.", "wp-file-upload"));
|
67 |
+
DEFINE("WFU_ERROR_ADMIN_FTPSOURCE_FAIL", __("Error. Could not open source file for ftp upload. Check if file is accessible.", "wp-file-upload"));
|
68 |
+
DEFINE("WFU_ERROR_ADMIN_FTPTRANSFER_FAIL", __("Error. Could not send data to ftp target file.", "wp-file-upload"));
|
69 |
+
DEFINE("WFU_ERROR_ADMIN_FTPHOST_FAIL", __("Error. Could not connect to ftp host. Check the domain in 'ftpinfo' attribute.", "wp-file-upload"));
|
70 |
+
DEFINE("WFU_ERROR_ADMIN_FTPLOGIN_FAIL", __("Error. Could not authenticate to ftp host. Check username and password in 'ftpinfo' attribute.", "wp-file-upload"));
|
71 |
+
DEFINE("WFU_ERROR_ADMIN_SFTPINIT_FAIL", __("Error. Could not initialize sftp subsystem. Please check if the server supports sftp.", "wp-file-upload"));
|
72 |
+
DEFINE("WFU_ERROR_ADMIN_SFTP_UNSUPPORTED", __("Error. The web server does not support sftp.", "wp-file-upload"));
|
73 |
+
DEFINE("WFU_ERROR_ADMIN_FILE_PHP_SIZE", __("Error. The upload size limit of PHP directive upload_max_filesize is preventing the upload of big files.\nPHP directive upload_max_filesize limit is: ".ini_get("upload_max_filesize").".\nTo increase the limit change the value of the directive from php.ini.\nIf you don't have access to php.ini, then try adding the following line to your .htaccess file:\n\nphp_value upload_max_filesize 10M\n\n(adjust the size according to your needs)\n\nThe file .htaccess is found in your website root directory (where index.php is found).\nIf your don't have this file, then create it.\nIf this does not work either, then contact your domain provider.", "wp-file-upload"));
|
74 |
+
DEFINE("WFU_ERROR_ADMIN_FILE_PHP_TIME", __("The upload time limit of PHP directive max_input_time is preventing the upload of big files.\nPHP directive max_input_time limit is: ".ini_get("max_input_time")." seconds.\nTo increase the limit change the value of the directive from php.ini.\nIf you don't have access to php.ini, then add the following line to your .htaccess file:\n\nphp_value max_input_time 500\n\n(adjust the time according to your needs)\n\nThe file .htaccess is found in your website root directory (where index.php is found).\nIf your don't have this file, then create it.\nIf this does not work either, then contact your domain provider.", "wp-file-upload"));
|
75 |
+
DEFINE("WFU_ERROR_ADMIN_DIR_PERMISSION", __("Error. Permission denied to write to target folder.\nCheck and correct read/write permissions of target folder.", "wp-file-upload"));
|
76 |
+
DEFINE("WFU_ERROR_ADMIN_FILE_WRONGEXT", __("Error. This file was rejected because its extension is not correct. Its proper filename is: ", "wp-file-upload"));
|
77 |
+
DEFINE("WFU_ERROR_ADMIN_FILE_NOIMAGE", __("Error. This file was rejected because its not a valid image.", "wp-file-upload"));
|
78 |
+
DEFINE("WFU_ERROR_ADMIN_DOS_ATTACK", __("Too many files are uploaded in a short period of time. This may be a Denial-Of-Service attack, so file was rejected. Please check the upload log for suspicious behaviour.", "wp-file-upload"));
|
79 |
+
DEFINE("WFU_ERROR_DOS_ATTACK", __("File not uploaded in order to prevent overflow of the website. Please contact administrator.", "wp-file-upload"));
|
80 |
+
DEFINE("WFU_ERROR_DIR_EXIST", __("Target folder doesn't exist.", "wp-file-upload"));
|
81 |
+
DEFINE("WFU_ERROR_DIR_NOTEMP", __("Upload failed! Missing a temporary folder.", "wp-file-upload"));
|
82 |
+
DEFINE("WFU_ERROR_DIR_PERMISSION", __("Upload failed! Permission denied to write to target folder.", "wp-file-upload"));
|
83 |
+
DEFINE("WFU_ERROR_FILE_ALLOW", __("File not allowed.", "wp-file-upload"));
|
84 |
+
DEFINE("WFU_ERROR_FILE_REJECT", __("File is suspicious and was rejected.", "wp-file-upload"));
|
85 |
+
DEFINE("WFU_ERROR_FILE_PLUGIN_SIZE", __("The uploaded file exceeds the file size limit.", "wp-file-upload"));
|
86 |
+
DEFINE("WFU_ERROR_FILE_PLUGIN_2GBSIZE", __("The uploaded file exceeds 2GB and is not supported by this server.", "wp-file-upload"));
|
87 |
+
DEFINE("WFU_ERROR_FILE_PHP_SIZE", __("Upload failed! The uploaded file exceeds the file size limit of the server. Please contact the administrator.", "wp-file-upload"));
|
88 |
+
DEFINE("WFU_ERROR_FILE_PHP_TIME", __("Upload failed! The duration of the upload exceeded the time limit of the server. Please contact the administrator.", "wp-file-upload"));
|
89 |
+
DEFINE("WFU_ERROR_FILE_HTML_SIZE", __("Upload failed! The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.", "wp-file-upload"));
|
90 |
+
DEFINE("WFU_ERROR_FILE_PARTIAL", __("Upload failed! The uploaded file was only partially uploaded.", "wp-file-upload"));
|
91 |
+
DEFINE("WFU_ERROR_FILE_NOTHING", __("Upload failed! No file was uploaded.", "wp-file-upload"));
|
92 |
+
DEFINE("WFU_ERROR_FILE_WRITE", __("Upload failed! Failed to write file to disk.", "wp-file-upload"));
|
93 |
+
DEFINE("WFU_ERROR_FILE_MOVE", __("Upload failed! Error occured while moving temporary file. Please contact administrator.", "wp-file-upload"));
|
94 |
+
DEFINE("WFU_ERROR_FILE_CANCELLED", __("Upload cancelled!", "wp-file-upload"));
|
95 |
+
DEFINE("WFU_ERROR_UPLOAD_STOPPED", __("Upload failed! A PHP extension stopped the file upload. PHP does not provide a way to ascertain which extension caused the file upload to stop; examining the list of loaded extensions with phpinfo() may help.", "wp-file-upload"));
|
96 |
+
DEFINE("WFU_ERROR_UPLOAD_FAILED_WHILE", __("Upload failed! Error occured while attemting to upload the file.", "wp-file-upload"));
|
97 |
+
DEFINE("WFU_ERROR_UPLOAD_FAILED", __("Upload failed!", "wp-file-upload"));
|
98 |
+
DEFINE("WFU_ERROR_UPLOAD_NOFILESELECTED", __("No file!", "wp-file-upload"));
|
99 |
+
DEFINE("WFU_ERROR_UPLOAD_CANCELLED", __("Upload failed! The upload has been canceled by the user or the browser dropped the connection.", "wp-file-upload"));
|
100 |
+
DEFINE("WFU_ERROR_UNKNOWN", __("Upload failed! Unknown error.", "wp-file-upload"));
|
101 |
+
DEFINE("WFU_ERROR_CONTACT_ADMIN", __("Please contact the administrator.", "wp-file-upload"));
|
102 |
+
DEFINE("WFU_ERROR_REMOTESERVER_NORESULT", __("No result from remote server!", "wp-file-upload"));
|
103 |
+
DEFINE("WFU_ERROR_JSONPARSE_FILEMESSAGE", __(" but with warnings", "wp-file-upload"));
|
104 |
+
DEFINE("WFU_ERROR_JSONPARSE_MESSAGE", __("Warning: JSON parse error.", "wp-file-upload"));
|
105 |
+
DEFINE("WFU_ERROR_JSONPARSE_ADMINMESSAGE", __("Upload parameters of this file, passed as JSON string to the handler, could not be parsed.", "wp-file-upload"));
|
106 |
+
DEFINE("WFU_ERROR_JSONPARSE_HEADERMESSAGE", __("Warning: JSON parse error.", "wp-file-upload"));
|
107 |
+
DEFINE("WFU_ERROR_JSONPARSE_HEADERADMINMESSAGE", __("UploadStates, passed as JSON string to the handler, could not be parsed.", "wp-file-upload"));
|
108 |
+
DEFINE("WFU_ERROR_REDIRECTION_ERRORCODE0", __("Redirection to classic form functionality occurred due to unknown error.", "wp-file-upload"));
|
109 |
+
DEFINE("WFU_ERROR_REDIRECTION_ERRORCODE1", __("Redirection to classic form functionality occurred because AJAX is not supported.", "wp-file-upload"));
|
110 |
+
DEFINE("WFU_ERROR_REDIRECTION_ERRORCODE2", __("Redirection to classic form functionality occurred because HTML5 is not supported.", "wp-file-upload"));
|
111 |
+
DEFINE("WFU_ERROR_REDIRECTION_ERRORCODE3", __("Redirection to classic form functionality occurred due to JSON parse error.", "wp-file-upload"));
|
112 |
+
DEFINE("WFU_ERROR_ENABLE_POPUPS", __("Please enable popup windows from the browser's settings!", "wp-file-upload"));
|
113 |
+
DEFINE("WFU_ERROR_USERDATA_EMPTY", __("cannot be empty!", "wp-file-upload"));
|
114 |
+
DEFINE("WFU_ERROR_USERDATANUMBER_INVALID", __("number not valid!", "wp-file-upload"));
|
115 |
+
DEFINE("WFU_ERROR_USERDATAEMAIL_INVALID", __("email not valid!", "wp-file-upload"));
|
116 |
+
DEFINE("WFU_ERROR_USERDATACONFIRMEMAIL_NOMATCH", __("emails do not match!", "wp-file-upload"));
|
117 |
+
DEFINE("WFU_ERROR_USERDATACONFIRMEMAIL_NOBASE", __("no base email field in group!", "wp-file-upload"));
|
118 |
+
DEFINE("WFU_ERROR_USERDATACONFIRMPASSWORD_NOMATCH", __("passwords do not match!", "wp-file-upload"));
|
119 |
+
DEFINE("WFU_ERROR_USERDATACONFIRMPASSWORD_NOBASE", __("no base password field in group!", "wp-file-upload"));
|
120 |
+
DEFINE("WFU_ERROR_USERDATACHECKBOX_NOTCHECKED", __("checkbox unchecked!", "wp-file-upload"));
|
121 |
+
DEFINE("WFU_ERROR_USERDATARADIO_NOTSELECTED", __("no option selected!", "wp-file-upload"));
|
122 |
+
DEFINE("WFU_ERROR_USERDATALIST_NOITEMSELECTED", __("no item selected!", "wp-file-upload"));
|
123 |
+
DEFINE("WFU_ERROR_SAME_PLUGINID", __("There are more than one instances of the plugin in this page with the same id. Please change it.", "wp-file-upload"));
|
124 |
+
DEFINE("WFU_ERROR_PAGE_OBSOLETE", __("Cannot edit the shortcode because the page has been modified. Please reload the page.", "wp-file-upload"));
|
125 |
+
DEFINE("WFU_ERROR_WEBCAM_NOTSUPPORTED", __("Your browser does not support webcam capture!", "wp-file-upload"));
|
126 |
+
DEFINE("WFU_ERROR_WEBCAM_VIDEO_NOTSUPPORTED", __("Your browser does not support video recording from the webcam!", "wp-file-upload"));
|
127 |
+
DEFINE("WFU_ERROR_WEBCAM_VIDEO_NOTHINGRECORDED", __("No video was recorded!", "wp-file-upload"));
|
128 |
+
DEFINE("WFU_ERROR_CAPTCHA_OLDPHP", __("ERROR: Captcha not supported! You have an old PHP version. Upgrade your PHP or use RecaptchaV2 (no account).", "wp-file-upload"));
|
129 |
+
DEFINE("WFU_ERROR_CAPTCHA_MULTIPLE_NOTALLOWED", __("ERROR: Only one instance of RecaptchaV1 can exist on the same page. Please notify administrator.", "wp-file-upload"));
|
130 |
+
DEFINE("WFU_ERROR_CAPTCHA_MULTIPLE_NOTALLOWED_ADMIN", __("ERROR: Only one instance of RecaptchaV1 can exist on the same page. Please use RecaptchaV1 (no account).", "wp-file-upload"));
|
131 |
+
DEFINE("WFU_ERROR_CAPTCHA_NOSITEKEY", __("ERROR: No site key. Please contact administrator!", "wp-file-upload"));
|
132 |
+
DEFINE("WFU_ERROR_CAPTCHA_NOSITEKEY_ADMIN", __("ERROR: No site key defined! Please go to the plugin settings in Dashboard to define Google Recaptcha keys.", "wp-file-upload"));
|
133 |
+
DEFINE("WFU_ERROR_CAPTCHA_NOCHALLENGE", __("Bad captcha image!", "wp-file-upload"));
|
134 |
+
DEFINE("WFU_ERROR_CAPTCHA_NOINPUT", __("No input!", "wp-file-upload"));
|
135 |
+
DEFINE("WFU_ERROR_CAPTCHA_EMPTY", __("Captcha not completed!", "wp-file-upload"));
|
136 |
+
DEFINE("WFU_ERROR_CAPTCHA_WRONGCAPTCHA", __("Wrong captcha!", "wp-file-upload"));
|
137 |
+
DEFINE("WFU_ERROR_CAPTCHA_REFRESHING", __("Error refreshing captcha!", "wp-file-upload"));
|
138 |
+
DEFINE("WFU_ERROR_CAPTCHA_UNKNOWNERROR", __("Unknown captcha error!", "wp-file-upload"));
|
139 |
+
DEFINE("WFU_ERROR_CAPTCHA_NOTSUPPORTED", __("Captcha not supported by your browser!", "wp-file-upload"));
|
140 |
+
DEFINE("WFU_ERROR_CAPTCHA_MISSINGINPUTSECRET", __("the secret parameter is missing", "wp-file-upload"));
|
141 |
+
DEFINE("WFU_ERROR_CAPTCHA_INVALIDINPUTSECRET", __("the secret parameter is invalid or malformed", "wp-file-upload"));
|
142 |
+
DEFINE("WFU_ERROR_CAPTCHA_MISSINGINPUTRESPONSE", __("the response parameter is missing", "wp-file-upload"));
|
143 |
+
DEFINE("WFU_ERROR_CAPTCHA_INVALIDINPUTRESPONSE", __("the response parameter is invalid or malformed", "wp-file-upload"));
|
144 |
+
DEFINE("WFU_ERROR_REDIRECTION_NODRAGDROP", __("Please do not use drag drop due to an internal problem.", "wp-file-upload"));
|
145 |
+
DEFINE("WFU_ERROR_CHUNKEDUPLOAD_UNIQUEIDEMPTY", __("Error during chunked upload. Unique ID empty in chunk %d", "wp-file-upload"));
|
146 |
+
DEFINE("WFU_ERROR_CHUNKEDUPLOAD_NOTALLOWED", __("Chunked upload is not allowed!", "wp-file-upload"));
|
147 |
+
DEFINE("WFU_ERROR_CHUNKEDUPLOAD_ABORTED", __("Chunked upload aborted due to error in previous chunk!", "wp-file-upload"));
|
148 |
+
DEFINE("WFU_ERROR_CHUNKEDUPLOAD_CONCATFAILED", __("Chunked upload failed, final file could not be created!", "wp-file-upload"));
|
149 |
+
DEFINE("WFU_ERROR_ADMIN_CHUNKWRITEFAILED", __("Could not write file chuck to destination on chunk %d", "wp-file-upload"));
|
150 |
+
DEFINE("WFU_ERROR_ADMIN_CHUNKENLARGEFAILED", __("Could not enlarge destination file on chunk %d", "wp-file-upload"));
|
151 |
+
DEFINE("WFU_ERROR_ADMIN_CHUNKHANDLEFAILED", __("Could not open file handles on chunk %d", "wp-file-upload"));
|
152 |
+
DEFINE("WFU_BROWSER_DOWNLOADFILE_NOTALLOWED", __("You are not allowed to download this file!", "wp-file-upload"));
|
153 |
+
DEFINE("WFU_BROWSER_DOWNLOADFILE_NOTEXIST", __("File does not exist!", "wp-file-upload"));
|
154 |
+
DEFINE("WFU_BROWSER_DOWNLOADFILE_FAILED", __("Could not download file!", "wp-file-upload"));
|
155 |
+
DEFINE("WFU_BROWSER_DELETEFILE_NOTALLOWED", __("You are not allowed to delete this file!", "wp-file-upload"));
|
156 |
+
DEFINE("WFU_BROWSER_DELETEFILE_FAILED", __("File was not deleted!", "wp-file-upload"));
|
157 |
+
DEFINE("WFU_BROWSER_DELETEFILES_ALLFAILED", __("No file was deleted!", "wp-file-upload"));
|
158 |
+
DEFINE("WFU_BROWSER_DELETEFILES_SOMEFAILED", __("Some files were not deleted!", "wp-file-upload"));
|
159 |
+
//warning messages
|
160 |
+
DEFINE("WFU_WARNING_FILE_EXISTS", __("Upload skipped! File already exists.", "wp-file-upload"));
|
161 |
+
DEFINE("WFU_WARNING_FILE_SUSPICIOUS", __("The extension of the file does not match its contents.", "wp-file-upload"));
|
162 |
+
DEFINE("WFU_WARNING_ADMIN_FILE_SUSPICIOUS", __("Upload succeeded but the file is suspicious because its contents do not match its extension. Its proper filename is: ", "wp-file-upload"));
|
163 |
+
DEFINE("WFU_WARNING_NOFILES_SELECTED", __("No files have been selected!", "wp-file-upload"));
|
164 |
+
DEFINE("WFU_WARNING_CONSENT_NOTCOMPLETED", __("Please complete the consent question before continuing the upload!", "wp-file-upload"));
|
165 |
+
DEFINE("WFU_WARNING_WPFILEBASE_NOTUPDATED_NOFILES", __("WPFilebase Plugin not updated because there were no files uploaded.", "wp-file-upload"));
|
166 |
+
DEFINE("WFU_WARNING_NOTIFY_NOTSENT_NOFILES", __("Notification email was not sent because there were no files uploaded.", "wp-file-upload"));
|
167 |
+
DEFINE("WFU_WARNING_NOTIFY_NOTSENT_NORECIPIENTS", __("Notification email was not sent because no recipients were defined. Please check notifyrecipients attribute in the shortcode.", "wp-file-upload"));
|
168 |
+
DEFINE("WFU_WARNING_NOTIFY_NOTSENT_UNKNOWNERROR", __("Notification email was not sent due to an error. Please check notifyrecipients, notifysubject and notifymessage attributes for errors.", "wp-file-upload"));
|
169 |
+
DEFINE("WFU_WARNING_REDIRECT_NOTEXECUTED_EMPTY", __("Redirection not executed because redirection link is empty. Please check redirectlink attribute.", "wp-file-upload"));
|
170 |
+
DEFINE("WFU_WARNING_REDIRECT_NOTEXECUTED_FILESFAILED", __("Redirection not executed because not all files were successfully uploaded.", "wp-file-upload"));
|
171 |
+
DEFINE("WFU_WARNING_POTENTIAL_DOS_EMAIL_SUBJECT", __("Potential Denial-Of-Service Attack on {SITE}", "wp-file-upload"));
|
172 |
+
DEFINE("WFU_WARNING_POTENTIAL_DOS_EMAIL_MESSAGE", __("Hello admin\n\nThis is a message from Wordpress File Upload Plugin to notify you that a potential Denial-Of-Service attack has been detected on {SITE}.\n\nThe plugin detected more than {FILENUM} uploads within {INTERVAL} seconds.\n\nAll file uploads that exceed this limit are rejected to protect the website from overflowing.\n\nPlease check the upload history log in the plugin's area in Dashboard for any suspicious behaviour.\n\nA new message will follow if the situation remains.\n\nThanks", "wp-file-upload"));
|
173 |
+
DEFINE("WFU_WARNING_ALT_IPTANUS_SERVER_ACTIVATED", __("You have activated an alternative insecure Iptanus Services Server. For details please contact info@iptanus.com.", "wp-file-upload"));
|
174 |
+
DEFINE("WFU_WARNING_IPTANUS_SERVER_UNREACHABLE", __("Iptanus Services Server is unreachable. This may cause problems on some plugin functions. Please read this :article: for resolution.", "wp-file-upload"));
|
175 |
+
//admin area messages
|
176 |
+
DEFINE("WFU_DASHBOARD_ADD_SHORTCODE_REJECTED", __("Failed to add the shortcode to the page/post. Please try again. If the message persists, contact administrator.", "wp-file-upload"));
|
177 |
+
DEFINE("WFU_DASHBOARD_EDIT_SHORTCODE_REJECTED", __("Failed to edit the shortcode because the contents of the page changed. Try again to edit the shortcode.", "wp-file-upload"));
|
178 |
+
DEFINE("WFU_DASHBOARD_DELETE_SHORTCODE_REJECTED", __("Failed to delete the shortcode because the contents of the page changed. Try again to delete it.", "wp-file-upload"));
|
179 |
+
DEFINE("WFU_DASHBOARD_PAGE_OBSOLETE", __("The page containing the shortcode has been modified and it is no longer valid. Please go back to reload the shortcode.", "wp-file-upload"));
|
180 |
+
DEFINE("WFU_DASHBOARD_UPDATE_SHORTCODE_REJECTED", __("Failed to update the shortcode because the contents of the page changed. Go back to reload the shortcode.", "wp-file-upload"));
|
181 |
+
DEFINE("WFU_DASHBOARD_UPDATE_SHORTCODE_FAILED", __("Failed to update the shortcode. Please try again. If the problem persists, go back and reload the shortcode.", "wp-file-upload"));
|
182 |
+
//test messages
|
183 |
+
DEFINE("WFU_TESTMESSAGE_MESSAGE", __('This is a test message', 'wp-file-upload'));
|
184 |
+
DEFINE("WFU_TESTMESSAGE_ADMINMESSAGE", __('This is a test administrator message', 'wp-file-upload'));
|
185 |
+
DEFINE("WFU_TESTMESSAGE_FILE1_HEADER", __('File testfile 1 under test', 'wp-file-upload'));
|
186 |
+
DEFINE("WFU_TESTMESSAGE_FILE1_MESSAGE", __('File testfile 1 message', 'wp-file-upload'));
|
187 |
+
DEFINE("WFU_TESTMESSAGE_FILE1_ADMINMESSAGE", __('File testfile 1 administrator message', 'wp-file-upload'));
|
188 |
+
DEFINE("WFU_TESTMESSAGE_FILE2_HEADER", __('File testfile 2 under test', 'wp-file-upload'));
|
189 |
+
DEFINE("WFU_TESTMESSAGE_FILE2_MESSAGE", __('File testfile 2 message', 'wp-file-upload'));
|
190 |
+
DEFINE("WFU_TESTMESSAGE_FILE2_ADMINMESSAGE", __('File testfile 2 administrator message', 'wp-file-upload'));
|
191 |
+
//variables tool-tips
|
192 |
+
DEFINE("WFU_VARIABLE_TITLE_USERID", __("Insert variable %userid% inside text. It will be replaced by the id of the current user.", "wp-file-upload"));
|
193 |
+
DEFINE("WFU_VARIABLE_TITLE_USERNAME", __("Insert variable %username% inside text. It will be replaced by the username of the current user.", "wp-file-upload"));
|
194 |
+
DEFINE("WFU_VARIABLE_TITLE_USEREMAIL", __("Insert variable %useremail% inside text. It will be replaced by the email of the current user.", "wp-file-upload"));
|
195 |
+
DEFINE("WFU_VARIABLE_TITLE_FILENAME", __("Insert variable %filename% inside text. It will be replaced by the filename of the uploaded file.", "wp-file-upload"));
|
196 |
+
DEFINE("WFU_VARIABLE_TITLE_FILEPATH", __("Insert variable %filepath% inside text. It will be replaced by the full filepath of the uploaded file.", "wp-file-upload"));
|
197 |
+
DEFINE("WFU_VARIABLE_TITLE_BLOGID", __("Insert variable %blogid% inside text. It will be replaced by the blog id of the website.", "wp-file-upload"));
|
198 |
+
DEFINE("WFU_VARIABLE_TITLE_PAGEID", __("Insert variable %pageid% inside text. It will be replaced by the id of the current page.", "wp-file-upload"));
|
199 |
+
DEFINE("WFU_VARIABLE_TITLE_PAGETITLE", __("Insert variable %pagetitle% inside text. It will be replaced by the title of the current page.", "wp-file-upload"));
|
200 |
+
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.", "wp-file-upload"));
|
201 |
+
DEFINE("WFU_VARIABLE_TITLE_N", __("Insert variable %n% inside text to denote a line change.", "wp-file-upload"));
|
202 |
+
//other plugin values
|
203 |
+
DEFINE("WFU_WARNINGMESSAGE_NOSAVE", __('File %filename% uploaded successfully but not saved', 'wp-file-upload'));
|
204 |
+
DEFINE("WFU_NOTIFY_TESTMODE", __("Test Mode", "wp-file-upload"));
|
205 |
+
DEFINE("WFU_SUBDIR_SELECTDIR", __("select dir...", "wp-file-upload"));
|
206 |
+
DEFINE("WFU_SUBDIR_TYPEDIR", __("type dir", "wp-file-upload"));
|
207 |
+
DEFINE("WFU_SUCCESSMESSAGE_DETAILS", __('Upload path: %filepath%', 'wp-file-upload'));
|
208 |
+
DEFINE("WFU_FAILMESSAGE_DETAILS", __('Failed upload path: %filepath%', 'wp-file-upload'));
|
209 |
+
DEFINE("WFU_USERDATA_REQUIREDLABEL", __(' (required)', 'wp-file-upload'));
|
210 |
+
DEFINE("WFU_PAGEEXIT_PROMPT", __('Files are being uploaded. Are you sure you want to exit the page?', 'wp-file-upload'));
|
211 |
+
DEFINE("WFU_MESSAGE_CAPTCHA_CHECKING", __("checking captcha...", "wp-file-upload"));
|
212 |
+
DEFINE("WFU_MESSAGE_CAPTCHA_REFRESHING", __("refreshing...", "wp-file-upload"));
|
213 |
+
DEFINE("WFU_MESSAGE_CAPTCHA_OK", __("correct captcha", "wp-file-upload"));
|
214 |
+
DEFINE("WFU_CONFIRMBOX_CAPTION", __("click to continue the upload", "wp-file-upload"));
|
215 |
+
DEFINE("WFU_BROWSER_DELETEFILE_PROMPT", __("Are you sure you want to delete this file?", "wp-file-upload"));
|
216 |
+
DEFINE("WFU_BROWSER_DELETEFILES_PROMPT", __("Are you sure you want to delete these files?", "wp-file-upload"));
|
217 |
+
DEFINE("WFU_BROWSER_BULKACTION_TITLE", __("Bulk Actions", "wp-file-upload"));
|
218 |
+
DEFINE("WFU_BROWSER_BULKACTION_LABEL", __("Apply", "wp-file-upload"));
|
219 |
+
DEFINE("WFU_PAGINATION_PAGE", __("Page", "wp-file-upload"));
|
220 |
+
DEFINE("WFU_PAGINATION_OF", __("of ", "wp-file-upload"));
|
221 |
+
DEFINE("WFU_CANCEL_UPLOAD_PROMPT", __("Are you sure that you want to cancel the upload?", "wp-file-upload"));
|
222 |
+
DEFINE("WFU_FILE_CANCEL_HINT", __("cancel upload of this file", "wp-file-upload"));
|
223 |
+
DEFINE("WFU_UPLOAD_STATE0", __("Upload in progress", "wp-file-upload"));
|
224 |
+
DEFINE("WFU_UPLOAD_STATE1", __("Upload in progress with warnings!", "wp-file-upload"));
|
225 |
+
DEFINE("WFU_UPLOAD_STATE2", __("Upload in progress but some files already failed!", "wp-file-upload"));
|
226 |
+
DEFINE("WFU_UPLOAD_STATE3", __("Upload in progress but no files uploaded so far!", "wp-file-upload"));
|
227 |
+
DEFINE("WFU_UPLOAD_STATE4", __("All files uploaded successfully", "wp-file-upload"));
|
228 |
+
DEFINE("WFU_UPLOAD_STATE5", __("All files uploaded successfully but there are warnings!", "wp-file-upload"));
|
229 |
+
DEFINE("WFU_UPLOAD_STATE5_SINGLEFILE", __("File uploaded successfully but there are warnings!", "wp-file-upload"));
|
230 |
+
DEFINE("WFU_UPLOAD_STATE6", __("Some files failed to upload!", "wp-file-upload"));
|
231 |
+
DEFINE("WFU_UPLOAD_STATE7", __("All files failed to upload", "wp-file-upload"));
|
232 |
+
DEFINE("WFU_UPLOAD_STATE7_SINGLEFILE", __("File failed to upload", "wp-file-upload"));
|
233 |
+
DEFINE("WFU_UPLOAD_STATE8", __("There are no files to upload!", "wp-file-upload"));
|
234 |
+
DEFINE("WFU_UPLOAD_STATE9", __("Test upload message", "wp-file-upload"));
|
235 |
+
DEFINE("WFU_UPLOAD_STATE10", __("JSON parse warning!", "wp-file-upload"));
|
236 |
+
DEFINE("WFU_UPLOAD_STATE11", __("please wait while redirecting...", "wp-file-upload"));
|
237 |
+
DEFINE("WFU_UPLOAD_STATE12", __("Upload failed!", "wp-file-upload"));
|
238 |
+
DEFINE("WFU_UPLOAD_STATE13", __("Submitting data", "wp-file-upload"));
|
239 |
+
DEFINE("WFU_UPLOAD_STATE14", __("Data submitted successfully!", "wp-file-upload"));
|
240 |
+
DEFINE("WFU_UPLOAD_STATE15", __("Data were not submitted!", "wp-file-upload"));
|
241 |
+
DEFINE("WFU_UPLOAD_STATE16", __("Cancelling upload", "wp-file-upload"));
|
242 |
+
DEFINE("WFU_UPLOAD_STATE17", __("Upload cancelled!", "wp-file-upload"));
|
243 |
+
DEFINE("WFU_UPLOAD_STATE18", __("Upload succeeded!", "wp-file-upload"));
|
244 |
+
DEFINE("WFU_UPLOAD_STATE19", __("Upload completed but no files were saved!", "wp-file-upload"));
|
245 |
+
DEFINE("WFU_UPLOAD_STATE19_SINGLEFILE", __("File was not saved due to personal data policy!", "wp-file-upload"));
|
246 |
+
DEFINE("WFU_PAGE_PLUGINEDITOR_BUTTONTITLE", __("Open visual shortcode editor in new window", "wp-file-upload"));
|
247 |
+
DEFINE("WFU_PAGE_PLUGINEDITOR_LOADING", __("loading visual editor", "wp-file-upload"));
|
248 |
+
DEFINE("WFU_CONFIRM_CLEARFILES", __("Clear file list?", "wp-file-upload"));
|
249 |
+
DEFINE("WFU_DROP_HERE_MESSAGE", __('DROP HERE', 'wp-file-upload'));
|
250 |
+
//webcam values
|
251 |
+
DEFINE("WFU_WEBCAM_RECVIDEO_BTN", __('record video', 'wp-file-upload'));
|
252 |
+
DEFINE("WFU_WEBCAM_TAKEPIC_BTN", __('take a picture', 'wp-file-upload'));
|
253 |
+
DEFINE("WFU_WEBCAM_TURNONOFF_BTN", __('turn webcam on/off', 'wp-file-upload'));
|
254 |
+
DEFINE("WFU_WEBCAM_GOLIVE_BTN", __('go live again', 'wp-file-upload'));
|
255 |
+
DEFINE("WFU_WEBCAM_STOPREC_BTN", __('end recording', 'wp-file-upload'));
|
256 |
+
DEFINE("WFU_WEBCAM_PLAY_BTN", __('play', 'wp-file-upload'));
|
257 |
+
DEFINE("WFU_WEBCAM_PAUSE_BTN", __('pause', 'wp-file-upload'));
|
258 |
+
DEFINE("WFU_WEBCAM_GOBACK_BTN", __('go to the beginning', 'wp-file-upload'));
|
259 |
+
DEFINE("WFU_WEBCAM_GOFWD_BTN", __('go to the end', 'wp-file-upload'));
|
260 |
+
//widget values
|
261 |
+
DEFINE("WFU_WIDGET_PLUGINFORM_TITLE", __('Wordpress File Upload Form', 'wp-file-upload'));
|
262 |
+
DEFINE("WFU_WIDGET_PLUGINFORM_DESCRIPTION", __('Wordpress File Upload plugin uploader for sidebars', 'wp-file-upload'));
|
263 |
+
DEFINE("WFU_WIDGET_SIDEBAR_DEFAULTTITLE", __('Upload Files', 'wp-file-upload'));
|
264 |
+
}
|
265 |
+
|
266 |
+
/*********** Environment Variables ************/
|
267 |
+
//plugin default values
|
268 |
+
$GLOBALS["WFU_GLOBALS"] = array(
|
269 |
+
"WFU_UPLOADID" => array( "Default Upload ID", "string", "1", "The default upload ID of the uploader shortcode. It can be any integer from 1 and above." ),
|
270 |
+
"WFU_SINGLEBUTTON" => array( "Default Single-Button Status", "string", "false", "The default single-button status of the uploader shortcode. It can be 'true' or 'false'." ),
|
271 |
+
"WFU_UPLOADROLE" => array( "Default Upload Role", "string", "all,guests", "The default upload role of the uploader shortcode. It can be a comma-separated list of role slugs, including keywords 'all' and 'guests'." ),
|
272 |
+
"WFU_UPLOADPATH" => array( "Default Upload Path", "string", "uploads", "The default upload path of the uploader shortcode. It must be a folder relative to wp-content dir." ),
|
273 |
+
"WFU_FITMODE" => array( "Default Fit Mode", "string", "fixed", "The default fit mode of the uploader shortcode. It can be 'fixed' or 'responsive'." ),
|
274 |
+
"WFU_ALLOWNOFILE" => array( "Default Allow No File Mode", "string", "false", "The default mode for allowing no file uploads. If it is set to 'true' then an upload form can be submitted even if a file has not been selected. It can be 'true' or 'false'." ),
|
275 |
+
"WFU_ALLOWNOFILE" => array( "Default Allow No File Mode", "string", "false", "The default mode for allowing no file uploads. If it is set to 'true' then an upload form can be submitted even if a file has not been selected. It can be 'true' or 'false'." ),
|
276 |
+
"WFU_RESETMODE" => array( "Default Reset Form Mode", "string", "always", "The default reset mode of the upload form. It can be 'always', 'onsuccess' or 'never'." ),
|
277 |
+
"WFU_FORCEFILENAME" => array( "Default Force Filename State", "string", "false", "The default force filename state (force plugin to leave filename unchanged) of the uploader shortcode. It can be 'true' or 'false'." ),
|
278 |
+
"WFU_UPLOADPATTERNS" => array( "Default Upload Extensions", "string", "*.*", "The default allowed file extensions of the uploader shortcode. It can be a comma-separated list of wildcard extensions." ),
|
279 |
+
"WFU_MAXSIZE" => array( "Default Maximum File Size", "string", "50", "The default maximum allowed file size of the uploader shortcode in Megabytes. It can be any positive number." ),
|
280 |
+
"WFU_ACCESSMETHOD" => array( "Default Access Method", "string", "normal", "The default access method (of the website filesystem) of the uploader shortcode. It can be 'normal' or 'ftp'." ),
|
281 |
+
"WFU_FTPINFO" => array( "Default FTP Access Information", "string", "", "The default FTP access parameters of the uploader shortcode. It's syntax is 'username:password@ftp_domain'." ),
|
282 |
+
"WFU_USEFTPDOMAIN" => array( "Default Use FTP Domain State", "string", "false", "The default use FTP domain state (use the FTP domain defined in ftpinfo to store the uploaded files) of the uploader shortcode. It can be 'true' or 'false'." ),
|
283 |
+
"WFU_FTPPASSIVEMODE" => array( "Default FTP Passive Mode State", "string", "false", "The default FTP passive mode (use passive mode or not for FTP access) of the uploader shortcode. It can be 'true' or 'false'." ),
|
284 |
+
"WFU_FTPFILEPERMISSIONS" => array( "Default FTP File Permissions", "string", "", "The default FTP passive mode (use passive mode or not for FTP access) of the uploader shortcode. It can be 'true' or 'false'." ),
|
285 |
+
"WFU_DUBLICATESPOLICY" => array( "Default Duplicate File Action", "string", "overwrite", "The default duplicate file action of the uploader shortcode. It can be 'overwrite', 'reject' or 'mantain both'." ),
|
286 |
+
"WFU_UNIQUEPATTERN" => array( "Default Duplicate File Pattern", "string", "index", "The default duplicate file pattern of the uploader shortcode. It can be 'index' or 'datetimestamp'." ),
|
287 |
+
"WFU_FILEBASELINK" => array( "Default WPFilebase Update State", "string", "false", "The default WPFilebase plugin update state of the uploader shortcode. It can be 'true' or 'false'." ),
|
288 |
+
"WFU_NOTIFY" => array( "Default Email Notification State", "string", "false", "The default email notification state of the uploader shortcode. It can be 'true' or 'false'." ),
|
289 |
+
"WFU_NOTIFYRECIPIENTS" => array( "Default Email Recipients", "string", "", "The default email recipients of the uploader shortcode. It can be a comma-separated list of email addresses." ),
|
290 |
+
"WFU_NOTIFYHEADERS" => array( "Default Email Headers", "string", "", "The default email headers of the uploader shortcode." ),
|
291 |
+
"WFU_ATTACHFILE" => array( "Default Attach File State", "string", "false", "The default attach file to email state of the uploader shortcode. It can be 'true' or 'false'." ),
|
292 |
+
"WFU_REDIRECT" => array( "Default Redirection State", "string", "false", "The default redirection state of the uploader shortcode. It can be 'true' or 'false'." ),
|
293 |
+
"WFU_REDIRECTLINK" => array( "Default Redirect URL", "string", "", "The default redirect URL of the uploader shortcode." ),
|
294 |
+
"WFU_ADMINMESSAGES" => array( "Default State for Admin Messages", "string", "false", "The default state of displaying or not admin messages of the uploader shortcode. It can be 'true' or 'false'." ),
|
295 |
+
"WFU_SUCCESSMESSAGECOLORS" => array( "Default Colors for Success Message", "string", "#006600,#EEFFEE,#006666", "The default color triplet (text, background and border colors) of success message of the uploader shortcode." ),
|
296 |
+
"WFU_WARNINGMESSAGECOLORS" => array( "Default Colors for Warning Message", "string", "#F88017,#FEF2E7,#633309", "The default color triplet (text, background and border colors) of warning message of the uploader shortcode." ),
|
297 |
+
"WFU_FAILMESSAGECOLORS" => array( "Default Colors for Fail Message", "string", "#660000,#FFEEEE,#666600", "The default color triplet (text, background and border colors) of fail message of the uploader shortcode." ),
|
298 |
+
"WFU_WAITMESSAGECOLORS" => array( "Default Colors for Wait Message", "string", "#666666,#EEEEEE,#333333", "The default color triplet (text, background and border colors) of wait message of the uploader shortcode." ),
|
299 |
+
"WFU_SHOWTARGETFOLDER" => array( "Default State for Target Folder", "string", "false", "The default state of displaying or not the target folder of the uploader shortcode. It can be 'true' or 'false'." ),
|
300 |
+
"WFU_TARGETFOLDERLABEL" => array( "Default Text for Target Folder Label", "string", "Upload Directory", "The default text of the target folder label of the uploader shortcode." ),
|
301 |
+
"WFU_ASKFORSUBFOLDERS" => array( "Default Subfolders State", "string", "false", "The default state of displaying or not a list of subfolders of the uploader shortcode. It can be 'true' or 'false'." ),
|
302 |
+
"WFU_SUBFOLDERLABEL" => array( "Default Text of Subfolders Label", "string", "Select Subfolder", "The default text of subfolders label of the uploader shortcode." ),
|
303 |
+
"WFU_SUBFOLDERTREE" => array( "Default Subfolders List", "string", "", "The default list of subfolders of the uploader shortcode. Check plugin's support page for syntax." ),
|
304 |
+
"WFU_FORCECLASSIC" => array( "Default Disable AJAX State", "string", "false", "The default state of disabling or not AJAX functionality of the uploader shortcode. It can be 'true' or 'false'." ),
|
305 |
+
"WFU_TESTMODE" => array( "Default Test Mode State", "string", "false", "The default state of test mode of the uploader shortcode. It can be 'true' or 'false'." ),
|
306 |
+
"WFU_DEBUGMODE" => array( "Default Debug Mode State", "string", "false", "The default state of debug mode of the uploader shortcode. It can be 'true' or 'false'." ),
|
307 |
+
"WFU_WIDTHS" => array( "Default Element Widths", "string", "", "The default widths of the elements of the uploader shortcode. It is a comma-separated list of element widths." ),
|
308 |
+
"WFU_HEIGHTS" => array( "Default Element Heights", "string", "", "The default heights of the elements of the uploader shortcode. It is a comma-separated list of element heights." ),
|
309 |
+
"WFU_PLACEMENTS" => array( "Default Element Placements", "string", "title/filename+selectbutton+uploadbutton/subfolders"."/userdata"."/message", "The default placements of the elements of the uploader shortcode. Check plugin's support page for syntax." ),
|
310 |
+
"WFU_USERDATA" => array( "Default User Fields State", "string", "false", "The default state of custom user fields of the uploader shortcode. It can be 'true' or 'false'." ),
|
311 |
+
"WFU_MEDIALINK" => array( "Default Add to Media State", "string", "false", "The default state for adding files to Media of the uploader shortcode. It can be 'true' or 'false'." ),
|
312 |
+
"WFU_POSTLINK" => array( "Default Attachment to Post State", "string", "false", "The default state for attaching files to current post of the uploader shortcode. It can be 'true' or 'false'." ),
|
313 |
+
"WFU_WEBCAM" => array( "Default Webcam State", "string", "false", "The default state for webcam capture. It can be 'true' or 'false'." ),
|
314 |
+
"WFU_AUDIOCAPTURE" => array( "Default Capture Audio State", "string", "false", "The default state of audio capture. If it is set to 'true' then audio will be captured, together with video from the webcam. It can be 'true' or 'false'." ),
|
315 |
+
"WFU_WEBCAMMODE" => array( "Default Webcam Mode", "string", "capture video", "The default webcam capture mode. It can be 'capture video', 'take photos' or 'both'." ),
|
316 |
+
"WFU_VIDEOWIDTH" => array( "Default Video Width", "string", "", "The default preferable video width for webcam capture. It can be any positive integer in pixels." ),
|
317 |
+
"WFU_VIDEOHEIGHT" => array( "Default Video Height", "string", "", "The default preferable video height for webcam capture. It can be any positive integer in pixels." ),
|
318 |
+
"WFU_VIDEOASPECTRATIO" => array( "Default Video Aspect Ratio", "string", "", "The default preferable video aspect ratio for webcam video capture. It can be any positive value." ),
|
319 |
+
"WFU_VIDEOFRAMERATE" => array( "Default Video Frame Rate", "string", "", "The default preferable video frame rate for webcam video capture. It can be any positive value in frames/sec." ),
|
320 |
+
"WFU_CAMERAFACING" => array( "Default Camera Facing Mode", "string", "any", "The default preferable camera to be used for video/screenshot capture. It can be 'any', 'front' or 'back'." ),
|
321 |
+
"WFU_MAXRECORDTIME" => array( "Default Maximum Record Time", "string", "10", "The default maximum video recording time in seconds. The default value is 10 seconds." ),
|
322 |
+
"WFU_ASKCONSENT" => array( "Default Ask Consent State", "string", "false", "The default state of personal data consent request. The default value is false." ),
|
323 |
+
"WFU_PERSONALDATATYPES" => array( "Default Personal Data Types", "string", "userdata", "The default personal data types. The default value is 'userdata'." ),
|
324 |
+
"WFU_NOTREMEMBERCONSENT" => array( "Default Do Not Remember Consent Answer State", "string", "false", "The default state about remembering or not user's answer on consent question. The default value is true." ),
|
325 |
+
"WFU_CONSENTREJECTUPLOAD" => array( "Default Reject Upload on Consent Denial State", "string", "false", "The default state of continuing or rejecting the upload depending on consent answer. The default value is true." ),
|
326 |
+
"WFU_CONSENTFORMAT" => array( "Default Consent Format", "string", "radio", "The default format of consent question. The default value is 'checkbox'." ),
|
327 |
+
"WFU_CONSENTPRESELECT" => array( "Default Consent Preselect State", "string", "none", "The default preselect state of consent question when checkbox format is active. The default value is false." )
|
328 |
+
);
|
329 |
+
//other plugin values
|
330 |
+
$GLOBALS["WFU_GLOBALS"] += array(
|
331 |
+
"WFU_DEBUG" => array( "Plugin Debug Mode", "string", "OFF", "If DEBUG mode is activated then advanced hook of plugin's function can be performed. This option may make the plugin slower, so use it very carefully. It can be 'OFF' or 'ON'." ),
|
332 |
+
"WFU_RESTRICT_FRONTEND_LOADING" => array( "Restrict Front-End Loading", "string", "false", "It defines whether the plugin will load on all pages or specific ones. If it is 'false' then it will load on all pages. To restrict loading only on specific pages set a comma-separated list of page or post IDs." ),
|
333 |
+
"WFU_UPLOADPROGRESS_MODE" => array( "Upload Progress Mode", "string", "incremental", "Defines how the upload progress is calculated. It can be 'incremental' or 'absolute'. Default value is 'incremental'." ),
|
334 |
+
"WFU_DOS_ATTACKS_CHECK" => array( "Check for Denial-Of-Service Attacks", "string", "true", "If it is true then then plugin will check if the number of files uploaded within a specific amount of time exceeds the limit, thus protecting from DOS attacks. It can be 'true' or 'false'." ),
|
335 |
+
"WFU_DOS_ATTACKS_FILE_LIMIT" => array( "Denial-Of-Service File Limit", "integer", 10000, "Defines the maximum number of files that are allowed to be uploaded within a specific amount of time. It can be any positive integer." ),
|
336 |
+
"WFU_DOS_ATTACKS_TIME_INTERVAL" => array( "Denial-Of-Service Time Interval", "integer", 3600, "Defines the time interval for DOS attacks check. The time interval is given in seconds." ),
|
337 |
+
"WFU_DOS_ATTACKS_ADMIN_EMAIL_FREQUENCY" => array( "Denial-Of-Service Admin Email Frequency", "integer", 3600, "Defines how frequently an email will be sent to administrator notifying for Denial-Of-Service attacks. The time interval is given in seconds." ),
|
338 |
+
"WFU_SANITIZE_FILENAME_MODE" => array( "Filename Sanitization Mode", "string", "strict", "The sanitization mode for filenames. It can be 'strict' or 'loose'." ),
|
339 |
+
"WFU_SANITIZE_FILENAME_DOTS" => array( "Sanitize Filename Dots", "string", "true", "Convert dot symbols (.) in filename into dashes, in order to avoid double extensions. It can be 'true' or 'false'." ),
|
340 |
+
"WFU_WILDCARD_ASTERISK_MODE" => array( "Wildcard Asterisk Mode", "string", "strict", "The mode of wildcard pattern asterisk symbol. If it is strict, then the asterisk will not match dot (.) characters. It can be 'strict' or 'loose'." ),
|
341 |
+
"WFU_CHECKPHPTAGS_FILETYPES" => array( "PHP Tag Checking File Types", "string", "commonimages", "The file types for which the plugin will check their contents for PHP tags. It can be 'all', 'commonimages' or 'none'." ),
|
342 |
+
"WFU_PHP_ARRAY_MAXLEN" => array( "Max PHP Array Length", "string", "10000", "The maximum allowable number of items of a PHP array." ),
|
343 |
+
"WFU_ADMINBROWSER_TABLE_MAXROWS" => array( "Admin Browser Rows Per Page", "integer", 25, "The number of rows per page of the admin browser. A value equal to zero or less denotes no pagination." ),
|
344 |
+
"WFU_HISTORYLOG_TABLE_MAXROWS" => array( "History Log Table Rows Per Page", "integer", 25, "The number of rows per page of the History Log table." ),
|
345 |
+
"WFU_UPLOADEDFILES_TABLE_MAXROWS" => array( "Uploaded Files Table Rows Per Page", "integer", 25, "The number of rows per page of the Uploaded Files table." ),
|
346 |
+
"WFU_ALTERNATIVE_RANDOMIZER" => array( "Use Alternative Randomizer", "string", "false", "On fast web servers the plugin's generator of random strings may not work properly causing various problems. If it is set to true, an alternative randomizer method is employed that works for fast web servers. It can be 'true' or 'false'." ),
|
347 |
+
"WFU_FORCE_NOTIFICATIONS" => array( "Force Email Notifications", "string", "false", "Send email notifications (if they are activated) even if no file has been uploaded. It can be 'true' or 'false'." ),
|
348 |
+
"WFU_UPDATE_MEDIA_ON_DELETE" => array( "Update Media on Delete", "string", "true", "When an uploaded file is deleted then delete also the corresponding Media Library item if exists. It can be 'true' or 'false'." ),
|
349 |
+
"WFU_DASHBOARD_PROTECTED" => array( "Dashboard Is Protected", "string", "false", "If /wp-admin folder is password protected then this variable should be set to 'true' so that internal operations of the plugin can work. The username and password should also be set." ),
|
350 |
+
"WFU_DASHBOARD_USERNAME" => array( "Protected Dashboard Username", "string", "", "Username entry for accessing protected /wp-admin folder." ),
|
351 |
+
"WFU_DASHBOARD_PASSWORD" => array( "Protected Dashboard Password", "string", "", "Password entry for accessing protected /wp-admin folder." ),
|
352 |
+
"WFU_EXPORT_DATA_SEPARATOR" => array( "Export Data Separator", "string", ",", "This is the delimiter of the exported file data columns. It can be any symbol. Default value is comma (,)." ),
|
353 |
+
"WFU_EXPORT_USERDATA_SEPARATOR" => array( "Export User Data Separator", "string", ";", "This is the delimiter of the exported user data of each file. It can be any symbol. Default value is semicolon (;)." ),
|
354 |
+
"WFU_DISABLE_VERSION_CHECK" => array( "Disable Version Check", "string", "false", "If it is set to 'true' then the plugin will not check if there are any new versions available. This is a temporary solution to problems having some users accessing Iptanus Services server causing the plugin to stall. It can be 'true' or 'false'." ),
|
355 |
+
"WFU_RELAX_CURL_VERIFY_HOST" => array( "Relax cURL Host Verification", "string", "false", "If it is set to 'true' then CURLOPT_SSL_VERIFYHOST will be disabled when executing a cURL POST request. This is required in some cases so that the plugin can reach https://services2.iptanus.com, because on some servers it fails with a file_get_contents warning. It can be 'true' or 'false'." ),
|
356 |
+
"WFU_USE_ALT_IPTANUS_SERVER" => array( "Use Alternative Iptanus Server", "string", "false", "If it is set to 'true' then the alternative Iptanus server will be used. This is a work-around in some cases where the website cannot reach https://services2.iptanus.com. It can be 'true' or 'false'." ),
|
357 |
+
"WFU_ALT_IPTANUS_SERVER" => array( "Alternative Iptanus Server", "string", "https://iptanusservices.appspot.com", "If it is set then this is the URL of the alternative Iptanus server." ),
|
358 |
+
"WFU_ALT_VERSION_SERVER" => array( "Alternative Version Server", "string", "https://iptanusservices.appspot.com/g79xo30q8s", "If the alternative Iptanus server is used and this variable is not empty, then it will be used as the alternative Version Server URL." ),
|
359 |
+
"WFU_MINIFY_INLINE_CSS" => array( "Minify Inline CSS Code", "string", "true", "Defines whether the inline CSS code will be minified. It can be 'true' or 'false'." ),
|
360 |
+
"WFU_MINIFY_INLINE_JS" => array( "Minify Inline JS Code", "string", "true", "Defines whether the inline Javascript code will be minified. It can be 'true' or 'false'." ),
|
361 |
+
"WFU_US_SESSION_LEGACY" => array( "Session Legacy Option", "string", "true", "Defines whether the old (legacy) operation of reading and storing session data (using session_start in header) will be used. By default it is set to 'true' to maintain backward compatibility." ),
|
362 |
+
"WFU_US_COOKIE_LIFE" => array( "Session Cookie Life", "integer", 48, "Defines the life of session cookie, in hours." ),
|
363 |
+
"WFU_US_DBOPTION_BASE" => array( "DB Option User State Base", "string", "cookies", "Defines how DB option defines the unique user state key. It can take the values 'session' or 'cookies'." ),
|
364 |
+
"WFU_US_DBOPTION_CHECK" => array( "DB Option User State Check Interval", "integer", 7200, "Defines how often (in seconds) the plugin will update user state list, when user state is saved in DB option table." ),
|
365 |
+
"WFU_US_DBOPTION_LIFE" => array( "DB Option User State Life", "integer", 1800, "Defines the maximum time of inactivity of a user state, when user state is saved in DB option table." ),
|
366 |
+
"WFU_US_HANDLER_CHANGED" => array( "User State Handler Changed", "string", "false", "Defines whether the plugin changed automatically the user state handler during installation." ),
|
367 |
+
"WFU_US_DBOPTION_USEOLD" => array( "Use Old DB Option Handler", "string", "false", "Defines whether the old DBOption user state handlers will be used." ),
|
368 |
+
"WFU_US_DEADLOCK_TIMEOUT" => array( "Database Deadlock Timeout", "integer", 10, "Defines for how long a deadlocked database transaction will be repeated." ),
|
369 |
+
"WFU_US_LOG_DBERRORS" => array( "Log Database Errors", "string", "false", "Defines whether database errors will be logged." ),
|
370 |
+
"WFU_QUEUE_ACTIVE" => array( "Enable Queue Functionality", "string", "true", "Defines whether queue operation is active." ),
|
371 |
+
"WFU_QUEUE_THREAD_TIMEOUT" => array( "Queue Thread Timeout", "integer", 5, "Defines for how long, in seconds, a queue will wait for a thread to finish before aborting the operation." ),
|
372 |
+
"WFU_QUEUE_LOOP_DELAY" => array( "Queue Loop Delay", "integer", 100, "Defines the time, in milliseconds, a wait loop will sleep before continuing." ),
|
373 |
+
"WFU_PD_VISIBLE_OPLEVELS" => array( "Personal Data Visible Operation Levels", "integer", 3, "Defines how deep administrators can go into personal data operation details. A value of -1 denotes that there is no limit." ),
|
374 |
+
"WFU_PD_VISIBLE_PERLEVELS" => array( "Personal Data Visible Permission Levels", "integer", 2, "Defines how deep administrators can go into personal data permission details. A value of -1 denotes that there is no limit." ),
|
375 |
+
"WFU_PD_VISIBLE_LOGLEVELS" => array( "Personal Data Visible Log Action Levels", "integer", 2, "Defines how deep administrators can go into personal data log action details. A value of -1 denotes that there is no limit." ),
|
376 |
+
"WFU_UPLOADEDFILES_MENU" => array( "Uploaded Files Menu State", "string", "true", "Defines whether the Uploaded Files Dashboard menu item will be shown or not. It can be 'true' or 'false'." ),
|
377 |
+
"WFU_UPLOADEDFILES_DEFACTION" => array( "Uploaded Files Default Action", "string", "adminbrowser", "Defines the default action that will be executed when a file link is pressed in Uploaded Files page. It can be 'details', 'adminbrowser', 'historylog', 'link', 'download' and 'none'." ),
|
378 |
+
"WFU_UPLOADEDFILES_COLUMNS" => array( "Uploaded Files Columns", "string", "#, file, upload_date, user, properties, remarks, actions", "Defines the visible columns of the Uploaded Files list as well as their order. It is noted that 'File' column is always visible and it is the second column if '#' column is visible, or the first one if '#' column is hidden." ),
|
379 |
+
"WFU_UPLOADEDFILES_ACTIONS" => array( "Uploaded Files Actions", "string", "details, media, adminbrowser, historylog, link, download, remotelinks", "Defines the allowable actions and their order for each file in Uploaded Files list. It is noted that the actions shown for each file depend on its properties." ),
|
380 |
+
"WFU_UPLOADEDFILES_HIDEINVALID" => array( "Hide Invalid Uploaded Files", "string", "false", "Defines whether all uploaded file records will be shown in Uploaded File menu or only the valid ones. Invalid are the records who are obsolete or their files do not exist anymore." ),
|
381 |
+
"WFU_UPLOADEDFILES_RESET_TIME" => array( "Uploaded Files Reset Time", "integer", 5, "Defines the interval in seconds before the unread uploaded files can be marked as read. A value of -1 denotes that there is no interval." ),
|
382 |
+
"WFU_UPLOADEDFILES_BARMENU" => array( "Uploaded Files Toolbar Menu State", "string", "true", "Defines whether the Uploaded Files Toolbar (Admin Bar) menu item will be shown or not. It can be 'true' or 'false'." ),
|
383 |
+
"WFU_UPLOADEDFILES_BARAUTOHIDE" => array( "Uploaded Files Auto-Hide on Toolbar", "string", "false", "Defines whether the Uploaded Files Toolbar (Admin Bar) menu item will be hidden when there are no new uploads. It can be 'true' or 'false'." ),
|
384 |
+
"WFU_SHORTCODECOMPOSER_NOADMIN" => array( "Show Shortcode Composer to Non-Admins", "string", "true", "Defines whether the shortcode composer will be visible to non-admin users who can edit posts or pages. It can be 'true' or 'false'." ),
|
385 |
+
"WFU_FILEOPERATION_IGNOREFTP" => array( "Ignore FTP Path in File Operations", "string", "false", "Defines whether file functions, such as file_exists(), stat() etc. will be ignored for FTP paths. It can be 'true' or 'false'." ),
|
386 |
+
"WFU_FTPFILEEXISTS_DEFVALUE" => array( "Default Value of File Exists for FTP Paths", "string", "true", "Defines the default value that will be returned when file_exists() function is executed on an FTP path. It can be '*true', '*false', '*calc', 'true' or 'false'. If it starts with asterisk (*) then this variable takes precedence over the more general WFU_FILEOPERATION_IGNOREFTP." ),
|
387 |
+
"WFU_FTPSTAT_DEFVALUE" => array( "Default Value of Stat for FTP Paths", "string", "empty", "Defines the default value that will be returned when stat() function is executed on an FTP path. It can be '*empty', '*calc' or 'empty'. If it starts with asterisk (*) then this variable takes precedence over the more general WFU_FILEOPERATION_IGNOREFTP." ),
|
388 |
+
"WFU_FTPFILESIZE_DEFVALUE" => array( "Default Value of Filesize for FTP Paths", "string", "empty", "Defines the default value that will be returned when filesize() function is executed on an FTP path. It can be '*empty', '*calc' or 'empty'. If it starts with asterisk (*) then this variable takes precedence over the more general WFU_FILEOPERATION_IGNOREFTP." ),
|
389 |
+
"WFU_FTPFOPEN_DEFVALUE" => array( "Default Value of Fopen for FTP Paths", "string", "empty", "Defines the default value that will be returned when fopen() function is executed on an FTP path. It can be '*empty', '*calc' or 'empty'. If it starts with asterisk (*) then this variable takes precedence over the more general WFU_FILEOPERATION_IGNOREFTP." ),
|
390 |
+
"WFU_FTPFILEGETCONTENTS_DEFVALUE" => array( "Default Value of File Get Contents for FTP Paths", "string", "empty", "Defines the default value that will be returned when file_get_contents() function is executed on an FTP path. It can be '*empty', '*calc' or 'empty'. If it starts with asterisk (*) then this variable takes precedence over the more general WFU_FILEOPERATION_IGNOREFTP." ),
|
391 |
+
"WFU_FTPMD5FILE_DEFVALUE" => array( "Default Value of MD5 File for FTP Paths", "string", "empty", "Defines the default value that will be returned when md5_file() function is executed on an FTP path. It can be '*empty', '*calc' or 'empty'. If it starts with asterisk (*) then this variable takes precedence over the more general WFU_FILEOPERATION_IGNOREFTP." ),
|
392 |
+
"WFU_FTPUNLINK_DEFVALUE" => array( "Default Value of Unlink for FTP Paths", "string", "empty", "Defines the default value that will be returned when unlink() function is executed on an FTP path. It can be '*empty', '*calc' or 'empty'. If it starts with asterisk (*) then this variable takes precedence over the more general WFU_FILEOPERATION_IGNOREFTP." ),
|
393 |
+
"WFU_FILEOPERATION_IGNORESFTP" => array( "Ignore SFTP Path in File Operations", "string", "false", "Defines whether file functions, such as file_exists(), stat() etc. will be ignored for SFTP paths. It can be 'true' or 'false'." ),
|
394 |
+
"WFU_SFTPFILEEXISTS_DEFVALUE" => array( "Default Value of File Exists for SFTP Paths", "string", "true", "Defines the default value that will be returned when file_exists() function is executed on an SFTP path. It can be '*true', '*false', '*calc', 'true' or 'false'. If it starts with asterisk (*) then this variable takes precedence over the more general WFU_FILEOPERATION_IGNORESFTP." ),
|
395 |
+
"WFU_SFTPSTAT_DEFVALUE" => array( "Default Value of Stat for SFTP Paths", "string", "empty", "Defines the default value that will be returned when stat() function is executed on an SFTP path. It can be '*empty', '*calc' or 'empty'. If it starts with asterisk (*) then this variable takes precedence over the more general WFU_FILEOPERATION_IGNORESFTP." ),
|
396 |
+
"WFU_SFTPFILESIZE_DEFVALUE" => array( "Default Value of Filesize for SFTP Paths", "string", "empty", "Defines the default value that will be returned when filesize() function is executed on an SFTP path. It can be '*empty', '*calc' or 'empty'. If it starts with asterisk (*) then this variable takes precedence over the more general WFU_FILEOPERATION_IGNORESFTP." ),
|
397 |
+
"WFU_SFTPFOPEN_DEFVALUE" => array( "Default Value of Fopen for SFTP Paths", "string", "empty", "Defines the default value that will be returned when fopen() function is executed on an SFTP path. It can be '*empty', '*calc' or 'empty'. If it starts with asterisk (*) then this variable takes precedence over the more general WFU_FILEOPERATION_IGNORESFTP." ),
|
398 |
+
"WFU_SFTPFILEGETCONTENTS_DEFVALUE" => array( "Default Value of File Get Contents for SFTP Paths", "string", "empty", "Defines the default value that will be returned when file_get_contents() function is executed on an SFTP path. It can be '*empty', '*calc' or 'empty'. If it starts with asterisk (*) then this variable takes precedence over the more general WFU_FILEOPERATION_IGNORESFTP." ),
|
399 |
+
"WFU_SFTPMD5FILE_DEFVALUE" => array( "Default Value of MD5 File for SFTP Paths", "string", "empty", "Defines the default value that will be returned when md5_file() function is executed on an SFTP path. It can be '*empty', '*calc' or 'empty'. If it starts with asterisk (*) then this variable takes precedence over the more general WFU_FILEOPERATION_IGNORESFTP." ),
|
400 |
+
"WFU_SFTPUNLINK_DEFVALUE" => array( "Default Value of Unlink for SFTP Paths", "string", "empty", "Defines the default value that will be returned when unlink() function is executed on an SFTP path. It can be '*empty', '*calc' or 'empty'. If it starts with asterisk (*) then this variable takes precedence over the more general WFU_FILEOPERATION_IGNORESFTP." ),
|
401 |
+
);
|
402 |
+
//color definitions
|
403 |
+
$GLOBALS["WFU_GLOBALS"] += array(
|
404 |
+
"WFU_TESTMESSAGECOLORS" => array( "Colors for Message in Test Mode", "string", "#666666,#EEEEEE,#333333", "The color triplet (text, background and border colors) of message in Test mode of the uploader shortcode." ),
|
405 |
+
"WFU_DEFAULTMESSAGECOLORS" => array( "Defaults Message Colors", "string", "#666666,#EEEEEE,#333333", "The default color triplet (text, background and border colors) of message of the uploader shortcode." ),
|
406 |
+
"WFU_HEADERMESSAGECOLORS_STATE0" => array( "State 0 Message Colors", "string", "#666666,#EEEEEE,#333333", "The color triplet (text, background and border colors) of message of upload state 0 (upload in progress with no messages) of the uploader shortcode." ),
|
407 |
+
"WFU_HEADERMESSAGECOLORS_STATE1" => array( "State 1 Message Colors", "string", "#F88017,#FEF2E7,#633309", "The color triplet (text, background and border colors) of message of upload state 1 (upload in progress with messages) of the uploader shortcode." ),
|
408 |
+
"WFU_HEADERMESSAGECOLORS_STATE2" => array( "State 2 Message Colors", "string", "#F88017,#FEF2E7,#633309", "The color triplet (text, background and border colors) of message of upload state 2 (upload in progress with some files not uploaded) of the uploader shortcode." ),
|
409 |
+
"WFU_HEADERMESSAGECOLORS_STATE3" => array( "State 3 Message Colors", "string", "#F88017,#FEF2E7,#633309", "The color triplet (text, background and border colors) of message of upload state 3 (upload in progress with no files uploaded so far) of the uploader shortcode." ),
|
410 |
+
"WFU_HEADERMESSAGECOLORS_STATE4" => array( "State 4 Message Colors", "string", "#006600,#EEFFEE,#006666", "The color triplet (text, background and border colors) of message of upload state 4 (all files uploaded) of the uploader shortcode." ),
|
411 |
+
"WFU_HEADERMESSAGECOLORS_STATE5" => array( "State 5 Message Colors", "string", "#F88017,#FEF2E7,#633309", "The color triplet (text, background and border colors) of message of upload state 5 (all files uploaded with messages) of the uploader shortcode." ),
|
412 |
+
"WFU_HEADERMESSAGECOLORS_STATE6" => array( "State 6 Message Colors", "string", "#F88017,#FEF2E7,#633309", "The color triplet (text, background and border colors) of message of upload state 6 (some files not uploaded) of the uploader shortcode." ),
|
413 |
+
"WFU_HEADERMESSAGECOLORS_STATE7" => array( "State 7 Message Colors", "string", "#660000,#FFEEEE,#666600", "The color triplet (text, background and border colors) of message of upload state 7 (no files uploaded) of the uploader shortcode." ),
|
414 |
+
"WFU_HEADERMESSAGECOLORS_STATE8" => array( "State 8 Message Colors", "string", "#660000,#FFEEEE,#666600", "The color triplet (text, background and border colors) of message of upload state 8 (there are no files to upload) of the uploader shortcode." ),
|
415 |
+
"WFU_HEADERMESSAGECOLORS_STATE9" => array( "State 9 Message Colors", "string", "#666666,#EEEEEE,#333333", "The color triplet (text, background and border colors) of message of upload state 9 (test state) of the uploader shortcode." ),
|
416 |
+
"WFU_HEADERMESSAGECOLORS_STATE10" => array( "State 10 Message Colors", "string", "#660000,#FFEEEE,#666600", "The color triplet (text, background and border colors) of message of upload state 10 (JSON parse error) of the uploader shortcode." ),
|
417 |
+
"WFU_HEADERMESSAGECOLORS_STATE11" => array( "State 11 Message Colors", "string", "#666666,#EEEEEE,#333333", "The color triplet (text, background and border colors) of message of upload state 11 (redirecting) of the uploader shortcode." ),
|
418 |
+
"WFU_HEADERMESSAGECOLORS_STATE12" => array( "State 12 Message Colors", "string", "#660000,#FFEEEE,#666600", "The color triplet (text, background and border colors) of message of upload state 12 (upload failed) of the uploader shortcode." ),
|
419 |
+
"WFU_HEADERMESSAGECOLORS_STATE13" => array( "State 13 Message Colors", "string", "#666666,#EEEEEE,#333333", "The color triplet (text, background and border colors) of message of upload state 13 (sending data) of the uploader shortcode." ),
|
420 |
+
"WFU_HEADERMESSAGECOLORS_STATE14" => array( "State 14 Message Colors", "string", "#006600,#EEFFEE,#006666", "The color triplet (text, background and border colors) of message of upload state 14 (data submit succeeded) of the uploader shortcode." ),
|
421 |
+
"WFU_HEADERMESSAGECOLORS_STATE15" => array( "State 15 Message Colors", "string", "#660000,#FFEEEE,#666600", "The color triplet (text, background and border colors) of message of upload state 15 (data submit failed) of the uploader shortcode." ),
|
422 |
+
"WFU_HEADERMESSAGECOLORS_STATE16" => array( "State 16 Message Colors", "string", "#666666,#EEEEEE,#333333", "The color triplet (text, background and border colors) of message of upload state 16 (cancelling upload) of the uploader shortcode." ),
|
423 |
+
"WFU_HEADERMESSAGECOLORS_STATE17" => array( "State 17 Message Colors", "string", "#660000,#FFEEEE,#666600", "The color triplet (text, background and border colors) of message of upload state 17 (upload cancelled) of the uploader shortcode." ),
|
424 |
+
"WFU_HEADERMESSAGECOLORS_STATE18" => array( "State 18 Message Colors", "string", "#006600,#EEFFEE,#006666", "The color triplet (text, background and border colors) of message of upload state 18 (upload succeeded) of the uploader shortcode." ),
|
425 |
+
"WFU_HEADERMESSAGECOLORS_STATE19" => array( "State 19 Message Colors", "string", "#F88017,#FEF2E7,#633309", "The color triplet (text, background and border colors) of message of upload state 19 (upload completed but no files were saved due to personal data policy) of the uploader shortcode." )
|
426 |
+
);
|
427 |
+
//insert saved values to array
|
428 |
+
$envars = get_option("wfu_environment_variables", array());
|
429 |
+
foreach ( $GLOBALS["WFU_GLOBALS"] as $ind => $envar ) {
|
430 |
+
if ( isset($envars[$ind]) ) {
|
431 |
+
if ( $envar[1] == "integer" ) $saved = (int)$envars[$ind];
|
432 |
+
else $saved = (string)$envars[$ind];
|
433 |
+
}
|
434 |
+
else $saved = $envar[2];
|
435 |
+
array_splice($GLOBALS["WFU_GLOBALS"][$ind], 3, 0, array( $saved ));
|
436 |
+
//add visibility
|
437 |
+
$GLOBALS["WFU_GLOBALS"][$ind][5] = true;
|
438 |
+
}
|
439 |
+
|
440 |
+
//hide unwanted environment variables
|
441 |
+
$GLOBALS["WFU_GLOBALS"]["WFU_RELAX_CURL_VERIFY_HOST"][5] = false;
|
442 |
+
$GLOBALS["WFU_GLOBALS"]["WFU_USE_ALT_IPTANUS_SERVER"][5] = false;
|
443 |
+
|
444 |
+
/************** Constant Values ***************/
|
445 |
+
//other plugin values
|
446 |
+
DEFINE("WFU_SUCCESSMESSAGECOLOR", "green");
|
447 |
+
DEFINE("WFU_MAX_TIME_LIMIT", ini_get("max_input_time"));
|
448 |
+
DEFINE("WFU_RESPONSE_URL", WPFILEUPLOAD_DIR."wfu_response.php");
|
449 |
+
DEFINE("WFU_SERVICES_SERVER_URL", 'https://services2.iptanus.com');
|
450 |
+
DEFINE("WFU_VERSION_SERVER_URL", WFU_SERVICES_SERVER_URL.'/wp-admin/admin-ajax.php');
|
451 |
+
DEFINE("WFU_VERSION_HASH", '9npWpXMhAQ5e6AGJ5zqbaPxLk9ePD3eSu3WKeN9p89E9wmgL2PHtrqXPzBVpStzh');
|
452 |
+
DEFINE("WFU_DOWNLOADER_URL", WPFILEUPLOAD_DIR."wfu_file_downloader.php");
|
453 |
+
DEFINE("WFU_IPTANUS_SERVER_UNREACHABLE_ARTICLE", 'https://www.iptanus.com/iptanus-services-server-unreachable-error-wfu-plugin/');
|
454 |
+
//alternative insecure server
|
455 |
+
DEFINE("WFU_SERVICES_SERVER_ALT_URL", 'http://services.iptanus.com');
|
456 |
+
DEFINE("WFU_VERSION_SERVER_ALT_URL", WFU_SERVICES_SERVER_ALT_URL.'/wp-admin/admin-ajax.php');
|
457 |
+
DEFINE("WFU_PRO_VERSION_URL", 'https://www.iptanus.com/product/wordpress-file-upload-pro/');
|
458 |
+
//define images
|
459 |
+
DEFINE("WFU_IMAGE_ADMIN_HELP", WPFILEUPLOAD_DIR.'images/help_16.png');
|
460 |
+
DEFINE("WFU_IMAGE_ADMIN_RESTOREDEFAULT", WPFILEUPLOAD_DIR.'images/restore_16.png');
|
461 |
+
DEFINE("WFU_IMAGE_ADMIN_USERDATA_ADD", WPFILEUPLOAD_DIR.'images/add_12.png');
|
462 |
+
DEFINE("WFU_IMAGE_ADMIN_USERDATA_REMOVE", WPFILEUPLOAD_DIR.'images/remove_12.png');
|
463 |
+
DEFINE("WFU_IMAGE_ADMIN_USERDATA_UP", WPFILEUPLOAD_DIR.'images/up_12.png');
|
464 |
+
DEFINE("WFU_IMAGE_ADMIN_USERDATA_DOWN", WPFILEUPLOAD_DIR.'images/down_12.png');
|
465 |
+
DEFINE("WFU_IMAGE_ADMIN_SUBFOLDER_BROWSE", WPFILEUPLOAD_DIR.'images/tree_16.gif');
|
466 |
+
DEFINE("WFU_IMAGE_ADMIN_SUBFOLDER_OK", WPFILEUPLOAD_DIR.'images/ok_12.gif');
|
467 |
+
DEFINE("WFU_IMAGE_ADMIN_SUBFOLDER_CANCEL", WPFILEUPLOAD_DIR.'images/cancel_12.gif');
|
468 |
+
DEFINE("WFU_IMAGE_ADMIN_SUBFOLDER_LOADING", WPFILEUPLOAD_DIR.'images/refresh_16.gif');
|
469 |
+
DEFINE("WFU_IMAGE_SIMPLE_PROGBAR", WPFILEUPLOAD_DIR.'images/progbar.gif');
|
470 |
+
DEFINE("WFU_IMAGE_OVERLAY_EDITOR", WPFILEUPLOAD_DIR.'images/pencil.svg');
|
471 |
+
DEFINE("WFU_IMAGE_OVERLAY_LOADING", WPFILEUPLOAD_DIR.'images/loading_icon.gif');
|
472 |
+
DEFINE("WFU_IMAGE_FILE_CANCEL", WPFILEUPLOAD_DIR.'images/cancel_16.png');
|
473 |
+
DEFINE("WFU_IMAGE_MEDIA_BUTTONS", WPFILEUPLOAD_DIR.'images/open-iconic.svg');
|
474 |
+
DEFINE("WFU_IMAGE_VERSION_COMPARISON", WPFILEUPLOAD_DIR.'images/Version Comparison.png');
|
475 |
+
|
476 |
+
/**
|
477 |
+
* Front-End Constants Initialization
|
478 |
+
*
|
479 |
+
* This function initializes all constants that need to be passed to the front-
|
480 |
+
* end scripts of the upload form.
|
481 |
+
*
|
482 |
+
* @since 2.1.2
|
483 |
+
*/
|
484 |
+
function wfu_set_javascript_constants() {
|
485 |
+
$consts = array(
|
486 |
+
"notify_testmode" => WFU_NOTIFY_TESTMODE,
|
487 |
+
"nofilemessage" => WFU_ERROR_UPLOAD_NOFILESELECTED,
|
488 |
+
"enable_popups" => WFU_ERROR_ENABLE_POPUPS,
|
489 |
+
"remoteserver_noresult" => WFU_ERROR_REMOTESERVER_NORESULT,
|
490 |
+
"message_header" => WFU_ERRORMESSAGE,
|
491 |
+
"message_failed" => WFU_ERROR_UPLOAD_FAILED_WHILE,
|
492 |
+
"message_cancelled" => WFU_ERROR_UPLOAD_CANCELLED,
|
493 |
+
"message_unknown" => WFU_ERROR_UNKNOWN,
|
494 |
+
"adminmessage_unknown" => WFU_FAILMESSAGE_DETAILS,
|
495 |
+
"message_timelimit" => WFU_ERROR_FILE_PHP_TIME,
|
496 |
+
"message_admin_timelimit" => WFU_ERROR_ADMIN_FILE_PHP_TIME,
|
497 |
+
"cancel_upload_prompt" => WFU_CANCEL_UPLOAD_PROMPT,
|
498 |
+
"file_cancelled" => WFU_ERROR_FILE_CANCELLED,
|
499 |
+
"jsonparse_filemessage" => WFU_ERROR_JSONPARSE_FILEMESSAGE,
|
500 |
+
"jsonparse_message" => WFU_ERROR_JSONPARSE_MESSAGE,
|
501 |
+
"jsonparse_adminmessage" => WFU_ERROR_JSONPARSE_ADMINMESSAGE,
|
502 |
+
"jsonparse_headermessage" => WFU_ERROR_JSONPARSE_HEADERMESSAGE,
|
503 |
+
"jsonparse_headeradminmessage" => WFU_ERROR_JSONPARSE_HEADERADMINMESSAGE,
|
504 |
+
"same_pluginid" => WFU_ERROR_SAME_PLUGINID,
|
505 |
+
"webcam_video_notsupported" => WFU_ERROR_WEBCAM_VIDEO_NOTSUPPORTED,
|
506 |
+
"webcam_video_nothingrecorded" => WFU_ERROR_WEBCAM_VIDEO_NOTHINGRECORDED,
|
507 |
+
"default_colors" => WFU_VAR("WFU_DEFAULTMESSAGECOLORS"),
|
508 |
+
"fail_colors" => WFU_VAR("WFU_FAILMESSAGECOLORS"),
|
509 |
+
"max_time_limit" => WFU_MAX_TIME_LIMIT,
|
510 |
+
"response_url" => WFU_RESPONSE_URL,
|
511 |
+
"ajax_url" => wfu_ajaxurl(),
|
512 |
+
"wfu_pageexit_prompt" => WFU_PAGEEXIT_PROMPT,
|
513 |
+
"wfu_subdir_typedir" => WFU_SUBDIR_TYPEDIR,
|
514 |
+
"wfu_uploadprogress_mode" => WFU_VAR("WFU_UPLOADPROGRESS_MODE"),
|
515 |
+
"wfu_consent_notcompleted" => WFU_WARNING_CONSENT_NOTCOMPLETED
|
516 |
+
);
|
517 |
+
$consts_txt = "";
|
518 |
+
foreach ( $consts as $key => $val )
|
519 |
+
$consts_txt .= ( $consts_txt == "" ? "" : ";" ).wfu_plugin_encode_string($key).":".wfu_plugin_encode_string($val);
|
520 |
+
|
521 |
+
return $consts_txt;
|
522 |
}
|
lib/wfu_functions.php
CHANGED
@@ -1,6812 +1,7162 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* General Use Functions of Plugin
|
5 |
-
*
|
6 |
-
* This file contains general use functions of the plugin.
|
7 |
-
*
|
8 |
-
* @link /lib/wfu_functions.php
|
9 |
-
*
|
10 |
-
* @package WordPress File Upload Plugin
|
11 |
-
* @subpackage Core Components
|
12 |
-
* @since 2.1.2
|
13 |
-
*/
|
14 |
-
|
15 |
-
//********************* Debug Functions ****************************************
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Hook on plugin's functions.
|
19 |
-
*
|
20 |
-
* This is a very powerful function that enables almost all plugin functions to
|
21 |
-
* be redeclared, either in whole or partially. Here is what it can do:
|
22 |
-
*
|
23 |
-
* - It can execute a hook, based on the function parameters and then
|
24 |
-
* execute the original function.
|
25 |
-
* - It can execute a hook, based on the function's parameters and then
|
26 |
-
* return without executing the original function. This mode is like
|
27 |
-
* entirely redeclaring the original function.
|
28 |
-
* - It can execute a hook after execution of the original function.
|
29 |
-
* - It can redeclare the function parameters or pass new variables to the
|
30 |
-
* original function.
|
31 |
-
*
|
32 |
-
* In order to make a function redeclarable we just need to put the
|
33 |
-
* following 'magic' code at the top of its function block:
|
34 |
-
*
|
35 |
-
* $a = func_get_args(); $a = WFU_FUNCTION_HOOK(__FUNCTION__, $a, $out);
|
36 |
-
* if (isset($out['vars'])) foreach($out['vars'] as $p => $v) $$p = $v;
|
37 |
-
* switch($a) { case 'R': return $out['output']; break; case 'D':
|
38 |
-
* die($out['output']); }
|
39 |
-
*
|
40 |
-
* Then the function can be hooked through the filter wfu_debug-{__FUNCTION__}.
|
41 |
-
*
|
42 |
-
* The hook function takes the same parameters as the original function, plus
|
43 |
-
* one, which comes first and determines the behaviour of the hook function.
|
44 |
-
*
|
45 |
-
* This parameter is an array having three items as follows:
|
46 |
-
*
|
47 |
-
* - item 'output' contains the output of the original function (if exists)
|
48 |
-
* - item 'result' has no meaning as input parameter but as returning one
|
49 |
-
* - item 'vars' has no meaning as input parameter but as returning one
|
50 |
-
*
|
51 |
-
* The hook function must return the same array as follows:
|
52 |
-
*
|
53 |
-
* - item 'output' must contain the hook's output
|
54 |
-
* - item 'result' must be either 'X', 'R', or 'D' when the hook is executed
|
55 |
-
* at the beginning of the function, as explained below. It determines how
|
56 |
-
* the hook will be handled, as follows:
|
57 |
-
* - If 'result' is 'X' then the result of the hook function will be
|
58 |
-
* ignored and the original function will be executed afterwards.
|
59 |
-
* - If 'result' is 'R' then the original function will terminate
|
60 |
-
* returning the output of the hook function. So it is like having been
|
61 |
-
* entirely substituted by the hook function.
|
62 |
-
* - If 'result' is 'D' then the original function will die returning the
|
63 |
-
* output of the hook function. This applies to ajax handlers.
|
64 |
-
* In the case that the hook is executed at the end of the function, then
|
65 |
-
* item 'result' must always be 'R'.
|
66 |
-
* - item 'vars' is an associative array that contains any variables that the
|
67 |
-
* hook wants to pass to the original function like this:
|
68 |
-
* $res['output'] = array('varname1' => value1, 'varname2' => value2);
|
69 |
-
* Item 'vars' can be used to redeclare the function arguments and it is a
|
70 |
-
* workaround to handling arguments passed by reference.
|
71 |
-
*
|
72 |
-
* It is noted that the hook can be executed either before or after execution
|
73 |
-
* of the original function, despite the fact that the 'magic' code is added
|
74 |
-
* to the beginning of the function.
|
75 |
-
*
|
76 |
-
* - To execute the hook before the function a global variable with name
|
77 |
-
* wfu_debug-{__FUNCTION__} must be declared.
|
78 |
-
* - To execute the hook after the function a global variable with name
|
79 |
-
* wfu_debug_end-{__FUNCTION__} must be declared.
|
80 |
-
*
|
81 |
-
* It is noted that if both of these global variables are declared, or none of
|
82 |
-
* them then the hook will not work.
|
83 |
-
*
|
84 |
-
* Arguments passed by reference: When declaring the hook filter, all arguments
|
85 |
-
* are passed by value, even if some of the original function's arguments pass
|
86 |
-
* by reference. However no PHP warnings and errors will be generated due to
|
87 |
-
* this difference. If the hook wants to change the value of an argument and
|
88 |
-
* reflect this change to the original function, it is possible through item
|
89 |
-
* 'vars' explained above. For example, if the original function passes
|
90 |
-
* argument $var1 by reference (it is declared as &$var1 in the function
|
91 |
-
* parameters), we cannot use the syntax $var1 = ...; inside the hook filter
|
92 |
-
* but we can use the syntax $res['vars']['var1'] = ...; and this will result
|
93 |
-
* $var1 in the original function to get the new value!
|
94 |
-
*
|
95 |
-
* @since 3.11.0
|
96 |
-
*
|
97 |
-
* @param string $function The function name of the original function.
|
98 |
-
* @param array $args An array of parameters of the original function.
|
99 |
-
* @param string $out Tt stores the output of the hook function.
|
100 |
-
*
|
101 |
-
* @return string Returns how the hook function will be handled ('X': hook
|
102 |
-
* output must be ignored, 'R': the original function must return the
|
103 |
-
* hook's output, 'D': the original function must die returning the
|
104 |
-
* hook's output).
|
105 |
-
*/
|
106 |
-
function WFU_FUNCTION_HOOK($function, $args, &$out) {
|
107 |
-
// exit if plugin's debug mode is off or the hook has not been declared in
|
108 |
-
// global variables;
|
109 |
-
if ( WFU_VAR("WFU_DEBUG") != "ON" || !( isset($GLOBALS["wfu_debug-".$function]) xor isset($GLOBALS["wfu_debug_end-".$function]) ) ) return 'X';
|
110 |
-
// exit if function name is empty or invalid
|
111 |
-
if ( $function == "" || preg_replace("/[^0-9a-zA-Z_]/", "", $function) != $function ) return 'X';
|
112 |
-
//if the hook has been declared in global variables with wfu_debug_end-
|
113 |
-
//prefix then it will run at the end of the function
|
114 |
-
if ( isset($GLOBALS["wfu_debug_end-".$function]) ) {
|
115 |
-
$args_count = count($args);
|
116 |
-
//if a flag (specific string) is contained in the last position of the
|
117 |
-
//arguments list then do not re-execute the hook as this is the second
|
118 |
-
//pass
|
119 |
-
if ( $args_count > 0 && $args[$args_count - 1] === "wfu_debug_end-".$function."-second_pass" ) return 'X';
|
120 |
-
else {
|
121 |
-
//create an array of references to the function arguments and pass
|
122 |
-
//this to call_user_func_array instead of $args; this is a
|
123 |
-
//workaround to avoid PHP warnings when the original function passes
|
124 |
-
//arguments by reference
|
125 |
-
$args_byref = array();
|
126 |
-
foreach ( $args as $key => &$arg ) $args_byref[$key] = &$arg;
|
127 |
-
//add a flag (specific string) as the last argument in order to
|
128 |
-
//denote that the next execution of the hook is the second pass
|
129 |
-
array_push($args_byref, "wfu_debug_end-".$function."-second_pass");
|
130 |
-
//call the original function and get the returned value; it will
|
131 |
-
//contain the flag in the arguments, so the hook will not be
|
132 |
-
//executed again and the whole script will not be put in an infinite
|
133 |
-
//loop
|
134 |
-
$ret = call_user_func_array($function, $args_byref);
|
135 |
-
//pass the original function's output to the hook
|
136 |
-
array_splice($args, 0, 0, array( array( "output" => $ret, "result" => "X", "vars" => array() ) ));
|
137 |
-
/**
|
138 |
-
* Hook on a Specific Function.
|
139 |
-
*
|
140 |
-
* This filter allows to redeclare, or change the behaviour, of the
|
141 |
-
* original function $function.
|
142 |
-
*
|
143 |
-
* @since 3.11.0
|
144 |
-
*
|
145 |
-
* @param array $args Array of parameters of the original function.
|
146 |
-
*/
|
147 |
-
$res = apply_filters_ref_array("wfu_debug-".$function, $args);
|
148 |
-
if ( !is_array($res) || !isset($res["output"]) || !isset($res["result"]) ) $res = array( "output" => $ret, "result" => "R" );
|
149 |
-
if ( $res["result"] != 'R' ) $res["result"] = 'R';
|
150 |
-
if ( isset($res["vars"]) && !is_array($res["vars"]) ) $res["vars"] = array();
|
151 |
-
$out = $res;
|
152 |
-
return $res["result"];
|
153 |
-
}
|
154 |
-
}
|
155 |
-
else {
|
156 |
-
// prepare the arguments for the hook
|
157 |
-
array_splice($args, 0, 0, array( array( "output" => "", "result" => "X", "vars" => array() ) ));
|
158 |
-
/** This hook is decribed above. */
|
159 |
-
$res = apply_filters_ref_array("wfu_debug-".$function, $args);
|
160 |
-
// exit if $res is invalid
|
161 |
-
if ( !is_array($res) || !isset($res["output"]) || !isset($res["result"]) ) $res = array( "output" => "", "result" => "X" );
|
162 |
-
if ( $res["result"] != 'X' && $res["result"] != 'R' && $res["result"] != 'D' ) $res["result"] = 'X';
|
163 |
-
if ( isset($res["vars"]) && !is_array($res["vars"]) ) $res["vars"] = array();
|
164 |
-
$out = $res;
|
165 |
-
// if result is 'X' then the caller must ignore the hook
|
166 |
-
// if result is 'R' then the caller must return the hook's output
|
167 |
-
// if result is 'D' then the caller must die returning the hook's output
|
168 |
-
return $res["result"];
|
169 |
-
}
|
170 |
-
}
|
171 |
-
|
172 |
-
//********************* String Functions ***************************************
|
173 |
-
|
174 |
-
/**
|
175 |
-
* Sanitize Filename.
|
176 |
-
*
|
177 |
-
* This function sanitizes filename so that it is compatible with most file
|
178 |
-
* systems. Invalid non-latin characters will be converted into dashes.
|
179 |
-
*
|
180 |
-
* @since 2.1.2
|
181 |
-
*
|
182 |
-
* @param string $filename The file name.
|
183 |
-
*
|
184 |
-
* @return string The sanitized file name.
|
185 |
-
*/
|
186 |
-
function wfu_upload_plugin_clean($filename) {
|
187 |
-
$clean = sanitize_file_name($filename);
|
188 |
-
if ( WFU_VAR("WFU_SANITIZE_FILENAME_MODE") != "loose" ) {
|
189 |
-
$name = wfu_filename($clean);
|
190 |
-
$ext = wfu_fileext($clean);
|
191 |
-
if ( WFU_VAR("WFU_SANITIZE_FILENAME_DOTS") == "true" ) $name_search = array ( '@[^a-zA-Z0-9_]@' );
|
192 |
-
else $name_search = array ( '@[^a-zA-Z0-9._]@' );
|
193 |
-
$ext_search = array ( '@[^a-zA-Z0-9._]@' );
|
194 |
-
$replace = array ( '-' );
|
195 |
-
$clean_name = preg_replace($name_search, $replace, remove_accents($name));
|
196 |
-
$clean_ext = preg_replace($ext_search, $replace, remove_accents($ext));
|
197 |
-
$clean = $clean_name.".".$clean_ext;
|
198 |
-
}
|
199 |
-
|
200 |
-
return $clean;
|
201 |
-
}
|
202 |
-
|
203 |
-
/**
|
204 |
-
* Wildcard Conversion Callback.
|
205 |
-
*
|
206 |
-
* This function is a callback used in a preg_replace_callback() function to
|
207 |
-
* convert wildcard syntax to natural expression.
|
208 |
-
*
|
209 |
-
* @since 3.9.0
|
210 |
-
*
|
211 |
-
* @global array $wfu_preg_replace_callback_var An array with matches.
|
212 |
-
*
|
213 |
-
* @param array $matches An array of matches of preg_replace_callback().
|
214 |
-
*
|
215 |
-
* @return string The result of the callback processing the matches.
|
216 |
-
*/
|
217 |
-
function _wildcard_to_preg_preg_replace_callback($matches) {
|
218 |
-
global $wfu_preg_replace_callback_var;
|
219 |
-
array_push($wfu_preg_replace_callback_var, $matches[0]);
|
220 |
-
$key = count($wfu_preg_replace_callback_var) - 1;
|
221 |
-
return "[".$key."]";
|
222 |
-
}
|
223 |
-
|
224 |
-
/**
|
225 |
-
* Wildcard To Natural Expression Conversion.
|
226 |
-
*
|
227 |
-
* This function converts wildcard syntax of a pattern to natural expression.
|
228 |
-
*
|
229 |
-
* @since 2.1.2
|
230 |
-
*
|
231 |
-
* @global array $wfu_preg_replace_callback_var An array with matches.
|
232 |
-
*
|
233 |
-
* @param string $pattern The pattern to convert.
|
234 |
-
* @param bool $strict Optional. Strict matching. If true, dot symbols (.) will
|
235 |
-
* not be matched.
|
236 |
-
*
|
237 |
-
* @return The converted natural expression pattern.
|
238 |
-
*/
|
239 |
-
function wfu_upload_plugin_wildcard_to_preg($pattern, $strict = false) {
|
240 |
-
global $wfu_preg_replace_callback_var;
|
241 |
-
$wfu_preg_replace_callback_var = array();
|
242 |
-
$pattern = preg_replace_callback("/\[(.*?)\]/", "_wildcard_to_preg_preg_replace_callback", $pattern);
|
243 |
-
if ( !$strict ) $pattern = '/^' . str_replace(array('\*', '\?', '\[', '\]'), array('.*', '.', '[', ']'), preg_quote($pattern)) . '$/is';
|
244 |
-
else $pattern = '/^' . str_replace(array('\*', '\?', '\[', '\]'), array('[^.]*', '.', '[', ']'), preg_quote($pattern)) . '$/is';
|
245 |
-
foreach ($wfu_preg_replace_callback_var as $key => $match)
|
246 |
-
$pattern = str_replace("[".$key."]", $match, $pattern);
|
247 |
-
return $pattern;
|
248 |
-
}
|
249 |
-
|
250 |
-
/**
|
251 |
-
* Wildcard To MySQL Natural Expression Conversion.
|
252 |
-
*
|
253 |
-
* This function converts wildcard syntax of a pattern to MySQL natural
|
254 |
-
* expression.
|
255 |
-
*
|
256 |
-
* @since 3.2.1
|
257 |
-
*
|
258 |
-
* @redeclarable
|
259 |
-
*
|
260 |
-
* @param string $pattern The pattern to convert.
|
261 |
-
*
|
262 |
-
* @return The converted MySQL natural expression pattern.
|
263 |
-
*/
|
264 |
-
function wfu_upload_plugin_wildcard_to_mysqlregexp($pattern) {
|
265 |
-
$a = func_get_args(); $a = WFU_FUNCTION_HOOK(__FUNCTION__, $a, $out); if (isset($out['vars'])) foreach($out['vars'] as $p => $v) $$p = $v; switch($a) { case 'R': return $out['output']; break; case 'D': die($out['output']); }
|
266 |
-
if ( substr($pattern, 0, 6) == "regex:" ) return str_replace("\\", "\\\\", substr($pattern, 6));
|
267 |
-
else return str_replace("\\", "\\\\", '^'.str_replace(array('\*', '\?', '\[', '\]'), array('.*', '.', '[', ']'), preg_quote($pattern)).'$');
|
268 |
-
}
|
269 |
-
|
270 |
-
/**
|
271 |
-
* Match String With Pattern.
|
272 |
-
*
|
273 |
-
* This function checks if a specific string matches with a pattern.
|
274 |
-
*
|
275 |
-
* @since 2.1.2
|
276 |
-
*
|
277 |
-
* @param string $pattern The pattern to match.
|
278 |
-
* @param string $str The string to match.
|
279 |
-
* @param bool $strict Defines whether strict mode will be used. In strict mode
|
280 |
-
* dot symbols (.) are not considered as normal characters and are not
|
281 |
-
* matched with preg * symbol.
|
282 |
-
*
|
283 |
-
* @return bool True if there is a match, false otherwise.
|
284 |
-
*/
|
285 |
-
function wfu_upload_plugin_wildcard_match($pattern, $str, $strict = false) {
|
286 |
-
$pattern = wfu_upload_plugin_wildcard_to_preg($pattern, $strict);
|
287 |
-
return preg_match($pattern, $str);
|
288 |
-
}
|
289 |
-
|
290 |
-
/**
|
291 |
-
* Convert String to Hex.
|
292 |
-
*
|
293 |
-
* This function converts every character of a string into a 2-byte hex
|
294 |
-
* representation.
|
295 |
-
*
|
296 |
-
* @since 2.1.2
|
297 |
-
*
|
298 |
-
* @param string $string The string to convert.
|
299 |
-
*
|
300 |
-
* @return string The converted hex string.
|
301 |
-
*/
|
302 |
-
function wfu_plugin_encode_string($string) {
|
303 |
-
$array = unpack('H*', $string);
|
304 |
-
return $array[1];
|
305 |
-
|
306 |
-
$array = unpack('C*', $string);
|
307 |
-
$new_string = "";
|
308 |
-
for ($i = 1; $i <= count($array); $i ++) {
|
309 |
-
$new_string .= sprintf("%02X", $array[$i]);
|
310 |
-
}
|
311 |
-
return $new_string;
|
312 |
-
}
|
313 |
-
|
314 |
-
/**
|
315 |
-
* Convert Hex to String.
|
316 |
-
*
|
317 |
-
* This function converts a hex string into a normal ASCII string.
|
318 |
-
*
|
319 |
-
* @since 2.1.2
|
320 |
-
*
|
321 |
-
* @param string $string The hex string to convert.
|
322 |
-
*
|
323 |
-
* @return string The converted ASCII string.
|
324 |
-
*/
|
325 |
-
function wfu_plugin_decode_string($string) {
|
326 |
-
return pack('H*', $string);
|
327 |
-
|
328 |
-
$new_string = "";
|
329 |
-
for ($i = 0; $i < strlen($string); $i += 2 ) {
|
330 |
-
$new_string .= sprintf("%c", hexdec(substr($string, $i ,2)));
|
331 |
-
}
|
332 |
-
return $new_string;
|
333 |
-
}
|
334 |
-
|
335 |
-
/**
|
336 |
-
* Create a Random String.
|
337 |
-
*
|
338 |
-
* This function creates a random string composing of latin letters and numbers.
|
339 |
-
*
|
340 |
-
* @since 2.1.2
|
341 |
-
*
|
342 |
-
* @param integer $len The length of the string.
|
343 |
-
* @param bool $hex True if a hex string must be generated.
|
344 |
-
*
|
345 |
-
* @return string The random string.
|
346 |
-
*/
|
347 |
-
function wfu_create_random_string($len, $hex = false) {
|
348 |
-
$base1 = 'ABCDEFGHKLMNOPQRSTWXYZabcdefghjkmnpqrstwxyz123456789';
|
349 |
-
$base2 = 'ABCDEFGHKLMNOPQRSTWXYZabcdefghjkmnpqrstwxyz123456789';
|
350 |
-
if ( $hex ) {
|
351 |
-
$base1 = 'abcdef123456789';
|
352 |
-
$base2 = 'abcdef0123456789';
|
353 |
-
}
|
354 |
-
$max1 = strlen($base1) - 1;
|
355 |
-
$max2 = strlen($base2) - 1;
|
356 |
-
$activatecode = '';
|
357 |
-
if ( WFU_VAR("WFU_ALTERNATIVE_RANDOMIZER") != "true" )
|
358 |
-
mt_srand((double)microtime()*1000000);
|
359 |
-
else mt_srand((double)substr(uniqid("", true), 15));
|
360 |
-
$is_first = true;
|
361 |
-
while (strlen($activatecode) < $len) {
|
362 |
-
if ( $is_first ) {
|
363 |
-
$activatecode .= $base1[mt_rand(0, $max1)];
|
364 |
-
$is_first = false;
|
365 |
-
}
|
366 |
-
else $activatecode .= $base2[mt_rand(0, $max2)];
|
367 |
-
}
|
368 |
-
return $activatecode;
|
369 |
-
}
|
370 |
-
|
371 |
-
/**
|
372 |
-
* Join Two or More Strings.
|
373 |
-
*
|
374 |
-
* This function joins one or more strings. The strings are passed in the
|
375 |
-
* function as 2nd, 3rd, 4rth and so on parameters.
|
376 |
-
*
|
377 |
-
* @since 2.1.2
|
378 |
-
*
|
379 |
-
* @param string $delimeter The delimeter to use to join the strings.
|
380 |
-
*
|
381 |
-
* @return string The resulted joined string.
|
382 |
-
*/
|
383 |
-
function wfu_join_strings($delimeter) {
|
384 |
-
$arr = func_get_args();
|
385 |
-
unset($arr[0]);
|
386 |
-
foreach ($arr as $key => $item)
|
387 |
-
if ( $item == "" ) unset($arr[$key]);
|
388 |
-
return join($delimeter, $arr);
|
389 |
-
}
|
390 |
-
|
391 |
-
/**
|
392 |
-
* Create a String of Zeros.
|
393 |
-
*
|
394 |
-
* This function creates a string filled with zeros. It is designed to be fast
|
395 |
-
* even when the length of the string is large.
|
396 |
-
*
|
397 |
-
* @since 2.1.2
|
398 |
-
*
|
399 |
-
* @param integer $size The size of the string.
|
400 |
-
*
|
401 |
-
* @return string The resulted string.
|
402 |
-
*/
|
403 |
-
function wfu_create_string($size) {
|
404 |
-
$piece = str_repeat("0", 1024);
|
405 |
-
$str = "";
|
406 |
-
$reps = $size / 1024;
|
407 |
-
$rem = $size - 1024 * $reps;
|
408 |
-
for ( $i = 0; $i < $reps; $i++ ) $str .= $piece;
|
409 |
-
$str .= substr($piece, 0, $rem);
|
410 |
-
return $str;
|
411 |
-
}
|
412 |
-
|
413 |
-
/**
|
414 |
-
* Prepare String for HTML Output.
|
415 |
-
*
|
416 |
-
* This function converts newline characters into <br> tags and tabs/spaces into
|
417 |
-
* entities, so that they can be property shown in HTML output.
|
418 |
-
*
|
419 |
-
* @since 2.7.1
|
420 |
-
*
|
421 |
-
* @param string $output The string to be sent to output.
|
422 |
-
*
|
423 |
-
* @return string The converted HTML ready string.
|
424 |
-
*/
|
425 |
-
function wfu_html_output($output) {
|
426 |
-
$output = str_replace(array("\r\n", "\r", "\n"), "<br/>", $output);
|
427 |
-
return str_replace(array("\t", " "), " ", $output);
|
428 |
-
}
|
429 |
-
|
430 |
-
/**
|
431 |
-
* Sanitize a Code.
|
432 |
-
*
|
433 |
-
* This function sanitizes a code. A code must only contain latin letters and
|
434 |
-
* numbers.
|
435 |
-
*
|
436 |
-
* @since 3.0.0
|
437 |
-
*
|
438 |
-
* @param string $code The code to sanitize.
|
439 |
-
*
|
440 |
-
* @return string The sanitized code.
|
441 |
-
*/
|
442 |
-
function wfu_sanitize_code($code) {
|
443 |
-
return preg_replace("/[^A-Za-z0-9]/", "", $code);
|
444 |
-
}
|
445 |
-
|
446 |
-
/**
|
447 |
-
* Sanitize an Integer.
|
448 |
-
*
|
449 |
-
* This function sanitizes an integer (passed as string). An integer must only
|
450 |
-
* contain numbers, plus (+) and minus (-) symbols.
|
451 |
-
*
|
452 |
-
* @since 3.1.0
|
453 |
-
*
|
454 |
-
* @param string $code The integer to sanitize passed as string.
|
455 |
-
*
|
456 |
-
* @return string The sanitized integer returned as string.
|
457 |
-
*/
|
458 |
-
function wfu_sanitize_int($code) {
|
459 |
-
return preg_replace("/[^0-9+\-]/", "", $code);
|
460 |
-
}
|
461 |
-
|
462 |
-
/**
|
463 |
-
* Sanitize a Float.
|
464 |
-
*
|
465 |
-
* This function sanitizes a float (passed as string). A float must only contain
|
466 |
-
* numbers, plus (+), minus (-), dot (.) and comma (,) symbols.
|
467 |
-
*
|
468 |
-
* @since 4.3.3
|
469 |
-
*
|
470 |
-
* @param string $code The float to sanitize passed as string.
|
471 |
-
*
|
472 |
-
* @return string The sanitized float returned as string.
|
473 |
-
*/
|
474 |
-
function wfu_sanitize_float($code) {
|
475 |
-
return preg_replace("/[^0-9+\-\.,]/", "", $code);
|
476 |
-
}
|
477 |
-
|
478 |
-
/**
|
479 |
-
* Sanitize a Color Value.
|
480 |
-
*
|
481 |
-
* This function sanitizes a color value. A color value must only contain
|
482 |
-
* characters a-f or A-F, numbers, number sign (#) and comma (,) symbols.
|
483 |
-
*
|
484 |
-
* @since 4.3.3
|
485 |
-
*
|
486 |
-
* @param string $code The color value to sanitize.
|
487 |
-
*
|
488 |
-
* @return string The sanitized color value.
|
489 |
-
*/
|
490 |
-
function wfu_sanitize_colors($code) {
|
491 |
-
return preg_replace("/[^A-Fa-f0-9#,]/", "", $code);
|
492 |
-
}
|
493 |
-
|
494 |
-
/**
|
495 |
-
* Sanitize a Tag.
|
496 |
-
*
|
497 |
-
* This function sanitizes a tag. A tag must only contain latin characters,
|
498 |
-
* numbers and underscore (_) symbols.
|
499 |
-
*
|
500 |
-
* @since 3.1.0
|
501 |
-
*
|
502 |
-
* @param string $code The tag to sanitize.
|
503 |
-
*
|
504 |
-
* @return string The sanitized tag.
|
505 |
-
*/
|
506 |
-
function wfu_sanitize_tag($code) {
|
507 |
-
return preg_replace("/[^A-Za-z0-9_]/", "", $code);
|
508 |
-
}
|
509 |
-
|
510 |
-
/**
|
511 |
-
* Sanitize a URL.
|
512 |
-
*
|
513 |
-
* This function sanitizes a URL.
|
514 |
-
*
|
515 |
-
* @since 3.11.0
|
516 |
-
*
|
517 |
-
* @param string $url The URL to sanitize.
|
518 |
-
*
|
519 |
-
* @return string The sanitized URL.
|
520 |
-
*/
|
521 |
-
function wfu_sanitize_url($url) {
|
522 |
-
return filter_var(strip_tags($url), FILTER_SANITIZE_URL);
|
523 |
-
}
|
524 |
-
|
525 |
-
/**
|
526 |
-
* Sanitize a List of URL.
|
527 |
-
*
|
528 |
-
* This function sanitizes a list of URLs.
|
529 |
-
*
|
530 |
-
* @since 3.11.0
|
531 |
-
*
|
532 |
-
* @param string $urls The URLs to sanitize.
|
533 |
-
* @param string $separator The delimeter character of the URLs.
|
534 |
-
*
|
535 |
-
* @return string The sanitized URLs.
|
536 |
-
*/
|
537 |
-
function wfu_sanitize_urls($urls, $separator) {
|
538 |
-
$urls_arr = explode($separator, $urls);
|
539 |
-
foreach( $urls_arr as &$url ) $url = wfu_sanitize_url($url);
|
540 |
-
return implode($separator, $urls_arr);
|
541 |
-
}
|
542 |
-
|
543 |
-
/**
|
544 |
-
* Sanitize a Shortcode.
|
545 |
-
*
|
546 |
-
* This function sanitizes a shortcode, that is sanitizes all its attributes.
|
547 |
-
*
|
548 |
-
* @since 4.3.3
|
549 |
-
*
|
550 |
-
* @param string $shortcode The shortcode to sanitize.
|
551 |
-
* @param string $shortcode_tag The shortcode tag.
|
552 |
-
*
|
553 |
-
* @return string The sanitized shortcode.
|
554 |
-
*/
|
555 |
-
function wfu_sanitize_shortcode($shortcode, $shortcode_tag) {
|
556 |
-
$attrs = wfu_shortcode_string_to_array($shortcode);
|
557 |
-
$sanitized_attrs = wfu_sanitize_shortcode_array($attrs, $shortcode_tag);
|
558 |
-
//reconstruct sanitized shortcode string from array
|
559 |
-
$sanitized_shortcode = "";
|
560 |
-
foreach ( $sanitized_attrs as $attr => $value )
|
561 |
-
$sanitized_shortcode .= ( $sanitized_shortcode == "" ? "" : " " ).$attr.'="'.$value.'"';
|
562 |
-
|
563 |
-
return $sanitized_shortcode;
|
564 |
-
}
|
565 |
-
|
566 |
-
/**
|
567 |
-
* Sanitize Shortcode Attributes.
|
568 |
-
*
|
569 |
-
* This function sanitizes an array of shortcode attributes.
|
570 |
-
*
|
571 |
-
* @since 4.5.1
|
572 |
-
*
|
573 |
-
* @param array $attrs An array of shortcode attributes to sanitize.
|
574 |
-
* @param string $shortcode_tag The shortcode tag.
|
575 |
-
*
|
576 |
-
* @return array The sanitized array of shortcode attributes.
|
577 |
-
*/
|
578 |
-
function wfu_sanitize_shortcode_array($attrs, $shortcode_tag) {
|
579 |
-
$sanitized_attrs = array();
|
580 |
-
if ( $shortcode_tag == 'wordpress_file_upload' ) $defs = wfu_attribute_definitions();
|
581 |
-
else $defs = wfu_browser_attribute_definitions();
|
582 |
-
// get validator types for defs
|
583 |
-
$def_validators = array();
|
584 |
-
foreach ( $defs as $def ) $def_validators[$def['attribute']] = $def['validator'];
|
585 |
-
// sanitize each attribute
|
586 |
-
foreach ( $attrs as $attr => $value ) {
|
587 |
-
//first sanitize the attribute name
|
588 |
-
$sanitized = sanitize_text_field($attr);
|
589 |
-
//continue only for attributes that sanitization did not crop any
|
590 |
-
//characters
|
591 |
-
if ( $sanitized == $attr && $attr != "" ) {
|
592 |
-
//flatten attributes that have many occurencies
|
593 |
-
$flat = preg_replace("/^(.*?)[0-9]*$/", "$1", $attr);
|
594 |
-
//get validator type
|
595 |
-
$validator = "text";
|
596 |
-
if ( isset($def_validators[$flat]) ) $validator = $def_validators[$flat];
|
597 |
-
//sanitize value based on validator type
|
598 |
-
$new_value = $value;
|
599 |
-
switch( $validator ) {
|
600 |
-
case "text":
|
601 |
-
$new_value = wp_strip_all_tags($value);
|
602 |
-
break;
|
603 |
-
case "integer":
|
604 |
-
$new_value = wfu_sanitize_int($value);
|
605 |
-
break;
|
606 |
-
case "float":
|
607 |
-
$new_value = wfu_sanitize_float($value);
|
608 |
-
break;
|
609 |
-
case "path":
|
610 |
-
$new_value = wp_strip_all_tags($value);
|
611 |
-
break;
|
612 |
-
case "link":
|
613 |
-
$new_value = wp_strip_all_tags($value);
|
614 |
-
break;
|
615 |
-
case "emailheaders":
|
616 |
-
if ( strpos(strtolower($value), "<script") !== false ) $new_value = "";
|
617 |
-
break;
|
618 |
-
case "emailsubject":
|
619 |
-
if ( strpos(strtolower($value), "<script") !== false ) $new_value = "";
|
620 |
-
break;
|
621 |
-
case "emailbody":
|
622 |
-
if ( strpos(strtolower($value), "<script") !== false ) $new_value = "";
|
623 |
-
break;
|
624 |
-
case "colors":
|
625 |
-
$new_value = wfu_sanitize_colors($value);
|
626 |
-
break;
|
627 |
-
case "css":
|
628 |
-
$new_value = wp_strip_all_tags($value);
|
629 |
-
break;
|
630 |
-
case "datetime":
|
631 |
-
$new_value = wp_strip_all_tags($value);
|
632 |
-
break;
|
633 |
-
case "pattern":
|
634 |
-
if ( substr_count($value, "'") > 0 && substr_count($value, "'") > substr_count($value, "\\'") ) $new_value = "";
|
635 |
-
break;
|
636 |
-
default:
|
637 |
-
$new_value = wp_strip_all_tags($value);
|
638 |
-
}
|
639 |
-
/**
|
640 |
-
* Custom Shortcode Sanitization.
|
641 |
-
*
|
642 |
-
* This filter allows custom actions to change the sanitization
|
643 |
-
* result of shortcode attributes.
|
644 |
-
*
|
645 |
-
* @since 4.3.3
|
646 |
-
*
|
647 |
-
* @param string $new_value New sanitized value of the attribute.
|
648 |
-
* @param string $attr The attribute name.
|
649 |
-
* @param string $validator The type of attribute used to determine
|
650 |
-
* the type of validator to use.
|
651 |
-
* @param string $value The initial value of the attribute.
|
652 |
-
*/
|
653 |
-
$new_value = apply_filters("_wfu_sanitize_shortcode", $new_value, $attr, $validator, $value);
|
654 |
-
$sanitized_attrs[$attr] = $new_value;
|
655 |
-
}
|
656 |
-
}
|
657 |
-
|
658 |
-
return $sanitized_attrs;
|
659 |
-
}
|
660 |
-
|
661 |
-
/**
|
662 |
-
* Escape a Variable.
|
663 |
-
*
|
664 |
-
* This function escapes (adds backslashes before characters that need to be
|
665 |
-
* escaped) a variable, even if it is an array of unlimited depth.
|
666 |
-
*
|
667 |
-
* @since 3.3.0
|
668 |
-
*
|
669 |
-
* @param mixed $value The variable to be escaped.
|
670 |
-
*
|
671 |
-
* @return mixed The escaped variable.
|
672 |
-
*/
|
673 |
-
function wfu_slash( $value ) {
|
674 |
-
if ( is_array( $value ) ) {
|
675 |
-
foreach ( $value as $k => $v ) {
|
676 |
-
if ( is_array( $v ) ) {
|
677 |
-
$value[$k] = wfu_slash( $v );
|
678 |
-
}
|
679 |
-
else {
|
680 |
-
$value[$k] = addslashes( $v );
|
681 |
-
}
|
682 |
-
}
|
683 |
-
}
|
684 |
-
else {
|
685 |
-
$value = addslashes( $value );
|
686 |
-
}
|
687 |
-
|
688 |
-
return $value;
|
689 |
-
}
|
690 |
-
|
691 |
-
/**
|
692 |
-
* Generate a Global Short-Life Token.
|
693 |
-
*
|
694 |
-
* This function generates a short-life token that is stored in Wordpress
|
695 |
-
* Options and has a global scope (is accessible by all users).
|
696 |
-
*
|
697 |
-
* @since 3.5.0
|
698 |
-
*
|
699 |
-
* @param integer $timeout The life of the token in seconds.
|
700 |
-
*
|
701 |
-
* @return string The token.
|
702 |
-
*/
|
703 |
-
function wfu_generate_global_short_token($timeout) {
|
704 |
-
$token = wfu_create_random_string(16);
|
705 |
-
$expire = time() + (int)$timeout;
|
706 |
-
update_option('wfu_gst_'.$token, $expire);
|
707 |
-
return $token;
|
708 |
-
}
|
709 |
-
|
710 |
-
/**
|
711 |
-
* Verify a Global Short-Life Token.
|
712 |
-
*
|
713 |
-
* This function verifies that a global short-life token exists and it not
|
714 |
-
* expired. After verification the token is removed.
|
715 |
-
*
|
716 |
-
* @since 3.5.0
|
717 |
-
*
|
718 |
-
* @param string $token The token to verify.
|
719 |
-
*
|
720 |
-
* @return bool True if verification was successful, false otherwise.
|
721 |
-
*/
|
722 |
-
function wfu_verify_global_short_token($token) {
|
723 |
-
$timeout = get_option('wfu_gst_'.$token);
|
724 |
-
if ( $timeout === false ) return false;
|
725 |
-
delete_option('wfu_gst_'.$token);
|
726 |
-
return ( $timeout > time() );
|
727 |
-
}
|
728 |
-
|
729 |
-
/**
|
730 |
-
* Generate a User Short-Life Token.
|
731 |
-
*
|
732 |
-
* This function generates a short-life token that is stored in a user's User
|
733 |
-
* Space and has a user scope (is accessible only by this user).
|
734 |
-
*
|
735 |
-
* @since 4.9.0
|
736 |
-
*
|
737 |
-
* @param integer $timeout The life of the token in seconds.
|
738 |
-
*
|
739 |
-
* @return string The token.
|
740 |
-
*/
|
741 |
-
function wfu_generate_user_short_token($timeout) {
|
742 |
-
$token = wfu_create_random_string(16);
|
743 |
-
$expire = time() + (int)$timeout;
|
744 |
-
WFU_USVAR_store('wfu_ust_'.$token, $expire);
|
745 |
-
return $token;
|
746 |
-
}
|
747 |
-
|
748 |
-
/**
|
749 |
-
* Verify a User Short-Life Token.
|
750 |
-
*
|
751 |
-
* This function verifies that a user short-life token exists and it not
|
752 |
-
* expired. After verification the token is removed.
|
753 |
-
*
|
754 |
-
* @since 4.9.0
|
755 |
-
*
|
756 |
-
* @param string $token The token to verify.
|
757 |
-
*
|
758 |
-
* @return bool True if verification was successful, false otherwise.
|
759 |
-
*/
|
760 |
-
function wfu_verify_user_short_token($token) {
|
761 |
-
if ( !WFU_USVAR_exists('wfu_ust_'.$token) ) return false;
|
762 |
-
$timeout = WFU_USVAR('wfu_ust_'.$token);
|
763 |
-
WFU_USVAR_unset('wfu_ust_'.$token);
|
764 |
-
return ( $timeout > time() );
|
765 |
-
}
|
766 |
-
|
767 |
-
//********************* Array Functions ****************************************
|
768 |
-
|
769 |
-
/**
|
770 |
-
* Encode Array to String.
|
771 |
-
*
|
772 |
-
* This function converts an array to a JSON string and then encodes it to its
|
773 |
-
* hex representation.
|
774 |
-
*
|
775 |
-
* @since 2.1.2
|
776 |
-
*
|
777 |
-
* @param array $arr The array to encode.
|
778 |
-
*
|
779 |
-
* @return string The encoded hex string.
|
780 |
-
*/
|
781 |
-
function wfu_encode_array_to_string($arr) {
|
782 |
-
$arr_str = json_encode($arr);
|
783 |
-
$arr_str = wfu_plugin_encode_string($arr_str);
|
784 |
-
return $arr_str;
|
785 |
-
}
|
786 |
-
|
787 |
-
/**
|
788 |
-
* Decode Array from String.
|
789 |
-
*
|
790 |
-
* This function converts a hex string to its ASCII representation, which is a
|
791 |
-
* JSON string and then decodes it to an array.
|
792 |
-
*
|
793 |
-
* @since 2.1.2
|
794 |
-
*
|
795 |
-
* @param string $arr_str The encoded hex string to decode.
|
796 |
-
*
|
797 |
-
* @return array The decoded array.
|
798 |
-
*/
|
799 |
-
function wfu_decode_array_from_string($arr_str) {
|
800 |
-
$arr_str = wfu_plugin_decode_string($arr_str);
|
801 |
-
$arr = json_decode($arr_str, true);
|
802 |
-
return $arr;
|
803 |
-
}
|
804 |
-
|
805 |
-
/**
|
806 |
-
* Decode HTML Entities in Array.
|
807 |
-
*
|
808 |
-
* This function decodes HTML entities found in array values into their special
|
809 |
-
* characters. It is useful when reading a shortcode array.
|
810 |
-
*
|
811 |
-
* @since 2.1.2
|
812 |
-
*
|
813 |
-
* @param array $source The source array.
|
814 |
-
*
|
815 |
-
* @return array The decoded array.
|
816 |
-
*/
|
817 |
-
function wfu_plugin_parse_array($source) {
|
818 |
-
$keys = array_keys($source);
|
819 |
-
$new_arr = array();
|
820 |
-
for ($i = 0; $i < count($keys); $i ++)
|
821 |
-
$new_arr[$keys[$i]] = wp_specialchars_decode($source[$keys[$i]]);
|
822 |
-
return $new_arr;
|
823 |
-
}
|
824 |
-
|
825 |
-
/**
|
826 |
-
* Encode Special Characters in Array.
|
827 |
-
*
|
828 |
-
* This function converts special characters found in array values into HTML
|
829 |
-
* entities.
|
830 |
-
*
|
831 |
-
* @since 2.1.2
|
832 |
-
*
|
833 |
-
* @param array $arr The source array.
|
834 |
-
*
|
835 |
-
* @return array The encoded array.
|
836 |
-
*/
|
837 |
-
function wfu_safe_array($arr) {
|
838 |
-
return array_map("htmlspecialchars", $arr);
|
839 |
-
}
|
840 |
-
|
841 |
-
/**
|
842 |
-
* Remove Nulls from Array.
|
843 |
-
*
|
844 |
-
* This function removes null items from array.
|
845 |
-
*
|
846 |
-
* @since 2.1.2
|
847 |
-
*
|
848 |
-
* @param array $arr The source array.
|
849 |
-
*
|
850 |
-
* @return array The cleaned array.
|
851 |
-
*/
|
852 |
-
function wfu_array_remove_nulls(&$arr) {
|
853 |
-
foreach ( $arr as $key => $arri )
|
854 |
-
if ( $arri == null )
|
855 |
-
array_splice($arr, $key, 1);
|
856 |
-
}
|
857 |
-
|
858 |
-
/**
|
859 |
-
* Sanitize a Variable.
|
860 |
-
*
|
861 |
-
* This function sanitizes (converts special characters into HTML entities) a
|
862 |
-
* variable. If the variable is an array it will sanitize all elements
|
863 |
-
* recursively regardless of array depth. If the variable is not of an accepted
|
864 |
-
* type then its type will be returned.
|
865 |
-
*
|
866 |
-
* @since 2.4.4
|
867 |
-
*
|
868 |
-
* @param mixed $var The variable to sanitize.
|
869 |
-
*
|
870 |
-
* @return mixed The sanitized variable.
|
871 |
-
*/
|
872 |
-
function wfu_sanitize($var) {
|
873 |
-
$typ = gettype($var);
|
874 |
-
if ( $typ == "boolean" || $typ == "integer" || $typ == "double" || $typ == "resource" || $typ == "NULL" )
|
875 |
-
return $var;
|
876 |
-
elseif ( $typ == "string" )
|
877 |
-
return htmlspecialchars($var);
|
878 |
-
elseif ( $typ == "array" || $typ == "object" ) {
|
879 |
-
foreach ( $var as &$item ) $item = wfu_sanitize($item);
|
880 |
-
return $var;
|
881 |
-
}
|
882 |
-
else
|
883 |
-
return $typ;
|
884 |
-
}
|
885 |
-
|
886 |
-
/**
|
887 |
-
* Mask a Shortcode.
|
888 |
-
*
|
889 |
-
* This function is part of a process to safely parse a shortcode string into an
|
890 |
-
* associative array. It replaces all attribute values by tokens, so that it is
|
891 |
-
* easier and safer for the process to separate the attributes.
|
892 |
-
*
|
893 |
-
* @since 2.2.1
|
894 |
-
*
|
895 |
-
* @param string $contents The shortcode.
|
896 |
-
* @param string $token The token that replaces the shortcode attribute values.
|
897 |
-
*
|
898 |
-
* @return array An array of converted attributes.
|
899 |
-
*/
|
900 |
-
function _wfu_preg_replace_callback_alt($contents, $token) {
|
901 |
-
$in_block = false;
|
902 |
-
$prev_pos = 0;
|
903 |
-
$new_contents = '';
|
904 |
-
$ret['items'] = array();
|
905 |
-
$ret['tokens'] = array();
|
906 |
-
$ii = 0;
|
907 |
-
while ( ($pos = strpos($contents, '"', $prev_pos)) !== false ) {
|
908 |
-
if ( !$in_block ) {
|
909 |
-
$new_contents .= substr($contents, $prev_pos, $pos - $prev_pos + 1);
|
910 |
-
$in_block = true;
|
911 |
-
}
|
912 |
-
else {
|
913 |
-
$ret['items'][$ii] = substr($contents, $prev_pos, $pos - $prev_pos);
|
914 |
-
$ret['tokens'][$ii] = $token.sprintf('%03d', $ii);
|
915 |
-
$new_contents .= $token.sprintf('%03d', $ii).'"';
|
916 |
-
$ii ++;
|
917 |
-
$in_block = false;
|
918 |
-
}
|
919 |
-
$prev_pos = $pos + 1;
|
920 |
-
}
|
921 |
-
if ( $in_block ) {
|
922 |
-
$ret['items'][$ii] = substr($contents, $prev_pos);
|
923 |
-
$ret['tokens'][$ii] = $token.sprintf('%03d', $ii);
|
924 |
-
$new_contents .= $token.sprintf('%03d', $ii).'"';
|
925 |
-
}
|
926 |
-
else
|
927 |
-
$new_contents .= substr($contents, $prev_pos);
|
928 |
-
$ret['contents'] = $new_contents;
|
929 |
-
return $ret;
|
930 |
-
}
|
931 |
-
|
932 |
-
/**
|
933 |
-
* Parse a Shortcode.
|
934 |
-
*
|
935 |
-
* This function safely parses a shortcode string into an associative array.
|
936 |
-
*
|
937 |
-
* @since 2.1.3
|
938 |
-
*
|
939 |
-
* @param string $shortcode The shortcode.
|
940 |
-
*
|
941 |
-
* @return array The parsed shortcode as an associative array of attributes.
|
942 |
-
*/
|
943 |
-
function wfu_shortcode_string_to_array($shortcode) {
|
944 |
-
$i = 0;
|
945 |
-
$m1 = array();
|
946 |
-
$m2 = array();
|
947 |
-
//for some reason preg_replace_callback does not work in all cases, so it has been replaced by a similar custom inline routine
|
948 |
-
// $mm = preg_replace_callback('/"([^"]*)"/', function ($matches) use(&$i, &$m1, &$m2) {array_push($m1, $matches[1]); array_push($m2, "attr".$i); return "attr".$i++;}, $shortcode);
|
949 |
-
$ret = _wfu_preg_replace_callback_alt($shortcode, "attr");
|
950 |
-
$mm = $ret['contents'];
|
951 |
-
$m1 = $ret['items'];
|
952 |
-
$m2 = $ret['tokens'];
|
953 |
-
$arr = explode(" ", $mm);
|
954 |
-
$attrs = array();
|
955 |
-
foreach ( $arr as $attr ) {
|
956 |
-
if ( trim($attr) != "" ) {
|
957 |
-
$attr_arr = explode("=", $attr, 2);
|
958 |
-
$key = "";
|
959 |
-
if ( count($attr_arr) > 0 ) $key = $attr_arr[0];
|
960 |
-
$val = "";
|
961 |
-
if ( count($attr_arr) > 1 ) $val = $attr_arr[1];
|
962 |
-
if ( trim($key) != "" ) $attrs[trim($key)] = str_replace('"', '', $val);
|
963 |
-
}
|
964 |
-
}
|
965 |
-
$attrs2 = str_replace($m2, $m1, $attrs);
|
966 |
-
return $attrs2;
|
967 |
-
}
|
968 |
-
|
969 |
-
/**
|
970 |
-
* Compare Two Strings in Ascending Order.
|
971 |
-
*
|
972 |
-
* This function returns the comparison result of two strings. It is part of an
|
973 |
-
* array sorting mechanism.
|
974 |
-
*
|
975 |
-
* @since 3.8.5
|
976 |
-
*
|
977 |
-
* @param string $a The first string.
|
978 |
-
* @param string $b The second string.
|
979 |
-
*
|
980 |
-
* @return int Returns < 0 if a is less than b; > 0 if a is greater than b
|
981 |
-
* and 0 if they are equal.
|
982 |
-
*/
|
983 |
-
function wfu_array_sort_function_string_asc($a, $b) {
|
984 |
-
return strcmp(strtolower($a), strtolower($b));
|
985 |
-
}
|
986 |
-
|
987 |
-
/**
|
988 |
-
* Compare Two Strings Having a Second Property in Ascending Order.
|
989 |
-
*
|
990 |
-
* This function returns the comparison result of two strings. If the strings
|
991 |
-
* are equal then comparison will be done based on a second property (id0) of
|
992 |
-
* the strings, so that 0 is never returned. It is part of an array sorting
|
993 |
-
* mechanism.
|
994 |
-
*
|
995 |
-
* @since 3.8.5
|
996 |
-
*
|
997 |
-
* @param array $a The first string. It is passed as an array. 'value' item of
|
998 |
-
* the array is the string. 'id0' item is the second property.
|
999 |
-
* @param array $b The second string. It is passed as an array. 'value' item of
|
1000 |
-
* the array is the string. 'id0' item is the second property.
|
1001 |
-
*
|
1002 |
-
* @return int Returns < 0 if a is less than b; > 0 if a is greater.
|
1003 |
-
*/
|
1004 |
-
function wfu_array_sort_function_string_asc_with_id0($a, $b) {
|
1005 |
-
$cmp = strcmp(strtolower($a["value"]), strtolower($b["value"]));
|
1006 |
-
if ( $cmp == 0 ) $cmp = ( (int)$a["id0"] < (int)$b["id0"] ? -1 : 1 );
|
1007 |
-
return $cmp;
|
1008 |
-
}
|
1009 |
-
|
1010 |
-
/**
|
1011 |
-
* Compare Two Strings in Descending Order.
|
1012 |
-
*
|
1013 |
-
* This function returns the negstive of the comparison result of two strings.
|
1014 |
-
* It is part of an array sorting mechanism.
|
1015 |
-
*
|
1016 |
-
* @since 3.8.5
|
1017 |
-
*
|
1018 |
-
* @param string $a The first string.
|
1019 |
-
* @param string $b The second string.
|
1020 |
-
*
|
1021 |
-
* @return int Returns > 0 if a is less than b; < 0 if a is greater than b
|
1022 |
-
* and 0 if they are equal.
|
1023 |
-
*/
|
1024 |
-
function wfu_array_sort_function_string_desc($a, $b) {
|
1025 |
-
return -strcmp(strtolower($a), strtolower($b));
|
1026 |
-
}
|
1027 |
-
|
1028 |
-
/**
|
1029 |
-
* Compare Two Strings Having a Second Property in Descending Order.
|
1030 |
-
*
|
1031 |
-
* This function returns the negative of the comparison result of two strings.
|
1032 |
-
* If the strings are equal then comparison will be done based on a second
|
1033 |
-
* property (id0) of the strings, so that 0 is never returned. It is part of an
|
1034 |
-
* array sorting mechanism.
|
1035 |
-
*
|
1036 |
-
* @since 3.8.5
|
1037 |
-
*
|
1038 |
-
* @param array $a The first string. It is passed as an array. 'value' item of
|
1039 |
-
* the array is the string. 'id0' item is the second property.
|
1040 |
-
* @param array $b The second string. It is passed as an array. 'value' item of
|
1041 |
-
* the array is the string. 'id0' item is the second property.
|
1042 |
-
*
|
1043 |
-
* @return int Returns > 0 if a is less than b; < 0 if a is greater.
|
1044 |
-
*/
|
1045 |
-
function wfu_array_sort_function_string_desc_with_id0($a, $b) {
|
1046 |
-
$cmp = strcmp(strtolower($a["value"]), strtolower($b["value"]));
|
1047 |
-
if ( $cmp == 0 ) $cmp = ( (int)$a["id0"] < (int)$b["id0"] ? -1 : 1 );
|
1048 |
-
return -$cmp;
|
1049 |
-
}
|
1050 |
-
|
1051 |
-
/**
|
1052 |
-
* Compare Two Numbers in Ascending Order.
|
1053 |
-
*
|
1054 |
-
* This function returns the comparison result of two numbers. It is part of an
|
1055 |
-
* array sorting mechanism.
|
1056 |
-
*
|
1057 |
-
* @since 3.8.5
|
1058 |
-
*
|
1059 |
-
* @param int|float|double $a The first number.
|
1060 |
-
* @param int|float|double $b The second number.
|
1061 |
-
*
|
1062 |
-
* @return int Returns -1 if a is less than b; 1 if a is greater than b
|
1063 |
-
* and 0 if they are equal.
|
1064 |
-
*/
|
1065 |
-
function wfu_array_sort_function_numeric_asc($a, $b) {
|
1066 |
-
$aa = (double)$a;
|
1067 |
-
$bb = (double)$b;
|
1068 |
-
if ( $aa < $bb ) return -1;
|
1069 |
-
elseif ( $aa > $bb ) return 1;
|
1070 |
-
else return 0;
|
1071 |
-
}
|
1072 |
-
|
1073 |
-
/**
|
1074 |
-
* Compare Two Numbers Having a Second Property in Ascending Order.
|
1075 |
-
*
|
1076 |
-
* This function returns the comparison result of two numbers. If the numbers
|
1077 |
-
* are equal then comparison will be done based on a second property (id0) of
|
1078 |
-
* the numbers, so that 0 is never returned. It is part of an array sorting
|
1079 |
-
* mechanism.
|
1080 |
-
*
|
1081 |
-
* @since 3.8.5
|
1082 |
-
*
|
1083 |
-
* @param array $a The first number. It is passed as an array. 'value' item of
|
1084 |
-
* the array is the number. 'id0' item is the second property.
|
1085 |
-
* @param array $b The second number. It is passed as an array. 'value' item of
|
1086 |
-
* the array is the number. 'id0' item is the second property.
|
1087 |
-
*
|
1088 |
-
* @return int Returns -1 if a is less than b; 1 if a is greater.
|
1089 |
-
*/
|
1090 |
-
function wfu_array_sort_function_numeric_asc_with_id0($a, $b) {
|
1091 |
-
$aa = (double)$a["value"];
|
1092 |
-
$bb = (double)$b["value"];
|
1093 |
-
if ( $aa < $bb ) return -1;
|
1094 |
-
elseif ( $aa > $bb ) return 1;
|
1095 |
-
elseif ( (int)$a["id0"] < (int)$b["id0"] ) return -1;
|
1096 |
-
else return 1;
|
1097 |
-
}
|
1098 |
-
|
1099 |
-
/**
|
1100 |
-
* Compare Two Numbers in Descending Order.
|
1101 |
-
*
|
1102 |
-
* This function returns the negstive of the comparison result of two numbers.
|
1103 |
-
* It is part of an array sorting mechanism.
|
1104 |
-
*
|
1105 |
-
* @since 3.8.5
|
1106 |
-
*
|
1107 |
-
* @param int|float|number $a The first number.
|
1108 |
-
* @param int|float|number $b The second number.
|
1109 |
-
*
|
1110 |
-
* @return int Returns 1 if a is less than b; -1 if a is greater than b
|
1111 |
-
* and 0 if they are equal.
|
1112 |
-
*/
|
1113 |
-
function wfu_array_sort_function_numeric_desc($a, $b) {
|
1114 |
-
$aa = (double)$a;
|
1115 |
-
$bb = (double)$b;
|
1116 |
-
if ( $aa > $bb ) return -1;
|
1117 |
-
elseif ( $aa < $bb ) return 1;
|
1118 |
-
else return 0;
|
1119 |
-
}
|
1120 |
-
|
1121 |
-
/**
|
1122 |
-
* Compare Two Numbers Having a Second Property in Descending Order.
|
1123 |
-
*
|
1124 |
-
* This function returns the negative of the comparison result of two numbers.
|
1125 |
-
* If the numbers are equal then comparison will be done based on a second
|
1126 |
-
* property (id0) of the numbers, so that 0 is never returned. It is part of an
|
1127 |
-
* array sorting mechanism.
|
1128 |
-
*
|
1129 |
-
* @since 3.8.5
|
1130 |
-
*
|
1131 |
-
* @param array $a The first number. It is passed as an array. 'value' item of
|
1132 |
-
* the array is the number. 'id0' item is the second property.
|
1133 |
-
* @param array $b The second number. It is passed as an array. 'value' item of
|
1134 |
-
* the array is the number. 'id0' item is the second property.
|
1135 |
-
*
|
1136 |
-
* @return int Returns 1 if a is less than b; -1 if a is greater.
|
1137 |
-
*/
|
1138 |
-
function wfu_array_sort_function_numeric_desc_with_id0($a, $b) {
|
1139 |
-
$aa = (double)$a["value"];
|
1140 |
-
$bb = (double)$b["value"];
|
1141 |
-
if ( $aa > $bb ) return -1;
|
1142 |
-
elseif ( $aa < $bb ) return 1;
|
1143 |
-
elseif ( (int)$a["id0"] > (int)$b["id0"] ) return -1;
|
1144 |
-
else return 1;
|
1145 |
-
}
|
1146 |
-
|
1147 |
-
/**
|
1148 |
-
* Sort an Array Based on Key.
|
1149 |
-
*
|
1150 |
-
* This function sorts an array based on a key. It is used to sort a tabular
|
1151 |
-
* list based on a column. Every item of the array is another associative array
|
1152 |
-
* representing a row of the table. The key of every item is the column of the
|
1153 |
-
* table.
|
1154 |
-
*
|
1155 |
-
* @since 2.2.1
|
1156 |
-
*
|
1157 |
-
* @param array $array. The array to sort.
|
1158 |
-
* @param string $on. The sorting column name. If it is preceeded by 's:' it
|
1159 |
-
* will be sorted as string. If it is preceeded by 'n:' it will be sorted
|
1160 |
-
* as numeric.
|
1161 |
-
* @param int $order Optional. The sorting order. It can be SORT_ASC or
|
1162 |
-
* SORT_DESC.
|
1163 |
-
* @param bool $with_id0 Optional. A secord property will be used for sorting.
|
1164 |
-
*
|
1165 |
-
* @return array The sorted array.
|
1166 |
-
*/
|
1167 |
-
function wfu_array_sort($array, $on, $order = SORT_ASC, $with_id0 = false) {
|
1168 |
-
$new_array = array();
|
1169 |
-
$sortable_array = array();
|
1170 |
-
|
1171 |
-
$pos = strpos($on, ":");
|
1172 |
-
if ( $pos !== false ) {
|
1173 |
-
$sorttype = substr($on, $pos + 1);
|
1174 |
-
if ( $sorttype == "" ) $sorttype = "s";
|
1175 |
-
$on = substr($on, 0, $pos);
|
1176 |
-
}
|
1177 |
-
else $sorttype = "s";
|
1178 |
-
|
1179 |
-
if (count($array) > 0) {
|
1180 |
-
foreach ($array as $k => $v) {
|
1181 |
-
if (is_array($v)) {
|
1182 |
-
foreach ($v as $k2 => $v2) {
|
1183 |
-
if ($k2 == $on) {
|
1184 |
-
$sortable_array[$k] = ( $with_id0 ? array( "id0" => $v["id0"], "value" => $v2 ) : $v2 );
|
1185 |
-
}
|
1186 |
-
}
|
1187 |
-
} else {
|
1188 |
-
$sortable_array[$k] = $v;
|
1189 |
-
$with_id0 = false;
|
1190 |
-
}
|
1191 |
-
}
|
1192 |
-
|
1193 |
-
uasort($sortable_array, "wfu_array_sort_function_".( $sorttype == "n" ? "numeric" : "string" )."_".( $order == SORT_ASC ? "asc" : "desc" ).( $with_id0 ? "_with_id0" : "" ));
|
1194 |
-
|
1195 |
-
foreach ($sortable_array as $k => $v) {
|
1196 |
-
$new_array[$k] = $array[$k];
|
1197 |
-
}
|
1198 |
-
}
|
1199 |
-
|
1200 |
-
return $new_array;
|
1201 |
-
}
|
1202 |
-
|
1203 |
-
/**
|
1204 |
-
* Output Array Contents.
|
1205 |
-
*
|
1206 |
-
* This function echoes array contents to show properly in a front-end page.
|
1207 |
-
*
|
1208 |
-
* @since 3.4.0
|
1209 |
-
*
|
1210 |
-
* @param array $arr. The array to echo.
|
1211 |
-
*/
|
1212 |
-
function wfu_echo_array($arr) {
|
1213 |
-
if ( !is_array($arr) ) return;
|
1214 |
-
echo '<pre>'.print_r($arr, true).'</pre>';
|
1215 |
-
}
|
1216 |
-
|
1217 |
-
/**
|
1218 |
-
* Minify Code.
|
1219 |
-
*
|
1220 |
-
* This function minifies a piece of code. It is used to minify inline code of
|
1221 |
-
* the plugin. It supports minification of Javascript or CSS code.
|
1222 |
-
*
|
1223 |
-
* @since 4.2.0
|
1224 |
-
*
|
1225 |
-
* @param string $lang. The code language. It can be 'JS' or 'CSS'.
|
1226 |
-
* @param string $code. The code to minify.
|
1227 |
-
*
|
1228 |
-
* @return array An array holding minification result. Item 'result' is true if
|
1229 |
-
* minification was successful and false otherwise. Item 'minified_code'
|
1230 |
-
* holds the minified code.
|
1231 |
-
*/
|
1232 |
-
function wfu_minify_code($lang, $code) {
|
1233 |
-
$ret = array( "result" => false, "minified_code" => "" );
|
1234 |
-
$php_version = preg_replace("/-.*/", "", phpversion());
|
1235 |
-
$unsupported = false;
|
1236 |
-
$ret = wfu_compare_versions($php_version, '5.3.0');
|
1237 |
-
$unsupported = ( $ret['status'] && $ret['result'] == 'lower' );
|
1238 |
-
if ( !$unsupported ) {
|
1239 |
-
$path = ABSWPFILEUPLOAD_DIR;
|
1240 |
-
if ( !class_exists('MatthiasMullie\Minify\Minify') ) {
|
1241 |
-
include_once $path.'vendor/minifier/minify/src/Minify.php';
|
1242 |
-
include_once $path.'vendor/minifier/minify/src/CSS.php';
|
1243 |
-
include_once $path.'vendor/minifier/minify/src/JS.php';
|
1244 |
-
include_once $path.'vendor/minifier/minify/src/Exception.php';
|
1245 |
-
include_once $path.'vendor/minifier/minify/src/Exceptions/BasicException.php';
|
1246 |
-
include_once $path.'vendor/minifier/minify/src/Exceptions/FileImportException.php';
|
1247 |
-
include_once $path.'vendor/minifier/minify/src/Exceptions/IOException.php';
|
1248 |
-
}
|
1249 |
-
if ( !class_exists('MatthiasMullie\PathConverter\Converter') ) {
|
1250 |
-
include_once $path.'vendor/minifier/path-converter/src/ConverterInterface.php';
|
1251 |
-
include_once $path.'vendor/minifier/path-converter/src/Converter.php';
|
1252 |
-
}
|
1253 |
-
$minifier = null;
|
1254 |
-
eval('$minifier = new MatthiasMullie\Minify\\'.strtoupper($lang).'($code);');
|
1255 |
-
if ( $minifier !== null ) {
|
1256 |
-
$ret["result"] = true;
|
1257 |
-
$ret["minified_code"] = $minifier->minify();
|
1258 |
-
}
|
1259 |
-
}
|
1260 |
-
|
1261 |
-
return $ret;
|
1262 |
-
}
|
1263 |
-
|
1264 |
-
/**
|
1265 |
-
* Prepare CSS Code for Output.
|
1266 |
-
*
|
1267 |
-
* This function prepares CSS code for HTML output. It minifies the code if
|
1268 |
-
* necessary and encloses it in <style> tags.
|
1269 |
-
*
|
1270 |
-
* @since 4.0.0
|
1271 |
-
*
|
1272 |
-
* @param string $css. The CSS code to output.
|
1273 |
-
*
|
1274 |
-
* @return string The resulted HTML code.
|
1275 |
-
*/
|
1276 |
-
function wfu_css_to_HTML($css) {
|
1277 |
-
if ( WFU_VAR("WFU_MINIFY_INLINE_CSS") == "true" ) {
|
1278 |
-
$ret = wfu_minify_code("CSS", $css);
|
1279 |
-
if ( $ret["result"] ) $css = $ret["minified_code"];
|
1280 |
-
}
|
1281 |
-
$echo_str = "\n\t".'<style>';
|
1282 |
-
$echo_str .= "\n".$css;
|
1283 |
-
$echo_str .= "\n\t".'</style>';
|
1284 |
-
|
1285 |
-
return $echo_str;
|
1286 |
-
}
|
1287 |
-
|
1288 |
-
/**
|
1289 |
-
* Prepare Javascript Code for Output.
|
1290 |
-
*
|
1291 |
-
* This function prepares Javascript code for HTML output. It minifies the code
|
1292 |
-
* if necessary and encloses it in <script> tags.
|
1293 |
-
*
|
1294 |
-
* @since 4.0.0
|
1295 |
-
*
|
1296 |
-
* @param string $js. The Javascript code to output.
|
1297 |
-
*
|
1298 |
-
* @return string The resulted HTML code.
|
1299 |
-
*/
|
1300 |
-
function wfu_js_to_HTML($js) {
|
1301 |
-
if ( WFU_VAR("WFU_MINIFY_INLINE_JS") == "true" ) {
|
1302 |
-
$ret = wfu_minify_code("JS", $js);
|
1303 |
-
if ( $ret["result"] ) $js = $ret["minified_code"];
|
1304 |
-
}
|
1305 |
-
$echo_str = '<script type="text/javascript">';
|
1306 |
-
$echo_str .= "\n".$js;
|
1307 |
-
$echo_str .= "\n".'</script>';
|
1308 |
-
|
1309 |
-
return $echo_str;
|
1310 |
-
}
|
1311 |
-
|
1312 |
-
/**
|
1313 |
-
* Generate Basic Inline Javascript Loader Functions.
|
1314 |
-
*
|
1315 |
-
* This function returns the initialization code of the basic inline JS loader
|
1316 |
-
* functions:
|
1317 |
-
*
|
1318 |
-
* wfu_js_decode_obj: This JS function generates an object from its string
|
1319 |
-
* representation.
|
1320 |
-
*
|
1321 |
-
* wfu_run_js: This JS function calls other JS functions. It is used to run
|
1322 |
-
* inline functions safely. Inline functions use objects, like GlobalData,
|
1323 |
-
* which initialize after Javascript files of the plugin have been loaded.
|
1324 |
-
* Usually these files are declared at the header of a page and load before
|
1325 |
-
* the inline code. So objects like GlobalData have been initialized and
|
1326 |
-
* inline functions can run without errors. However sometimes Javascript files
|
1327 |
-
* are declared at the footer, or handled by cache plugins and load after the
|
1328 |
-
* inline code. In these cases wfu_run_js will not run the inline functions
|
1329 |
-
* immediately. It will put them in a JS Bank, so that they run safely after
|
1330 |
-
* the Javascript files have been loaded.
|
1331 |
-
*
|
1332 |
-
* @since 4.2.0
|
1333 |
-
*
|
1334 |
-
* @return string The HTML code of the inline Javascript loader functions.
|
1335 |
-
*/
|
1336 |
-
function wfu_init_run_js_script() {
|
1337 |
-
// $script = 'if (typeof wfu_js_decode_obj == "undefined") function wfu_js_decode_obj(obj_str) { var obj = null; if (obj_str == "window") obj = window; else { var match = obj_str.match(new RegExp(\'GlobalData(\\\\.(WFU|WFUB)\\\\[(.*?)\\\\](\\\\.(.*))?)?$\')); if (match) { obj = GlobalData; if (match[3]) obj = obj[match[2]][match[3]]; if (match[5]) obj = obj[match[5]]; } } return obj; }';
|
1338 |
-
$script = 'if (typeof wfu_js_decode_obj == "undefined") function wfu_js_decode_obj(obj_str) { var obj = null; if (obj_str == "window") obj = window; else { var dbs = String.fromCharCode(92); var match = obj_str.match(new RegExp(\'GlobalData(\' + dbs + \'.(WFU|WFUB)\' + dbs + \'[(.*?)\' + dbs + \'](\' + dbs + \'.(.*))?)?$\')); if (match) { obj = GlobalData; if (match[3]) obj = obj[match[2]][match[3]]; if (match[5]) obj = obj[match[5]]; } } return obj; }';
|
1339 |
-
$script .= "\n".'if (typeof wfu_run_js == "undefined") function wfu_run_js(obj_str, func) { if (typeof GlobalData == "undefined") { if (typeof window.WFU_JS_BANK == "undefined") WFU_JS_BANK = []; WFU_JS_BANK.push({obj_str: obj_str, func: func}) } else { var obj = wfu_js_decode_obj(obj_str); if (obj) obj[func].call(obj); } }';
|
1340 |
-
return wfu_js_to_HTML($script);
|
1341 |
-
}
|
1342 |
-
|
1343 |
-
/**
|
1344 |
-
* Convert PHP Array to JS Object.
|
1345 |
-
*
|
1346 |
-
* This function converts an associative PHP array into a Javascript object.
|
1347 |
-
*
|
1348 |
-
* @since 4.0.0
|
1349 |
-
*
|
1350 |
-
* @param array $arr. The associative PHP array to convert.
|
1351 |
-
*
|
1352 |
-
* @return string The converted Javascript object as a string.
|
1353 |
-
*/
|
1354 |
-
function wfu_PHP_array_to_JS_object($arr) {
|
1355 |
-
$ret = "";
|
1356 |
-
foreach ( $arr as $prop => $value ) {
|
1357 |
-
if ( is_string($value) ) $ret .= ( $ret == "" ? "" : ", " )."$prop: \"$value\"";
|
1358 |
-
elseif ( is_numeric($value) ) $ret .= ( $ret == "" ? "" : ", " )."$prop: $value";
|
1359 |
-
elseif ( is_bool($value) ) $ret .= ( $ret == "" ? "" : ", " )."$prop: ".( $value ? "true" : "false" );
|
1360 |
-
}
|
1361 |
-
return ( $ret == "" ? "{ }" : "{ $ret }" );
|
1362 |
-
}
|
1363 |
-
|
1364 |
-
/**
|
1365 |
-
* Convert PHP Array to URL GET Params.
|
1366 |
-
*
|
1367 |
-
* This function converts an associative PHP array into GET parameters to add in
|
1368 |
-
* a URL.
|
1369 |
-
*
|
1370 |
-
* @since 4.9.0
|
1371 |
-
*
|
1372 |
-
* @param array $arr. The associative PHP array to convert.
|
1373 |
-
*
|
1374 |
-
* @return string The converted GET parameters.
|
1375 |
-
*/
|
1376 |
-
function wfu_array_to_GET_params($arr) {
|
1377 |
-
$str = "";
|
1378 |
-
foreach ( $arr as $key => $var )
|
1379 |
-
$str .= ( $str == "" ? "" : "&" ).$key."=".$var;
|
1380 |
-
|
1381 |
-
return $str;
|
1382 |
-
}
|
1383 |
-
|
1384 |
-
//********************* Shortcode Attribute Functions **************************
|
1385 |
-
|
1386 |
-
/**
|
1387 |
-
* Insert a Category in a List of Categories.
|
1388 |
-
*
|
1389 |
-
* This function inserts a new category in a list of categories.
|
1390 |
-
*
|
1391 |
-
* @since 4.1.0
|
1392 |
-
*
|
1393 |
-
* @param array $categories. The list of categories.
|
1394 |
-
* @param string $before_category. Insert the new category before this one.
|
1395 |
-
* @param string $new_category. The new category to insert.
|
1396 |
-
*
|
1397 |
-
* @return array The updated list of categories.
|
1398 |
-
*/
|
1399 |
-
function wfu_insert_category($categories, $before_category, $new_category) {
|
1400 |
-
if ( $before_category == "" ) $index = count($categories);
|
1401 |
-
else {
|
1402 |
-
$index = array_search($before_category, array_keys($categories));
|
1403 |
-
if ( $index === false ) $index = count($categories);
|
1404 |
-
}
|
1405 |
-
|
1406 |
-
return array_merge(array_slice($categories, 0, $index), $new_category, array_slice($categories, $index));
|
1407 |
-
}
|
1408 |
-
|
1409 |
-
/**
|
1410 |
-
* Insert new Attributes in a List of Attributes.
|
1411 |
-
*
|
1412 |
-
* This function inserts one or more attributes in a list of attributes.
|
1413 |
-
*
|
1414 |
-
* @since 4.1.0
|
1415 |
-
*
|
1416 |
-
* @param array $attributes. The list of attributes.
|
1417 |
-
* @param string $in_category. Insert the new attribute in this category.
|
1418 |
-
* @param string $in_subcategory. Insert the new attribute in this subcategory.
|
1419 |
-
* @param string $position. Position of the new attribute. It can be 'first' or
|
1420 |
-
* 'last'.
|
1421 |
-
* @param array $new_attributes. The new attributes to insert.
|
1422 |
-
*
|
1423 |
-
* @return array The updated list of attributes.
|
1424 |
-
*/
|
1425 |
-
function wfu_insert_attributes($attributes, $in_category, $in_subcategory, $position, $new_attributes) {
|
1426 |
-
$index = -1;
|
1427 |
-
if ( $in_category == "" ) {
|
1428 |
-
if ( $position == "first" ) $index = 0;
|
1429 |
-
elseif ( $position == "last" ) $index = count($attributes);
|
1430 |
-
}
|
1431 |
-
else {
|
1432 |
-
foreach ( $attributes as $pos => $attribute ) {
|
1433 |
-
$match = ( $attribute["category"] == $in_category );
|
1434 |
-
if ( $in_subcategory != "" ) $match = $match && ( $attribute["subcategory"] == $in_subcategory );
|
1435 |
-
if ( $match ) {
|
1436 |
-
if ( $position == "first" ) {
|
1437 |
-
$index = $pos;
|
1438 |
-
break;
|
1439 |
-
}
|
1440 |
-
elseif ( $position == "last" ) {
|
1441 |
-
$index = $pos + 1;
|
1442 |
-
}
|
1443 |
-
}
|
1444 |
-
}
|
1445 |
-
}
|
1446 |
-
if ( $index > -1 ) array_splice($attributes, $index, 0, $new_attributes);
|
1447 |
-
|
1448 |
-
return $attributes;
|
1449 |
-
}
|
1450 |
-
|
1451 |
-
//********************* Plugin Options Functions *******************************
|
1452 |
-
|
1453 |
-
/**
|
1454 |
-
* Get Server Environment.
|
1455 |
-
*
|
1456 |
-
* This function gets the server environment, whether it is 32 or 64 bit.
|
1457 |
-
*
|
1458 |
-
* @since 2.6.0
|
1459 |
-
*
|
1460 |
-
* @redeclarable
|
1461 |
-
*
|
1462 |
-
* @return string The server environment, '32bit' or '64bit'.
|
1463 |
-
*/
|
1464 |
-
function wfu_get_server_environment() {
|
1465 |
-
$a = func_get_args(); $a = WFU_FUNCTION_HOOK(__FUNCTION__, $a, $out); if (isset($out['vars'])) foreach($out['vars'] as $p => $v) $$p = $v; switch($a) { case 'R': return $out['output']; break; case 'D': die($out['output']); }
|
1466 |
-
$php_env = '';
|
1467 |
-
if ( PHP_INT_SIZE == 4 ) $php_env = '32bit';
|
1468 |
-
elseif ( PHP_INT_SIZE == 8 ) $php_env = '64bit';
|
1469 |
-
else {
|
1470 |
-
$int = "9223372036854775807";
|
1471 |
-
$int = intval($int);
|
1472 |
-
if ($int == 9223372036854775807) $php_env = '64bit';
|
1473 |
-
elseif ($int == 2147483647) $php_env = '32bit';
|
1474 |
-
}
|
1475 |
-
|
1476 |
-
return $php_env;
|
1477 |
-
}
|
1478 |
-
|
1479 |
-
/**
|
1480 |
-
* Get AJAX URL.
|
1481 |
-
*
|
1482 |
-
* This function gets the URL of admin-ajax.php for AJAX requests.
|
1483 |
-
*
|
1484 |
-
* @since 3.7.2
|
1485 |
-
*
|
1486 |
-
* @redeclarable
|
1487 |
-
*
|
1488 |
-
* @return string The full URL for AJAX requests.
|
1489 |
-
*/
|
1490 |
-
function wfu_ajaxurl() {
|
1491 |
-
$a = func_get_args(); $a = WFU_FUNCTION_HOOK(__FUNCTION__, $a, $out); if (isset($out['vars'])) foreach($out['vars'] as $p => $v) $$p = $v; switch($a) { case 'R': return $out['output']; break; case 'D': die($out['output']); }
|
1492 |
-
$plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
|
1493 |
-
return ( $plugin_options['admindomain'] == 'siteurl' || $plugin_options['admindomain'] == '' ? site_url("wp-admin/admin-ajax.php") : ( $plugin_options['admindomain'] == 'adminurl' ? admin_url("admin-ajax.php") : home_url("wp-admin/admin-ajax.php") ) );
|
1494 |
-
}
|
1495 |
-
|
1496 |
-
/**
|
1497 |
-
* Get Plugin Environment Variable Value.
|
1498 |
-
*
|
1499 |
-
* This function gets the value of a plugin's environment variable.
|
1500 |
-
*
|
1501 |
-
* @since 3.7.1
|
1502 |
-
*
|
1503 |
-
* @param string $varname The name of the environment variable.
|
1504 |
-
*
|
1505 |
-
* @return mixed The value of the environment variable.
|
1506 |
-
*/
|
1507 |
-
function WFU_VAR($varname) {
|
1508 |
-
if ( !isset($GLOBALS["WFU_GLOBALS"][$varname]) ) return false;
|
1509 |
-
if ( $GLOBALS["WFU_GLOBALS"][$varname][5] ) return $GLOBALS["WFU_GLOBALS"][$varname][3];
|
1510 |
-
//in case the environment variable is hidden then return the default value
|
1511 |
-
else return $GLOBALS["WFU_GLOBALS"][$varname][2];
|
1512 |
-
}
|
1513 |
-
|
1514 |
-
/**
|
1515 |
-
* Get Plugin Version.
|
1516 |
-
*
|
1517 |
-
* This function gets the plugin's version.
|
1518 |
-
*
|
1519 |
-
* @since 2.4.6
|
1520 |
-
*
|
1521 |
-
* @return string The plugin's version.
|
1522 |
-
*/
|
1523 |
-
function wfu_get_plugin_version() {
|
1524 |
-
$plugin_data = get_plugin_data(WPFILEUPLOAD_PLUGINFILE);
|
1525 |
-
return $plugin_data['Version'];
|
1526 |
-
}
|
1527 |
-
|
1528 |
-
/**
|
1529 |
-
* Get Plugin's Latest Version.
|
1530 |
-
*
|
1531 |
-
* This function gets the plugin's latest version from Iptanus Services Server.
|
1532 |
-
*
|
1533 |
-
* @since 2.4.6
|
1534 |
-
*
|
1535 |
-
* @redeclarable
|
1536 |
-
*
|
1537 |
-
* @return string The plugin's latest version.
|
1538 |
-
*/
|
1539 |
-
function wfu_get_latest_version() {
|
1540 |
-
$a = func_get_args(); $a = WFU_FUNCTION_HOOK(__FUNCTION__, $a, $out); if (isset($out['vars'])) foreach($out['vars'] as $p => $v) $$p = $v; switch($a) { case 'R': return $out['output']; break; case 'D': die($out['output']); }
|
1541 |
-
$plugin_options = wfu_decode_plugin_options(get_option( "wordpress_file_upload_options" ));
|
1542 |
-
$postfields = array();
|
1543 |
-
$postfields['action'] = 'wfuca_check_latest_version_free';
|
1544 |
-
$postfields['version_hash'] = WFU_VERSION_HASH;
|
1545 |
-
$url = ( $plugin_options["altserver"] == "1" && trim(WFU_VAR("WFU_ALT_IPTANUS_SERVER")) != "" ? ( trim(WFU_VAR("WFU_ALT_VERSION_SERVER")) != "" ? trim(WFU_VAR("WFU_ALT_VERSION_SERVER")) : trim(WFU_VAR("WFU_ALT_IPTANUS_SERVER")).'/wp-admin/admin-ajax.php' ) : WFU_VERSION_SERVER_URL );
|
1546 |
-
$result = null;
|
1547 |
-
if ( WFU_VAR("WFU_DISABLE_VERSION_CHECK") != "true" )
|
1548 |
-
$result = wfu_post_request($url, $postfields, false, false, 10);
|
1549 |
-
return $result;
|
1550 |
-
}
|
1551 |
-
|
1552 |
-
/**
|
1553 |
-
* Compare Current and Latest Version.
|
1554 |
-
*
|
1555 |
-
* This function compares curent version with latest one.
|
1556 |
-
*
|
1557 |
-
* @since 2.4.6
|
1558 |
-
*
|
1559 |
-
* @param string $current The curent plugin version.
|
1560 |
-
* @param string $latest The latest plugin version.
|
1561 |
-
*
|
1562 |
-
* @return string The comparison result. It can have the following values:
|
1563 |
-
* 'equal': both versions are equal.
|
1564 |
-
* 'lower': current version is lower than latest.
|
1565 |
-
* 'current version invalid' current version is invalid.
|
1566 |
-
* 'latest version invalid' latest version is invalid.
|
1567 |
-
*/
|
1568 |
-
function wfu_compare_versions($current, $latest) {
|
1569 |
-
$ret['status'] = true;
|
1570 |
-
$ret['custom'] = false;
|
1571 |
-
$ret['result'] = 'equal';
|
1572 |
-
$res = preg_match('/^([0-9]*)\.([0-9]*)\.([0-9]*)(.*)/', $current, $cur_data);
|
1573 |
-
if ( !$res || count($cur_data) < 5 )
|
1574 |
-
return array( 'status' => false, 'custom' => false, 'result' => 'current version invalid' );
|
1575 |
-
if ( $cur_data[1] == '' || $cur_data[2] == '' || $cur_data[3] == '' )
|
1576 |
-
return array( 'status' => false, 'custom' => false, 'result' => 'current version invalid' );
|
1577 |
-
$custom = ( $cur_data[4] != '' );
|
1578 |
-
$res = preg_match('/^([0-9]*)\.([0-9]*)\.([0-9]*)/', $latest, $lat_data);
|
1579 |
-
if ( !$res || count($lat_data) < 4 )
|
1580 |
-
return array( 'status' => false, 'custom' => $custom, 'result' => 'latest version invalid' );
|
1581 |
-
if ( $lat_data[1] == '' || $lat_data[2] == '' || $lat_data[3] == '' )
|
1582 |
-
return array( 'status' => false, 'custom' => $custom, 'result' => 'latest version invalid' );
|
1583 |
-
if ( intval($cur_data[1]) < intval($lat_data[1]) )
|
1584 |
-
return array( 'status' => true, 'custom' => $custom, 'result' => 'lower' );
|
1585 |
-
elseif ( intval($cur_data[1]) > intval($lat_data[1]) )
|
1586 |
-
return array( 'status' => false, 'custom' => $custom, 'result' => 'current version invalid' );
|
1587 |
-
if ( intval($cur_data[2]) < intval($lat_data[2]) )
|
1588 |
-
return array( 'status' => true, 'custom' => $custom, 'result' => 'lower' );
|
1589 |
-
elseif ( intval($cur_data[2]) > intval($lat_data[2]) )
|
1590 |
-
return array( 'status' => false, 'custom' => $custom, 'result' => 'current version invalid' );
|
1591 |
-
if ( intval($cur_data[3]) < intval($lat_data[3]) )
|
1592 |
-
return array( 'status' => true, 'custom' => $custom, 'result' => 'lower' );
|
1593 |
-
elseif ( intval($cur_data[3]) > intval($lat_data[3]) )
|
1594 |
-
return array( 'status' => false, 'custom' => $custom, 'result' => 'current version invalid' );
|
1595 |
-
return array( 'status' => true, 'custom' => $custom, 'result' => 'equal' );
|
1596 |
-
}
|
1597 |
-
|
1598 |
-
//********************* File / Directory Functions *****************************
|
1599 |
-
|
1600 |
-
/**
|
1601 |
-
* Get Root Path of Website.
|
1602 |
-
*
|
1603 |
-
* This function gets the root (absolute) path of the website. If it cannot be
|
1604 |
-
* retrieved then content path is returned.
|
1605 |
-
*
|
1606 |
-
* @since 4.0.0
|
1607 |
-
*
|
1608 |
-
* @return string The absolute path of the website.
|
1609 |
-
*/
|
1610 |
-
function wfu_abspath() {
|
1611 |
-
$path = WP_CONTENT_DIR;
|
1612 |
-
//remove trailing slash if exists
|
1613 |
-
if ( substr($path, -1) == '/' ) $path = substr($path, 0, -1);
|
1614 |
-
$pos = strrpos($path, '/');
|
1615 |
-
//to find abspath we go one dir up from content path
|
1616 |
-
if ( $pos !== false ) $path = substr($path, 0, $pos + 1);
|
1617 |
-
//else if we cannot go up we stay at content path adding a trailing slash
|
1618 |
-
else $path .= '/';
|
1619 |
-
|
1620 |
-
return $path;
|
1621 |
-
}
|
1622 |
-
|
1623 |
-
/**
|
1624 |
-
* Extract Extension from Filename.
|
1625 |
-
*
|
1626 |
-
* This function extracts the extension part from filename.
|
1627 |
-
*
|
1628 |
-
* @since 3.8.0
|
1629 |
-
*
|
1630 |
-
* @param string $basename The filename to extract the extension from.
|
1631 |
-
* @param bool $with_dot Optional. If true the dot symbol will be included in
|
1632 |
-
* the extension.
|
1633 |
-
*
|
1634 |
-
* @return string The extracted extension.
|
1635 |
-
*/
|
1636 |
-
function wfu_fileext($basename, $with_dot = false) {
|
1637 |
-
if ( $with_dot ) return preg_replace("/^.*?(\.[^.]*)?$/", "$1", $basename);
|
1638 |
-
else return preg_replace("/^.*?(\.([^.]*))?$/", "$2", $basename);
|
1639 |
-
}
|
1640 |
-
|
1641 |
-
/**
|
1642 |
-
* Extract Name Part from Filename.
|
1643 |
-
*
|
1644 |
-
* This function extracts the name part from filename without the extension.
|
1645 |
-
*
|
1646 |
-
* @since 3.8.0
|
1647 |
-
*
|
1648 |
-
* @param string $basename The filename to extract the name part from.
|
1649 |
-
*
|
1650 |
-
* @return string The extracted name part.
|
1651 |
-
*/
|
1652 |
-
function wfu_filename($basename) {
|
1653 |
-
return preg_replace("/^(.*?)(\.[^.]*)?$/", "$1", $basename);
|
1654 |
-
}
|
1655 |
-
|
1656 |
-
/**
|
1657 |
-
* Extract Filename From Path.
|
1658 |
-
*
|
1659 |
-
* This function extracts the filename from path.
|
1660 |
-
*
|
1661 |
-
* @since 2.6.0
|
1662 |
-
*
|
1663 |
-
* @param string $path The path to extract the filename from.
|
1664 |
-
*
|
1665 |
-
* @return string The extracted filename.
|
1666 |
-
*/
|
1667 |
-
function wfu_basename($path) {
|
1668 |
-
if ( !$path || $path == "" ) return "";
|
1669 |
-
return preg_replace('/.*(\\\\|\\/)/', '', $path);
|
1670 |
-
}
|
1671 |
-
|
1672 |
-
/**
|
1673 |
-
* Extract Dir From Path.
|
1674 |
-
*
|
1675 |
-
* This function extracts the dir part from path without the filename.
|
1676 |
-
*
|
1677 |
-
* @since 2.7.1
|
1678 |
-
*
|
1679 |
-
* @param string $path The path to extract the dir part from.
|
1680 |
-
*
|
1681 |
-
* @return string The extracted dir part.
|
1682 |
-
*/
|
1683 |
-
function wfu_basedir($path) {
|
1684 |
-
if ( !$path || $path == "" ) return "";
|
1685 |
-
return substr($path, 0, strlen($path) - strlen(wfu_basename($path)));
|
1686 |
-
}
|
1687 |
-
|
1688 |
-
/**
|
1689 |
-
* Convert Absolute Path to Relative.
|
1690 |
-
*
|
1691 |
-
* This function converts an absolute path to relative one by removing the
|
1692 |
-
* root path of the website. If the path points to an FTP location then no
|
1693 |
-
* conversion happens. If the path is outside the root, then 'abs:' is appended
|
1694 |
-
* to the path.
|
1695 |
-
*
|
1696 |
-
* @since 3.1.0
|
1697 |
-
*
|
1698 |
-
* @param string $path The absolute path.
|
1699 |
-
*
|
1700 |
-
* @return string The relative path.
|
1701 |
-
*/
|
1702 |
-
function wfu_path_abs2rel($path) {
|
1703 |
-
$abspath_notrailing_slash = substr(wfu_abspath(), 0, -1);
|
1704 |
-
if ( substr($path, 0, 6) == 'ftp://' || substr($path, 0, 7) == 'ftps://' || substr($path, 0, 7) == 'sftp://' ) return $path;
|
1705 |
-
else {
|
1706 |
-
$is_outside_root = ( substr($path, 0, strlen($abspath_notrailing_slash)) != $abspath_notrailing_slash );
|
1707 |
-
if ( $is_outside_root ) return 'abs:'.$path;
|
1708 |
-
// else return str_replace($abspath_notrailing_slash, "", $path);
|
1709 |
-
else return substr($path, strlen($abspath_notrailing_slash));
|
1710 |
-
}
|
1711 |
-
}
|
1712 |
-
|
1713 |
-
/**
|
1714 |
-
* Convert Relative Path to Absolute.
|
1715 |
-
*
|
1716 |
-
* This function converts a relative path to absolute one by prepending the root
|
1717 |
-
* path of the website.
|
1718 |
-
*
|
1719 |
-
* @since 3.1.0
|
1720 |
-
*
|
1721 |
-
* @param string $path The relative path.
|
1722 |
-
*
|
1723 |
-
* @return string The absolute path.
|
1724 |
-
*/
|
1725 |
-
function wfu_path_rel2abs($path) {
|
1726 |
-
if ( substr($path, 0, 1) == "/" ) $path = substr($path, 1);
|
1727 |
-
if ( substr($path, 0, 6) == 'ftp://' || substr($path, 0, 7) == 'ftps://' || substr($path, 0, 7) == 'sftp://' ) return $path;
|
1728 |
-
elseif ( substr($path, 0, 4) == 'abs:' ) return substr($path, 4);
|
1729 |
-
else return wfu_abspath().$path;
|
1730 |
-
}
|
1731 |
-
|
1732 |
-
/**
|
1733 |
-
* Delete an Uploaded File.
|
1734 |
-
*
|
1735 |
-
* This function deletes an uploaded file from the website. It marks the file as
|
1736 |
-
* deleted in the database. It also deletes any linked attachments or
|
1737 |
-
* thumbnails.
|
1738 |
-
*
|
1739 |
-
* @since 4.2.0
|
1740 |
-
*
|
1741 |
-
* @redeclarable
|
1742 |
-
*
|
1743 |
-
* @param string $filepath The path of the file to delete.
|
1744 |
-
* @param int $userid The ID of the user who performs the deletion.
|
1745 |
-
* @param object $filerec Optional. The db record of the file, if available.
|
1746 |
-
*
|
1747 |
-
* @return bool True if the deletion succeeded, false otherwise.
|
1748 |
-
*/
|
1749 |
-
function wfu_delete_file_execute($filepath, $userid, $filerec = null) {
|
1750 |
-
$a = func_get_args(); $a = WFU_FUNCTION_HOOK(__FUNCTION__, $a, $out); if (isset($out['vars'])) foreach($out['vars'] as $p => $v) $$p = $v; switch($a) { case 'R': return $out['output']; break; case 'D': die($out['output']); }
|
1751 |
-
if ( $filerec == null ) $filedata = wfu_get_filedata($filepath);
|
1752 |
-
else $filedata = wfu_get_filedata_from_rec($filerec, true, false, false);
|
1753 |
-
$delete_rec = true;
|
1754 |
-
if ( $delete_rec ) $retid = wfu_log_action('delete', $filepath, $userid, '', 0, 0, '', null, $filerec);
|
1755 |
-
$result = unlink($filepath);
|
1756 |
-
if ( !$result ) wfu_revert_log_action($retid);
|
1757 |
-
elseif ( $delete_rec ) {
|
1758 |
-
//delete linked attachment if exists and it is allowed to be deleted
|
1759 |
-
if ( $filedata != null && isset($filedata["media"]) && WFU_VAR("WFU_UPDATE_MEDIA_ON_DELETE") == "true" )
|
1760 |
-
wp_delete_attachment( $filedata["media"]["attach_id"] );
|
1761 |
-
}
|
1762 |
-
|
1763 |
-
return $result;
|
1764 |
-
}
|
1765 |
-
|
1766 |
-
/**
|
1767 |
-
* Extract FTP Information From ftpinfo Attribute.
|
1768 |
-
*
|
1769 |
-
* This function extracts FTP information from ftpinfo attribute of the uploader
|
1770 |
-
* shortcode.
|
1771 |
-
*
|
1772 |
-
* @since 4.11.2
|
1773 |
-
*
|
1774 |
-
* @param string $ftpdata The ftpinfo attribute.
|
1775 |
-
*
|
1776 |
-
* @return array {
|
1777 |
-
* An array of extracted FTP information.
|
1778 |
-
*
|
1779 |
-
* @type bool $error Defines whether there was an error during
|
1780 |
-
* extraction of FTP information.
|
1781 |
-
* @type array $data {
|
1782 |
-
* The extracted FTP information.
|
1783 |
-
*
|
1784 |
-
* @type string $username The FTP login username.
|
1785 |
-
* @type string $password The FTP login password.
|
1786 |
-
* @type string $ftpdomain The FTP domain.
|
1787 |
-
* @type string $port The FTP port.
|
1788 |
-
* @type bool $sftp Defines whether sFTP connection will be used.
|
1789 |
-
* }
|
1790 |
-
* }
|
1791 |
-
*/
|
1792 |
-
function wfu_decode_ftpinfo($ftpdata) {
|
1793 |
-
$ret = array(
|
1794 |
-
"error" => true,
|
1795 |
-
"data" => array(
|
1796 |
-
"username" => "",
|
1797 |
-
"password" => "",
|
1798 |
-
"ftpdomain" => "",
|
1799 |
-
"port" => "",
|
1800 |
-
"sftp" => false
|
1801 |
-
)
|
1802 |
-
);
|
1803 |
-
$ftpdata_flat = str_replace(array('\\:', '\\@'), array('\\_', '\\_'), $ftpdata);
|
1804 |
-
$pos1 = strpos($ftpdata_flat, ":");
|
1805 |
-
$pos2 = strpos($ftpdata_flat, "@");
|
1806 |
-
if ( $pos1 && $pos2 && $pos2 > $pos1 ) {
|
1807 |
-
$ret["error"] = false;
|
1808 |
-
$ret["data"]["username"] = str_replace(array('\\\\:', '\\\\@'), array(':', '@'), substr($ftpdata, 0, $pos1));
|
1809 |
-
$ret["data"]["password"] = str_replace(array('\\\\:', '\\\\@'), array(':', '@'), substr($ftpdata, $pos1 + 1, $pos2 - $pos1 - 1));
|
1810 |
-
$ftp_host = substr($ftpdata, $pos2 + 1);
|
1811 |
-
$ret["data"]["ftpdomain"] = preg_replace("/:.*/", "", $ftp_host);
|
1812 |
-
if ( trim($ret["data"]["ftpdomain"]) == "" ) $ret["error"] = true;
|
1813 |
-
$ftp_port = preg_replace("/^[^:]*:?/", "", $ftp_host);
|
1814 |
-
if ( substr($ftp_port, 0, 1) == "s" ) {
|
1815 |
-
$ret["data"]["sftp"] = true;
|
1816 |
-
$ftp_port = substr($ftp_port, 1);
|
1817 |
-
}
|
1818 |
-
$ret["data"]["port"] = $ftp_port;
|
1819 |
-
}
|
1820 |
-
elseif ( $pos2 ) {
|
1821 |
-
$ret["error"] = false;
|
1822 |
-
$ret["data"]["username"] = str_replace(array('\\\\:', '\\\\@'), array(':', '@'), substr($ftpdata, 0, $pos2));
|
1823 |
-
$ftp_host = substr($ftpdata, $pos2 + 1);
|
1824 |
-
$ret["data"]["ftpdomain"] = preg_replace("/:.*/", "", $ftp_host);
|
1825 |
-
if ( trim($ret["data"]["ftpdomain"]) == "" ) $ret["error"] = true;
|
1826 |
-
$ftp_port = preg_replace("/^[^:]*:?/", "", $ftp_host);
|
1827 |
-
if ( substr($ftp_port, 0, 1) == "s" ) {
|
1828 |
-
$ret["data"]["sftp"] = true;
|
1829 |
-
$ftp_port = substr($ftp_port, 1);
|
1830 |
-
}
|
1831 |
-
$ret["data"]["port"] = $ftp_port;
|
1832 |
-
}
|
1833 |
-
elseif ( $pos1 ) {
|
1834 |
-
$ret["error"] = true;
|
1835 |
-
$ret["data"]["username"] = str_replace(array('\\\\:', '\\\\@'), array(':', '@'), substr($ftpdata, 0, $pos1));
|
1836 |
-
$ret["data"]["password"] = str_replace(array('\\\\:', '\\\\@'), array(':', '@'),substr($ftpdata, $pos1 + 1));
|
1837 |
-
}
|
1838 |
-
else {
|
1839 |
-
$ret["error"] = true;
|
1840 |
-
$ret["data"]["username"] = str_replace(array('\\\\:', '\\\\@'), array(':', '@'), $ftpdata);
|
1841 |
-
}
|
1842 |
-
|
1843 |
-
return $ret;
|
1844 |
-
}
|
1845 |
-
|
1846 |
-
/**
|
1847 |
-
* Get Full Upload Path.
|
1848 |
-
*
|
1849 |
-
* This function calculates the full upload path of an uploader shortcode from
|
1850 |
-
* its attributes.
|
1851 |
-
*
|
1852 |
-
* @since 2.1.2
|
1853 |
-
*
|
1854 |
-
* @param array $params The shortcode attributes.
|
1855 |
-
*
|
1856 |
-
* @return string The full uplod path.
|
1857 |
-
*/
|
1858 |
-
function wfu_upload_plugin_full_path( $params ) {
|
1859 |
-
$path = $params["uploadpath"];
|
1860 |
-
if ( $params["accessmethod"] == 'ftp' && $params["ftpinfo"] != '' && $params["useftpdomain"] == "true" ) {
|
1861 |
-
//remove parent folder symbol (..) in path so that the path does not go outside host
|
1862 |
-
$ftpdata = str_replace('..', '', $params["ftpinfo"]);
|
1863 |
-
$ftpinfo = wfu_decode_ftpinfo($ftpdata);
|
1864 |
-
if ( !$ftpinfo["error"] ) {
|
1865 |
-
$data = $ftpinfo["data"];
|
1866 |
-
//extract relative FTP path
|
1867 |
-
$ftp_port = $data["port"];
|
1868 |
-
if ( $data["sftp"] && $ftp_port == "" ) $ftp_port = "22";
|
1869 |
-
$ftp_host = $data["ftpdomain"].( $ftp_port != "" ? ":".$ftp_port : "" );
|
1870 |
-
$ftp_username = str_replace('@', '%40', $data["username"]); //if username contains @ character then convert it to %40
|
1871 |
-
$ftp_password = str_replace('@', '%40', $data["password"]); //if password contains @ character then convert it to %40
|
1872 |
-
$start_folder = ( $data["sftp"] ? 's' : '' ).'ftp://'.$ftp_username.':'.$ftp_password."@".$ftp_host.'/';
|
1873 |
-
}
|
1874 |
-
else $start_folder = 'ftp://'.$params["ftpinfo"].'/';
|
1875 |
-
}
|
1876 |
-
else $start_folder = WP_CONTENT_DIR.'/';
|
1877 |
-
if ($path) {
|
1878 |
-
if ( $path == ".." || substr($path, 0, 3) == "../" ) {
|
1879 |
-
$start_folder = wfu_abspath();
|
1880 |
-
$path = substr($path, 2, strlen($path) - 2);
|
1881 |
-
}
|
1882 |
-
//remove additional parent folder symbols (..) in path so that the path does not go outside the $start_folder
|
1883 |
-
$path = str_replace('..', '', $path);
|
1884 |
-
if ( substr($path, 0, 1) == "/" ) $path = substr($path, 1, strlen($path) - 1);
|
1885 |
-
if ( substr($path, -1, 1) == "/" ) $path = substr($path, 0, strlen($path) - 1);
|
1886 |
-
$full_upload_path = $start_folder;
|
1887 |
-
if ( $path != "" ) $full_upload_path .= $path.'/';
|
1888 |
-
}
|
1889 |
-
else {
|
1890 |
-
$full_upload_path = $start_folder;
|
1891 |
-
}
|
1892 |
-
return $full_upload_path;
|
1893 |
-
}
|
1894 |
-
|
1895 |
-
/**
|
1896 |
-
* Get Full Upload Path.
|
1897 |
-
*
|
1898 |
-
* This function calculates the full upload path of an uploader shortcode from
|
1899 |
-
* its attributes.
|
1900 |
-
*
|
1901 |
-
* @since 2.1.2
|
1902 |
-
*
|
1903 |
-
* @param array $params The shortcode attributes.
|
1904 |
-
*
|
1905 |
-
* @return string The full upload path.
|
1906 |
-
*/
|
1907 |
-
function wfu_upload_plugin_directory( $path ) {
|
1908 |
-
$dirparts = explode("/", $path);
|
1909 |
-
return $dirparts[count($dirparts) - 1];
|
1910 |
-
}
|
1911 |
-
|
1912 |
-
/**
|
1913 |
-
* Extract Additional Data From Complex Path.
|
1914 |
-
*
|
1915 |
-
* This function is used to extract sort, filename or filter information from
|
1916 |
-
* a complex path. A complex path is used by the plugin to pass additional
|
1917 |
-
* information between requests. In a complex path sort, filename and filter
|
1918 |
-
* information are stored as [[-sort]], {{filename}} and ((filter)).
|
1919 |
-
*
|
1920 |
-
* @since 2.2.1
|
1921 |
-
*
|
1922 |
-
* @param string $path The complex path.
|
1923 |
-
*
|
1924 |
-
* @return array {
|
1925 |
-
* Additional data extracted from path.
|
1926 |
-
*
|
1927 |
-
* @type string $path The clean path.
|
1928 |
-
* @type string $sort Sort information of a file list.
|
1929 |
-
* @type string $file Filename of a specific file.
|
1930 |
-
* @type string $filter Filter information of a file list.
|
1931 |
-
* }
|
1932 |
-
*/
|
1933 |
-
function wfu_extract_sortdata_from_path($path) {
|
1934 |
-
$ret['path'] = $path;
|
1935 |
-
$ret['sort'] = "";
|
1936 |
-
$ret['file'] = "";
|
1937 |
-
$ret['filter'] = "";
|
1938 |
-
//extract sort info
|
1939 |
-
$pos1 = strpos($path, '[[');
|
1940 |
-
$pos2 = strpos($path, ']]');
|
1941 |
-
if ( $pos1 !== false && $pos2 !== false )
|
1942 |
-
if ( $pos2 > $pos1 ) {
|
1943 |
-
$ret['sort'] = substr($path, $pos1 + 2, $pos2 - $pos1 - 2);
|
1944 |
-
$ret['path'] = str_replace('[['.$ret['sort'].']]', '', $path);
|
1945 |
-
}
|
1946 |
-
//extract filename info
|
1947 |
-
$pos1 = strpos($path, '{{');
|
1948 |
-
$pos2 = strpos($path, '}}');
|
1949 |
-
if ( $pos1 !== false && $pos2 !== false )
|
1950 |
-
if ( $pos2 > $pos1 ) {
|
1951 |
-
$ret['file'] = substr($path, $pos1 + 2, $pos2 - $pos1 - 2);
|
1952 |
-
$ret['path'] = str_replace('{{'.$ret['file'].'}}', '', $path);
|
1953 |
-
}
|
1954 |
-
//extract filter info
|
1955 |
-
$pos1 = strpos($path, '((');
|
1956 |
-
$pos2 = strpos($path, '))');
|
1957 |
-
if ( $pos1 !== false && $pos2 !== false )
|
1958 |
-
if ( $pos2 > $pos1 ) {
|
1959 |
-
$ret['filter'] = substr($path, $pos1 + 2, $pos2 - $pos1 - 2);
|
1960 |
-
$ret['path'] = str_replace('(('.$ret['filter'].'))', '', $path);
|
1961 |
-
}
|
1962 |
-
return $ret;
|
1963 |
-
}
|
1964 |
-
|
1965 |
-
/**
|
1966 |
-
* Flatten A Complex Path.
|
1967 |
-
*
|
1968 |
-
* This function returns only the clean path from a complex path.
|
1969 |
-
*
|
1970 |
-
* @since 2.2.1
|
1971 |
-
*
|
1972 |
-
* @param string $path The complex path.
|
1973 |
-
*
|
1974 |
-
* @return string The clean path.
|
1975 |
-
*/
|
1976 |
-
function wfu_flatten_path($path) {
|
1977 |
-
$ret = wfu_extract_sortdata_from_path($path);
|
1978 |
-
return $ret['path'];
|
1979 |
-
}
|
1980 |
-
|
1981 |
-
/**
|
1982 |
-
* Delete a Directory Recursively.
|
1983 |
-
*
|
1984 |
-
* This function deletes a directory recursively.
|
1985 |
-
*
|
1986 |
-
* @since 2.2.1
|
1987 |
-
*
|
1988 |
-
* @param string $dir The directory to delete.
|
1989 |
-
*
|
1990 |
-
* @return bool True if the deletion suceeded, false otherwise.
|
1991 |
-
*/
|
1992 |
-
fu
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|