Version Description
- 29.09.2022 = Fixed: WP VIP servers bug ( #1052 ) thanks to @jesusfreak3 Fixed: Progress loader for external sources ( #1051 ) Fixed: Reports Page Most downloaded Download not shown correctly ( #1048 )
Download this release
Release Info
Developer | raldea89 |
Plugin | Download Monitor |
Version | 4.6.2 |
Comparing to | |
See all releases |
Code changes from version 4.6.1 to 4.6.2
- assets/css/frontend.css +2 -1
- assets/css/frontend.less +2 -1
- assets/css/frontend.min.css +1 -1
- assets/js/dlm-xhr.js +19 -0
- assets/js/dlm-xhr.min.js +1 -1
- assets/js/reports/reports.js +1 -1
- assets/js/reports/reports.min.js +1 -1
- changelog.txt +5 -0
- download-monitor.php +2 -2
- readme.txt +6 -1
- src/Admin/Reports/Page.php +1 -1
- src/FileManager.php +19 -1
assets/css/frontend.css
CHANGED
@@ -446,7 +446,8 @@ html body a.download-link.dlm-download-complete::before {
|
|
446 |
color: red;
|
447 |
}
|
448 |
.dlm-xhr-progress {
|
449 |
-
width: 75px;
|
|
|
450 |
display: inline-block;
|
451 |
position: relative;
|
452 |
}
|
446 |
color: red;
|
447 |
}
|
448 |
.dlm-xhr-progress {
|
449 |
+
min-width: 75px;
|
450 |
+
width: auto;
|
451 |
display: inline-block;
|
452 |
position: relative;
|
453 |
}
|
assets/css/frontend.less
CHANGED
@@ -441,7 +441,8 @@ html body a.download-link {
|
|
441 |
}
|
442 |
|
443 |
.dlm-xhr-progress {
|
444 |
-
width:75px;
|
|
|
445 |
display:inline-block;
|
446 |
position:relative;
|
447 |
}
|
441 |
}
|
442 |
|
443 |
.dlm-xhr-progress {
|
444 |
+
min-width:75px;
|
445 |
+
width:auto;
|
446 |
display:inline-block;
|
447 |
position:relative;
|
448 |
}
|
assets/css/frontend.min.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
.download-box{width:250px;border:1px solid #ccc;-moz-border-radius:4px;-webkit-border-radius:4px;border-radius:4px;text-align:center;position:relative;margin:1em auto;box-shadow:0 2px 4px rgba(0,0,0,.1),inset 0 1px 0 rgba(255,255,255,.4)}.download-box h1{margin:.5em 0!important}.download-box img.wp-post-image{margin:0;padding:0;display:block;width:100%;-moz-border-radius:0;-webkit-border-radius:0;-moz-border-top-left-radius:3px;-moz-border-top-right-radius:3px;-webkit-border-top-left-radius:3px;-webkit-border-top-right-radius:3px;border-radius:0;border-top-left-radius:3px;border-top-right-radius:3px;box-shadow:inset 0 1px 0 rgba(255,255,255,.4)}.download-box .download-box-content{padding:0 1em 1em}.download-box .download-count{-moz-border-radius:1em;-webkit-border-radius:1em;border-radius:1em;color:#777;text-shadow:0 1px 0 rgba(255,255,255,.5);background:#ddd;box-shadow:0 2px 4px rgba(0,0,0,.1),inset 0 1px 0 rgba(255,255,255,.4);position:absolute;top:0;right:0;padding:.6em;width:auto;min-width:1em;font-size:1em;text-align:center;vertical-align:middle;line-height:1em;border:1px solid #bbb;margin:-.5em -.5em 0 0}.download-button{text-align:center;text-decoration:none!important;padding:.75em 1em;color:#fff;display:block;font-size:1.2em;line-height:1.5em;background-color:#09c;background-image:-webkit-linear-gradient(#009fd4,#09c,#0086b2);background-image:-moz-linear-gradient(#009fd4,#09c,#0086b2);-moz-border-radius:4px;-webkit-border-radius:4px;border-radius:4px;text-shadow:0 -1px 0 rgba(0,0,0,.5);box-shadow:0 2px 4px rgba(0,0,0,.3),inset 0 1px 0 rgba(255,255,255,.4);border:1px solid #0086b2;cursor:pointer}.download-button:hover{color:#fff;background-color:#09c;background-image:-webkit-linear-gradient(#09c,#0086b2);background-image:-moz-linear-gradient(#09c,#0086b2)}.download-button:visited{color:#fff;text-decoration:none}.download-button small{font-size:.8em;opacity:.8;display:block}.filetype-icon{padding-left:19px;background-repeat:no-repeat;background-position:left;background-image:url(../images/filetypes/document.png)}.filetype-pdf{background-image:url(../images/filetypes/document-pdf.png)}.filetype-aif,.filetype-aifc,.filetype-aiff,.filetype-au,.filetype-kar,.filetype-m3u,.filetype-m4r,.filetype-mid,.filetype-midi,.filetype-mp2,.filetype-mp3,.filetype-mpga,.filetype-ra,.filetype-ram,.filetype-rm,.filetype-rpm,.filetype-snd,.filetype-wav,.filetype-wave{background-image:url(../images/filetypes/document-music.png)}.filetype-avi,.filetype-divx,.filetype-mov,.filetype-movie,.filetype-mp4,.filetype-mpe,.filetype-mpeg,.filetype-mpg,.filetype-mxu,.filetype-qt,.filetype-wmv{background-image:url(../images/filetypes/document-film.png)}.filetype-7z,.filetype-gz,.filetype-rar,.filetype-sit,.filetype-tar,.filetype-zip{background-image:url(../images/filetypes/document-zipper.png)}.filetype-csv,.filetype-tsv,.filetype-xls,.filetype-xlsx{background-image:url(../images/filetypes/document-excel.png)}.filetype-doc,.filetype-docx{background-image:url(../images/filetypes/document-word-text.png)}.filetype-ai{background-image:url(../images/filetypes/document-illustrator.png)}.filetype-swf{background-image:url(../images/filetypes/document-flash-movie.png)}.filetype-bmp,.filetype-djv,.filetype-eps,.filetype-gif,.filetype-ief,.filetype-jpe,.filetype-jpeg,.filetype-jpg,.filetype-pbm,.filetype-pgm,.filetype-png,.filetype-pnm,.filetype-ppm,.filetype-ps,.filetype-ras,.filetype-rgb,.filetype-tif,.filetype-tiff,.filetype-wbmp,.filetype-xbm,.filetype-xpm,.filetype-xwd{background-image:url(../images/filetypes/document-image.png)}.filetype-psd{background-image:url(../images/filetypes/document-photoshop.png)}.filetype-ppt,.filetype-pptx{background-image:url(../images/filetypes/document-powerpoint.png)}.filetype-as,.filetype-css,.filetype-htaccess,.filetype-htm,.filetype-html,.filetype-js,.filetype-php,.filetype-sql,.filetype-xml,.filetype-xsl{background-image:url(../images/filetypes/document-code.png)}.filetype-rtf,.filetype-rtx{background-image:url(../images/filetypes/document-text-image.png)}.filetype-txt{background-image:url(../images/filetypes/document-text.png)}#content nav.download-monitor-pagination,nav.download-monitor-pagination{text-align:center}#content nav.download-monitor-pagination ul,nav.download-monitor-pagination ul{display:inline-block;white-space:nowrap;padding:0;clear:both;border:1px solid #eee;border-right:0;margin:1px}#content nav.download-monitor-pagination ul li,nav.download-monitor-pagination ul li{border-right:1px solid #eee;padding:0;margin:0;float:left;display:inline;overflow:hidden}#content nav.download-monitor-pagination ul li a,#content nav.download-monitor-pagination ul li span,nav.download-monitor-pagination ul li a,nav.download-monitor-pagination ul li span{margin:0;text-decoration:none;padding:0;line-height:1em;font-size:1em;font-weight:400;padding:.5em;min-width:1em;display:block}#content nav.download-monitor-pagination ul li a:focus,#content nav.download-monitor-pagination ul li a:hover,#content nav.download-monitor-pagination ul li span.current,nav.download-monitor-pagination ul li a:focus,nav.download-monitor-pagination ul li a:hover,nav.download-monitor-pagination ul li span.current{background:#eee;color:#888}.dlm_widget_downloads ul,.dlm_widget_downloads ul li{list-style:none}.dlm-hidden-info{visibility:hidden}@keyframes infinite-spinning{from{transform:rotate(0)}to{transform:rotate(360deg)}}data.dlm-hidden-info{position:relative}data.dlm-hidden-info span{font-weight:700;color:green}.dlm-hidden-info .progress.dlm-visible-spinner{display:inline-block;visibility:visible}.dlm-hidden-info .progress.box{width:100%}.dlm-hidden-info .progress.box span.download-done::after{content:'✓'}.dlm-hidden-info .progress.box .progress-inner{height:6px;top:0;width:0%;-webkit-transition:width .3s,opacity .3s;transition:width .3s,opacity .3s;position:absolute;left:0;background:#006080;animation:none}.dlm-hidden-info .progress .progress-inner{display:none;width:75px;position:relative;margin-left:15px}.dlm-hidden-info .progress .progress-inner .dlm-visible-spinner{display:inline-block;visibility:visible}html body a.download-button{position:relative}html body a.download-button.dlm-download-started{text-decoration:none}html body a.download-button.dlm-download-complete::after{content:'✓';width:20px;right:-30px;position:absolute;height:100%;z-index:3;background:0 0;color:green;bottom:0;left:auto}html body a.download-button::before{content:'';position:absolute;height:2px;z-index:3;bottom:-2px;left:0;width:0;background:red;transition:width .5s;box-shadow:0 0 3px rgba(255,0,0,.8);border-radius:5px}html body a.download-button.download-10:before{width:10%}html body a.download-button.download-20:before{width:20%}html body a.download-button.download-30:before{width:30%}html body a.download-button.download-40:before{width:40%}html body a.download-button.download-50:before{width:50%}html body a.download-button.download-60:before{width:60%}html body a.download-button.download-70:before{width:70%}html body a.download-button.download-80:before{width:80%}html body a.download-button.download-90:before{width:90%}html body a.download-button.download-100:before{width:100%}a.download-button.dlm-download-complete::after{height:auto;top:50%;transform:translateY(-50%)}a.download-button::before{z-index:0}a.download-button>*{z-index:2;position:relative}html body a.download-link{position:relative}html body a.download-link::after,html body a.download-link::before{content:'';position:absolute;right:-40px;border-radius:5px;display:block;background:red;height:10px;width:10px;opacity:0;z-index:-1;transform:translateY(-50%);top:calc(50% - 5px)}html body a.download-link::before{animation:lds-ellipsis1 .6s infinite}html body a.download-link::after{animation:lds-ellipsis2 .6s infinite}html body a.download-link.dlm-download-started{text-decoration:none}html body a.download-link.dlm-download-started::after,html body a.download-link.dlm-download-started::before{opacity:1;z-index:99}html body a.download-link.dlm-download-complete::after{content:'✓';opacity:1;z-index:99;background:0 0;animation:none;transform:translateY(-50%);top:calc(50% - 5px);line-height:initial}html body a.download-link.dlm-download-complete::before{opacity:0;z-index:-1}@keyframes lds-ellipsis1{0%{transform:scale(0)}100%{transform:scale(1)}}@keyframes lds-ellipsis2{0%{transform:translate(0,0)}100%{transform:translate(24px,0)}}.dlm-xhr-error{font-size:12px;color:red}.dlm-xhr-progress{width:75px;display:inline-block;position:relative}
|
1 |
+
.download-box{width:250px;border:1px solid #ccc;-moz-border-radius:4px;-webkit-border-radius:4px;border-radius:4px;text-align:center;position:relative;margin:1em auto;box-shadow:0 2px 4px rgba(0,0,0,.1),inset 0 1px 0 rgba(255,255,255,.4)}.download-box h1{margin:.5em 0!important}.download-box img.wp-post-image{margin:0;padding:0;display:block;width:100%;-moz-border-radius:0;-webkit-border-radius:0;-moz-border-top-left-radius:3px;-moz-border-top-right-radius:3px;-webkit-border-top-left-radius:3px;-webkit-border-top-right-radius:3px;border-radius:0;border-top-left-radius:3px;border-top-right-radius:3px;box-shadow:inset 0 1px 0 rgba(255,255,255,.4)}.download-box .download-box-content{padding:0 1em 1em}.download-box .download-count{-moz-border-radius:1em;-webkit-border-radius:1em;border-radius:1em;color:#777;text-shadow:0 1px 0 rgba(255,255,255,.5);background:#ddd;box-shadow:0 2px 4px rgba(0,0,0,.1),inset 0 1px 0 rgba(255,255,255,.4);position:absolute;top:0;right:0;padding:.6em;width:auto;min-width:1em;font-size:1em;text-align:center;vertical-align:middle;line-height:1em;border:1px solid #bbb;margin:-.5em -.5em 0 0}.download-button{text-align:center;text-decoration:none!important;padding:.75em 1em;color:#fff;display:block;font-size:1.2em;line-height:1.5em;background-color:#09c;background-image:-webkit-linear-gradient(#009fd4,#09c,#0086b2);background-image:-moz-linear-gradient(#009fd4,#09c,#0086b2);-moz-border-radius:4px;-webkit-border-radius:4px;border-radius:4px;text-shadow:0 -1px 0 rgba(0,0,0,.5);box-shadow:0 2px 4px rgba(0,0,0,.3),inset 0 1px 0 rgba(255,255,255,.4);border:1px solid #0086b2;cursor:pointer}.download-button:hover{color:#fff;background-color:#09c;background-image:-webkit-linear-gradient(#09c,#0086b2);background-image:-moz-linear-gradient(#09c,#0086b2)}.download-button:visited{color:#fff;text-decoration:none}.download-button small{font-size:.8em;opacity:.8;display:block}.filetype-icon{padding-left:19px;background-repeat:no-repeat;background-position:left;background-image:url(../images/filetypes/document.png)}.filetype-pdf{background-image:url(../images/filetypes/document-pdf.png)}.filetype-aif,.filetype-aifc,.filetype-aiff,.filetype-au,.filetype-kar,.filetype-m3u,.filetype-m4r,.filetype-mid,.filetype-midi,.filetype-mp2,.filetype-mp3,.filetype-mpga,.filetype-ra,.filetype-ram,.filetype-rm,.filetype-rpm,.filetype-snd,.filetype-wav,.filetype-wave{background-image:url(../images/filetypes/document-music.png)}.filetype-avi,.filetype-divx,.filetype-mov,.filetype-movie,.filetype-mp4,.filetype-mpe,.filetype-mpeg,.filetype-mpg,.filetype-mxu,.filetype-qt,.filetype-wmv{background-image:url(../images/filetypes/document-film.png)}.filetype-7z,.filetype-gz,.filetype-rar,.filetype-sit,.filetype-tar,.filetype-zip{background-image:url(../images/filetypes/document-zipper.png)}.filetype-csv,.filetype-tsv,.filetype-xls,.filetype-xlsx{background-image:url(../images/filetypes/document-excel.png)}.filetype-doc,.filetype-docx{background-image:url(../images/filetypes/document-word-text.png)}.filetype-ai{background-image:url(../images/filetypes/document-illustrator.png)}.filetype-swf{background-image:url(../images/filetypes/document-flash-movie.png)}.filetype-bmp,.filetype-djv,.filetype-eps,.filetype-gif,.filetype-ief,.filetype-jpe,.filetype-jpeg,.filetype-jpg,.filetype-pbm,.filetype-pgm,.filetype-png,.filetype-pnm,.filetype-ppm,.filetype-ps,.filetype-ras,.filetype-rgb,.filetype-tif,.filetype-tiff,.filetype-wbmp,.filetype-xbm,.filetype-xpm,.filetype-xwd{background-image:url(../images/filetypes/document-image.png)}.filetype-psd{background-image:url(../images/filetypes/document-photoshop.png)}.filetype-ppt,.filetype-pptx{background-image:url(../images/filetypes/document-powerpoint.png)}.filetype-as,.filetype-css,.filetype-htaccess,.filetype-htm,.filetype-html,.filetype-js,.filetype-php,.filetype-sql,.filetype-xml,.filetype-xsl{background-image:url(../images/filetypes/document-code.png)}.filetype-rtf,.filetype-rtx{background-image:url(../images/filetypes/document-text-image.png)}.filetype-txt{background-image:url(../images/filetypes/document-text.png)}#content nav.download-monitor-pagination,nav.download-monitor-pagination{text-align:center}#content nav.download-monitor-pagination ul,nav.download-monitor-pagination ul{display:inline-block;white-space:nowrap;padding:0;clear:both;border:1px solid #eee;border-right:0;margin:1px}#content nav.download-monitor-pagination ul li,nav.download-monitor-pagination ul li{border-right:1px solid #eee;padding:0;margin:0;float:left;display:inline;overflow:hidden}#content nav.download-monitor-pagination ul li a,#content nav.download-monitor-pagination ul li span,nav.download-monitor-pagination ul li a,nav.download-monitor-pagination ul li span{margin:0;text-decoration:none;padding:0;line-height:1em;font-size:1em;font-weight:400;padding:.5em;min-width:1em;display:block}#content nav.download-monitor-pagination ul li a:focus,#content nav.download-monitor-pagination ul li a:hover,#content nav.download-monitor-pagination ul li span.current,nav.download-monitor-pagination ul li a:focus,nav.download-monitor-pagination ul li a:hover,nav.download-monitor-pagination ul li span.current{background:#eee;color:#888}.dlm_widget_downloads ul,.dlm_widget_downloads ul li{list-style:none}.dlm-hidden-info{visibility:hidden}@keyframes infinite-spinning{from{transform:rotate(0)}to{transform:rotate(360deg)}}data.dlm-hidden-info{position:relative}data.dlm-hidden-info span{font-weight:700;color:green}.dlm-hidden-info .progress.dlm-visible-spinner{display:inline-block;visibility:visible}.dlm-hidden-info .progress.box{width:100%}.dlm-hidden-info .progress.box span.download-done::after{content:'✓'}.dlm-hidden-info .progress.box .progress-inner{height:6px;top:0;width:0%;-webkit-transition:width .3s,opacity .3s;transition:width .3s,opacity .3s;position:absolute;left:0;background:#006080;animation:none}.dlm-hidden-info .progress .progress-inner{display:none;width:75px;position:relative;margin-left:15px}.dlm-hidden-info .progress .progress-inner .dlm-visible-spinner{display:inline-block;visibility:visible}html body a.download-button{position:relative}html body a.download-button.dlm-download-started{text-decoration:none}html body a.download-button.dlm-download-complete::after{content:'✓';width:20px;right:-30px;position:absolute;height:100%;z-index:3;background:0 0;color:green;bottom:0;left:auto}html body a.download-button::before{content:'';position:absolute;height:2px;z-index:3;bottom:-2px;left:0;width:0;background:red;transition:width .5s;box-shadow:0 0 3px rgba(255,0,0,.8);border-radius:5px}html body a.download-button.download-10:before{width:10%}html body a.download-button.download-20:before{width:20%}html body a.download-button.download-30:before{width:30%}html body a.download-button.download-40:before{width:40%}html body a.download-button.download-50:before{width:50%}html body a.download-button.download-60:before{width:60%}html body a.download-button.download-70:before{width:70%}html body a.download-button.download-80:before{width:80%}html body a.download-button.download-90:before{width:90%}html body a.download-button.download-100:before{width:100%}a.download-button.dlm-download-complete::after{height:auto;top:50%;transform:translateY(-50%)}a.download-button::before{z-index:0}a.download-button>*{z-index:2;position:relative}html body a.download-link{position:relative}html body a.download-link::after,html body a.download-link::before{content:'';position:absolute;right:-40px;border-radius:5px;display:block;background:red;height:10px;width:10px;opacity:0;z-index:-1;transform:translateY(-50%);top:calc(50% - 5px)}html body a.download-link::before{animation:lds-ellipsis1 .6s infinite}html body a.download-link::after{animation:lds-ellipsis2 .6s infinite}html body a.download-link.dlm-download-started{text-decoration:none}html body a.download-link.dlm-download-started::after,html body a.download-link.dlm-download-started::before{opacity:1;z-index:99}html body a.download-link.dlm-download-complete::after{content:'✓';opacity:1;z-index:99;background:0 0;animation:none;transform:translateY(-50%);top:calc(50% - 5px);line-height:initial}html body a.download-link.dlm-download-complete::before{opacity:0;z-index:-1}@keyframes lds-ellipsis1{0%{transform:scale(0)}100%{transform:scale(1)}}@keyframes lds-ellipsis2{0%{transform:translate(0,0)}100%{transform:translate(24px,0)}}.dlm-xhr-error{font-size:12px;color:red}.dlm-xhr-progress{min-width:75px;width:auto;display:inline-block;position:relative}
|
assets/js/dlm-xhr.js
CHANGED
@@ -312,6 +312,25 @@ class DLM_XHR_Download {
|
|
312 |
}
|
313 |
};
|
314 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
315 |
request.onerror = function () {
|
316 |
console.log('** An error occurred during the transaction');
|
317 |
};
|
312 |
}
|
313 |
};
|
314 |
|
315 |
+
request.addEventListener('progress', function (e) {
|
316 |
+
let percent_complete = (e.loaded / e.total) * 100;
|
317 |
+
// Force perfect complete to have 2 digits
|
318 |
+
percent_complete = percent_complete.toFixed(2);
|
319 |
+
let $class = 'dlm-download-started';
|
320 |
+
buttonObj.find('span.dlm-xhr-progress').remove();
|
321 |
+
// Comment below lines for the new XHR loader so that we know where to rever
|
322 |
+
$class = $class + ' download-' + Math.ceil(percent_complete / 10) * 10;
|
323 |
+
|
324 |
+
if (Infinity != percent_complete) {
|
325 |
+
buttonObj.append('<span class="dlm-xhr-progress"> ' + percent_complete + '%</span>');
|
326 |
+
}
|
327 |
+
|
328 |
+
// Show spinner
|
329 |
+
buttonObj.removeClass().addClass(buttonClass + ' ' + $class);
|
330 |
+
// Trigger the `dlm_download_progress` action
|
331 |
+
jQuery(document).trigger('dlm_download_progress', [this, button, buttonObj, _OBJECT_URL, e, percent_complete]);
|
332 |
+
});
|
333 |
+
|
334 |
request.onerror = function () {
|
335 |
console.log('** An error occurred during the transaction');
|
336 |
};
|
assets/js/dlm-xhr.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
jQuery(function(e){new DLM_XHR_Download});class DLM_XHR_Download{constructor(){(dlmXHRinstance=this).init()}init(){dlmXHRinstance.attachButtonEvent()}attachButtonEvent(){let d="",o="";jQuery.each(dlmXHR.xhr_links.class,function(e,t){-1<t.indexOf("[class")||-1<t.indexOf("[id")?d+=o+" "+t:d+=o+" ."+t,o=","}),jQuery("html, body").on("click",d,function(e){dlmXHRinstance.handleDownloadClick(this,e)})}handleDownloadClick(e,t){t.stopPropagation();var d=e.getAttribute("href");let o={button:e,href:d,buttonObj:jQuery(e)};-1===o.href.indexOf("blob:http")&&"#"!==o.href&&(t.preventDefault(),dlmXHRinstance.retrieveBlob(o))}retrieveBlob(e){let{button:l,href:r,buttonObj:a}=e,s;const i=new XMLHttpRequest,c=dlmXHR.prevent_duplicates;let m=a.attr("class");m=m.replace("dlm-download-started","").replace("dlm-download-completed",""),a.addClass("dlm-download-started"),l.setAttribute("href","#"),l.removeAttribute("download"),l.setAttribute("disabled","disabled");e=0<r.indexOf("?")?r+"&nonce="+dlmXHR.nonce:r+"?nonce="+dlmXHR.nonce;jQuery(document).trigger("dlm_download_triggered",[this,l,a,s]),i.responseType="blob",i.onreadystatechange=function(){var{status:e,readyState:t,statusText:d}=i;let o=i.getAllResponseHeaders().split("\r\n").reduce((e,t)=>{var[t,d]=t.split(": ");return e[t]=d,e},{});if(void 0!==o["dlm-no-waypoints"]&&(i.abort(),window.location.href=r),void 0!==o["dlm-external-download"])return i.abort(),n=o["dlm-file-name"].replace(/\"/g,"").replace(";",""),void dlmXHRinstance.dlmExternalDownload(o,l,a,n,r);if(2==i.readyState&&void 0!==o["dlm-error"]&&""!==o["dlm-error"]&&null!==o["dlm-error"])return dlmXHRinstance.dlmLogDownload(o["dlm-download-id"],o["dlm-version-id"],"failed",!1),i.abort(),void a.append('<span class="dlm-xhr-error">'+o["dlm-error"]+"</span>");if(2==i.readyState&&void 0!==o["dlm-redirect"]&&""!==o["dlm-redirect"]&&null!==o["dlm-redirect"])return dlmXHRinstance.dlmLogDownload(o["dlm-download-id"],o["dlm-version-id"],"redirected",!1,o["dlm-redirect"],o["dlm-no-access"]),void i.abort();if(2==i.readyState&&i.status,404==e&&2==t){let e=document.createElement("p");e.innerHTML=d,l.parentNode.appendChild(e)}if(401==e&&2==t&&(window.location.href=d),403==e&&2==t){let e=document.createElement("p");e.innerHTML=d,l.parentNode.appendChild(e)}if(200==e&&4==t){var n=i.response;let e=o["content-disposition"].split("filename=")[1];e=e.replace(/\"/g,"").replace(";",""),s=URL.createObjectURL(n),l.removeEventListener("click",dlmXHRinstance.handleDownloadClick),l.setAttribute("download",""+e),l.setAttribute("href",s),l.click(),a.removeClass().addClass(m+" dlm-download-complete"),dlmXHRinstance.attachButtonEvent(),jQuery(document).trigger("dlm_download_complete",[this,l,a,s]),dlmXHRinstance.dlmLogDownload(o["dlm-download-id"],o["dlm-version-id"],"completed",c),window.URL.revokeObjectURL(s),l.removeAttribute("download"),l.setAttribute("href",r),setTimeout(function(){a.removeClass().addClass(m).find("span.dlm-xhr-progress").remove()},4e3)}},i.addEventListener("progress",function(e){let t=e.loaded/e.total*100;t=t.toFixed(2);var d;a.find("span.dlm-xhr-progress").remove(),d="dlm-download-started download-"+10*Math.ceil(t/10),1/0!=t&&a.append('<span class="dlm-xhr-progress"> '+t+"%</span>"),a.removeClass().addClass(m+" "+d),jQuery(document).trigger("dlm_download_progress",[this,l,a,s,e,t])}),i.onerror=function(){console.log("** An error occurred during the transaction")},i.open("GET",e,!0),i.setRequestHeader("dlm-xhr-request","dlm_XMLHttpRequest"),i.send()}dlmLogDownload(e,t,d,o,n=null,l=null){null!==l?window.location.href=n:(l={download_id:e,version_id:t,status:d,cookie:o,currentURL:window.location.href,action:"log_dlm_xhr_download",nonce:dlmXHR.nonce},jQuery.post(dlmXHR.ajaxUrl,l,function(e){null!==n&&(window.location.href=n)}))}dlmExternalDownload(d,o,n,l,r){const a=new XMLHttpRequest,e=d["dlm-external-download"];let s=n.attr("class"),i;s=s.replace("dlm-download-started","").replace("dlm-download-completed",""),n.addClass("dlm-download-started"),o.setAttribute("href","#"),o.removeAttribute("download"),o.setAttribute("disabled","disabled"),jQuery(document).trigger("dlm_download_triggered",[this,o,n,
|
1 |
+
jQuery(function(e){new DLM_XHR_Download});class DLM_XHR_Download{constructor(){(dlmXHRinstance=this).init()}init(){dlmXHRinstance.attachButtonEvent()}attachButtonEvent(){let d="",o="";jQuery.each(dlmXHR.xhr_links.class,function(e,t){-1<t.indexOf("[class")||-1<t.indexOf("[id")?d+=o+" "+t:d+=o+" ."+t,o=","}),jQuery("html, body").on("click",d,function(e){dlmXHRinstance.handleDownloadClick(this,e)})}handleDownloadClick(e,t){t.stopPropagation();var d=e.getAttribute("href");let o={button:e,href:d,buttonObj:jQuery(e)};-1===o.href.indexOf("blob:http")&&"#"!==o.href&&(t.preventDefault(),dlmXHRinstance.retrieveBlob(o))}retrieveBlob(e){let{button:l,href:r,buttonObj:a}=e,s;const i=new XMLHttpRequest,c=dlmXHR.prevent_duplicates;let m=a.attr("class");m=m.replace("dlm-download-started","").replace("dlm-download-completed",""),a.addClass("dlm-download-started"),l.setAttribute("href","#"),l.removeAttribute("download"),l.setAttribute("disabled","disabled");e=0<r.indexOf("?")?r+"&nonce="+dlmXHR.nonce:r+"?nonce="+dlmXHR.nonce;jQuery(document).trigger("dlm_download_triggered",[this,l,a,s]),i.responseType="blob",i.onreadystatechange=function(){var{status:e,readyState:t,statusText:d}=i;let o=i.getAllResponseHeaders().split("\r\n").reduce((e,t)=>{var[t,d]=t.split(": ");return e[t]=d,e},{});if(void 0!==o["dlm-no-waypoints"]&&(i.abort(),window.location.href=r),void 0!==o["dlm-external-download"])return i.abort(),n=o["dlm-file-name"].replace(/\"/g,"").replace(";",""),void dlmXHRinstance.dlmExternalDownload(o,l,a,n,r);if(2==i.readyState&&void 0!==o["dlm-error"]&&""!==o["dlm-error"]&&null!==o["dlm-error"])return dlmXHRinstance.dlmLogDownload(o["dlm-download-id"],o["dlm-version-id"],"failed",!1),i.abort(),void a.append('<span class="dlm-xhr-error">'+o["dlm-error"]+"</span>");if(2==i.readyState&&void 0!==o["dlm-redirect"]&&""!==o["dlm-redirect"]&&null!==o["dlm-redirect"])return dlmXHRinstance.dlmLogDownload(o["dlm-download-id"],o["dlm-version-id"],"redirected",!1,o["dlm-redirect"],o["dlm-no-access"]),void i.abort();if(2==i.readyState&&i.status,404==e&&2==t){let e=document.createElement("p");e.innerHTML=d,l.parentNode.appendChild(e)}if(401==e&&2==t&&(window.location.href=d),403==e&&2==t){let e=document.createElement("p");e.innerHTML=d,l.parentNode.appendChild(e)}if(200==e&&4==t){var n=i.response;let e=o["content-disposition"].split("filename=")[1];e=e.replace(/\"/g,"").replace(";",""),s=URL.createObjectURL(n),l.removeEventListener("click",dlmXHRinstance.handleDownloadClick),l.setAttribute("download",""+e),l.setAttribute("href",s),l.click(),a.removeClass().addClass(m+" dlm-download-complete"),dlmXHRinstance.attachButtonEvent(),jQuery(document).trigger("dlm_download_complete",[this,l,a,s]),dlmXHRinstance.dlmLogDownload(o["dlm-download-id"],o["dlm-version-id"],"completed",c),window.URL.revokeObjectURL(s),l.removeAttribute("download"),l.setAttribute("href",r),setTimeout(function(){a.removeClass().addClass(m).find("span.dlm-xhr-progress").remove()},4e3)}},i.addEventListener("progress",function(e){let t=e.loaded/e.total*100;t=t.toFixed(2);var d;a.find("span.dlm-xhr-progress").remove(),d="dlm-download-started download-"+10*Math.ceil(t/10),1/0!=t&&a.append('<span class="dlm-xhr-progress"> '+t+"%</span>"),a.removeClass().addClass(m+" "+d),jQuery(document).trigger("dlm_download_progress",[this,l,a,s,e,t])}),i.onerror=function(){console.log("** An error occurred during the transaction")},i.open("GET",e,!0),i.setRequestHeader("dlm-xhr-request","dlm_XMLHttpRequest"),i.send()}dlmLogDownload(e,t,d,o,n=null,l=null){null!==l?window.location.href=n:(l={download_id:e,version_id:t,status:d,cookie:o,currentURL:window.location.href,action:"log_dlm_xhr_download",nonce:dlmXHR.nonce},jQuery.post(dlmXHR.ajaxUrl,l,function(e){null!==n&&(window.location.href=n)}))}dlmExternalDownload(d,o,n,l,r){const a=new XMLHttpRequest,e=d["dlm-external-download"];let s=n.attr("class"),i;s=s.replace("dlm-download-started","").replace("dlm-download-completed",""),n.addClass("dlm-download-started"),o.setAttribute("href","#"),o.removeAttribute("download"),o.setAttribute("disabled","disabled"),jQuery(document).trigger("dlm_download_triggered",[this,o,n,i]),a.responseType="blob",a.onreadystatechange=function(){var{status:e,readyState:t}=a;a.getAllResponseHeaders().split("\r\n").reduce((e,t)=>{var[t,d]=t.split(": ");return e[t]=d,e},{});if(403===e)return dlmXHRinstance.dlmLogDownload(d["dlm-download-id"],d["dlm-version-id"],"failed",!1),a.abort(),void n.append('<span class="dlm-xhr-error">Acces Denied to file.</span>');200==e&&4==t&&(e=a.response,i=URL.createObjectURL(e),o.removeEventListener("click",dlmXHRinstance.handleDownloadClick),o.setAttribute("download",""+l),o.setAttribute("href",i),o.click(),n.removeClass().addClass(s+" dlm-download-complete"),dlmXHRinstance.attachButtonEvent(),jQuery(document).trigger("dlm_download_complete",[this,o,n,i]),dlmXHRinstance.dlmLogDownload(d["dlm-download-id"],d["dlm-version-id"],"completed",!1),window.URL.revokeObjectURL(i),o.removeAttribute("download"),o.setAttribute("href",r),setTimeout(function(){n.removeClass().addClass(s).find("span.dlm-xhr-progress").remove()},1e3))},a.addEventListener("progress",function(e){let t=e.loaded/e.total*100;t=t.toFixed(2);var d;n.find("span.dlm-xhr-progress").remove(),d="dlm-download-started download-"+10*Math.ceil(t/10),1/0!=t&&n.append('<span class="dlm-xhr-progress"> '+t+"%</span>"),n.removeClass().addClass(s+" "+d),jQuery(document).trigger("dlm_download_progress",[this,o,n,i,e,t])}),a.onerror=function(){console.log("** An error occurred during the transaction")},a.open("GET",e,!0),a.setRequestHeader("dlm-xhr-request","dlm_XMLHttpRequest"),a.send()}}
|
assets/js/reports/reports.js
CHANGED
@@ -1146,7 +1146,7 @@ class DLM_Reports {
|
|
1146 |
* @param {*} mostDownloaded
|
1147 |
*/
|
1148 |
setMostDownloaded(mostDownloaded) {
|
1149 |
-
jQuery('.dlm-reports-block-summary li#
|
1150 |
}
|
1151 |
|
1152 |
/**
|
1146 |
* @param {*} mostDownloaded
|
1147 |
*/
|
1148 |
setMostDownloaded(mostDownloaded) {
|
1149 |
+
jQuery('.dlm-reports-block-summary li#most_popular span').html(mostDownloaded); // this is a string
|
1150 |
}
|
1151 |
|
1152 |
/**
|
assets/js/reports/reports.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
jQuery(function(e){const t=new DLM_Reports;dlmReportsInstance.fetchReportsData(),e(document).on("dlm_downloads_report_fetched",function(){t.init()})});class DLM_Reports{dlmReportsStats=[];dlmUsersStats={logs:[],users:[]};currentFilters=[];tempDownloads=null;templates={};totalDownloads=0;constructor(){(dlmReportsInstance=this).chartContainer=document.getElementById("total_downloads_chart");const e=dlmReportsInstance.chartContainer.getContext("2d");dlmReportsInstance.chartColors={purple:{default:"rgba(149, 76, 233, 1)",threesome:"rgba(149, 76, 233, 0.75)",half:"rgba(149, 76, 233, 0.5)",quarter:"rgba(149, 76, 233, 0.5)",zero:"rgba(149, 76, 233, 0.05)"},blue:{default:"rgba(67, 56, 202, 1)",threesome:"rgba(67, 56, 202, 0.75)",half:"rgba(67, 56, 202, 0.5)",quarter:"rgba(67, 56, 202, 0.25)",zero:"rgba(67, 56, 202, 0.05)"},green:{default:"rgba(00, 255, 00, 1)",threesome:"rgba(00, 255, 00, 0.75)",half:"rgba(00, 255, 00, 0.5)",quarter:"rgba(00, 255, 00, 0.25)",zero:"rgba(67, 56, 202, 0.05)"},royalBlue:{default:"rgba(65, 105, 225, 1)",threesome:"rgba(65, 105, 225, 0.75)",half:"rgba(65, 105, 225, 0.5)",quarter:"rgba(65, 105, 225, 0.25)",zero:"rgba(65, 105, 225, 0.05)"},persianBlue:{default:"rgba(28, 57, 187, 1)",threesome:"rgba(28, 57, 187, 0.75)",half:"rgba(28, 57, 187, 0.5)",quarter:"rgba(28, 57, 187, 0.25)",zero:"rgba(28, 57, 187, 0.05)"},darkCyan:{default:"rgba(0,129,167, 1)",threesome:"rgba(0,129,167, 0.75)",half:"rgba(0,129,167, 0.5)",quarter:"rgba(0,129,167, 0.25)",zero:"rgba(0,129,167, 0.05)"},strongCyan:{default:"rgba(0, 175, 185, 1)",threesome:"rgba(0, 175, 185, 0.75)",half:"rgba(0, 175, 185, 0.5)",quarter:"rgba(0, 175, 185, 0.25)",zero:"rgba(0, 175, 185, 0.05)"}},dlmReportsInstance.chartGradient=e.createLinearGradient(0,25,0,300),dlmReportsInstance.chartGradient.addColorStop(0,dlmReportsInstance.chartColors.darkCyan.half),dlmReportsInstance.chartGradient.addColorStop(.45,dlmReportsInstance.chartColors.darkCyan.quarter),dlmReportsInstance.chartGradient.addColorStop(1,dlmReportsInstance.chartColors.darkCyan.zero),dlmReportsInstance.datePickerContainer=document.getElementById("dlm-date-range-picker"),dlmReportsInstance.dataSets=[];let t=new Date;dlmReportsInstance.dates={downloads:{start_date:new Date(t.setMonth(t.getMonth()-1)),end_date:new Date}},dlmReportsInstance.chartDataObject={}}async fetchReportsData(){const e=jQuery('div[data-id="general_info"]'),t=await fetch(dlmDownloadReportsAPI);if(!t.ok){const a=document.createElement("div"),n=(a.className="dlm-loading-data",document.createTextNode("Seems like we bumped into an error! ")),s=document.createTextNode("Data fetching returned a status text of : "+fetchedData.statusText),o=document.createElement("h1"),r=document.createElement("h3");throw o.appendChild(n),r.appendChild(s),a.appendChild(o),a.appendChild(r),e.find(".dlm-loading-data").remove(),e.append(a),new Error("Something went wrong! Reports response did not come OK - "+fetchedData.statusText)}dlmReportsInstance.dlmReportsStats=await t.json(),dlmReportsInstance.mostDownloaded=!1,dlmReportsInstance.stats=!1,dlmReportsInstance.chartType="day",0<window.location.href.indexOf("dlm_time")&&(dlmReportsInstance.dates.downloads.start_date=0<Object.keys(dlmReportsInstance.dlmReportsStats).length?new Date(dlmReportsInstance.dlmReportsStats[0].date):new Date,dlmReportsInstance.dates.downloads.end_date=new Date,jQuery("#dlm-date-range-picker .date-range-info").html(dlmReportsInstance.dates.downloads.start_date.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"2-digit"})+" - "+dlmReportsInstance.dates.downloads.end_date.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"2-digit"}))),dlmReportsInstance.createDataOnDate(dlmReportsInstance.dates.downloads.start_date,dlmReportsInstance.dates.downloads.end_date),dlmReportsInstance.datePicker={opened:!1},jQuery(document).trigger("dlm_downloads_report_fetched",[dlmReportsInstance,dlmReportsInstance.dlmReportsStats])}async fetchUsersReportsData(e=0,t=dlmPHPinfo.retrieved_rows){const a=jQuery('div[data-id="user_reports"]');let n=dlmUserReportsAPI+"?offset="+e+"&limit="+t;0<dlmUserReportsAPI.indexOf("index.php?")&&(n=dlmUserReportsAPI+"&offset="+e+"&limit="+t);const s=await fetch(n);if(!s.ok)throw new Error("Something went wrong! Reports response did not come OK - "+s.statusText);e=await s.json();dlmReportsInstance.dlmUsersStats.logs=dlmReportsInstance.dlmUsersStats.logs.concat(e.logs),!0===e.done?(dlmReportsInstance.userDownloads=void 0!==dlmReportsInstance.dlmUsersStats.logs?JSON.parse(JSON.stringify(dlmReportsInstance.dlmUsersStats.logs)):{},a.find(".dlm-loading-data").remove(),dlmReportsInstance.userReportsTab(),dlmReportsInstance.setTopDownloads(),dlmReportsInstance.stopSpinner(jQuery("#total_downloads_table_wrapper2"))):dlmReportsInstance.fetchUsersReportsData(e.offset)}async fetchUserData(){const e=await fetch(dlmUserDataAPI);if(!e.ok)throw new Error("Something went wrong! Reports response did not come OK - "+e.statusText);var t=await e.json();dlmReportsInstance.dlmUsersStats.users=dlmReportsInstance.dlmUsersStats.users.concat(t)}init(){dlmReportsInstance.tabNagivation(),dlmReportsInstance.overViewTab(),dlmReportsInstance.togglePageSettings(),dlmReportsInstance.fetchUserData(),dlmReportsInstance.setSpinner(jQuery("#users_download_log")),dlmReportsInstance.setSpinner(jQuery("#total_downloads_table_wrapper2")),dlmReportsInstance.fetchUsersReportsData(),jQuery(document).trigger("dlm_reports_init",[dlmReportsInstance]),dlmReportsInstance.eventsFunctions()}overViewTab(){dlmReportsInstance.dlmCreateChart(dlmReportsInstance.stats.chartStats,dlmReportsInstance.chartContainer),dlmReportsInstance.dlmDownloadsSummary(),dlmReportsInstance.datePickerContainer.addEventListener("click",dlmReportsInstance.toggleDatepicker.bind(this)),dlmReportsInstance.setTodayDownloads(),dlmReportsInstance.handleTopDownloads(),jQuery(document).on("click","body",function(e){e.stopPropagation(),0<jQuery(dlmReportsInstance.datePickerContainer).find("#dlm_date_range_picker").length&&dlmReportsInstance.hideDatepicker(jQuery(dlmReportsInstance.datePickerContainer),{target:"dlm-date-range-picker"})})}userReportsTab(){0!==Object.values(dlmReportsInstance.dlmUsersStats).length&&(dlmReportsInstance.logsDataByDate(dlmReportsInstance.dates.downloads.start_date,dlmReportsInstance.dates.downloads.end_date),dlmReportsInstance.handleUserDownloads(),dlmReportsInstance.filterDownloads())}getDates(e,t){const a={};let n=e;for(;n<=t;)a[this.createDateElement(n)]=0,n=this.getNextDay(n);return a}getMonths(e){const t={};return Object.keys(e).map(e=>{e=e.substring(0,7);void 0===t[e]&&(t[e]=0)}),t}getDoubleMonths(e){const t={},a=Object.keys(e)[0],n=Object.keys(e)[Object.keys(e).length-1];let s=0,o=a.substring(0,7),r=n.substring(0,7);return Object.keys(e).map(e=>{e=e.substring(0,7);o!==e&&r!==e&&(o=e,s++),void 0===t[e]&&0==s%2&&(t[e]=0)}),t}getWeeks(e){let a={};return Object.keys(e).forEach(e=>{let t;t=15<moment(e).date()?e.substring(0,7)+"-15":e.substring(0,7)+"-01",void 0===a[t]&&(a[t]=0)}),a}getWeek(e){let t={},a=Object.keys(e)[Object.keys(e).length-1],n=0;return Object.keys(e).map(e=>{void 0===t[e]&&0==n%7&&(t[e]=0),n++}),void 0===t[a]&&(t[a]=0),t}getDoubleDays(e){let t={},a=Object.keys(e)[0],n=Object.keys(e)[Object.keys(e).length-1],s=0;return Object.keys(e).map(e=>{a!==e&&n!==e&&(a=e,s++),void 0===t[e]&&0==s%2&&(t[e]=0)}),t}getNextDay(e){const t=new Date(e);return t.setDate(e.getDate()+1),t}createDateElement(e){var t=(e.getMonth()+1<10?"0":"")+(e.getMonth()+1);return e.getFullYear()+"-"+t+"-"+("0"+e.getDate()).slice(-2)}getSetDates(e,t){let a,n;if(void 0!==e&&e)a=dlmReportsInstance.createDateElement(new Date(e));else{const s=new Date;s.setDate(s.getDate()-30),a=dlmReportsInstance.createDateElement(s)}if(void 0!==t&&t){e=new Date(t);n=dlmReportsInstance.createDateElement(e)}else{const o=new Date;o.setDate(o.getDate()+1),n=dlmReportsInstance.createDateElement(o)}return{startDate:a,endDate:n}}createDataOnDate(e,t){let{startDate:a,endDate:n}={...dlmReportsInstance.getSetDates(e,t)},s,o,r,d,l,c=(dlmReportsInstance.reportsData=void 0!==dlmReportsInstance.dlmReportsStats?JSON.parse(JSON.stringify(dlmReportsInstance.dlmReportsStats)):{},o=moment(n,"YYYY-MM-DD").month()-moment(a,"YYYY-MM-DD").month(),r=moment(n,"YYYY-MM-DD").year()-moment(a,"YYYY-MM-DD").year(),s=moment(n).date()-moment(a).date(),dlmReportsInstance.chartType="day",0==r&&-6<o&&o<6?1<o||o<-1?dlmReportsInstance.chartType=2==o?"week":"weeks":1==o&&(8<s||-14<s||0==s)&&(dlmReportsInstance.chartType="days"):o<=0?dlmReportsInstance.chartType="month":dlmReportsInstance.chartType="months",dlmReportsInstance.getDates(new Date(a),new Date(n))),m,i,p,g;switch(dlmReportsInstance.chartType){case"months":i=dlmReportsInstance.getDoubleMonths(c),l=i;break;case"month":var u=dlmReportsInstance.getMonths(c);l=u;break;case"weeks":p=dlmReportsInstance.getWeeks(c),l=p;break;case"week":g=dlmReportsInstance.getWeek(c),l=g;break;case"days":m=dlmReportsInstance.getDoubleDays(c),l=m;break;case"day":l=c}Object.values(dlmReportsInstance.reportsData).forEach((s,e)=>{var o=JSON.parse(s.download_ids);if(void 0!==c[s.date])switch(dlmReportsInstance.chartType){case"months":d=s.date.substring(0,7);let e=parseInt(s.date.substring(5,7)),t=s.date.substring(0,5),a=6<(e-1).length?t+(e-1):t+"0"+(e-1);Object.values(o).forEach((e,t)=>{void 0===i[d]?void 0!==i[a]&&(i[a]=i[a]+e.downloads):i[d]=i[d]+e.downloads}),l=i;break;case"month":d=s.date.substring(0,7),Object.values(o).forEach((e,t)=>{monthDownloads[d]=void 0!==monthDownloads[d]?monthDownloads[d]+e.downloads:e.downloads}),l=monthDownloads;break;case"weeks":d=15<moment(s.date).date()?s.date.substring(0,7)+"-15":s.date.substring(0,7)+"-01",Object.values(o).forEach((e,t)=>{p[d]=void 0!==p[d]?p[d]+e.downloads:e.downloads}),l=p;break;case"week":d=s.date,Object.values(o).forEach((t,e)=>{if(void 0===g[d])for(let e=1;e<8;e++){var a=moment(s.date).date(moment(s.date).date()-e).format("YYYY-MM-DD");void 0!==g[a]&&(g[a]=g[a]+t.downloads)}else g[d]=g[d]+t.downloads}),l=g;break;case"days":d=s.date;let n=moment(s.date).date(moment(s.date).date()-1).format("YYYY-MM-DD");Object.values(o).forEach((e,t)=>{void 0===m[d]?void 0!==m[n]&&(m[n]=m[n]+e.downloads):m[d]=m[d]+e.downloads}),l=m;break;case"day":Object.values(o).forEach((e,t)=>{c[s.date]=c[s.date]+e.downloads}),l=c}else delete dlmReportsInstance.reportsData[e]});const h=Object.keys(c);e=h.length,t=h.findIndex(e=>a===e);let I=h.findIndex(e=>n===e);-1===t&&-1===I?dlmReportsInstance.stats={chartStats:Object.assign({},l),summaryStats:!1,daysLength:e}:(-1===I&&(I=e),dlmReportsInstance.stats={chartStats:Object.assign({},l),summaryStats:dlmReportsInstance.reportsData,daysLength:e})}dlmCreateChart(t,a,n=!1){if(t&&a){let e=Chart.getChart("total_downloads_chart");dlmReportsInstance.chartDataObject={dataSetLabel:"Downloads",dataSetColor:"#27ae60",dataSetbg:dlmReportsInstance.chartGradient,dataSetPointbg:dlmReportsInstance.chartColors.darkCyan.default,dataSetBorder:dlmReportsInstance.chartColors.darkCyan.default,dataSetElementColor:"#2ecc71",lineType:"original",xAxis:"x",chartData:t},void 0!==e&&e.destroy(),jQuery(document).trigger("dlm_reports_before_data_sets",[dlmReportsInstance.chartDataObject,t,n]),0<dlmReportsInstance.dataSets.length&&(dlmReportsInstance.dataSets=dlmReportsInstance.dataSets.filter(e=>dlmReportsInstance.chartDataObject.lineType!==e.origin)),dlmReportsInstance.dataSets.push({origin:dlmReportsInstance.chartDataObject.lineType,label:dlmReportsInstance.chartDataObject.dataSetLabel,color:dlmReportsInstance.chartDataObject.dataSetColor,data:dlmReportsInstance.chartDataObject.chartData,type:"line",fill:!0,backgroundColor:dlmReportsInstance.chartDataObject.dataSetbg,pointBackgroundColor:dlmReportsInstance.chartDataObject.dataSetPointbg,pointHoverBackgroundColor:"#fff",borderColor:dlmReportsInstance.chartDataObject.dataSetBorder,pointBorderWidth:1,lineTension:.3,borderWidth:1,pointRadius:3,elements:{line:{borderColor:dlmReportsInstance.chartDataObject.dataSetElementColor,borderWidth:1},point:{radius:4,hoverRadius:4,pointStyle:"circle"}}});t=Object.values(dlmReportsInstance.dataSets).filter(e=>"original"===e.origin);let o=Object.keys(t[0].data);dlmReportsInstance.dataSets.sort(function(e,t){return"original"===e.origin?-1:1}),dlmReportsInstance.chart=new Chart(a,{title:"",data:{datasets:dlmReportsInstance.dataSets},height:450,is_series:1,options:{aspectRatio:5,animation:!1,interaction:{mode:"index",intersect:!1},stacked:!1,scales:{x:{grid:{display:!1},ticks:{callback:e=>{let t="";var a=o[e],n=o[o.length-1],s=moment(n).month(moment(n).month()-1).format("YYYY-MM");return t="undefined"!==dlmReportsInstance.chartType&&"months"===dlmReportsInstance.chartType?(e=moment(o[e]).month())<11?a===s?moment(a).format("MMM, YYYY"):moment(a).format("MMM")+" - "+moment(a).month(e+1).format("MMM")+moment(a).format(", YYYY"):a===s||a===n?moment(a).format("MMM, YYYY"):moment(a).format("MMM")+moment(a).format(" YYYY")+" - "+moment(a).month(e+1).format("MMM")+moment(a).month(e+1).format(", YYYY"):"undefined"!==dlmReportsInstance.chartType&&"months"===dlmReportsInstance.chartType?moment(a).format("MMMM, YYYY"):moment(a).format("D MMM")}}},y:{grid:{drawBorder:!1},min:0,max:0!==dlmReportsInstance.getMaxDownload()?1===Math.ceil(dlmReportsInstance.getMaxDownload()/10)?dlmReportsInstance.getMaxDownload()+1:10*Math.ceil(dlmReportsInstance.getMaxDownload()/10):100,ticks:{stepSize:0!==dlmReportsInstance.getMaxDownload()?Math.ceil(dlmReportsInstance.getMaxDownload()/4):25,callback:e=>dlmReportsInstance.shortNumber(e)}}},normalized:!0,parsing:{xAxisKey:"x",yAxisKey:"y"},plugins:{tooltip:{enabled:!1,external:dlmReportsInstance.externalTooltipHandler.bind(dlmReportsInstance,this)},legend:{display:!0}}}})}}dlmDownloadsSummary(){let a={};if(!1===dlmReportsInstance.stats||!1===dlmReportsInstance.stats.summaryStats||Object.keys(dlmReportsInstance.stats.summaryStats).length<=0)return this.setTotalDownloads(0),this.setDailyAverage(0),void this.setMostDownloaded("--");dlmReportsInstance.totalDownloads=0,dlmReportsInstance.stats.summaryStats.forEach(e=>{e=JSON.parse(e.download_ids),Object.entries(e).forEach(([e,t])=>{dlmReportsInstance.totalDownloads+=t.downloads,a[e]=void 0===a[e]?{downloads:t.downloads,title:t.title,id:e}:{downloads:a[e].downloads+t.downloads,title:t.title,id:e}})}),dlmReportsInstance.mostDownloaded=dlmReportsInstance.orderItems(Object.values(a),"desc","downloads"),dlmReportsInstance.setTotalDownloads(dlmReportsInstance.totalDownloads),dlmReportsInstance.setDailyAverage((dlmReportsInstance.totalDownloads/parseInt(dlmReportsInstance.stats.daysLength)).toFixed(0)),dlmReportsInstance.setMostDownloaded(dlmReportsInstance.mostDownloaded[0].title)}createDatepicker(e,t,a){const n=new Date;let s=n.getDate()-1,o=n.getMonth()+1,r=o-1;var d=n.getFullYear(),l=(s<10&&(s="0"+s),o<10&&(o="0"+o),r<10&&(r="0"+r),d+"-"+o+"-"+s),d=d+"-"+r+"-"+s,c=jQuery("<div>").addClass("dlm_rdrs_overlay"),a=jQuery("<div>").attr("id",a.replace("#",""));return"dlm-date-range-picker"===t.target?(dlmReportsInstance.startDateInput=jQuery("<input>").attr("type","hidden").attr("id","dlm_start_date").attr("value",d),dlmReportsInstance.endDateInput=jQuery("<input>").attr("type","hidden").attr("id","dlm_end_date").attr("value",l),c.append(a).append(dlmReportsInstance.startDateInput).append(dlmReportsInstance.endDateInput)):jQuery(document).trigger("dlm_create_date_picker_"+t.target,[dlmReportsInstance,c,a,d,l]),c}displayDatepicker(e,o){var t;if(jQuery(e)){if(t="#"+jQuery(e).attr("id").replace(/-/gi,"_"),"dlm-date-range-picker"===o.target){if(dlmReportsInstance.datePicker.opened)return;dlmReportsInstance.datePicker.opened=!0}else jQuery(document).trigger("dlm_display_datepicker_"+o.target,[dlmReportsInstance,o,e]);let s=dlmReportsInstance.createDatepicker(e,o,t);e.append(s);var a=0<Object.keys(dlmReportsInstance.dlmReportsStats).length?new Date(dlmReportsInstance.dlmReportsStats[0].date):new Date,n=(new Date,[]),e=(jQuery(document).trigger("dlm_datepicker_shortcuts_"+o.target,[dlmReportsInstance,o,e,n]),{separator:" to ",autoClose:!0,getValue:function(){},setValue:function(e,t,a){s.find('input[type="hidden"]').first().val(t),s.find('input[type="hidden"]').last().val(a)},inline:!0,alwaysOpen:!0,container:t,endDate:new Date,startDate:a,showShortcuts:!0,shortcuts:null,customShortcuts:n});s.dateRangePicker(e).on("datepicker-change",(e,t)=>{var a,n;t.date1&&t.date2&&(a=t.date1.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"2-digit"}),n=t.date2.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"2-digit"}),s.parent().find("span.date-range-info").text(a+" - "+n)),"dlm-date-range-picker"===o.target?(dlmReportsInstance.dates.downloads={start_date:t.date1,end_date:t.date2},dlmReportsInstance.createDataOnDate(dlmReportsInstance.dates.downloads.start_date,dlmReportsInstance.dates.downloads.end_date),dlmReportsInstance.dlmCreateChart(dlmReportsInstance.stats.chartStats,dlmReportsInstance.chartContainer,!1),dlmReportsInstance.dlmDownloadsSummary(),0<Object.values(dlmReportsInstance.dlmUsersStats.logs).length&&dlmReportsInstance.logsDataByDate(dlmReportsInstance.dates.downloads.start_date,dlmReportsInstance.dates.downloads.end_date)):jQuery(document).trigger("dlm_daterangepicker_init_"+o.target,[dlmReportsInstance,t.date1,t.date2]),dlmReportsInstance.setTopDownloads(),s.data("dateRangePicker").close()}),"dlm-date-range-picker"===o.target?s.data("dateRangePicker").setDateRange(dlmReportsInstance.dates.downloads.start_date,dlmReportsInstance.dates.downloads.end_date):jQuery(document).trigger("dlm_daterangepicker_after_init_"+o.target,[s,dlmReportsInstance])}}hideDatepicker(e,t){"dlm-date-range-picker"===t.target?dlmReportsInstance.datePicker.opened=!1:jQuery(document).trigger("dlm_hide_datepicker_"+t.target,[dlmReportsInstance,e,t]),e.find(".dlm_rdrs_overlay").remove()}toggleDatepicker(e){e.stopPropagation();const t=jQuery(e.target).parents(".dlm-reports-header-date-selector");e={target:t.attr("id"),object:dlmReportsInstance.datePicker};dlmReportsInstance.closeDatePickers(t),"dlm-date-range-picker"===e.target?dlmReportsInstance.datePicker.opened?dlmReportsInstance.hideDatepicker(t,e):dlmReportsInstance.displayDatepicker(t,e):jQuery(document).trigger("dlm_toggle_datepicker_"+e.target,[dlmReportsInstance,t,e])}setTotalDownloads(e){jQuery(".dlm-reports-block-summary li#total span").html(e.toLocaleString())}setDailyAverage(e){jQuery(".dlm-reports-block-summary li#average span").html(e.toLocaleString())}setMostDownloaded(e){jQuery(".dlm-reports-block-summary li#popular span").html(e)}setTodayDownloads(){let e=0;Object.keys(dlmReportsInstance.dlmReportsStats).length<=0?jQuery(".dlm-reports-block-summary li#today span").html(e.toLocaleString()):(dlmReportsInstance.dlmReportsStats[dlmReportsInstance.dlmReportsStats.length-1].date===dlmReportsInstance.createDateElement(new Date)&&(e=Object.values(JSON.parse(dlmReportsInstance.dlmReportsStats[dlmReportsInstance.dlmReportsStats.length-1].download_ids)).reduce((e,t)=>e+t.downloads,0)),jQuery(".dlm-reports-block-summary li#today span").html(e))}setTopDownloads(e=0,t=!1){const a=jQuery("#total_downloads_table_wrapper2"),n=jQuery("#total_downloads_table_wrapper2 .total_downloads_table__list");if(n.empty(),n.parent().addClass("empty"),dlmReportsInstance.mostDownloaded&&!0!==t){var s=JSON.parse(JSON.stringify(dlmReportsInstance.mostDownloaded)).slice(10*parseInt(e),10*parseInt(e+1));for(let e=0;e<s.length;e++){const r=dlmReportsInstance.getDownloadByID(s[e].id);if(void 0===r)return;var o={id:s[e].id,title:s[e].title,edit_link:dlmAdminUrl+"post.php?post="+s[e].id+"&action=edit",total_downloads:r.total.toLocaleString()};jQuery(document).trigger("dlm_reports_top_downloads_item_before_render",[o,dlmReportsInstance,s[e],r]),new dlmBackBone.modelTopDownloads(o)}n.parent().removeClass("empty"),10<dlmReportsInstance.mostDownloaded.length?a.find(".downloads-block-navigation button").removeClass("hidden"):a.find(".downloads-block-navigation button").addClass("hidden"),dlmReportsInstance.stopSpinner(jQuery("#total_downloads_table_wrapper2"))}}handleTopDownloads(){jQuery("html body").on("click","#total_downloads_table_wrapper2 .downloads-block-navigation button",function(){let e=jQuery(this).parents("#total_downloads_table_wrapper2"),t=e,a=e.attr("data-page"),n=jQuery(this),s=parseInt(a)+1,o=0!==a?parseInt(a)-1:0,r=e.find(".downloads-block-navigation").find("button").first(),d=e.find(".downloads-block-navigation").find("button").last();n.attr("disabled","disabled");var l={data:dlmReportsInstance.mostDownloaded,main_parent:e,offsetHolder:t,offset:a,link:n,nextPage:s,prevPage:o,prevButton:r,nextButton:d,doAction:dlmReportsInstance.setTopDownloads};dlmReportsInstance.handleSliderNavigation(l)})}handleSliderNavigation(e){const{data:t,offsetHolder:a,offset:n,link:s,nextPage:o,prevPage:r,prevButton:d,nextButton:l,doAction:c}={...e};"load-more"===s.data("action")?(a.attr("data-page",o),c(o),Math.ceil(t.length/10)>o+1&&l.removeAttr("disabled"),d.removeAttr("disabled")):0!==parseInt(n)&&(a.attr("data-page",r),c(r),1!==parseInt(n)&&d.removeAttr("disabled"),l.removeAttr("disabled"))}tabNagivation(){jQuery(document).on("click",".dlm-reports .dlm-insights-tab-navigation > li",function(){const e=jQuery(this),t=jQuery(".dlm-reports .dlm-insights-tab-navigation > li").not(e),a=jQuery('div.dlm-insights-tab-navigation__content[data-id="'+e.attr("id")+'"]'),n=jQuery("div.dlm-insights-tab-navigation__content").not(a);e.hasClass("active")||(e.addClass("active"),t.removeClass("active"),a.addClass("active"),n.removeClass("active"))})}getOrCreateTooltip(e){let t=e.canvas.parentNode.querySelector("div.dlm-canvas-tooltip"),a=e.canvas.parentNode.querySelector("div.dlm-reports-tooltip__line");if(t||((a=document.createElement("div")).className="dlm-reports-tooltip__line"),!t){(t=document.createElement("div")).className="dlm-canvas-tooltip";const n=document.createElement("div");n.className="dlm-reports-tooltip",t.appendChild(n),e.canvas.parentNode.appendChild(t),e.canvas.parentNode.appendChild(a)}return{tooltipEl:t,tooltipLine:a}}externalTooltipHandler(d,e){const{chart:t,tooltip:l}=e,{tooltipEl:a,tooltipLine:n}={...d.getOrCreateTooltip(t)};e=jQuery(a).parent().width();if(0===l.opacity)return a.style.opacity=0,void(n.style.opacity=0);if(l.body){const c=l.title||[],m=document.createElement("div"),i=(m.className="dlm-reports-tooltip__header",c.forEach(e=>{const t=document.createElement("div"),a=(t.className="dlm-reports-tooltip__row",document.createElement("p")),n=(a.className="dlm-reports-tooltip__info",a.appendChild(document.createTextNode("Downloads")),t.appendChild(a),jQuery(document).trigger("dlm_chart_tooltip_before",[dlmReportsInstance,l,t,d]),document.createElement("p"));n.className="dlm-reports-tooltip__date";var s=dlmReportsInstance.setChartTooltipDate(l.dataPoints[0].label,d,d.stats.chartStats);n.appendChild(document.createTextNode(s)),t.appendChild(n);const o=document.createElement("p"),r=(o.className="dlm-reports-tooltip__downloads",document.createElement("span"));r.className="dlm-reports-tooltip__downloads_pointer",r.style.backgroundColor=dlmReportsInstance.chartColors.darkCyan.default,o.appendChild(r),o.appendChild(document.createTextNode(dlmReportsInstance.shortNumber(l.dataPoints[0].formattedValue))),t.appendChild(o),jQuery(document).trigger("dlm_chart_tooltip_after",[dlmReportsInstance,l,t,d]),m.appendChild(t)}),a.querySelector("div.dlm-reports-tooltip"));for(;i.firstChild;)i.firstChild.remove();i.appendChild(m)}var{offsetLeft:s,offsetTop:o}=t.canvas;a.style.opacity=1;let r={isMargin:!(n.style.opacity=1),left:!1};l.caretX-l.width<0&&(r.isMargin=!0,r.left=!0),s+l.caretX+l.width>e&&(r.isMargin=!0,r.left=!1),r.isMargin?r.left?a.style.left=s+l.width+"px":a.style.left=e-l.width+"px":a.style.left=s+l.caretX+"px",n.style.left=s+l.caretX+"px",a.style.top=o+l.caretY-a.offsetHeight-10+"px"}createUserRelatedData(){dlmReportsInstance.userRelatedData=[],Object.values(dlmReportsInstance.userDownloads).forEach((e,t)=>{var a;"0"!==e.user_id&&(a=[e.user_id,e.download_id,e.download_date,e.download_status],e="user_"+e.user_id,void 0!==dlmReportsInstance.userRelatedData[e]?dlmReportsInstance.userRelatedData[e].push(a):dlmReportsInstance.userRelatedData[e]=[a])})}logsDataByDate(e,t){var{startDate:e,endDate:t}={...dlmReportsInstance.getSetDates(e,t)};dlmReportsInstance.userDownloads=JSON.parse(JSON.stringify(dlmReportsInstance.dlmUsersStats.logs));let a=new Date(e),n=(a.setDate(a.getDate()-1),a=a.getTime(),new Date(t));n.setDate(n.getDate()+1),n=n.getTime(),dlmReportsInstance.userDownloads=dlmReportsInstance.userDownloads.filter((e,t)=>{e=dlmReportsInstance.createDateElement(new Date(e.download_date));return(e=new Date(e).getTime())>a&&e<n}),dlmReportsInstance.createUserRelatedData(),dlmReportsInstance.filterDownloads(),dlmReportsInstance.setMostActiveUser(),dlmReportsInstance.setLoggedOutDownloads(),dlmReportsInstance.setLoggedInDownloads(),jQuery(document).trigger("dlm_set_logs_data_by_date",[dlmReportsInstance])}setMostActiveUser(){var e=dlmReportsInstance.getUserByID(dlmReportsInstance.getMostActiveID()[0]);jQuery(".dlm-reports-block-summary li#most_active_user span").html(dlmReportsInstance.userToolTipMarkup(e))}getMostActiveID(){return Object.values(dlmReportsInstance.userRelatedData).length?Object.values(dlmReportsInstance.userRelatedData).reduce((e,t,a)=>parseInt(e.length)>parseInt(t.length)&&0<e.length&&null!==dlmReportsInstance.getUserByID(e[0][0])?e:null!==dlmReportsInstance.getUserByID(t[0][0])?t:[],[]):0}getUserByID(t){if(!t||"0"===t)return null;var e=Object.values(dlmReportsInstance.dlmUsersStats.users).filter(e=>parseInt(t)===parseInt(e.id));return Array.isArray(e)?0===e.length?null:e[0]:e}getLoggedInDownloads(){return Object.values(dlmReportsInstance.userRelatedData).length?1<Object.values(dlmReportsInstance.userRelatedData).length?Object.values(dlmReportsInstance.userRelatedData).reduce((e,t)=>parseInt(e)+parseInt(t.length),0):Object.values(dlmReportsInstance.userRelatedData)[0].length:0}setLoggedInDownloads(){const e=dlmReportsInstance.getLoggedInDownloads();jQuery(".dlm-reports-block-summary li#logged_in span,#total_downloads_summary_wrapper .dlm-reports-logged-in").html(e.toLocaleString())}getLoggedOutDownloads(){return dlmReportsInstance.userDownloads.length-dlmReportsInstance.getLoggedInDownloads()}setLoggedOutDownloads(){const e=dlmReportsInstance.getLoggedOutDownloads();jQuery(".dlm-reports-block-summary li#logged_out span,#total_downloads_summary_wrapper .dlm-reports-logged-out").html(e.toLocaleString())}userToolTipMarkup(e){let t='<div class="dlm-user-reports">';return t=(t=t+'<div class="wpchill-tooltip"><i>[?]</i>'+'<div class="wpchill-tooltip-content">')+("<span>User ID: "+(null!==e?e.id:"--")+"</span>"),"object"!=typeof e&&e.url.length&&(t+="<span>User URL: "+(null!==e?e.url:"--")+"</span>"),t+="<span>User registration date: "+(null!==e?e.registered:"--")+"</span>",null!==e&&void 0!==e.role&&e.role.length&&(t+="<span>User role: "+e.role+"</span>"),t=(t+="</div></div>")+(null!==e?e.display_name:"--")+"</div>"}setUserDownloads(e=0,t=!1){const a=jQuery("#users_download_log"),n=jQuery("#users_download_log .user-logs__list");if(n.empty(),!0!==t){let t=[];t=(null!==dlmReportsInstance.tempDownloads?JSON.parse(JSON.stringify(dlmReportsInstance.tempDownloads)):JSON.parse(JSON.stringify(dlmReportsInstance.userDownloads))).slice(10*parseInt(e),10*parseInt(e+1));for(let e=0;e<t.length;e++){var s=dlmReportsInstance.getUserByID(t[e].user_id.toString()),o=dlmReportsInstance.getDownloadCPT(t[e].download_id.toString()),r={key:e,user:"0"!==t[e].user_id&&null!=s?s.display_name:"--",ip:t[e].user_ip,role:null!==s&&null!==s.role?s.role:"--",download:void 0!==o?o.title:"--",valid_user:"0"!==t[e].user_id,edit_link:"user-edit.php?user_id="+t[e].user_id,edit_download_link:void 0!==o?dlmAdminUrl+"post.php?post="+o.id+"&action=edit":"#",status:t[e].download_status,download_date:t[e].download_date};jQuery(document).trigger("dlm_reports_user_logs_item_before_render",[r,dlmReportsInstance,t[e],s,o]),new dlmBackBone.modelUserLogs(r)}dlmReportsInstance.stopSpinner(jQuery("#users_download_log")),10!==t.length?a.find('.user-downloads-block-navigation button[data-action="load-more"]').attr("disabled","disabled"):a.find('.user-downloads-block-navigation button[data-action="load-more"]').removeAttr("disabled"),10<dlmReportsInstance.userDownloads.length?a.find(".user-downloads-block-navigation button").removeClass("hidden"):a.find(".user-downloads-block-navigation button").addClass("hidden")}}filterDownloads(){dlmReportsInstance.tempDownloads=JSON.parse(JSON.stringify(dlmReportsInstance.userDownloads)),dlmReportsInstance.currentFilters.length&&dlmReportsInstance.currentFilters.forEach(t=>{dlmReportsInstance.tempDownloads=dlmReportsInstance.tempDownloads.filter(e=>t.on===e[t.type])}),dlmReportsInstance.setUserDownloads()}handleUserDownloads(){jQuery(".user-downloads-block-navigation").on("click","button",function(e){e.stopPropagation();let t=jQuery(this).parents("#users_downloads_table_wrapper"),a=t.find("#users_download_log"),n=a.attr("data-page"),s=jQuery(this),o=parseInt(n)+1,r=0!==n?parseInt(n)-1:0,d=t.find(".downloads-block-navigation button").first(),l=t.find(".downloads-block-navigation button").last();s.attr("disabled","disabled");e={data:dlmReportsInstance.tempDownloads,main_parent:t,offsetHolder:a,offset:n,link:s,nextPage:o,prevPage:r,prevButton:d,nextButton:l,doAction:dlmReportsInstance.setUserDownloads};dlmReportsInstance.handleSliderNavigation(e)})}togglePageSettings(){jQuery("#dlm-toggle-settings").on("click",function(e){e.stopPropagation(),jQuery(this).find(".dlm-toggle-settings__settings").toggleClass("display")}),jQuery(".dlm-toggle-settings__settings").on("click",function(e){e.stopPropagation()}),jQuery("html,body").on("click",function(){jQuery(this).find(".dlm-toggle-settings__settings").removeClass("display")}),jQuery(document).on("change",".wpchill-toggle__input",function(e){const t=jQuery(this),a=t.attr("name"),n={action:"dlm_update_report_setting",name:a,checked:t.is(":checked"),_ajax_nonce:dlmReportsNonce};jQuery.post(ajaxurl,n,function(e){a,jQuery(document).trigger("dlm_settings_ajax_response",[dlmReportsInstance,t,e])})})}getMaxDownload(){let t=0;return dlmReportsInstance.dataSets.forEach(e=>{e=Object.values(e.data).reduce((e,t)=>t<e?e:t,0);t<e&&(t=e)}),parseInt(t)}setChartTooltipDate(e,t,a){let n="";var s,o,r;return n="undefined"!==t.chartType&&"months"===t.chartType?(moment(e).year(),s=moment(e).month(),a=Object.keys(a)[Object.keys(a).length-1],o=moment(a).month(moment(a).month()-1).format("YYYY-MM"),r=moment(e).format("YYYY-MM"),s<11?r===o?moment(r).format("MMMM, YYYY"):moment(e).format("MMM")+" - "+moment(e).month(s+1).format("MMM")+moment(e).format(", YYYY"):r===o||r===a?moment(r).format("MMMM, YYYY"):moment(e).format("MMM")+moment(e).format(" YYYY")+" - "+moment(e).month(s+1).format("MMM")+moment(e).month(s+1).format(", YYYY")):"undefined"!==t.chartType&&"months"===t.chartType?moment(e).format("MMMM, YYYY"):moment(e).format("MMMM Do, YY")}closeDatePickers(e){jQuery(".dlm-reports-header-date-selector").not(e).each(function(){var e={target:jQuery(this).attr("id")};dlmReportsInstance.hideDatepicker(jQuery(this),e)})}shortNumber(e){return e=4<=(e="string"==typeof e?e.replace(/,/gi,""):parseInt(e).toString()).length?parseInt(e.substring(0,e.length-3)).toLocaleString()+"k":e}getDownloadByID(t){let a={total:0},n;return dlmReportsInstance.tempDownloads.forEach(function(e){t===e.download_id&&(n=e,a.total=a.total+1,jQuery(document).trigger("dlm_download_by_id",[dlmReportsInstance,a,n]))}),a}getDownloadCPT(t){var e=dlmReportsInstance.mostDownloaded.filter(e=>e.id===t,0)[0];return jQuery(document).trigger("dlm_download_cpt",[dlmReportsInstance,e]),e}setSpinner(e){e.append('<div class="dlm-reports-spinner"><span></span></div>')}stopSpinner(e){e.find(".dlm-reports-spinner").remove()}eventsFunctions(){jQuery("body").on("click",".total_downloads_table_filters_total_downloads > a",function(e){e.preventDefault(),jQuery(this).parent().find("span.dashicons").toggleClass("dashicons-arrow-down dashicons-arrow-up"),dlmReportsInstance.orderOverviewItemsByTotal()}),jQuery("body").on("click",".total_downloads_table_filters_download_date > a",function(e){e.preventDefault(),jQuery(this).parent().find("span.dashicons").toggleClass("dashicons-arrow-down dashicons-arrow-up"),dlmReportsInstance.orderUserReportsItemsByDate()})}orderItems(e,a,n,t=0){return e.sort((e,t)=>"asc"!==a?t[n]-e[n]:e[n]-t[n]),e}orderOverviewItemsByTotal(){dlmReportsInstance.mostDownloaded=dlmReportsInstance.mostDownloaded.reverse(),dlmReportsInstance.setTopDownloads()}orderUserReportsItemsByDate(){dlmReportsInstance.tempDownloads=dlmReportsInstance.tempDownloads.reverse(),dlmReportsInstance.setUserDownloads()}}
|
1 |
+
jQuery(function(e){const t=new DLM_Reports;dlmReportsInstance.fetchReportsData(),e(document).on("dlm_downloads_report_fetched",function(){t.init()})});class DLM_Reports{dlmReportsStats=[];dlmUsersStats={logs:[],users:[]};currentFilters=[];tempDownloads=null;templates={};totalDownloads=0;constructor(){(dlmReportsInstance=this).chartContainer=document.getElementById("total_downloads_chart");const e=dlmReportsInstance.chartContainer.getContext("2d");dlmReportsInstance.chartColors={purple:{default:"rgba(149, 76, 233, 1)",threesome:"rgba(149, 76, 233, 0.75)",half:"rgba(149, 76, 233, 0.5)",quarter:"rgba(149, 76, 233, 0.5)",zero:"rgba(149, 76, 233, 0.05)"},blue:{default:"rgba(67, 56, 202, 1)",threesome:"rgba(67, 56, 202, 0.75)",half:"rgba(67, 56, 202, 0.5)",quarter:"rgba(67, 56, 202, 0.25)",zero:"rgba(67, 56, 202, 0.05)"},green:{default:"rgba(00, 255, 00, 1)",threesome:"rgba(00, 255, 00, 0.75)",half:"rgba(00, 255, 00, 0.5)",quarter:"rgba(00, 255, 00, 0.25)",zero:"rgba(67, 56, 202, 0.05)"},royalBlue:{default:"rgba(65, 105, 225, 1)",threesome:"rgba(65, 105, 225, 0.75)",half:"rgba(65, 105, 225, 0.5)",quarter:"rgba(65, 105, 225, 0.25)",zero:"rgba(65, 105, 225, 0.05)"},persianBlue:{default:"rgba(28, 57, 187, 1)",threesome:"rgba(28, 57, 187, 0.75)",half:"rgba(28, 57, 187, 0.5)",quarter:"rgba(28, 57, 187, 0.25)",zero:"rgba(28, 57, 187, 0.05)"},darkCyan:{default:"rgba(0,129,167, 1)",threesome:"rgba(0,129,167, 0.75)",half:"rgba(0,129,167, 0.5)",quarter:"rgba(0,129,167, 0.25)",zero:"rgba(0,129,167, 0.05)"},strongCyan:{default:"rgba(0, 175, 185, 1)",threesome:"rgba(0, 175, 185, 0.75)",half:"rgba(0, 175, 185, 0.5)",quarter:"rgba(0, 175, 185, 0.25)",zero:"rgba(0, 175, 185, 0.05)"}},dlmReportsInstance.chartGradient=e.createLinearGradient(0,25,0,300),dlmReportsInstance.chartGradient.addColorStop(0,dlmReportsInstance.chartColors.darkCyan.half),dlmReportsInstance.chartGradient.addColorStop(.45,dlmReportsInstance.chartColors.darkCyan.quarter),dlmReportsInstance.chartGradient.addColorStop(1,dlmReportsInstance.chartColors.darkCyan.zero),dlmReportsInstance.datePickerContainer=document.getElementById("dlm-date-range-picker"),dlmReportsInstance.dataSets=[];let t=new Date;dlmReportsInstance.dates={downloads:{start_date:new Date(t.setMonth(t.getMonth()-1)),end_date:new Date}},dlmReportsInstance.chartDataObject={}}async fetchReportsData(){const e=jQuery('div[data-id="general_info"]'),t=await fetch(dlmDownloadReportsAPI);if(!t.ok){const a=document.createElement("div"),n=(a.className="dlm-loading-data",document.createTextNode("Seems like we bumped into an error! ")),s=document.createTextNode("Data fetching returned a status text of : "+fetchedData.statusText),o=document.createElement("h1"),r=document.createElement("h3");throw o.appendChild(n),r.appendChild(s),a.appendChild(o),a.appendChild(r),e.find(".dlm-loading-data").remove(),e.append(a),new Error("Something went wrong! Reports response did not come OK - "+fetchedData.statusText)}dlmReportsInstance.dlmReportsStats=await t.json(),dlmReportsInstance.mostDownloaded=!1,dlmReportsInstance.stats=!1,dlmReportsInstance.chartType="day",0<window.location.href.indexOf("dlm_time")&&(dlmReportsInstance.dates.downloads.start_date=0<Object.keys(dlmReportsInstance.dlmReportsStats).length?new Date(dlmReportsInstance.dlmReportsStats[0].date):new Date,dlmReportsInstance.dates.downloads.end_date=new Date,jQuery("#dlm-date-range-picker .date-range-info").html(dlmReportsInstance.dates.downloads.start_date.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"2-digit"})+" - "+dlmReportsInstance.dates.downloads.end_date.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"2-digit"}))),dlmReportsInstance.createDataOnDate(dlmReportsInstance.dates.downloads.start_date,dlmReportsInstance.dates.downloads.end_date),dlmReportsInstance.datePicker={opened:!1},jQuery(document).trigger("dlm_downloads_report_fetched",[dlmReportsInstance,dlmReportsInstance.dlmReportsStats])}async fetchUsersReportsData(e=0,t=dlmPHPinfo.retrieved_rows){const a=jQuery('div[data-id="user_reports"]');let n=dlmUserReportsAPI+"?offset="+e+"&limit="+t;0<dlmUserReportsAPI.indexOf("index.php?")&&(n=dlmUserReportsAPI+"&offset="+e+"&limit="+t);const s=await fetch(n);if(!s.ok)throw new Error("Something went wrong! Reports response did not come OK - "+s.statusText);e=await s.json();dlmReportsInstance.dlmUsersStats.logs=dlmReportsInstance.dlmUsersStats.logs.concat(e.logs),!0===e.done?(dlmReportsInstance.userDownloads=void 0!==dlmReportsInstance.dlmUsersStats.logs?JSON.parse(JSON.stringify(dlmReportsInstance.dlmUsersStats.logs)):{},a.find(".dlm-loading-data").remove(),dlmReportsInstance.userReportsTab(),dlmReportsInstance.setTopDownloads(),dlmReportsInstance.stopSpinner(jQuery("#total_downloads_table_wrapper2"))):dlmReportsInstance.fetchUsersReportsData(e.offset)}async fetchUserData(){const e=await fetch(dlmUserDataAPI);if(!e.ok)throw new Error("Something went wrong! Reports response did not come OK - "+e.statusText);var t=await e.json();dlmReportsInstance.dlmUsersStats.users=dlmReportsInstance.dlmUsersStats.users.concat(t)}init(){dlmReportsInstance.tabNagivation(),dlmReportsInstance.overViewTab(),dlmReportsInstance.togglePageSettings(),dlmReportsInstance.fetchUserData(),dlmReportsInstance.setSpinner(jQuery("#users_download_log")),dlmReportsInstance.setSpinner(jQuery("#total_downloads_table_wrapper2")),dlmReportsInstance.fetchUsersReportsData(),jQuery(document).trigger("dlm_reports_init",[dlmReportsInstance]),dlmReportsInstance.eventsFunctions()}overViewTab(){dlmReportsInstance.dlmCreateChart(dlmReportsInstance.stats.chartStats,dlmReportsInstance.chartContainer),dlmReportsInstance.dlmDownloadsSummary(),dlmReportsInstance.datePickerContainer.addEventListener("click",dlmReportsInstance.toggleDatepicker.bind(this)),dlmReportsInstance.setTodayDownloads(),dlmReportsInstance.handleTopDownloads(),jQuery(document).on("click","body",function(e){e.stopPropagation(),0<jQuery(dlmReportsInstance.datePickerContainer).find("#dlm_date_range_picker").length&&dlmReportsInstance.hideDatepicker(jQuery(dlmReportsInstance.datePickerContainer),{target:"dlm-date-range-picker"})})}userReportsTab(){0!==Object.values(dlmReportsInstance.dlmUsersStats).length&&(dlmReportsInstance.logsDataByDate(dlmReportsInstance.dates.downloads.start_date,dlmReportsInstance.dates.downloads.end_date),dlmReportsInstance.handleUserDownloads(),dlmReportsInstance.filterDownloads())}getDates(e,t){const a={};let n=e;for(;n<=t;)a[this.createDateElement(n)]=0,n=this.getNextDay(n);return a}getMonths(e){const t={};return Object.keys(e).map(e=>{e=e.substring(0,7);void 0===t[e]&&(t[e]=0)}),t}getDoubleMonths(e){const t={},a=Object.keys(e)[0],n=Object.keys(e)[Object.keys(e).length-1];let s=0,o=a.substring(0,7),r=n.substring(0,7);return Object.keys(e).map(e=>{e=e.substring(0,7);o!==e&&r!==e&&(o=e,s++),void 0===t[e]&&0==s%2&&(t[e]=0)}),t}getWeeks(e){let a={};return Object.keys(e).forEach(e=>{let t;t=15<moment(e).date()?e.substring(0,7)+"-15":e.substring(0,7)+"-01",void 0===a[t]&&(a[t]=0)}),a}getWeek(e){let t={},a=Object.keys(e)[Object.keys(e).length-1],n=0;return Object.keys(e).map(e=>{void 0===t[e]&&0==n%7&&(t[e]=0),n++}),void 0===t[a]&&(t[a]=0),t}getDoubleDays(e){let t={},a=Object.keys(e)[0],n=Object.keys(e)[Object.keys(e).length-1],s=0;return Object.keys(e).map(e=>{a!==e&&n!==e&&(a=e,s++),void 0===t[e]&&0==s%2&&(t[e]=0)}),t}getNextDay(e){const t=new Date(e);return t.setDate(e.getDate()+1),t}createDateElement(e){var t=(e.getMonth()+1<10?"0":"")+(e.getMonth()+1);return e.getFullYear()+"-"+t+"-"+("0"+e.getDate()).slice(-2)}getSetDates(e,t){let a,n;if(void 0!==e&&e)a=dlmReportsInstance.createDateElement(new Date(e));else{const s=new Date;s.setDate(s.getDate()-30),a=dlmReportsInstance.createDateElement(s)}if(void 0!==t&&t){e=new Date(t);n=dlmReportsInstance.createDateElement(e)}else{const o=new Date;o.setDate(o.getDate()+1),n=dlmReportsInstance.createDateElement(o)}return{startDate:a,endDate:n}}createDataOnDate(e,t){let{startDate:a,endDate:n}={...dlmReportsInstance.getSetDates(e,t)},s,o,r,d,l,c=(dlmReportsInstance.reportsData=void 0!==dlmReportsInstance.dlmReportsStats?JSON.parse(JSON.stringify(dlmReportsInstance.dlmReportsStats)):{},o=moment(n,"YYYY-MM-DD").month()-moment(a,"YYYY-MM-DD").month(),r=moment(n,"YYYY-MM-DD").year()-moment(a,"YYYY-MM-DD").year(),s=moment(n).date()-moment(a).date(),dlmReportsInstance.chartType="day",0==r&&-6<o&&o<6?1<o||o<-1?dlmReportsInstance.chartType=2==o?"week":"weeks":1==o&&(8<s||-14<s||0==s)&&(dlmReportsInstance.chartType="days"):o<=0?dlmReportsInstance.chartType="month":dlmReportsInstance.chartType="months",dlmReportsInstance.getDates(new Date(a),new Date(n))),m,i,p,g;switch(dlmReportsInstance.chartType){case"months":i=dlmReportsInstance.getDoubleMonths(c),l=i;break;case"month":var u=dlmReportsInstance.getMonths(c);l=u;break;case"weeks":p=dlmReportsInstance.getWeeks(c),l=p;break;case"week":g=dlmReportsInstance.getWeek(c),l=g;break;case"days":m=dlmReportsInstance.getDoubleDays(c),l=m;break;case"day":l=c}Object.values(dlmReportsInstance.reportsData).forEach((s,e)=>{var o=JSON.parse(s.download_ids);if(void 0!==c[s.date])switch(dlmReportsInstance.chartType){case"months":d=s.date.substring(0,7);let e=parseInt(s.date.substring(5,7)),t=s.date.substring(0,5),a=6<(e-1).length?t+(e-1):t+"0"+(e-1);Object.values(o).forEach((e,t)=>{void 0===i[d]?void 0!==i[a]&&(i[a]=i[a]+e.downloads):i[d]=i[d]+e.downloads}),l=i;break;case"month":d=s.date.substring(0,7),Object.values(o).forEach((e,t)=>{monthDownloads[d]=void 0!==monthDownloads[d]?monthDownloads[d]+e.downloads:e.downloads}),l=monthDownloads;break;case"weeks":d=15<moment(s.date).date()?s.date.substring(0,7)+"-15":s.date.substring(0,7)+"-01",Object.values(o).forEach((e,t)=>{p[d]=void 0!==p[d]?p[d]+e.downloads:e.downloads}),l=p;break;case"week":d=s.date,Object.values(o).forEach((t,e)=>{if(void 0===g[d])for(let e=1;e<8;e++){var a=moment(s.date).date(moment(s.date).date()-e).format("YYYY-MM-DD");void 0!==g[a]&&(g[a]=g[a]+t.downloads)}else g[d]=g[d]+t.downloads}),l=g;break;case"days":d=s.date;let n=moment(s.date).date(moment(s.date).date()-1).format("YYYY-MM-DD");Object.values(o).forEach((e,t)=>{void 0===m[d]?void 0!==m[n]&&(m[n]=m[n]+e.downloads):m[d]=m[d]+e.downloads}),l=m;break;case"day":Object.values(o).forEach((e,t)=>{c[s.date]=c[s.date]+e.downloads}),l=c}else delete dlmReportsInstance.reportsData[e]});const h=Object.keys(c);e=h.length,t=h.findIndex(e=>a===e);let I=h.findIndex(e=>n===e);-1===t&&-1===I?dlmReportsInstance.stats={chartStats:Object.assign({},l),summaryStats:!1,daysLength:e}:(-1===I&&(I=e),dlmReportsInstance.stats={chartStats:Object.assign({},l),summaryStats:dlmReportsInstance.reportsData,daysLength:e})}dlmCreateChart(t,a,n=!1){if(t&&a){let e=Chart.getChart("total_downloads_chart");dlmReportsInstance.chartDataObject={dataSetLabel:"Downloads",dataSetColor:"#27ae60",dataSetbg:dlmReportsInstance.chartGradient,dataSetPointbg:dlmReportsInstance.chartColors.darkCyan.default,dataSetBorder:dlmReportsInstance.chartColors.darkCyan.default,dataSetElementColor:"#2ecc71",lineType:"original",xAxis:"x",chartData:t},void 0!==e&&e.destroy(),jQuery(document).trigger("dlm_reports_before_data_sets",[dlmReportsInstance.chartDataObject,t,n]),0<dlmReportsInstance.dataSets.length&&(dlmReportsInstance.dataSets=dlmReportsInstance.dataSets.filter(e=>dlmReportsInstance.chartDataObject.lineType!==e.origin)),dlmReportsInstance.dataSets.push({origin:dlmReportsInstance.chartDataObject.lineType,label:dlmReportsInstance.chartDataObject.dataSetLabel,color:dlmReportsInstance.chartDataObject.dataSetColor,data:dlmReportsInstance.chartDataObject.chartData,type:"line",fill:!0,backgroundColor:dlmReportsInstance.chartDataObject.dataSetbg,pointBackgroundColor:dlmReportsInstance.chartDataObject.dataSetPointbg,pointHoverBackgroundColor:"#fff",borderColor:dlmReportsInstance.chartDataObject.dataSetBorder,pointBorderWidth:1,lineTension:.3,borderWidth:1,pointRadius:3,elements:{line:{borderColor:dlmReportsInstance.chartDataObject.dataSetElementColor,borderWidth:1},point:{radius:4,hoverRadius:4,pointStyle:"circle"}}});t=Object.values(dlmReportsInstance.dataSets).filter(e=>"original"===e.origin);let o=Object.keys(t[0].data);dlmReportsInstance.dataSets.sort(function(e,t){return"original"===e.origin?-1:1}),dlmReportsInstance.chart=new Chart(a,{title:"",data:{datasets:dlmReportsInstance.dataSets},height:450,is_series:1,options:{aspectRatio:5,animation:!1,interaction:{mode:"index",intersect:!1},stacked:!1,scales:{x:{grid:{display:!1},ticks:{callback:e=>{let t="";var a=o[e],n=o[o.length-1],s=moment(n).month(moment(n).month()-1).format("YYYY-MM");return t="undefined"!==dlmReportsInstance.chartType&&"months"===dlmReportsInstance.chartType?(e=moment(o[e]).month())<11?a===s?moment(a).format("MMM, YYYY"):moment(a).format("MMM")+" - "+moment(a).month(e+1).format("MMM")+moment(a).format(", YYYY"):a===s||a===n?moment(a).format("MMM, YYYY"):moment(a).format("MMM")+moment(a).format(" YYYY")+" - "+moment(a).month(e+1).format("MMM")+moment(a).month(e+1).format(", YYYY"):"undefined"!==dlmReportsInstance.chartType&&"months"===dlmReportsInstance.chartType?moment(a).format("MMMM, YYYY"):moment(a).format("D MMM")}}},y:{grid:{drawBorder:!1},min:0,max:0!==dlmReportsInstance.getMaxDownload()?1===Math.ceil(dlmReportsInstance.getMaxDownload()/10)?dlmReportsInstance.getMaxDownload()+1:10*Math.ceil(dlmReportsInstance.getMaxDownload()/10):100,ticks:{stepSize:0!==dlmReportsInstance.getMaxDownload()?Math.ceil(dlmReportsInstance.getMaxDownload()/4):25,callback:e=>dlmReportsInstance.shortNumber(e)}}},normalized:!0,parsing:{xAxisKey:"x",yAxisKey:"y"},plugins:{tooltip:{enabled:!1,external:dlmReportsInstance.externalTooltipHandler.bind(dlmReportsInstance,this)},legend:{display:!0}}}})}}dlmDownloadsSummary(){let a={};if(!1===dlmReportsInstance.stats||!1===dlmReportsInstance.stats.summaryStats||Object.keys(dlmReportsInstance.stats.summaryStats).length<=0)return this.setTotalDownloads(0),this.setDailyAverage(0),void this.setMostDownloaded("--");dlmReportsInstance.totalDownloads=0,dlmReportsInstance.stats.summaryStats.forEach(e=>{e=JSON.parse(e.download_ids),Object.entries(e).forEach(([e,t])=>{dlmReportsInstance.totalDownloads+=t.downloads,a[e]=void 0===a[e]?{downloads:t.downloads,title:t.title,id:e}:{downloads:a[e].downloads+t.downloads,title:t.title,id:e}})}),dlmReportsInstance.mostDownloaded=dlmReportsInstance.orderItems(Object.values(a),"desc","downloads"),dlmReportsInstance.setTotalDownloads(dlmReportsInstance.totalDownloads),dlmReportsInstance.setDailyAverage((dlmReportsInstance.totalDownloads/parseInt(dlmReportsInstance.stats.daysLength)).toFixed(0)),dlmReportsInstance.setMostDownloaded(dlmReportsInstance.mostDownloaded[0].title)}createDatepicker(e,t,a){const n=new Date;let s=n.getDate()-1,o=n.getMonth()+1,r=o-1;var d=n.getFullYear(),l=(s<10&&(s="0"+s),o<10&&(o="0"+o),r<10&&(r="0"+r),d+"-"+o+"-"+s),d=d+"-"+r+"-"+s,c=jQuery("<div>").addClass("dlm_rdrs_overlay"),a=jQuery("<div>").attr("id",a.replace("#",""));return"dlm-date-range-picker"===t.target?(dlmReportsInstance.startDateInput=jQuery("<input>").attr("type","hidden").attr("id","dlm_start_date").attr("value",d),dlmReportsInstance.endDateInput=jQuery("<input>").attr("type","hidden").attr("id","dlm_end_date").attr("value",l),c.append(a).append(dlmReportsInstance.startDateInput).append(dlmReportsInstance.endDateInput)):jQuery(document).trigger("dlm_create_date_picker_"+t.target,[dlmReportsInstance,c,a,d,l]),c}displayDatepicker(e,o){var t;if(jQuery(e)){if(t="#"+jQuery(e).attr("id").replace(/-/gi,"_"),"dlm-date-range-picker"===o.target){if(dlmReportsInstance.datePicker.opened)return;dlmReportsInstance.datePicker.opened=!0}else jQuery(document).trigger("dlm_display_datepicker_"+o.target,[dlmReportsInstance,o,e]);let s=dlmReportsInstance.createDatepicker(e,o,t);e.append(s);var a=0<Object.keys(dlmReportsInstance.dlmReportsStats).length?new Date(dlmReportsInstance.dlmReportsStats[0].date):new Date,n=(new Date,[]),e=(jQuery(document).trigger("dlm_datepicker_shortcuts_"+o.target,[dlmReportsInstance,o,e,n]),{separator:" to ",autoClose:!0,getValue:function(){},setValue:function(e,t,a){s.find('input[type="hidden"]').first().val(t),s.find('input[type="hidden"]').last().val(a)},inline:!0,alwaysOpen:!0,container:t,endDate:new Date,startDate:a,showShortcuts:!0,shortcuts:null,customShortcuts:n});s.dateRangePicker(e).on("datepicker-change",(e,t)=>{var a,n;t.date1&&t.date2&&(a=t.date1.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"2-digit"}),n=t.date2.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"2-digit"}),s.parent().find("span.date-range-info").text(a+" - "+n)),"dlm-date-range-picker"===o.target?(dlmReportsInstance.dates.downloads={start_date:t.date1,end_date:t.date2},dlmReportsInstance.createDataOnDate(dlmReportsInstance.dates.downloads.start_date,dlmReportsInstance.dates.downloads.end_date),dlmReportsInstance.dlmCreateChart(dlmReportsInstance.stats.chartStats,dlmReportsInstance.chartContainer,!1),dlmReportsInstance.dlmDownloadsSummary(),0<Object.values(dlmReportsInstance.dlmUsersStats.logs).length&&dlmReportsInstance.logsDataByDate(dlmReportsInstance.dates.downloads.start_date,dlmReportsInstance.dates.downloads.end_date)):jQuery(document).trigger("dlm_daterangepicker_init_"+o.target,[dlmReportsInstance,t.date1,t.date2]),dlmReportsInstance.setTopDownloads(),s.data("dateRangePicker").close()}),"dlm-date-range-picker"===o.target?s.data("dateRangePicker").setDateRange(dlmReportsInstance.dates.downloads.start_date,dlmReportsInstance.dates.downloads.end_date):jQuery(document).trigger("dlm_daterangepicker_after_init_"+o.target,[s,dlmReportsInstance])}}hideDatepicker(e,t){"dlm-date-range-picker"===t.target?dlmReportsInstance.datePicker.opened=!1:jQuery(document).trigger("dlm_hide_datepicker_"+t.target,[dlmReportsInstance,e,t]),e.find(".dlm_rdrs_overlay").remove()}toggleDatepicker(e){e.stopPropagation();const t=jQuery(e.target).parents(".dlm-reports-header-date-selector");e={target:t.attr("id"),object:dlmReportsInstance.datePicker};dlmReportsInstance.closeDatePickers(t),"dlm-date-range-picker"===e.target?dlmReportsInstance.datePicker.opened?dlmReportsInstance.hideDatepicker(t,e):dlmReportsInstance.displayDatepicker(t,e):jQuery(document).trigger("dlm_toggle_datepicker_"+e.target,[dlmReportsInstance,t,e])}setTotalDownloads(e){jQuery(".dlm-reports-block-summary li#total span").html(e.toLocaleString())}setDailyAverage(e){jQuery(".dlm-reports-block-summary li#average span").html(e.toLocaleString())}setMostDownloaded(e){jQuery(".dlm-reports-block-summary li#most_popular span").html(e)}setTodayDownloads(){let e=0;Object.keys(dlmReportsInstance.dlmReportsStats).length<=0?jQuery(".dlm-reports-block-summary li#today span").html(e.toLocaleString()):(dlmReportsInstance.dlmReportsStats[dlmReportsInstance.dlmReportsStats.length-1].date===dlmReportsInstance.createDateElement(new Date)&&(e=Object.values(JSON.parse(dlmReportsInstance.dlmReportsStats[dlmReportsInstance.dlmReportsStats.length-1].download_ids)).reduce((e,t)=>e+t.downloads,0)),jQuery(".dlm-reports-block-summary li#today span").html(e))}setTopDownloads(e=0,t=!1){const a=jQuery("#total_downloads_table_wrapper2"),n=jQuery("#total_downloads_table_wrapper2 .total_downloads_table__list");if(n.empty(),n.parent().addClass("empty"),dlmReportsInstance.mostDownloaded&&!0!==t){var s=JSON.parse(JSON.stringify(dlmReportsInstance.mostDownloaded)).slice(10*parseInt(e),10*parseInt(e+1));for(let e=0;e<s.length;e++){const r=dlmReportsInstance.getDownloadByID(s[e].id);if(void 0===r)return;var o={id:s[e].id,title:s[e].title,edit_link:dlmAdminUrl+"post.php?post="+s[e].id+"&action=edit",total_downloads:r.total.toLocaleString()};jQuery(document).trigger("dlm_reports_top_downloads_item_before_render",[o,dlmReportsInstance,s[e],r]),new dlmBackBone.modelTopDownloads(o)}n.parent().removeClass("empty"),10<dlmReportsInstance.mostDownloaded.length?a.find(".downloads-block-navigation button").removeClass("hidden"):a.find(".downloads-block-navigation button").addClass("hidden"),dlmReportsInstance.stopSpinner(jQuery("#total_downloads_table_wrapper2"))}}handleTopDownloads(){jQuery("html body").on("click","#total_downloads_table_wrapper2 .downloads-block-navigation button",function(){let e=jQuery(this).parents("#total_downloads_table_wrapper2"),t=e,a=e.attr("data-page"),n=jQuery(this),s=parseInt(a)+1,o=0!==a?parseInt(a)-1:0,r=e.find(".downloads-block-navigation").find("button").first(),d=e.find(".downloads-block-navigation").find("button").last();n.attr("disabled","disabled");var l={data:dlmReportsInstance.mostDownloaded,main_parent:e,offsetHolder:t,offset:a,link:n,nextPage:s,prevPage:o,prevButton:r,nextButton:d,doAction:dlmReportsInstance.setTopDownloads};dlmReportsInstance.handleSliderNavigation(l)})}handleSliderNavigation(e){const{data:t,offsetHolder:a,offset:n,link:s,nextPage:o,prevPage:r,prevButton:d,nextButton:l,doAction:c}={...e};"load-more"===s.data("action")?(a.attr("data-page",o),c(o),Math.ceil(t.length/10)>o+1&&l.removeAttr("disabled"),d.removeAttr("disabled")):0!==parseInt(n)&&(a.attr("data-page",r),c(r),1!==parseInt(n)&&d.removeAttr("disabled"),l.removeAttr("disabled"))}tabNagivation(){jQuery(document).on("click",".dlm-reports .dlm-insights-tab-navigation > li",function(){const e=jQuery(this),t=jQuery(".dlm-reports .dlm-insights-tab-navigation > li").not(e),a=jQuery('div.dlm-insights-tab-navigation__content[data-id="'+e.attr("id")+'"]'),n=jQuery("div.dlm-insights-tab-navigation__content").not(a);e.hasClass("active")||(e.addClass("active"),t.removeClass("active"),a.addClass("active"),n.removeClass("active"))})}getOrCreateTooltip(e){let t=e.canvas.parentNode.querySelector("div.dlm-canvas-tooltip"),a=e.canvas.parentNode.querySelector("div.dlm-reports-tooltip__line");if(t||((a=document.createElement("div")).className="dlm-reports-tooltip__line"),!t){(t=document.createElement("div")).className="dlm-canvas-tooltip";const n=document.createElement("div");n.className="dlm-reports-tooltip",t.appendChild(n),e.canvas.parentNode.appendChild(t),e.canvas.parentNode.appendChild(a)}return{tooltipEl:t,tooltipLine:a}}externalTooltipHandler(d,e){const{chart:t,tooltip:l}=e,{tooltipEl:a,tooltipLine:n}={...d.getOrCreateTooltip(t)};e=jQuery(a).parent().width();if(0===l.opacity)return a.style.opacity=0,void(n.style.opacity=0);if(l.body){const c=l.title||[],m=document.createElement("div"),i=(m.className="dlm-reports-tooltip__header",c.forEach(e=>{const t=document.createElement("div"),a=(t.className="dlm-reports-tooltip__row",document.createElement("p")),n=(a.className="dlm-reports-tooltip__info",a.appendChild(document.createTextNode("Downloads")),t.appendChild(a),jQuery(document).trigger("dlm_chart_tooltip_before",[dlmReportsInstance,l,t,d]),document.createElement("p"));n.className="dlm-reports-tooltip__date";var s=dlmReportsInstance.setChartTooltipDate(l.dataPoints[0].label,d,d.stats.chartStats);n.appendChild(document.createTextNode(s)),t.appendChild(n);const o=document.createElement("p"),r=(o.className="dlm-reports-tooltip__downloads",document.createElement("span"));r.className="dlm-reports-tooltip__downloads_pointer",r.style.backgroundColor=dlmReportsInstance.chartColors.darkCyan.default,o.appendChild(r),o.appendChild(document.createTextNode(dlmReportsInstance.shortNumber(l.dataPoints[0].formattedValue))),t.appendChild(o),jQuery(document).trigger("dlm_chart_tooltip_after",[dlmReportsInstance,l,t,d]),m.appendChild(t)}),a.querySelector("div.dlm-reports-tooltip"));for(;i.firstChild;)i.firstChild.remove();i.appendChild(m)}var{offsetLeft:s,offsetTop:o}=t.canvas;a.style.opacity=1;let r={isMargin:!(n.style.opacity=1),left:!1};l.caretX-l.width<0&&(r.isMargin=!0,r.left=!0),s+l.caretX+l.width>e&&(r.isMargin=!0,r.left=!1),r.isMargin?r.left?a.style.left=s+l.width+"px":a.style.left=e-l.width+"px":a.style.left=s+l.caretX+"px",n.style.left=s+l.caretX+"px",a.style.top=o+l.caretY-a.offsetHeight-10+"px"}createUserRelatedData(){dlmReportsInstance.userRelatedData=[],Object.values(dlmReportsInstance.userDownloads).forEach((e,t)=>{var a;"0"!==e.user_id&&(a=[e.user_id,e.download_id,e.download_date,e.download_status],e="user_"+e.user_id,void 0!==dlmReportsInstance.userRelatedData[e]?dlmReportsInstance.userRelatedData[e].push(a):dlmReportsInstance.userRelatedData[e]=[a])})}logsDataByDate(e,t){var{startDate:e,endDate:t}={...dlmReportsInstance.getSetDates(e,t)};dlmReportsInstance.userDownloads=JSON.parse(JSON.stringify(dlmReportsInstance.dlmUsersStats.logs));let a=new Date(e),n=(a.setDate(a.getDate()-1),a=a.getTime(),new Date(t));n.setDate(n.getDate()+1),n=n.getTime(),dlmReportsInstance.userDownloads=dlmReportsInstance.userDownloads.filter((e,t)=>{e=dlmReportsInstance.createDateElement(new Date(e.download_date));return(e=new Date(e).getTime())>a&&e<n}),dlmReportsInstance.createUserRelatedData(),dlmReportsInstance.filterDownloads(),dlmReportsInstance.setMostActiveUser(),dlmReportsInstance.setLoggedOutDownloads(),dlmReportsInstance.setLoggedInDownloads(),jQuery(document).trigger("dlm_set_logs_data_by_date",[dlmReportsInstance])}setMostActiveUser(){var e=dlmReportsInstance.getUserByID(dlmReportsInstance.getMostActiveID()[0]);jQuery(".dlm-reports-block-summary li#most_active_user span").html(dlmReportsInstance.userToolTipMarkup(e))}getMostActiveID(){return Object.values(dlmReportsInstance.userRelatedData).length?Object.values(dlmReportsInstance.userRelatedData).reduce((e,t,a)=>parseInt(e.length)>parseInt(t.length)&&0<e.length&&null!==dlmReportsInstance.getUserByID(e[0][0])?e:null!==dlmReportsInstance.getUserByID(t[0][0])?t:[],[]):0}getUserByID(t){if(!t||"0"===t)return null;var e=Object.values(dlmReportsInstance.dlmUsersStats.users).filter(e=>parseInt(t)===parseInt(e.id));return Array.isArray(e)?0===e.length?null:e[0]:e}getLoggedInDownloads(){return Object.values(dlmReportsInstance.userRelatedData).length?1<Object.values(dlmReportsInstance.userRelatedData).length?Object.values(dlmReportsInstance.userRelatedData).reduce((e,t)=>parseInt(e)+parseInt(t.length),0):Object.values(dlmReportsInstance.userRelatedData)[0].length:0}setLoggedInDownloads(){const e=dlmReportsInstance.getLoggedInDownloads();jQuery(".dlm-reports-block-summary li#logged_in span,#total_downloads_summary_wrapper .dlm-reports-logged-in").html(e.toLocaleString())}getLoggedOutDownloads(){return dlmReportsInstance.userDownloads.length-dlmReportsInstance.getLoggedInDownloads()}setLoggedOutDownloads(){const e=dlmReportsInstance.getLoggedOutDownloads();jQuery(".dlm-reports-block-summary li#logged_out span,#total_downloads_summary_wrapper .dlm-reports-logged-out").html(e.toLocaleString())}userToolTipMarkup(e){let t='<div class="dlm-user-reports">';return t=(t=t+'<div class="wpchill-tooltip"><i>[?]</i>'+'<div class="wpchill-tooltip-content">')+("<span>User ID: "+(null!==e?e.id:"--")+"</span>"),"object"!=typeof e&&e.url.length&&(t+="<span>User URL: "+(null!==e?e.url:"--")+"</span>"),t+="<span>User registration date: "+(null!==e?e.registered:"--")+"</span>",null!==e&&void 0!==e.role&&e.role.length&&(t+="<span>User role: "+e.role+"</span>"),t=(t+="</div></div>")+(null!==e?e.display_name:"--")+"</div>"}setUserDownloads(e=0,t=!1){const a=jQuery("#users_download_log"),n=jQuery("#users_download_log .user-logs__list");if(n.empty(),!0!==t){let t=[];t=(null!==dlmReportsInstance.tempDownloads?JSON.parse(JSON.stringify(dlmReportsInstance.tempDownloads)):JSON.parse(JSON.stringify(dlmReportsInstance.userDownloads))).slice(10*parseInt(e),10*parseInt(e+1));for(let e=0;e<t.length;e++){var s=dlmReportsInstance.getUserByID(t[e].user_id.toString()),o=dlmReportsInstance.getDownloadCPT(t[e].download_id.toString()),r={key:e,user:"0"!==t[e].user_id&&null!=s?s.display_name:"--",ip:t[e].user_ip,role:null!==s&&null!==s.role?s.role:"--",download:void 0!==o?o.title:"--",valid_user:"0"!==t[e].user_id,edit_link:"user-edit.php?user_id="+t[e].user_id,edit_download_link:void 0!==o?dlmAdminUrl+"post.php?post="+o.id+"&action=edit":"#",status:t[e].download_status,download_date:t[e].download_date};jQuery(document).trigger("dlm_reports_user_logs_item_before_render",[r,dlmReportsInstance,t[e],s,o]),new dlmBackBone.modelUserLogs(r)}dlmReportsInstance.stopSpinner(jQuery("#users_download_log")),10!==t.length?a.find('.user-downloads-block-navigation button[data-action="load-more"]').attr("disabled","disabled"):a.find('.user-downloads-block-navigation button[data-action="load-more"]').removeAttr("disabled"),10<dlmReportsInstance.userDownloads.length?a.find(".user-downloads-block-navigation button").removeClass("hidden"):a.find(".user-downloads-block-navigation button").addClass("hidden")}}filterDownloads(){dlmReportsInstance.tempDownloads=JSON.parse(JSON.stringify(dlmReportsInstance.userDownloads)),dlmReportsInstance.currentFilters.length&&dlmReportsInstance.currentFilters.forEach(t=>{dlmReportsInstance.tempDownloads=dlmReportsInstance.tempDownloads.filter(e=>t.on===e[t.type])}),dlmReportsInstance.setUserDownloads()}handleUserDownloads(){jQuery(".user-downloads-block-navigation").on("click","button",function(e){e.stopPropagation();let t=jQuery(this).parents("#users_downloads_table_wrapper"),a=t.find("#users_download_log"),n=a.attr("data-page"),s=jQuery(this),o=parseInt(n)+1,r=0!==n?parseInt(n)-1:0,d=t.find(".downloads-block-navigation button").first(),l=t.find(".downloads-block-navigation button").last();s.attr("disabled","disabled");e={data:dlmReportsInstance.tempDownloads,main_parent:t,offsetHolder:a,offset:n,link:s,nextPage:o,prevPage:r,prevButton:d,nextButton:l,doAction:dlmReportsInstance.setUserDownloads};dlmReportsInstance.handleSliderNavigation(e)})}togglePageSettings(){jQuery("#dlm-toggle-settings").on("click",function(e){e.stopPropagation(),jQuery(this).find(".dlm-toggle-settings__settings").toggleClass("display")}),jQuery(".dlm-toggle-settings__settings").on("click",function(e){e.stopPropagation()}),jQuery("html,body").on("click",function(){jQuery(this).find(".dlm-toggle-settings__settings").removeClass("display")}),jQuery(document).on("change",".wpchill-toggle__input",function(e){const t=jQuery(this),a=t.attr("name"),n={action:"dlm_update_report_setting",name:a,checked:t.is(":checked"),_ajax_nonce:dlmReportsNonce};jQuery.post(ajaxurl,n,function(e){a,jQuery(document).trigger("dlm_settings_ajax_response",[dlmReportsInstance,t,e])})})}getMaxDownload(){let t=0;return dlmReportsInstance.dataSets.forEach(e=>{e=Object.values(e.data).reduce((e,t)=>t<e?e:t,0);t<e&&(t=e)}),parseInt(t)}setChartTooltipDate(e,t,a){let n="";var s,o,r;return n="undefined"!==t.chartType&&"months"===t.chartType?(moment(e).year(),s=moment(e).month(),a=Object.keys(a)[Object.keys(a).length-1],o=moment(a).month(moment(a).month()-1).format("YYYY-MM"),r=moment(e).format("YYYY-MM"),s<11?r===o?moment(r).format("MMMM, YYYY"):moment(e).format("MMM")+" - "+moment(e).month(s+1).format("MMM")+moment(e).format(", YYYY"):r===o||r===a?moment(r).format("MMMM, YYYY"):moment(e).format("MMM")+moment(e).format(" YYYY")+" - "+moment(e).month(s+1).format("MMM")+moment(e).month(s+1).format(", YYYY")):"undefined"!==t.chartType&&"months"===t.chartType?moment(e).format("MMMM, YYYY"):moment(e).format("MMMM Do, YY")}closeDatePickers(e){jQuery(".dlm-reports-header-date-selector").not(e).each(function(){var e={target:jQuery(this).attr("id")};dlmReportsInstance.hideDatepicker(jQuery(this),e)})}shortNumber(e){return e=4<=(e="string"==typeof e?e.replace(/,/gi,""):parseInt(e).toString()).length?parseInt(e.substring(0,e.length-3)).toLocaleString()+"k":e}getDownloadByID(t){let a={total:0},n;return dlmReportsInstance.tempDownloads.forEach(function(e){t===e.download_id&&(n=e,a.total=a.total+1,jQuery(document).trigger("dlm_download_by_id",[dlmReportsInstance,a,n]))}),a}getDownloadCPT(t){var e=dlmReportsInstance.mostDownloaded.filter(e=>e.id===t,0)[0];return jQuery(document).trigger("dlm_download_cpt",[dlmReportsInstance,e]),e}setSpinner(e){e.append('<div class="dlm-reports-spinner"><span></span></div>')}stopSpinner(e){e.find(".dlm-reports-spinner").remove()}eventsFunctions(){jQuery("body").on("click",".total_downloads_table_filters_total_downloads > a",function(e){e.preventDefault(),jQuery(this).parent().find("span.dashicons").toggleClass("dashicons-arrow-down dashicons-arrow-up"),dlmReportsInstance.orderOverviewItemsByTotal()}),jQuery("body").on("click",".total_downloads_table_filters_download_date > a",function(e){e.preventDefault(),jQuery(this).parent().find("span.dashicons").toggleClass("dashicons-arrow-down dashicons-arrow-up"),dlmReportsInstance.orderUserReportsItemsByDate()})}orderItems(e,a,n,t=0){return e.sort((e,t)=>"asc"!==a?t[n]-e[n]:e[n]-t[n]),e}orderOverviewItemsByTotal(){dlmReportsInstance.mostDownloaded=dlmReportsInstance.mostDownloaded.reverse(),dlmReportsInstance.setTopDownloads()}orderUserReportsItemsByDate(){dlmReportsInstance.tempDownloads=dlmReportsInstance.tempDownloads.reverse(),dlmReportsInstance.setUserDownloads()}}
|
changelog.txt
CHANGED
@@ -1,3 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
1 |
= 4.6.1 - 26.09.2022 =
|
2 |
Fixed: User reports user fetching and displaying was broken ( [#1040](https://github.com/WPChill/download-monitor/issues/1040) ).
|
3 |
Fixed: Versions did not add the meta to the count ( [#1041](https://github.com/WPChill/download-monitor/issues/1041) ).
|
1 |
+
= 4.6.2 - 29.09.2022 =
|
2 |
+
Fixed: WP VIP servers bug ( [#1052](https://github.com/WPChill/download-monitor/issues/1052) ) thanks to @jesusfreak3
|
3 |
+
Fixed: Progress loader for external sources ( [#1051](https://github.com/WPChill/download-monitor/issues/1051) )
|
4 |
+
Fixed: Reports Page Most downloaded Download not shown correctly ( [#1048](https://github.com/WPChill/download-monitor/issues/1048) )
|
5 |
+
|
6 |
= 4.6.1 - 26.09.2022 =
|
7 |
Fixed: User reports user fetching and displaying was broken ( [#1040](https://github.com/WPChill/download-monitor/issues/1040) ).
|
8 |
Fixed: Versions did not add the meta to the count ( [#1041](https://github.com/WPChill/download-monitor/issues/1041) ).
|
download-monitor.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Download Monitor
|
4 |
Plugin URI: https://www.download-monitor.com
|
5 |
Description: A full solution for managing and selling downloadable files, monitoring downloads and outputting download links and file information on your WordPress powered site.
|
6 |
-
Version: 4.6.
|
7 |
Author: WPChill
|
8 |
Author URI: https://wpchill.com
|
9 |
Requires at least: 5.4
|
@@ -34,7 +34,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
34 |
|
35 |
// Define DLM Version
|
36 |
|
37 |
-
define( 'DLM_VERSION', '4.6.
|
38 |
define( 'DLM_UPGRADER_VERSION', '4.6.0' );
|
39 |
|
40 |
// Define DLM FILE
|
3 |
Plugin Name: Download Monitor
|
4 |
Plugin URI: https://www.download-monitor.com
|
5 |
Description: A full solution for managing and selling downloadable files, monitoring downloads and outputting download links and file information on your WordPress powered site.
|
6 |
+
Version: 4.6.2
|
7 |
Author: WPChill
|
8 |
Author URI: https://wpchill.com
|
9 |
Requires at least: 5.4
|
34 |
|
35 |
// Define DLM Version
|
36 |
|
37 |
+
define( 'DLM_VERSION', '4.6.2' );
|
38 |
define( 'DLM_UPGRADER_VERSION', '4.6.0' );
|
39 |
|
40 |
// Define DLM FILE
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: wpchill, silkalns, barrykooij, mikejolley
|
|
3 |
Tags: download manager, document management, file manager, digital store, ecommerce, document management plugin, download monitor, download counter, password protection, download protection, password, protect downloads, tracker, sell, shop, ecommerce, paypal
|
4 |
Requires at least: 5.4
|
5 |
Tested up to: 6.0
|
6 |
-
Stable tag: 4.
|
7 |
License: GPLv3
|
8 |
Text Domain: -
|
9 |
Requires PHP: 5.6
|
@@ -121,6 +121,11 @@ More documentation can be found in our [Knowledge Base](https://www.download-mon
|
|
121 |
|
122 |
== Changelog ==
|
123 |
|
|
|
|
|
|
|
|
|
|
|
124 |
= 4.6.1 - 26.09.2022 =
|
125 |
Fixed: User reports user fetching and displaying was broken ( [#1040](https://github.com/WPChill/download-monitor/issues/1040) ).
|
126 |
Fixed: Versions did not add the meta to the count ( [#1041](https://github.com/WPChill/download-monitor/issues/1041) ).
|
3 |
Tags: download manager, document management, file manager, digital store, ecommerce, document management plugin, download monitor, download counter, password protection, download protection, password, protect downloads, tracker, sell, shop, ecommerce, paypal
|
4 |
Requires at least: 5.4
|
5 |
Tested up to: 6.0
|
6 |
+
Stable tag: 4.6.2
|
7 |
License: GPLv3
|
8 |
Text Domain: -
|
9 |
Requires PHP: 5.6
|
121 |
|
122 |
== Changelog ==
|
123 |
|
124 |
+
= 4.6.2 - 29.09.2022 =
|
125 |
+
Fixed: WP VIP servers bug ( [#1052](https://github.com/WPChill/download-monitor/issues/1052) ) thanks to @jesusfreak3
|
126 |
+
Fixed: Progress loader for external sources ( [#1051](https://github.com/WPChill/download-monitor/issues/1051) )
|
127 |
+
Fixed: Reports Page Most downloaded Download not shown correctly ( [#1048](https://github.com/WPChill/download-monitor/issues/1048) )
|
128 |
+
|
129 |
= 4.6.1 - 26.09.2022 =
|
130 |
Fixed: User reports user fetching and displaying was broken ( [#1040](https://github.com/WPChill/download-monitor/issues/1040) ).
|
131 |
Fixed: Versions did not add the meta to the count ( [#1041](https://github.com/WPChill/download-monitor/issues/1041) ).
|
src/Admin/Reports/Page.php
CHANGED
@@ -253,7 +253,7 @@ class DLM_Reports_Page {
|
|
253 |
<div
|
254 |
class="wpchill-tooltip-content"><?php esc_html_e( 'The most downloaded file for the time period.', 'download-monitor' ); ?></div>
|
255 |
</div>
|
256 |
-
</label><span><?php esc_html_e( '
|
257 |
</li>
|
258 |
</ul>
|
259 |
</div>
|
253 |
<div
|
254 |
class="wpchill-tooltip-content"><?php esc_html_e( 'The most downloaded file for the time period.', 'download-monitor' ); ?></div>
|
255 |
</div>
|
256 |
+
</label><span><?php esc_html_e( 'No data', 'download-monitor' ); ?></span>
|
257 |
</li>
|
258 |
</ul>
|
259 |
</div>
|
src/FileManager.php
CHANGED
@@ -95,7 +95,25 @@ class DLM_File_Manager {
|
|
95 |
$file_path = realpath( $file_path );
|
96 |
}
|
97 |
|
98 |
-
} elseif ( strpos( $
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
|
100 |
/** This is a local file given by URL, so we need to figure out the path */
|
101 |
$remote_file = false;
|
95 |
$file_path = realpath( $file_path );
|
96 |
}
|
97 |
|
98 |
+
} elseif ( strpos( $wp_uploads_dir, '://' ) !== false ) {
|
99 |
+
|
100 |
+
/**
|
101 |
+
* This is a file located on a network drive.
|
102 |
+
* WordPress VIP is a providor that uses network drive paths
|
103 |
+
* Only allow if root (vip://) is predefined in Settings > Misc > Other downloads path
|
104 |
+
* Example of path: vip://wp-content/upload...
|
105 |
+
**/
|
106 |
+
$remote_file = false;
|
107 |
+
$path = array_reduce( $allowed_paths, function ($carry, $path) use ($wp_uploads_dir, $wp_uploads_url, $file_path ) {
|
108 |
+
return strpos( $path, '://' ) !== false && strpos( $wp_uploads_dir, $path ) !== false
|
109 |
+
? trim( str_replace( $wp_uploads_url, $wp_uploads_dir, $file_path ) )
|
110 |
+
: $carry;
|
111 |
+
}, false);
|
112 |
+
|
113 |
+
// realpath() will return false on network drive paths, so just check if exists
|
114 |
+
$file_path = file_exists( $path ) ? $path : realpath( $file_path );
|
115 |
+
|
116 |
+
} elseif ( strpos( $file_path, $wp_uploads_url ) !== false ) {
|
117 |
|
118 |
/** This is a local file given by URL, so we need to figure out the path */
|
119 |
$remote_file = false;
|