PluginProbe ʕ •ᴥ•ʔ
Download Manager / 3.3.64
Download Manager v3.3.64
3.3.66 3.3.65 3.3.64 3.3.63 3.3.62 3.3.61 3.3.60 3.3.59 3.3.58 3.3.57 3.3.56 trunk 2.1.3 2.3.0 2.5.96 2.5.97 2.6.2 2.6.96 2.8.3 2.9.99 3.0.4 3.1.05 3.1.07 3.1.08 3.1.11 3.1.12 3.1.14 3.1.17 3.1.18 3.1.22 3.1.23 3.1.24 3.1.25 3.1.26 3.1.27 3.1.28 3.2.04 3.2.13 3.2.14 3.2.16 3.2.18 3.2.19 3.2.21 3.2.22 3.2.23 3.2.24 3.2.25 3.2.27 3.2.28 3.2.29 3.2.30 3.2.31 3.2.32 3.2.33 3.2.34 3.2.35 3.2.37 3.2.38 3.2.39 3.2.40 3.2.41 3.2.42 3.2.43 3.2.44 3.2.45 3.2.46 3.2.47 3.2.48 3.2.49 3.2.50 3.2.51 3.2.52 3.2.53 3.2.54 3.2.55 3.2.56 3.2.57 3.2.58 3.2.59 3.2.60 3.2.61 3.2.63 3.2.64 3.2.65 3.2.66 3.2.67 3.2.68 3.2.69 3.2.70 3.2.71 3.2.72 3.2.73 3.2.74 3.2.75 3.2.76 3.2.77 3.2.78 3.2.79 3.2.80 3.2.81 3.2.82 3.2.83 3.2.84 3.2.85 3.2.86 3.2.87 3.2.88 3.2.89 3.2.90 3.2.91 3.2.92 3.2.93 3.2.94 3.2.95 3.2.96 3.2.97 3.2.98 3.2.99 3.3.00 3.3.01 3.3.02 3.3.03 3.3.04 3.3.05 3.3.06 3.3.07 3.3.08 3.3.09 3.3.10 3.3.11 3.3.12 3.3.13 3.3.14 3.3.15 3.3.16 3.3.17 3.3.18 3.3.19 3.3.20 3.3.21 3.3.22 3.3.23 3.3.24 3.3.25 3.3.26 3.3.27 3.3.28 3.3.29 3.3.30 3.3.31 3.3.32 3.3.33 3.3.34 3.3.35 3.3.36 3.3.37 3.3.38 3.3.39 3.3.40 3.3.41 3.3.42 3.3.43 3.3.44 3.3.45 3.3.46 3.3.47 3.3.48 3.3.49 3.3.50 3.3.51 3.3.52 3.3.53 3.3.54 3.3.55
download-manager / src / Admin / views / metaboxes / attach-file / upload-file.php
download-manager / src / Admin / views / metaboxes / attach-file Last commit date
media-library-file.php 7 months ago remote-url.php 2 years ago server-file.php 3 years ago upload-file.php 7 months ago
upload-file.php
289 lines
1 <?php
2 if(!defined("ABSPATH")) die("Shit happens!");
3 $afiles = maybe_unserialize(get_post_meta(get_the_ID(), "__wpdm_files", true));
4 if(!is_array($afiles)) $afiles = [];
5 $afiles = array_values($afiles);
6 $afile = wpdm_valueof($afiles, 0);
7 ?>
8 <div class="w3eden">
9
10 <input type="hidden" name="file[files][]" value="<?php echo esc_attr($afile); ?>" id="wpdmfile" />
11
12 <div class="cfile" id="cfl">
13 <?php
14 $icon_info = ['icon' => 'fa-file', 'color' => '#28a745', 'gradient' => 'linear-gradient(135deg, #28a745 0%, #20c997 100%)'];
15 $filesize = "<em style='color: darkred'>( ".__("attached file is missing/deleted",'download-manager')." )</em>";
16 $afile = rtrim($afile);
17
18 $url = false;
19 if($afile !=''){
20 if(substr_count($afile, "://") > 0){
21 $fparts = parse_url($afile);
22 $url = true;
23 $hurl = strlen($fparts['host']) > 20 ? substr($fparts['host'], 0, 20)."..." : $fparts['host'];
24 $filesize = "<span class='w3eden'><span class='text-primary ellipsis ttip' title='".esc_attr($afile)."'><i class='fa fa-link'></i>".esc_html($hurl)."</span></span>";
25 }
26 else {
27 $filesize = wpdm_file_size($afile);
28 }
29
30 if(strpos($afile, "#")) {
31 $afile = explode("#", $afile);
32 $afile = $afile[1];
33 }
34
35 // Determine file icon based on extension
36 $file_ext = strtolower(pathinfo($afile, PATHINFO_EXTENSION));
37 $icon_map = [
38 // Documents
39 'pdf' => ['icon' => 'fa-file-pdf', 'color' => '#e53e3e', 'gradient' => 'linear-gradient(135deg, #e53e3e 0%, #c53030 100%)'],
40 'doc' => ['icon' => 'fa-file-word', 'color' => '#2b6cb0', 'gradient' => 'linear-gradient(135deg, #3182ce 0%, #2b6cb0 100%)'],
41 'docx' => ['icon' => 'fa-file-word', 'color' => '#2b6cb0', 'gradient' => 'linear-gradient(135deg, #3182ce 0%, #2b6cb0 100%)'],
42 'xls' => ['icon' => 'fa-file-excel', 'color' => '#276749', 'gradient' => 'linear-gradient(135deg, #38a169 0%, #276749 100%)'],
43 'xlsx' => ['icon' => 'fa-file-excel', 'color' => '#276749', 'gradient' => 'linear-gradient(135deg, #38a169 0%, #276749 100%)'],
44 'ppt' => ['icon' => 'fa-file-powerpoint', 'color' => '#c05621', 'gradient' => 'linear-gradient(135deg, #dd6b20 0%, #c05621 100%)'],
45 'pptx' => ['icon' => 'fa-file-powerpoint', 'color' => '#c05621', 'gradient' => 'linear-gradient(135deg, #dd6b20 0%, #c05621 100%)'],
46 'txt' => ['icon' => 'fa-file-alt', 'color' => '#718096', 'gradient' => 'linear-gradient(135deg, #a0aec0 0%, #718096 100%)'],
47 // Archives
48 'zip' => ['icon' => 'fa-file-archive', 'color' => '#d69e2e', 'gradient' => 'linear-gradient(135deg, #ecc94b 0%, #d69e2e 100%)'],
49 'rar' => ['icon' => 'fa-file-archive', 'color' => '#d69e2e', 'gradient' => 'linear-gradient(135deg, #ecc94b 0%, #d69e2e 100%)'],
50 '7z' => ['icon' => 'fa-file-archive', 'color' => '#d69e2e', 'gradient' => 'linear-gradient(135deg, #ecc94b 0%, #d69e2e 100%)'],
51 'tar' => ['icon' => 'fa-file-archive', 'color' => '#d69e2e', 'gradient' => 'linear-gradient(135deg, #ecc94b 0%, #d69e2e 100%)'],
52 'gz' => ['icon' => 'fa-file-archive', 'color' => '#d69e2e', 'gradient' => 'linear-gradient(135deg, #ecc94b 0%, #d69e2e 100%)'],
53 // Images
54 'jpg' => ['icon' => 'fa-file-image', 'color' => '#805ad5', 'gradient' => 'linear-gradient(135deg, #9f7aea 0%, #805ad5 100%)'],
55 'jpeg' => ['icon' => 'fa-file-image', 'color' => '#805ad5', 'gradient' => 'linear-gradient(135deg, #9f7aea 0%, #805ad5 100%)'],
56 'png' => ['icon' => 'fa-file-image', 'color' => '#805ad5', 'gradient' => 'linear-gradient(135deg, #9f7aea 0%, #805ad5 100%)'],
57 'gif' => ['icon' => 'fa-file-image', 'color' => '#805ad5', 'gradient' => 'linear-gradient(135deg, #9f7aea 0%, #805ad5 100%)'],
58 'svg' => ['icon' => 'fa-file-image', 'color' => '#805ad5', 'gradient' => 'linear-gradient(135deg, #9f7aea 0%, #805ad5 100%)'],
59 'webp' => ['icon' => 'fa-file-image', 'color' => '#805ad5', 'gradient' => 'linear-gradient(135deg, #9f7aea 0%, #805ad5 100%)'],
60 // Audio
61 'mp3' => ['icon' => 'fa-file-audio', 'color' => '#00b5d8', 'gradient' => 'linear-gradient(135deg, #0bc5ea 0%, #00b5d8 100%)'],
62 'wav' => ['icon' => 'fa-file-audio', 'color' => '#00b5d8', 'gradient' => 'linear-gradient(135deg, #0bc5ea 0%, #00b5d8 100%)'],
63 'ogg' => ['icon' => 'fa-file-audio', 'color' => '#00b5d8', 'gradient' => 'linear-gradient(135deg, #0bc5ea 0%, #00b5d8 100%)'],
64 'flac' => ['icon' => 'fa-file-audio', 'color' => '#00b5d8', 'gradient' => 'linear-gradient(135deg, #0bc5ea 0%, #00b5d8 100%)'],
65 // Video
66 'mp4' => ['icon' => 'fa-file-video', 'color' => '#e53e3e', 'gradient' => 'linear-gradient(135deg, #fc8181 0%, #e53e3e 100%)'],
67 'avi' => ['icon' => 'fa-file-video', 'color' => '#e53e3e', 'gradient' => 'linear-gradient(135deg, #fc8181 0%, #e53e3e 100%)'],
68 'mov' => ['icon' => 'fa-file-video', 'color' => '#e53e3e', 'gradient' => 'linear-gradient(135deg, #fc8181 0%, #e53e3e 100%)'],
69 'mkv' => ['icon' => 'fa-file-video', 'color' => '#e53e3e', 'gradient' => 'linear-gradient(135deg, #fc8181 0%, #e53e3e 100%)'],
70 'webm' => ['icon' => 'fa-file-video', 'color' => '#e53e3e', 'gradient' => 'linear-gradient(135deg, #fc8181 0%, #e53e3e 100%)'],
71 // Code
72 'html' => ['icon' => 'fa-file-code', 'color' => '#ed8936', 'gradient' => 'linear-gradient(135deg, #f6ad55 0%, #ed8936 100%)'],
73 'css' => ['icon' => 'fa-file-code', 'color' => '#3182ce', 'gradient' => 'linear-gradient(135deg, #63b3ed 0%, #3182ce 100%)'],
74 'js' => ['icon' => 'fa-file-code', 'color' => '#ecc94b', 'gradient' => 'linear-gradient(135deg, #faf089 0%, #ecc94b 100%)'],
75 'php' => ['icon' => 'fa-file-code', 'color' => '#667eea', 'gradient' => 'linear-gradient(135deg, #7f9cf5 0%, #667eea 100%)'],
76 'json' => ['icon' => 'fa-file-code', 'color' => '#48bb78', 'gradient' => 'linear-gradient(135deg, #68d391 0%, #48bb78 100%)'],
77 'xml' => ['icon' => 'fa-file-code', 'color' => '#ed8936', 'gradient' => 'linear-gradient(135deg, #f6ad55 0%, #ed8936 100%)'],
78 ];
79
80 $icon_info = $icon_map[$file_ext] ?? ['icon' => 'fa-file', 'color' => '#28a745', 'gradient' => 'linear-gradient(135deg, #28a745 0%, #20c997 100%)'];
81
82 // Use link icon for URLs
83 if ($url) {
84 $icon_info = ['icon' => 'fa-link', 'color' => '#3182ce', 'gradient' => 'linear-gradient(135deg, #4299e1 0%, #3182ce 100%)'];
85 }
86 ?>
87 <div style="display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: linear-gradient(135deg, #f8fffe 0%, #f0faf7 100%); border: 1px solid #d4edda; border-radius: 8px; transition: all 0.2s ease;">
88 <div style="width: 42px; height: 42px; background: <?php echo $icon_info['gradient']; ?>; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; box-shadow: 0 2px 8px <?php echo $icon_info['color']; ?>40;">
89 <i class="fas <?php echo $icon_info['icon']; ?>" style="color: #fff; font-size: 18px;"></i>
90 </div>
91 <div class="media-body" style="flex: 1; min-width: 0;">
92 <strong style="display: block; font-size: 13px; color: #2d3748; line-height: 1.4; word-break: break-word; margin-bottom: 2px;"><?php echo esc_html(basename(urldecode($afile))); ?></strong>
93 <span style="font-size: 12px; color: #718096;"><?php echo $filesize; ?></span>
94 </div>
95 <a href="#" id="dcf" title="Delete Current File" style="width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; background: #fff; border: 1px solid #e2e8f0; border-radius: 6px; color: #a0aec0; transition: all 0.2s ease; flex-shrink: 0;" onmouseover="this.style.background='#fed7d7'; this.style.borderColor='#fc8181'; this.style.color='#c53030';" onmouseout="this.style.background='#fff'; this.style.borderColor='#e2e8f0'; this.style.color='#a0aec0';">
96 <i class="fa fa-trash" style="font-size: 14px;"></i>
97 </a>
98 </div>
99
100 <?php } else { ?>
101 <div style="display: flex; padding: 10px; gap: 10px; background: linear-gradient(135deg, #fefefe 0%, #f7fafc 100%); border: 2px dashed #e2e8f0; border-radius: 8px; text-align: left;">
102 <div style="width: 48px; height: 48px; background: linear-gradient(135deg, #edf2f7 0%, #e2e8f0 100%); border-radius: 50%; display: flex; align-items: center; justify-content: center;">
103 <i class="fas fa-cloud-upload-alt" style="font-size: 20px; color: #a0aec0;"></i>
104 </div>
105 <div>
106 <div style="font-size: 14px; margin-top: 4px; color: #718096; font-weight: 500;"><?php echo __('No file attached yet!', 'download-manager'); ?></div>
107 <span style="font-size: 11px; color: #a0aec0; margin-top: 4px;"><?php echo __('Use any option below', 'download-manager'); ?></span>
108 </div>
109 </div>
110 <?php } ?>
111 <div style="clear: both;"></div>
112 </div>
113
114
115 <div id="upload">
116 <div id="plupload-upload-ui" class="hide-if-no-js">
117 <div id="drag-drop-area">
118 <div class="drag-drop-inside" style="margin-top: 40px">
119 <p class="drag-drop-info" style="letter-spacing: 1px;font-size: 10pt"><?php _e('Drop file here','download-manager'); ?><p>
120 <p>&mdash; <?php _ex('or', 'Uploader: Drop file here - or - Select File','download-manager'); ?> &mdash;</p>
121 <p class="drag-drop-buttons">
122 <button id="plupload-browse-button" type="button" class="btn btn-sm btn-success wpdm-whatsapp"><i class="fa fa-file"></i> <?php esc_attr_e('Select File','download-manager'); ?></button><br/>
123 <small style="margin-top: 15px;display: block">[ <?php _e('Max', 'download-manager'); ?>: <?php echo get_option('__wpdm_chunk_upload',0) == 1?'No Limit':(int)(wp_max_upload_size()/1048576).' MB'; ?> ]</small>
124 </p>
125 </div>
126 </div>
127 </div>
128
129 <?php
130
131 $plupload_init = array(
132 'runtimes' => 'html5,silverlight,flash,html4',
133 'browse_button' => 'plupload-browse-button',
134 'container' => 'plupload-upload-ui',
135 'drop_element' => 'drag-drop-area',
136 'file_data_name' => 'package_file',
137 'multiple_queues' => true,
138 'url' => admin_url('admin-ajax.php'),
139 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
140 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
141 'filters' => array(array('title' => __('Allowed Files'), 'extensions' => WPDM()->fileSystem->getAllowedFileTypes(false) )),
142 'multipart' => true,
143 'urlstream_upload' => true,
144 // additional post data to send to our ajax hook
145 'multipart_params' => array(
146 '_ajax_nonce' => wp_create_nonce(NONCE_KEY),
147 'type' => 'package_attachment',
148 'package_id' => get_the_ID(),
149 'action' => 'wpdm_admin_upload_file', // the ajax action name
150 ),
151 );
152
153 if(get_option('__wpdm_chunk_upload',0) == 1){
154 $plupload_init['chunk_size'] = (int)get_option('__wpdm_chunk_size', 1024).'kb';
155 $plupload_init['max_retries'] = 3;
156 } else
157 $plupload_init['max_file_size'] = wp_max_upload_size().'b';
158
159 // we should probably not apply this filter, plugins may expect wp's media uploader...
160 $plupload_init = apply_filters('plupload_init', $plupload_init); ?>
161
162 <script type="text/javascript">
163
164 jQuery(document).ready(function($){
165
166 // create the uploader and pass the config from above
167 var uploader = new plupload.Uploader(<?php echo json_encode($plupload_init); ?>);
168
169 // checks if browser supports drag and drop upload, makes some css adjustments if necessary
170 uploader.bind('Init', function(up){
171 var uploaddiv = jQuery('#plupload-upload-ui');
172
173 if(up.features.dragdrop){
174 uploaddiv.addClass('drag-drop');
175 jQuery('#drag-drop-area')
176 .bind('dragover.wp-uploader', function(){ uploaddiv.addClass('drag-over'); })
177 .bind('dragleave.wp-uploader, drop.wp-uploader', function(){ uploaddiv.removeClass('drag-over'); });
178
179 }else{
180 uploaddiv.removeClass('drag-drop');
181 jQuery('#drag-drop-area').unbind('.wp-uploader');
182 }
183 });
184
185 uploader.init();
186
187 // a file was added in the queue
188 uploader.bind('FilesAdded', function(up, files){
189 //var hundredmb = 100 * 1024 * 1024, max = parseInt(up.settings.max_file_size, 10);
190
191
192
193 plupload.each(files, function(file){
194 jQuery('#filelist').append(
195 '<div class="file" id="' + file.id + '"><b>' +
196
197 file.name.replace(/</ig, "&lt;") + '</b> (<span>' + plupload.formatSize(0) + '</span>/' + plupload.formatSize(file.size) + ') ' +
198 '<div class="progress progress-success progress-striped active"><div class="bar fileprogress"></div></div></div>');
199 });
200
201 up.refresh();
202 up.start();
203 });
204
205 uploader.bind('UploadProgress', function(up, file) {
206
207 jQuery('#' + file.id + " .fileprogress").width(file.percent + "%");
208 jQuery('#' + file.id + " span").html(plupload.formatSize(parseInt(file.size * file.percent / 100)));
209 });
210
211
212 // a file was uploaded
213 uploader.bind('FileUploaded', function(up, file, response) {
214
215 jQuery('#' + file.id ).remove();
216 var d = new Date();
217 var ID = d.getTime();
218 response = response.response;
219 if(response == -3)
220 jQuery('#cfl').html('<span class="text-danger"><i class="fa fa-exclamation-triangle"></i> &nbsp; <?php _e('Invalid File Type!','download-manager');?></span>');
221 else if(response == -2)
222 jQuery('#cfl').html('<span class="text-danger"><i class="fa fa-exclamation-triangle"></i> &nbsp; <?php _e('Unauthorized Access!','download-manager');?></span>');
223 else {
224 var data = response.split("|||");
225 jQuery('#wpdmfile').val(data[1]);
226 jQuery('#cfl').html('<div class="media"><a href="#" class="pull-right ttip" id="dcf" title="<?php _e('Delete Current File', 'download-manager');?>" style="font-size: 24px"><i class="fa fa-trash color-red"></i></a><div class="media-body"><strong>' + data[1] + '</strong><br/>'+data[2]+' </div></div>').slideDown();
227 }
228 });
229 });
230
231 </script>
232 <div id="filelist"></div>
233
234 <div class="clear"></div>
235 </div>
236
237 <script type="text/x-template" id="atftpl">
238 <div style="display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: linear-gradient(135deg, #f8fffe 0%, #f0faf7 100%); border: 1px solid #d4edda; border-radius: 8px; transition: all 0.2s ease;">
239 <div style="width: 42px; height: 42px; background: <?php echo $icon_info['gradient']; ?>; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; box-shadow: 0 2px 8px <?php echo $icon_info['color']; ?>40;">
240 <i class="fas <?php echo $icon_info['icon']; ?>" style="color: #fff; font-size: 18px;"></i>
241 </div>
242 <div class="media-body" style="flex: 1; min-width: 0;">
243 <strong style="display: block; font-size: 13px; color: #2d3748; line-height: 1.4; word-break: break-word; margin-bottom: 2px;">{{filetitle}}</strong>
244 <span style="font-size: 12px; color: #718096;"><i class="fa fa-check-double"></i> Attached</span>
245 </div>
246 <a href="#" id="dcf" title="Delete Current File" style="width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; background: #fff; border: 1px solid #e2e8f0; border-radius: 6px; color: #a0aec0; transition: all 0.2s ease; flex-shrink: 0;" onmouseover="this.style.background='#fed7d7'; this.style.borderColor='#fc8181'; this.style.color='#c53030';" onmouseout="this.style.background='#fff'; this.style.borderColor='#e2e8f0'; this.style.color='#a0aec0';">
247 <i class="fa fa-trash" style="font-size: 14px;"></i>
248 </a>
249 </div>
250 </script>
251
252
253 <script>
254 function wpdm_html_compile(html, dataset){
255 return html.replace(/{{(.*?)}}/g,
256 function (...match) {
257 return dataset[match[1]];
258 });
259 }
260 function wpdm_attach_file(file)
261 {
262 jQuery('#wpdmfile').val(file.filepath);
263 let atftpl = jQuery('#atftpl').html();
264 atftpl = wpdm_html_compile(atftpl, file);
265 jQuery('#cfl').html(atftpl);
266 //jQuery('#cfl').html('<div class="media"><a href="#" class="pull-right ttip" id="dcf" title="<?php _e('Delete Current File', 'download-manager');?>" style="font-size: 24px"><i class="fa fa-trash color-red"></i></a><div class="media-body"><strong>' + file.filetitle + '</strong><br/>&mdash;</div></div>').slideDown();
267
268
269 }
270
271 jQuery(function($){
272
273
274 $('body').on('click', '#dcf', function(){
275 if(!confirm('<?php _e('Are you sure?','download-manager'); ?>')) return false;
276 $('#wpdmfile').val('');
277 $('#cfl').html('<?php _e('<div class="w3eden"><div class="text-danger"><i class="fa fa-check-circle"></i> Removed!</div></div>','download-manager'); ?>');
278 });
279
280
281
282
283 });
284
285 </script>
286
287
288 </div>
289