WordPress Download Manager - Version 3.2.56

Version Description

  • 2022.09.08 =
  • Fixed case sensitive file extension issue
Download this release

Release Info

Developer codename065
Plugin Icon 128x128 WordPress Download Manager
Version 3.2.56
Comparing to
See all releases

Code changes from version 3.2.55 to 3.2.56

download-manager.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: https://www.wpdownloadmanager.com/purchases/
5
  Description: Manage, Protect and Track file downloads, and sell digital products from your WordPress site. A complete digital asset management solution.
6
  Author: W3 Eden, Inc.
7
  Author URI: https://www.wpdownloadmanager.com/
8
- Version: 3.2.55
9
  Text Domain: download-manager
10
  Domain Path: /languages
11
  */
@@ -39,7 +39,7 @@ use WPDM\Widgets\WidgetController;
39
 
40
  global $WPDM;
41
 
42
- define('WPDM_VERSION','3.2.55');
43
 
44
  define('WPDM_TEXT_DOMAIN','download-manager');
45
 
5
  Description: Manage, Protect and Track file downloads, and sell digital products from your WordPress site. A complete digital asset management solution.
6
  Author: W3 Eden, Inc.
7
  Author URI: https://www.wpdownloadmanager.com/
8
+ Version: 3.2.56
9
  Text Domain: download-manager
10
  Domain Path: /languages
11
  */
39
 
40
  global $WPDM;
41
 
42
+ define('WPDM_VERSION','3.2.56');
43
 
44
  define('WPDM_TEXT_DOMAIN','download-manager');
45
 
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: download manager, document management, file manager, digital store, ecomme
5
  Requires at least: 5.3
6
  Tested up to: 6.0
7
  License: GPLv2 or later
8
- Stable tag: 3.2.55
9
 
10
 
11
  This File Management & Digital Store plugin will help you to control file downloads & sell digital products from your WP site.
@@ -181,6 +181,9 @@ Check download stats and get a push notification when someone downloads, install
181
 
182
  == Changelog ==
183
 
 
 
 
184
  = 3.2.55 - 2022.08.31 =
185
  * Fixed an issue with file browser root dir selection
186
  * Fixed an issue with URL encoding
5
  Requires at least: 5.3
6
  Tested up to: 6.0
7
  License: GPLv2 or later
8
+ Stable tag: 3.2.56
9
 
10
 
11
  This File Management & Digital Store plugin will help you to control file downloads & sell digital products from your WP site.
181
 
182
  == Changelog ==
183
 
184
+ = 3.2.56 - 2022.09.08 =
185
+ * Fixed case sensitive file extension issue
186
+
187
  = 3.2.55 - 2022.08.31 =
188
  * Fixed an issue with file browser root dir selection
189
  * Fixed an issue with URL encoding
src/Admin/Menu/Packages.php CHANGED
@@ -10,273 +10,303 @@ use WPDM\__\FileSystem;
10
  use WPDM\Package\Package;
11
  use WPDM\WordPressDownloadManager;
12
 
13
- class Packages
14
- {
15
-
16
- var $sanitize = array(
17
- 'icon' => 'url',
18
- 'version' => 'txt',
19
- 'link_label' => 'txt',
20
- 'package_size' => 'txt',
21
- 'page_template' => 'txt',
22
- 'view_count' => 'int',
23
- 'download_count' => 'int',
24
- 'terms_conditions' => 'kses',
25
- );
26
-
27
- function __construct()
28
- {
29
-
30
- add_action('wp_ajax_wpdm_admin_upload_file', array($this, 'uploadFile'));
31
- add_action('save_post', array($this, 'savePackage'));
32
-
33
- add_action('manage_wpdmpro_posts_columns', array($this, 'columnsTH'));
34
- add_action('manage_wpdmpro_posts_custom_column', array($this, 'columnsTD'), 10, 2);
35
-
36
- add_filter( 'request', array($this, 'orderbyDownloads') );
37
- add_filter( 'manage_edit-wpdmpro_sortable_columns', array($this, 'sortableDownloads') );
38
-
39
- add_filter('post_row_actions', array($this, 'rowActions'), 10, 2);
40
-
41
- add_action('admin_footer', array($this, 'footerScripts'));
42
-
43
- add_action("admin_init", [$this, 'duplicate']);
44
-
45
- }
46
-
47
- function savePackage($post)
48
- {
49
- if(!current_user_can('edit_post', $post) || !current_user_can('upload_files', $post)) return;
50
- if (get_post_type() != 'wpdmpro' || !isset($_POST['file'])) return;
51
-
52
- // Deleted old zipped file
53
- $zipped = get_post_meta($post, "__wpdm_zipped_file", true);
54
- if($zipped!='' && file_exists($zipped)) { @unlink($zipped); }
55
-
56
- $cdata = get_post_custom($post);
57
- $donot_delete_meta = array('__wpdm_favs', '__wpdm_masterkey');
58
- foreach ($cdata as $k => $v) {
59
- $tk = str_replace("__wpdm_", "", $k);
60
- if (!isset($_POST['file'][$tk]) && $tk !== $k && !in_array($k, $donot_delete_meta))
61
- delete_post_meta($post, $k);
62
-
63
- }
64
-
65
- foreach ($_POST['file'] as $meta_key => $meta_value) {
66
- $key_name = "__wpdm_" . $meta_key;
67
- if($meta_key == 'package_size' && (double)$meta_value == 0) $meta_value = "";
68
- if($meta_key == 'files'){
69
- foreach ($meta_value as &$value){
70
- $value = wpdm_escs($value);
71
- if(!__::is_url($value)) {
72
- if(WPDM()->fileSystem->isBlocked($value)) $value = '';
73
- $abspath = WPDM()->fileSystem->locateFile( $value );
74
- if ( ! WPDM()->fileSystem->allowedPath( $abspath ) ) {
75
- $value = '';
76
- }
77
- }
78
- }
79
- $meta_value = array_unique($meta_value);
80
- } else if($meta_key == 'terms_conditions'){
81
- $meta_value = __::sanitize_var($meta_value, 'kses');
82
- } else
83
- $meta_value = is_array($meta_value)?wpdm_sanitize_array($meta_value, 'txt'):htmlspecialchars($meta_value);
84
- update_post_meta($post, $key_name, $meta_value);
85
- }
86
-
87
- $masterKey = Crypt::encrypt(['id' => $post, 'time' => time()]);
88
- if(get_post_meta($post, '__wpdm_masterkey', true) == '')
89
- update_post_meta($post, '__wpdm_masterkey', $masterKey);
90
-
91
- if (isset($_POST['reset_key']) && $_POST['reset_key'] == 1)
92
- update_post_meta($post, '__wpdm_masterkey', $masterKey);
93
-
94
- if(isset($_REQUEST['reset_udl'])) WPDM()->downloadHistory->resetUserDownloadCount($post, 'all');
95
- do_action('wpdm_admin_update_package',$post, $_POST['file']);
96
- }
97
-
98
- function duplicate()
99
- {
100
- if(wpdm_query_var('wpdm_duplicate', 'int') > 0 && get_post_type(wpdm_query_var('wpdm_duplicate')) === 'wpdmpro') {
101
- if(!current_user_can('edit_posts') || !wp_verify_nonce(wpdm_query_var('__copynonce'), NONCE_KEY)) wp_die(esc_attr__( 'You are not authorized!', 'download-manager' ));
102
- Package::copy(wpdm_query_var('wpdm_duplicate', 'int'));
103
- wp_redirect("edit.php?post_type=wpdmpro");
104
- die();
105
- }
106
- }
107
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
 
109
- function uploadFile(){
110
- check_ajax_referer(NONCE_KEY);
111
- if(!current_user_can('upload_files')) die('-2');
 
112
 
113
- $name = isset($_FILES['package_file']['name']) && !isset($_REQUEST["chunks"])?sanitize_file_name($_FILES['package_file']['name']):wpdm_query_var('name', 'txt');
 
 
 
 
 
114
 
115
- $ext = FileSystem::fileExt($name);
116
 
117
- if(WPDM()->fileSystem->isBlocked($name, $_FILES['package_file']['tmp_name'])) die('-3');
118
-
119
- do_action("wpdm_before_upload_file", $_FILES['package_file']);
120
-
121
- @set_time_limit(0);
122
-
123
- if(!file_exists(UPLOAD_DIR)){
124
- WPDM()->createDir();
125
- }
126
-
127
- if(file_exists(UPLOAD_DIR.$name) && get_option('__wpdm_overwrrite_file',0)==1){
128
- @unlink(UPLOAD_DIR.$name);
129
- }
130
- if(file_exists(UPLOAD_DIR.$name) && !isset($_REQUEST["chunks"]))
131
- $filename = time().'wpdm_'.$name;
132
- else
133
- $filename = $name;
134
-
135
- //$filename = esc_html($filename);
136
-
137
- if(get_option('__wpdm_sanitize_filename', 0) == 1)
138
- $filename = sanitize_file_name($filename);
139
- else {
140
- $filename = str_replace(["/", "\\"], "_", $filename);
141
- }
142
-
143
- if(isset($_REQUEST["chunks"])) $this->chunkUploadFile(UPLOAD_DIR.$filename);
144
- else {
145
- move_uploaded_file($_FILES['package_file']['tmp_name'], UPLOAD_DIR . $filename);
146
- do_action("wpdm_after_upload_file", UPLOAD_DIR . $filename);
147
- }
148
-
149
- //$filename = apply_filters("wpdm_after_upload_file", $filename, UPLOAD_DIR);
150
-
151
- echo "|||".$filename."|||";
152
- exit;
153
- }
154
-
155
-
156
- function chunkUploadFile($destFilePath){
157
-
158
- if($destFilePath === '') return;
159
- $chunk = isset($_REQUEST["chunk"]) ? intval($_REQUEST["chunk"]) : 0;
160
- $chunks = isset($_REQUEST["chunks"]) ? intval($_REQUEST["chunks"]) : 0;
161
- $out = @fopen("{$destFilePath}.part", $chunk == 0 ? "wb" : "ab");
162
-
163
- if ($out) {
164
- // Read binary input stream and append it to temp file
165
- $in = @fopen($_FILES['package_file']['tmp_name'], "rb");
166
-
167
- if ($in) {
168
- while ($buff = fread($in, 4096))
169
- fwrite($out, $buff);
170
- } else
171
- die('-3');
172
-
173
- @fclose($in);
174
- @fclose($out);
175
-
176
- @unlink($_FILES['package_file']['tmp_name']);
177
- } else {
178
- die('-3'.$destFilePath);
179
- }
180
-
181
- if (!$chunks || $chunk == $chunks - 1) {
182
- // Strip the temp .part suffix off
183
- rename("{$destFilePath}.part", $destFilePath);
184
- do_action("wpdm_after_upload_file", $destFilePath);
185
- }
186
- }
187
 
 
 
188
 
189
- function columnsTH($defaults) {
190
- if(get_post_type()!='wpdmpro') return $defaults;
191
- $img['image'] = "<span class='wpdm-th-icon ttip' style='font-size: 0.8em'><i style='font-size: 80%' class='far fa-image'></i></span>";
192
- __::array_splice_assoc( $defaults, 1, 0, $img );
193
- $otf['download_count'] = "<span class='wpdm-th-icon ttip' style='font-size: 0.8em'><i style='font-size: 80%' class='fas fa-arrow-down'></i></span>";
194
- $otf['wpdmembed'] = esc_attr__( 'Shortcode', 'download-manager' );
195
- __::array_splice_assoc( $defaults, 3, 0, $otf );
196
- return $defaults;
197
- }
198
 
 
 
 
 
 
199
 
200
- function columnsTD($column_name, $post_ID) {
201
- if(get_post_type()!='wpdmpro') return;
202
- if ($column_name == 'download_count') {
203
 
204
- echo current_user_can(WPDM_ADMIN_CAP) || get_the_author_meta('ID') === get_current_user_id()?(int)get_post_meta($post_ID, '__wpdm_download_count', true):'&mdash;';
 
205
 
206
- }
207
- if ($column_name == 'wpdmembed') {
208
 
209
- echo "<div class='w3eden'><div class='input-group short-code-wpdm'><input readonly=readonly class='form-control bg-white' onclick='this.select();' value=\"[wpdm_package id='$post_ID']\" id='sci{$post_ID}' /><div class='input-group-btn'><button type='button' onclick=\"WPDM.copy('sci{$post_ID}')\" class='btn btn-secondary'><i class='fa fa-copy'></i></button></div></div></div>";
210
- //echo "<div class='w3eden'><button type='button' href='#' data-toggle='modal' data-target='#embModal' data-pid='{$post_ID}' class='btn btn-secondary btn-embed'><i class='fa fa-bars'></i></button></div>";
211
-
212
- }
213
- if ($column_name == 'image') {
214
- if(has_post_thumbnail($post_ID))
215
- echo get_the_post_thumbnail( $post_ID, 'thumbnail', array('class'=>'img60px') );
216
- else {
217
- $icon = get_post_meta($post_ID,'__wpdm_icon', true);
218
- if($icon!=''){
219
- $icon = $icon;
220
- echo "<img src='$icon' class='img60px' alt='Icon' />";
221
- }
222
- }
223
- }
224
- }
225
 
226
 
227
- function orderbyDownloads( $vars ) {
228
 
229
- if ( isset( $vars['orderby'] ) && 'download_count' == $vars['orderby'] ) {
230
- $vars = array_merge( $vars, array(
231
- 'meta_key' => '__wpdm_download_count',
232
- 'orderby' => 'meta_value_num'
233
- ) );
234
- }
235
 
236
- return $vars;
237
- }
238
 
239
- function sortableDownloads( $columns ) {
240
 
241
- if(get_post_type()!='wpdmpro') return $columns;
 
 
242
 
243
- $columns['download_count'] = 'download_count';
244
 
245
- return $columns;
246
- }
 
 
 
 
 
 
 
 
 
 
247
 
 
 
248
 
249
- function rowActions($actions, $post)
250
- {
251
- if($post->post_type == 'wpdmpro' && current_user_can(WPDM_ADMIN_CAP)) {
252
- $actions['duplicate'] = '<a title="' . __( "Duplicate" , "download-manager" ) . '" href="' . admin_url("/?wpdm_duplicate={$post->ID}&__copynonce=".wp_create_nonce(NONCE_KEY)) . '" class="wpdm_duplicate w3eden">'.esc_attr__( 'Duplicate', 'download-manager' ).'</a>';
253
- $actions['view_stats'] = '<a title="' . __( "Stats" , "download-manager" ) . '" href="edit.php?post_type=wpdmpro&page=wpdm-stats&pid=' . $post->ID . '" class="view_stats w3eden"><i class="fas fa-chart-pie color-blue"></i></a>';
254
- if($post->post_status == 'publish')
255
- $actions['download_link'] = '<a title="' . __( "Master Download URL" , "download-manager" ) . '" href="#" class="gdl_action w3eden" data-mdlu="'.WPDM()->package->getMasterDownloadURL($post->ID).'" data-toggle="modal" data-target="#gdluModal" data-pid="'.$post->ID.'"><i class="far fa-arrow-alt-circle-down color-purple"></i></a>';
256
- }
257
- return $actions;
258
- }
259
 
260
-
261
- function footerScripts(){
262
- global $pagenow;
263
- if(wpdm_query_var('post_type') === 'wpdmpro' && $pagenow === 'edit.php') {
264
- ?>
265
 
266
  <style>
267
  .w3eden #edlModal .modal-content,
268
- .w3eden #gdluModal .modal-content{
269
  padding: 20px;
270
  border-radius: 15px;
271
  }
 
272
  .w3eden #edlModal .modal-content .modal-header i,
273
- .w3eden #gdluModal .modal-content .modal-header i{
274
  margin-right: 6px;
275
  }
 
276
  .w3eden #gdluModal .modal-content .modal-footer,
277
  .w3eden #gdluModal .modal-content .modal-header,
278
  .w3eden #edlModal .modal-content .modal-footer,
279
- .w3eden #edlModal .modal-content .modal-header{
280
  border: 0;
281
  }
282
  </style>
@@ -287,53 +317,71 @@ class Packages
287
  <div class="modal-content">
288
 
289
  <div class="modal-header">
290
- <h4 class="modal-title"><i class="fa fa-paste color-green"></i> <?php _e("Embed Package", "download-manager"); ?></h4>
 
 
291
  </div>
292
  <div class="modal-body">
293
 
294
  <div class="input-group input-group-lg">
295
- <input type="text" value="[wpdm_package id='{{ID}}']" id="cpsc" readonly="readonly" class="form-control bg-white" style="font-family: monospace;font-weight: bold;text-align: center">
 
 
296
  <div class="input-group-btn">
297
- <button style="padding-left: 30px;padding-right: 30px" onclick="WPDM.copy('cpsc');" type="button" class="btn btn-secondary"><i class="fa fa-copy"></i> <?php echo esc_attr__( 'Copy', 'download-manager' );?></button>
 
 
 
298
  </div>
299
  </div>
300
  <div class="alert alert-info" style="margin-top: 20px">
301
- <?php echo esc_attr__( 'If you are on Gutenberg Editor or elementor, you may use gutenberg block or elementor add-on for wpdm to embed wpdm packages and categories or generate another available layouts', 'download-manager' ); ?>
302
  </div>
303
 
304
  <div class="panel panel-default card-plain">
305
  <div class="panel-heading">
306
- <?php echo esc_attr__( 'Go To Page', 'download-manager' );?>
307
  </div>
308
  <div class="panel-body">
309
  <div class="row">
310
- <div class="col-md-9"><?php wp_dropdown_pages(['class' => 'form-control wpdm-custom-select', 'id' => 'gotopg']); ?></div>
311
- <div class="col-md-3"><button onclick="location.href='post.php?action=edit&post='+jQuery('#gotopg').val()" type="button" class="btn btn-secondary btn-block"><?php echo esc_attr__( 'Go', 'download-manager' ); ?></button></div>
 
 
 
 
 
 
 
312
  </div>
313
 
314
  </div>
315
  <div class="panel-footer bg-white">
316
- <a href="post-new.php?post_type=page"><?php echo esc_attr__( 'Create new page', 'download-manager' );?></a>
317
  </div>
318
  </div>
319
 
320
 
321
- <?php if(!defined('__WPDM_GB__')) { ?>
322
- <a class="btn btn-block btn-secondary thickbox open-plugin-details-modal" href="<?php echo admin_url('/plugin-install.php?tab=plugin-information&plugin=wpdm-gutenberg-blocks&TB_iframe=true&width=600&height=550')?>"><?php echo esc_attr__( 'Install Gutenberg Blocks by WordPress Download Manager', 'download-manager' );?></a>
323
- <?php } ?>
324
- <?php if(!defined('__WPDM_ELEMENTOR__')) { ?>
325
- <a class="btn btn-block btn-secondary thickbox open-plugin-details-modal" style="margin-top: 10px" href="<?php echo admin_url('/plugin-install.php?tab=plugin-information&plugin=wpdm-elementor&TB_iframe=true&width=600&height=550')?>"><?php echo esc_attr__( 'Install Download Manager Addons for Elementor', 'download-manager' );?></a>
326
- <?php } ?>
327
- <?php if(!function_exists('LiveForms')) { ?>
328
- <a class="btn btn-block btn-info thickbox open-plugin-details-modal" style="margin-top: 10px" href="<?php echo admin_url('/plugin-install.php?tab=plugin-information&plugin=liveforms&TB_iframe=true&width=600&height=550')?>"><?php echo esc_attr__( 'Install The Best WordPress Contact Form Builder', 'download-manager' );?></a>
329
- <?php } ?>
330
-
331
-
 
 
 
332
 
333
 
334
  </div>
335
  <div class="modal-footer">
336
- <button type="button" class="btn btn-secondary" data-dismiss="modal"><?php _e("Close", "download-manager"); ?></button>
 
337
  </div>
338
  </div><!-- /.modal-content -->
339
  </div><!-- /.modal-dialog -->
@@ -344,15 +392,19 @@ class Packages
344
  <div class="modal-content">
345
 
346
  <div class="modal-header">
347
- <h4 class="modal-title"><i class="far fa-arrow-alt-circle-down color-purple"></i> <?php _e("Generate Download Link", "download-manager"); ?></h4>
 
 
348
  </div>
349
  <div class="modal-body">
350
 
351
 
352
  <div class="panel panel-default">
353
  <div class="panel-heading">
354
- <div class="pull-right"><a id="mdlx" href="#" class="btn btn-xs btn-primary"><i class="fas fa-arrow-alt-circle-down"></i> <?php _e('Download', WPDM_TEXT_DOMAIN); ?></a></div>
355
- <?php _e("Master Download Link:", "download-manager"); ?>
 
 
356
  </div>
357
  <div class="panel-body"><input readonly="readonly" onclick="this.select()"
358
  type="text" class="form-control color-purple"
@@ -360,21 +412,29 @@ class Packages
360
  id="mdl"/></div>
361
  </div>
362
 
363
- <div class="panel panel-default ttip" style="opacity: 0.3" title="Available with the pro version only">
 
364
  <div class="panel-heading">Generate Temporary Download Link</div>
365
  <div class="panel-body">
366
 
367
  <div class="row">
368
  <div class="col-md-3">
369
  <label>Usage Limit:</label>
370
- <input disabled="disabled" min="1" class="form-control" id="ulimit" type="number" placeholder="<?php echo __( "Count", "download-manager" ) ?>" value="3">
 
 
 
371
  </div>
372
  <div class="col-md-5">
373
  <label>Expire After:</label>
374
  <div class="input-group">
375
- <input disabled="disabled" id="exmisd" min="0.5" step="0.5" class="form-control"
376
- type="number" value="600" style="width: 50%;display: inline-block;">
377
- <select disabled="disabled" id="expire_multiply" class="form-control wpdm-custom-select" style="min-width: 50%;max-width: 50% !important;display: inline-block;margin-left: -1px">
 
 
 
 
378
  <option value="60">Mins</option>
379
  <option value="3600">Hours</option>
380
  <option value="86400">Days</option>
@@ -384,7 +444,7 @@ class Packages
384
 
385
  <div class="col-md-4">
386
  <label>&nbsp;</label><br/>
387
- <button disabled="disabled" class="btn btn-secondary btn-block"
388
  style="height: 34px" type="button">Generate
389
  </button>
390
  </div>
@@ -432,7 +492,7 @@ class Packages
432
  $('#tmpgdlp').val('');
433
  });
434
 
435
- $('body').on('click', '.btn-embed', function (){
436
  var sc = "[wpdm_package id='{{ID}}']";
437
  sc = sc.replace("{{ID}}", $(this).data('pid'));
438
  console.log(sc);
@@ -443,24 +503,22 @@ class Packages
443
  });
444
  </script>
445
 
446
- <?php
447
- }
448
 
449
- if($pagenow === 'themes.php' || $pagenow === 'theme-install.php'){
450
- if(!file_exists(ABSPATH.'/wp-content/themes/attire/')) {
451
- ?>
452
  <script>
453
  jQuery(function ($) {
454
- $('.page-title-action').after('<a href="<?php echo admin_url('/theme-install.php?search=attire'); ?>" class="hide-if-no-js page-title-action" style="border: 1px solid #0f9cdd;background: #13aef6;color: #ffffff;">Suggested Theme</a>');
455
  });
456
  </script>
457
- <?php
458
- }
459
- }
460
-
461
- }
462
-
463
 
 
464
 
465
 
466
  }
10
  use WPDM\Package\Package;
11
  use WPDM\WordPressDownloadManager;
12
 
13
+ class Packages {
14
+
15
+ var $sanitize = array(
16
+ 'icon' => 'url',
17
+ 'version' => 'txt',
18
+ 'link_label' => 'txt',
19
+ 'package_size' => 'txt',
20
+ 'page_template' => 'txt',
21
+ 'view_count' => 'int',
22
+ 'download_count' => 'int',
23
+ 'terms_conditions' => 'kses',
24
+ );
25
+
26
+ function __construct() {
27
+
28
+ add_action( 'wp_ajax_wpdm_admin_upload_file', array( $this, 'uploadFile' ) );
29
+ add_action( 'save_post', array( $this, 'savePackage' ) );
30
+
31
+ add_action( 'manage_wpdmpro_posts_columns', array( $this, 'columnsTH' ) );
32
+ add_action( 'manage_wpdmpro_posts_custom_column', array( $this, 'columnsTD' ), 10, 2 );
33
+
34
+ add_filter( 'request', array( $this, 'orderbyDownloads' ) );
35
+ add_filter( 'manage_edit-wpdmpro_sortable_columns', array( $this, 'sortableDownloads' ) );
36
+
37
+ add_filter( 'post_row_actions', array( $this, 'rowActions' ), 10, 2 );
38
+
39
+ add_action( 'admin_footer', array( $this, 'footerScripts' ) );
40
+
41
+ add_action( "admin_init", [ $this, 'duplicate' ] );
42
+
43
+ }
44
+
45
+ function savePackage( $post ) {
46
+ if ( ! current_user_can( 'edit_post', $post ) || ! current_user_can( 'upload_files', $post ) ) {
47
+ return;
48
+ }
49
+ if ( get_post_type() != 'wpdmpro' || ! isset( $_POST['file'] ) ) {
50
+ return;
51
+ }
52
+
53
+ // Deleted old zipped file
54
+ $zipped = get_post_meta( $post, "__wpdm_zipped_file", true );
55
+ if ( $zipped != '' && file_exists( $zipped ) ) {
56
+ @unlink( $zipped );
57
+ }
58
+
59
+ $cdata = get_post_custom( $post );
60
+ $donot_delete_meta = array( '__wpdm_favs', '__wpdm_masterkey' );
61
+ foreach ( $cdata as $k => $v ) {
62
+ $tk = str_replace( "__wpdm_", "", $k );
63
+ if ( ! isset( $_POST['file'][ $tk ] ) && $tk !== $k && ! in_array( $k, $donot_delete_meta ) ) {
64
+ delete_post_meta( $post, $k );
65
+ }
66
+
67
+ }
68
+
69
+ foreach ( $_POST['file'] as $meta_key => $meta_value ) {
70
+ $key_name = "__wpdm_" . $meta_key;
71
+ if ( $meta_key == 'package_size' && (double) $meta_value == 0 ) {
72
+ $meta_value = "";
73
+ }
74
+ if ( $meta_key == 'files' ) {
75
+ foreach ( $meta_value as &$value ) {
76
+ $value = wpdm_escs( $value );
77
+ if ( ! __::is_url( $value ) ) {
78
+ if ( WPDM()->fileSystem->isBlocked( $value ) ) {
79
+ $value = '';
80
+ }
81
+ $abspath = WPDM()->fileSystem->locateFile( $value );
82
+ if ( ! WPDM()->fileSystem->allowedPath( $abspath ) ) {
83
+ $value = '';
84
+ }
85
+ }
86
+ }
87
+ $meta_value = array_unique( $meta_value );
88
+ } else if ( $meta_key == 'terms_conditions' ) {
89
+ $meta_value = __::sanitize_var( $meta_value, 'kses' );
90
+ } else {
91
+ $meta_value = is_array( $meta_value ) ? wpdm_sanitize_array( $meta_value, 'txt' ) : htmlspecialchars( $meta_value );
92
+ }
93
+ update_post_meta( $post, $key_name, $meta_value );
94
+ }
95
+
96
+ $masterKey = Crypt::encrypt( [ 'id' => $post, 'time' => time() ] );
97
+ if ( get_post_meta( $post, '__wpdm_masterkey', true ) == '' ) {
98
+ update_post_meta( $post, '__wpdm_masterkey', $masterKey );
99
+ }
100
+
101
+ if ( isset( $_POST['reset_key'] ) && $_POST['reset_key'] == 1 ) {
102
+ update_post_meta( $post, '__wpdm_masterkey', $masterKey );
103
+ }
104
+
105
+ if ( isset( $_REQUEST['reset_udl'] ) ) {
106
+ WPDM()->downloadHistory->resetUserDownloadCount( $post, 'all' );
107
+ }
108
+ do_action( 'wpdm_admin_update_package', $post, $_POST['file'] );
109
+ }
110
+
111
+ function duplicate() {
112
+ if ( wpdm_query_var( 'wpdm_duplicate', 'int' ) > 0 && get_post_type( wpdm_query_var( 'wpdm_duplicate' ) ) === 'wpdmpro' ) {
113
+ if ( ! current_user_can( 'edit_posts' ) || ! wp_verify_nonce( wpdm_query_var( '__copynonce' ), NONCE_KEY ) ) {
114
+ wp_die( esc_attr__( 'You are not authorized!', 'download-manager' ) );
115
+ }
116
+ Package::copy( wpdm_query_var( 'wpdm_duplicate', 'int' ) );
117
+ wp_redirect( "edit.php?post_type=wpdmpro" );
118
+ die();
119
+ }
120
+ }
121
+
122
+
123
+ function uploadFile() {
124
+ check_ajax_referer( NONCE_KEY );
125
+ if ( ! current_user_can( 'upload_files' ) ) {
126
+ die( '-2' );
127
+ }
128
+
129
+ $name = isset( $_FILES['package_file']['name'] ) && ! isset( $_REQUEST["chunks"] ) ? sanitize_file_name( $_FILES['package_file']['name'] ) : wpdm_query_var( 'name', 'txt' );
130
+
131
+ $ext = FileSystem::fileExt( $name );
132
+
133
+ if ( WPDM()->fileSystem->isBlocked( $name, $_FILES['package_file']['tmp_name'] ) ) {
134
+ die( '-3' );
135
+ }
136
+
137
+ do_action( "wpdm_before_upload_file", $_FILES['package_file'] );
138
+
139
+ @set_time_limit( 0 );
140
+
141
+ if ( ! file_exists( UPLOAD_DIR ) ) {
142
+ WPDM()->createDir();
143
+ }
144
+
145
+ $filename = $name;
146
+
147
+ if ( (int)get_option( '__wpdm_sanitize_filename', 0 ) === 1 ) {
148
+ $filename = sanitize_file_name( $filename );
149
+ } else {
150
+ $filename = str_replace( [ "/", "\\" ], "_", $filename );
151
+ }
152
+
153
+ if ( file_exists( UPLOAD_DIR . $filename ) && ! isset( $_REQUEST["chunks"] ) ) {
154
+ $filename = time() . 'wpdm_' . $filename;
155
+ }
156
+
157
+
158
+ if ( isset( $_REQUEST["chunks"] ) ) {
159
+ $this->chunkUploadFile( UPLOAD_DIR . $filename );
160
+ } else {
161
+ move_uploaded_file( $_FILES['package_file']['tmp_name'], UPLOAD_DIR . $filename );
162
+ do_action( "wpdm_after_upload_file", UPLOAD_DIR . $filename );
163
+ }
164
+
165
+ //$filename = apply_filters("wpdm_after_upload_file", $filename, UPLOAD_DIR);
166
+
167
+ echo "|||" . $filename . "|||";
168
+ exit;
169
+ }
170
+
171
+
172
+ function chunkUploadFile( $destFilePath ) {
173
+
174
+ if ( $destFilePath === '' ) {
175
+ return;
176
+ }
177
+ $chunk = isset( $_REQUEST["chunk"] ) ? intval( $_REQUEST["chunk"] ) : 0;
178
+ $chunks = isset( $_REQUEST["chunks"] ) ? intval( $_REQUEST["chunks"] ) : 0;
179
+ $out = @fopen( "{$destFilePath}.part", $chunk == 0 ? "wb" : "ab" );
180
+
181
+ if ( $out ) {
182
+ // Read binary input stream and append it to temp file
183
+ $in = @fopen( $_FILES['package_file']['tmp_name'], "rb" );
184
+
185
+ if ( $in ) {
186
+ while ( $buff = fread( $in, 4096 ) ) {
187
+ fwrite( $out, $buff );
188
+ }
189
+ } else {
190
+ die( '-3' );
191
+ }
192
+
193
+ @fclose( $in );
194
+ @fclose( $out );
195
 
196
+ @unlink( $_FILES['package_file']['tmp_name'] );
197
+ } else {
198
+ die( '-3' . $destFilePath );
199
+ }
200
 
201
+ if ( ! $chunks || $chunk == $chunks - 1 ) {
202
+ // Strip the temp .part suffix off
203
+ rename( "{$destFilePath}.part", $destFilePath );
204
+ do_action( "wpdm_after_upload_file", $destFilePath );
205
+ }
206
+ }
207
 
 
208
 
209
+ function columnsTH( $defaults ) {
210
+ if ( get_post_type() != 'wpdmpro' ) {
211
+ return $defaults;
212
+ }
213
+ $img['image'] = "<span class='wpdm-th-icon ttip' style='font-size: 0.8em'><i style='font-size: 80%' class='far fa-image'></i></span>";
214
+ __::array_splice_assoc( $defaults, 1, 0, $img );
215
+ $otf['download_count'] = "<span class='wpdm-th-icon ttip' style='font-size: 0.8em'><i style='font-size: 80%' class='fas fa-arrow-down'></i></span>";
216
+ $otf['wpdmembed'] = esc_attr__( 'Shortcode', 'download-manager' );
217
+ __::array_splice_assoc( $defaults, 3, 0, $otf );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
218
 
219
+ return $defaults;
220
+ }
221
 
 
 
 
 
 
 
 
 
 
222
 
223
+ function columnsTD( $column_name, $post_ID ) {
224
+ if ( get_post_type() != 'wpdmpro' ) {
225
+ return;
226
+ }
227
+ if ( $column_name == 'download_count' ) {
228
 
229
+ echo current_user_can( WPDM_ADMIN_CAP ) || get_the_author_meta( 'ID' ) === get_current_user_id() ? (int) get_post_meta( $post_ID, '__wpdm_download_count', true ) : '&mdash;';
 
 
230
 
231
+ }
232
+ if ( $column_name == 'wpdmembed' ) {
233
 
234
+ echo "<div class='w3eden'><div class='input-group short-code-wpdm'><input readonly=readonly class='form-control bg-white' onclick='this.select();' value=\"[wpdm_package id='$post_ID']\" id='sci{$post_ID}' /><div class='input-group-btn'><button type='button' onclick=\"WPDM.copy('sci{$post_ID}')\" class='btn btn-secondary'><i class='fa fa-copy'></i></button></div></div></div>";
235
+ //echo "<div class='w3eden'><button type='button' href='#' data-toggle='modal' data-target='#embModal' data-pid='{$post_ID}' class='btn btn-secondary btn-embed'><i class='fa fa-bars'></i></button></div>";
236
 
237
+ }
238
+ if ( $column_name == 'image' ) {
239
+ if ( has_post_thumbnail( $post_ID ) ) {
240
+ echo get_the_post_thumbnail( $post_ID, 'thumbnail', array( 'class' => 'img60px' ) );
241
+ } else {
242
+ $icon = get_post_meta( $post_ID, '__wpdm_icon', true );
243
+ if ( $icon != '' ) {
244
+ $icon = $icon;
245
+ echo "<img src='$icon' class='img60px' alt='Icon' />";
246
+ }
247
+ }
248
+ }
249
+ }
 
 
 
250
 
251
 
252
+ function orderbyDownloads( $vars ) {
253
 
254
+ if ( isset( $vars['orderby'] ) && 'download_count' == $vars['orderby'] ) {
255
+ $vars = array_merge( $vars, array(
256
+ 'meta_key' => '__wpdm_download_count',
257
+ 'orderby' => 'meta_value_num'
258
+ ) );
259
+ }
260
 
261
+ return $vars;
262
+ }
263
 
264
+ function sortableDownloads( $columns ) {
265
 
266
+ if ( get_post_type() != 'wpdmpro' ) {
267
+ return $columns;
268
+ }
269
 
270
+ $columns['download_count'] = 'download_count';
271
 
272
+ return $columns;
273
+ }
274
+
275
+
276
+ function rowActions( $actions, $post ) {
277
+ if ( $post->post_type == 'wpdmpro' && current_user_can( WPDM_ADMIN_CAP ) ) {
278
+ $actions['duplicate'] = '<a title="' . __( "Duplicate", "download-manager" ) . '" href="' . admin_url( "/?wpdm_duplicate={$post->ID}&__copynonce=" . wp_create_nonce( NONCE_KEY ) ) . '" class="wpdm_duplicate w3eden">' . esc_attr__( 'Duplicate', 'download-manager' ) . '</a>';
279
+ $actions['view_stats'] = '<a title="' . __( "Stats", "download-manager" ) . '" href="edit.php?post_type=wpdmpro&page=wpdm-stats&pid=' . $post->ID . '" class="view_stats w3eden"><i class="fas fa-chart-pie color-blue"></i></a>';
280
+ if ( $post->post_status == 'publish' ) {
281
+ $actions['download_link'] = '<a title="' . __( "Master Download URL", "download-manager" ) . '" href="#" class="gdl_action w3eden" data-mdlu="' . WPDM()->package->getMasterDownloadURL( $post->ID ) . '" data-toggle="modal" data-target="#gdluModal" data-pid="' . $post->ID . '"><i class="far fa-arrow-alt-circle-down color-purple"></i></a>';
282
+ }
283
+ }
284
 
285
+ return $actions;
286
+ }
287
 
 
 
 
 
 
 
 
 
 
 
288
 
289
+ function footerScripts() {
290
+ global $pagenow;
291
+ if ( wpdm_query_var( 'post_type' ) === 'wpdmpro' && $pagenow === 'edit.php' ) {
292
+ ?>
 
293
 
294
  <style>
295
  .w3eden #edlModal .modal-content,
296
+ .w3eden #gdluModal .modal-content {
297
  padding: 20px;
298
  border-radius: 15px;
299
  }
300
+
301
  .w3eden #edlModal .modal-content .modal-header i,
302
+ .w3eden #gdluModal .modal-content .modal-header i {
303
  margin-right: 6px;
304
  }
305
+
306
  .w3eden #gdluModal .modal-content .modal-footer,
307
  .w3eden #gdluModal .modal-content .modal-header,
308
  .w3eden #edlModal .modal-content .modal-footer,
309
+ .w3eden #edlModal .modal-content .modal-header {
310
  border: 0;
311
  }
312
  </style>
317
  <div class="modal-content">
318
 
319
  <div class="modal-header">
320
+ <h4 class="modal-title"><i
321
+ class="fa fa-paste color-green"></i> <?php _e( "Embed Package", "download-manager" ); ?>
322
+ </h4>
323
  </div>
324
  <div class="modal-body">
325
 
326
  <div class="input-group input-group-lg">
327
+ <input type="text" value="[wpdm_package id='{{ID}}']" id="cpsc" readonly="readonly"
328
+ class="form-control bg-white"
329
+ style="font-family: monospace;font-weight: bold;text-align: center">
330
  <div class="input-group-btn">
331
+ <button style="padding-left: 30px;padding-right: 30px"
332
+ onclick="WPDM.copy('cpsc');" type="button" class="btn btn-secondary"><i
333
+ class="fa fa-copy"></i> <?php echo esc_attr__( 'Copy', 'download-manager' ); ?>
334
+ </button>
335
  </div>
336
  </div>
337
  <div class="alert alert-info" style="margin-top: 20px">
338
+ <?php echo esc_attr__( 'If you are on Gutenberg Editor or elementor, you may use gutenberg block or elementor add-on for wpdm to embed wpdm packages and categories or generate another available layouts', 'download-manager' ); ?>
339
  </div>
340
 
341
  <div class="panel panel-default card-plain">
342
  <div class="panel-heading">
343
+ <?php echo esc_attr__( 'Go To Page', 'download-manager' ); ?>
344
  </div>
345
  <div class="panel-body">
346
  <div class="row">
347
+ <div class="col-md-9"><?php wp_dropdown_pages( [
348
+ 'class' => 'form-control wpdm-custom-select',
349
+ 'id' => 'gotopg'
350
+ ] ); ?></div>
351
+ <div class="col-md-3">
352
+ <button onclick="location.href='post.php?action=edit&post='+jQuery('#gotopg').val()"
353
+ type="button"
354
+ class="btn btn-secondary btn-block"><?php echo esc_attr__( 'Go', 'download-manager' ); ?></button>
355
+ </div>
356
  </div>
357
 
358
  </div>
359
  <div class="panel-footer bg-white">
360
+ <a href="post-new.php?post_type=page"><?php echo esc_attr__( 'Create new page', 'download-manager' ); ?></a>
361
  </div>
362
  </div>
363
 
364
 
365
+ <?php if ( ! defined( '__WPDM_GB__' ) ) { ?>
366
+ <a class="btn btn-block btn-secondary thickbox open-plugin-details-modal"
367
+ href="<?php echo admin_url( '/plugin-install.php?tab=plugin-information&plugin=wpdm-gutenberg-blocks&TB_iframe=true&width=600&height=550' ) ?>"><?php echo esc_attr__( 'Install Gutenberg Blocks by WordPress Download Manager', 'download-manager' ); ?></a>
368
+ <?php } ?>
369
+ <?php if ( ! defined( '__WPDM_ELEMENTOR__' ) ) { ?>
370
+ <a class="btn btn-block btn-secondary thickbox open-plugin-details-modal"
371
+ style="margin-top: 10px"
372
+ href="<?php echo admin_url( '/plugin-install.php?tab=plugin-information&plugin=wpdm-elementor&TB_iframe=true&width=600&height=550' ) ?>"><?php echo esc_attr__( 'Install Download Manager Addons for Elementor', 'download-manager' ); ?></a>
373
+ <?php } ?>
374
+ <?php if ( ! function_exists( 'LiveForms' ) ) { ?>
375
+ <a class="btn btn-block btn-info thickbox open-plugin-details-modal"
376
+ style="margin-top: 10px"
377
+ href="<?php echo admin_url( '/plugin-install.php?tab=plugin-information&plugin=liveforms&TB_iframe=true&width=600&height=550' ) ?>"><?php echo esc_attr__( 'Install The Best WordPress Contact Form Builder', 'download-manager' ); ?></a>
378
+ <?php } ?>
379
 
380
 
381
  </div>
382
  <div class="modal-footer">
383
+ <button type="button" class="btn btn-secondary"
384
+ data-dismiss="modal"><?php _e( "Close", "download-manager" ); ?></button>
385
  </div>
386
  </div><!-- /.modal-content -->
387
  </div><!-- /.modal-dialog -->
392
  <div class="modal-content">
393
 
394
  <div class="modal-header">
395
+ <h4 class="modal-title"><i
396
+ class="far fa-arrow-alt-circle-down color-purple"></i> <?php _e( "Generate Download Link", "download-manager" ); ?>
397
+ </h4>
398
  </div>
399
  <div class="modal-body">
400
 
401
 
402
  <div class="panel panel-default">
403
  <div class="panel-heading">
404
+ <div class="pull-right"><a id="mdlx" href="#" class="btn btn-xs btn-primary"><i
405
+ class="fas fa-arrow-alt-circle-down"></i> <?php _e( 'Download', WPDM_TEXT_DOMAIN ); ?>
406
+ </a></div>
407
+ <?php _e( "Master Download Link:", "download-manager" ); ?>
408
  </div>
409
  <div class="panel-body"><input readonly="readonly" onclick="this.select()"
410
  type="text" class="form-control color-purple"
412
  id="mdl"/></div>
413
  </div>
414
 
415
+ <div class="panel panel-default ttip" style="opacity: 0.3"
416
+ title="Available with the pro version only">
417
  <div class="panel-heading">Generate Temporary Download Link</div>
418
  <div class="panel-body">
419
 
420
  <div class="row">
421
  <div class="col-md-3">
422
  <label>Usage Limit:</label>
423
+ <input disabled="disabled" min="1" class="form-control" id="ulimit"
424
+ type="number"
425
+ placeholder="<?php echo __( "Count", "download-manager" ) ?>"
426
+ value="3">
427
  </div>
428
  <div class="col-md-5">
429
  <label>Expire After:</label>
430
  <div class="input-group">
431
+ <input disabled="disabled" id="exmisd" min="0.5" step="0.5"
432
+ class="form-control"
433
+ type="number" value="600"
434
+ style="width: 50%;display: inline-block;">
435
+ <select disabled="disabled" id="expire_multiply"
436
+ class="form-control wpdm-custom-select"
437
+ style="min-width: 50%;max-width: 50% !important;display: inline-block;margin-left: -1px">
438
  <option value="60">Mins</option>
439
  <option value="3600">Hours</option>
440
  <option value="86400">Days</option>
444
 
445
  <div class="col-md-4">
446
  <label>&nbsp;</label><br/>
447
+ <button disabled="disabled" class="btn btn-secondary btn-block"
448
  style="height: 34px" type="button">Generate
449
  </button>
450
  </div>
492
  $('#tmpgdlp').val('');
493
  });
494
 
495
+ $('body').on('click', '.btn-embed', function () {
496
  var sc = "[wpdm_package id='{{ID}}']";
497
  sc = sc.replace("{{ID}}", $(this).data('pid'));
498
  console.log(sc);
503
  });
504
  </script>
505
 
506
+ <?php
507
+ }
508
 
509
+ if ( $pagenow === 'themes.php' || $pagenow === 'theme-install.php' ) {
510
+ if ( ! file_exists( ABSPATH . '/wp-content/themes/attire/' ) ) {
511
+ ?>
512
  <script>
513
  jQuery(function ($) {
514
+ $('.page-title-action').after('<a href="<?php echo admin_url( '/theme-install.php?search=attire' ); ?>" class="hide-if-no-js page-title-action" style="border: 1px solid #0f9cdd;background: #13aef6;color: #ffffff;">Suggested Theme</a>');
515
  });
516
  </script>
517
+ <?php
518
+ }
519
+ }
 
 
 
520
 
521
+ }
522
 
523
 
524
  }
src/Admin/Menu/Settings.php CHANGED
@@ -123,6 +123,12 @@ class Settings
123
  foreach ($_POST as $optn => $optv) {
124
  if(strpos("__".$optn, '_wpdm_')) {
125
  $optv = wpdm_sanitize_array($optv);
 
 
 
 
 
 
126
  update_option($optn, $optv, false);
127
  }
128
  }
123
  foreach ($_POST as $optn => $optv) {
124
  if(strpos("__".$optn, '_wpdm_')) {
125
  $optv = wpdm_sanitize_array($optv);
126
+ if($optn === '_wpdm_file_browser_root') {
127
+ $optv = realpath( get_home_path() . '/' . $optv );
128
+ if ( $optv ) {
129
+ $optv = trailingslashit( $optv );
130
+ }
131
+ }
132
  update_option($optn, $optv, false);
133
  }
134
  }
src/AssetManager/AssetManager.php CHANGED
@@ -58,7 +58,7 @@ class AssetManager
58
  if($realUserRootExt) $realUserRootExt = self::fsPath($realUserRootExt);
59
  $userRootExt = self::fsPath($userRootExt);
60
 
61
- if(substr_count($userRootExt, $userRoot) == 0 || !$realUserRootExt || substr_count($realUserRootExt, $userRoot) === 0) return "[INVALID_PATH] {$realUserRootExt} {$userRoot}";
62
 
63
  if (is_dir($userRootExt)) $userRootExt = trailingslashit($userRootExt);
64
 
58
  if($realUserRootExt) $realUserRootExt = self::fsPath($realUserRootExt);
59
  $userRootExt = self::fsPath($userRootExt);
60
 
61
+ if(substr_count($userRootExt, $userRoot) == 0 || !$realUserRootExt || substr_count($realUserRootExt, $userRoot) === 0) return "[INVALID_PATH]";
62
 
63
  if (is_dir($userRootExt)) $userRootExt = trailingslashit($userRootExt);
64
 
src/__/FileSystem.php CHANGED
@@ -817,7 +817,7 @@ class FileSystem
817
 
818
  if(!$ext)
819
  $ext = self::fileExt($filename);
820
-
821
  return !in_array($ext, $types);
822
  }
823
 
817
 
818
  if(!$ext)
819
  $ext = self::fileExt($filename);
820
+ $ext = strtolower($ext);
821
  return !in_array($ext, $types);
822
  }
823