WordPress File Upload - Version 4.16.1

Version Description

  • corrected $_SESSION variable problem in maintenance purge function
Download this release

Release Info

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

Code changes from version 4.16.0 to 4.16.1

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&amp;action=sync_db&amp;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&amp;action=clean_log_ask&amp;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&amp;action=purge_data_ask&amp;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&amp;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&amp;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&amp;action=sync_db&amp;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&amp;action=clean_log_ask&amp;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&amp;action=purge_data_ask&amp;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&amp;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&amp;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 = ( isset($_SESSION) ? array_keys($_SESSION) : array() );
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
  }
readme.txt CHANGED
@@ -149,6 +149,9 @@ There is an option in plugin's settings in Dashboard to relax the CSS rules, so
149
 
150
  == Changelog ==
151
 
 
 
 
152
  = 4.16.0 =
153
  * visual editor edit button misalignment fixed
154
  * corrected echo problem when recording from webcam with sound
@@ -903,6 +906,9 @@ Initial version.
903
 
904
  == Upgrade Notice ==
905
 
 
 
 
906
  = 4.16.0 =
907
  Regular update to fix some bugs and introduce some code improvements.
908
 
149
 
150
  == Changelog ==
151
 
152
+ = 4.16.1 =
153
+ * corrected $_SESSION variable problem in maintenance purge function
154
+
155
  = 4.16.0 =
156
  * visual editor edit button misalignment fixed
157
  * corrected echo problem when recording from webcam with sound
906
 
907
  == Upgrade Notice ==
908
 
909
+ = 4.16.1 =
910
+ Regular update to fix some bugs and introduce some code improvements.
911
+
912
  = 4.16.0 =
913
  Regular update to fix some bugs and introduce some code improvements.
914
 
release_notes.txt CHANGED
@@ -1,3 +1,3 @@
1
- <!-- --><span><strong>Version 4.16.0</strong> is a regular update that introduces some code improvements and bug fixes.<br /><br />
2
  For more details about this version's changes please visit the <strong>Release Notes</strong> of the plugin's </span><a href="http://www.iptanus.com/wordpress-plugins/wordpress-file-upload/">support page</a><span>.</span><!-- -->
3
  <!-- -->
1
+ <!-- --><span><strong>Version 4.16.1</strong> is a minor update that introduces a fix in <strong>Maintenance Actions Purge</strong> function.<br /><br />
2
  For more details about this version's changes please visit the <strong>Release Notes</strong> of the plugin's </span><a href="http://www.iptanus.com/wordpress-plugins/wordpress-file-upload/">support page</a><span>.</span><!-- -->
3
  <!-- -->
wordpress_file_upload.php CHANGED
@@ -3,14 +3,14 @@
3
  /*
4
  Plugin URI: https://www.iptanus.com/support/wordpress-file-upload
5
  Description: Simple interface to upload files from a page.
6
- Version: 4.16.0
7
  Author: Nickolas Bossinas
8
  Author URI: https://www.iptanus.com/nickolas
9
  Text Domain: wp-file-upload
10
  Domain Path: /languages
11
 
12
  Wordpress File Upload (Wordpress Plugin)
13
- Copyright (C) 2010-2020 Nickolas Bossinas
14
  Contact me at https://www.iptanus.com/contact
15
 
16
  This program is free software: you can redistribute it and/or modify
3
  /*
4
  Plugin URI: https://www.iptanus.com/support/wordpress-file-upload
5
  Description: Simple interface to upload files from a page.
6
+ Version: 4.16.1
7
  Author: Nickolas Bossinas
8
  Author URI: https://www.iptanus.com/nickolas
9
  Text Domain: wp-file-upload
10
  Domain Path: /languages
11
 
12
  Wordpress File Upload (Wordpress Plugin)
13
+ Copyright (C) 2010-2021 Nickolas Bossinas
14
  Contact me at https://www.iptanus.com/contact
15
 
16
  This program is free software: you can redistribute it and/or modify