diff --git a/assets/css/main.css b/assets/css/main.css
index bd032907a..6312b9178 100644
--- a/assets/css/main.css
+++ b/assets/css/main.css
@@ -1 +1 @@
-@charset "UTF-8";.backwpup-max-width{max-width:800px}@font-face{font-family:'backwpup';src:url('../fonts/backwpup.eot');src:url('../fonts/backwpup.eot?#iefix') format('embedded-opentype'), url('../fonts/backwpup.ttf') format('truetype'), url('../fonts/backwpup.woff') format('woff'), url('../fonts/backwpup.svg#backwpup') format('svg');font-weight:normal;font-style:normal;}.error{color:#f00}.warning{color:#ffba00}.success{color:#86cf6f}#wp-admin-bar-backwpup .ab-icon{font:normal 20px/1 'backwpup' !important}#wp-admin-bar-backwpup .ab-icon::before{content:"\e600";top:2px}@media screen and (max-width:48.875em){#wp-admin-bar-backwpup .ab-icon{font:normal 32px/1 'backwpup' !important;display:block;text-indent:0;speak:none;top:7px;width:50px;text-align:center;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}#wp-admin-bar-backwpup::before{top:0}}#adminmenu #toplevel_page_backwpup div.wp-menu-image:before{font:normal 20px/1 'backwpup' !important;content:"\e600"}#adminmenu #toplevel_page_backwpup a[href$="backwpuprestore"]::after{content:'New';font-size:0.55rem;color:#fff;padding:0.18rem 0.33rem;background:#97c24f;border-radius:0.23rem;line-height:1;position:relative;bottom:5px;left:1em}#backwpup-page hr{border:0;border-top:none;border-bottom:1px solid #eee}#backwpup-page .backwpup-floated-postbox{margin:25px 0 0;max-width:100%;overflow:hidden;padding:15px;position:relative}#backwpup-page .backwpup-floated-postbox h3 a{font-size:14px;text-decoration:none;font-weight:600}#backwpup-page .backwpup-cleared-postbox{clear:both;margin:25px 0 0;padding:10px}#backwpup-page .postbox ul{padding-left:10px}#backwpup-page .postbox table{caption-side:top;margin-bottom:25px}#backwpup-page .postbox table caption{color:#222;font-size:14px;font-weight:600;padding:8px 12px;margin:0;line-height:1.4;text-align:left}#backwpup-page .postbox .hndle{cursor:auto}#backwpup-page .postbox .backwpup-bullet-list{list-style:disc;padding-left:16px}#backwpup-page .postbox ol.backwpup-bullet-list{list-style:decimal}#backwpup-page .wizardbox{color:#fff;background:#1d94cf url('../images/hgbox.png') no-repeat right bottom;min-height:20em}#backwpup-page .wizardbox:hover{background-color:#0f79ae}#backwpup-page .wizardbox .wizardbox_name{color:#fff;margin-top:0}#backwpup-page .wizardbox .wizardbox_start{position:absolute;bottom:10px;left:10px}#backwpup-page .wizardbox select{max-width:100%;width:100%}#backwpup-page .button-bwp,#backwpup-page .button-primary-bwp{border-radius:0;-webkit-box-shadow:none;box-shadow:none}#backwpup-page .button-primary-bwp{border:none;background:#38b0eb;color:#fff;min-width:8em}#backwpup-page .button-primary-bwp:hover{background:#064565}#backwpup-page .backwpup-table-wrap{overflow-x:auto}#backwpup-page .backwpup-banner-img{display:block;height:auto;margin:26px auto;max-width:100%}#backwpup-page .backwpup-text-center{text-align:center}#backwpup-page ul.backwpup-text-center{padding-left:0}#backwpup-page .backwpup-message{background-color:#fff;border:none;border-left:4px solid #ccc;box-shadow:0px 1px 1px 0px rgba(0, 0, 0, 0.1);margin:5px 0 15px;padding:1px 12px;-webkit-box-shadow:0px 1px 1px 0px rgba(0, 0, 0, 0.1)}#backwpup-page .backwpup-message p{margin:0.5em 0;padding:2px}#backwpup-page .backwpup-info{border-left:4px solid #38b0eb;}#backwpup-page .backwpup-warning{border-left:4px solid #ffba00;}#backwpup-page .backwpup-full-width{max-width:100%}#backwpup-page .backwpup-full-width.action{margin-bottom:20px}#backwpup-page .notice ul{list-style-type:disc;margin-left:2em}@media screen and (min-width:45em){#backwpup-page .backwpup-floated-postbox{float:left;margin:25px 25px 25px 0;width:290px}#backwpup-page #backwpup-one-click-backup,#backwpup-page #wizard-jobimport,#backwpup-page #backwpup-thank-you,#backwpup-page #backwpup-stats{margin-right:0}#backwpup-page #backwpup-one-click-backup + .backwpup-floated-postbox,#backwpup-page #backwpup-thank-you,#backwpup-page #backwpup-stats{clear:left}}@media screen and (min-width:64em){#backwpup-page .backwpup-floated-postbox{width:362px}#backwpup-page .wizardbox{width:225px;min-height:225px}#backwpup-page .backwpup-max-width{max-width:800px}body[class*="_backwpupabout"] #backwpup-page .backwpup-welcome{max-width:none}}.progressbar{margin-top:20px;height:auto;background:#f6f6f6 url('../../assets/images/progressbarhg.jpg')}.progressbar #progresssteps{background-color:#007fb6}.progressbar .bwpu-progress{background-color:#1d94cf;color:#fff;padding:5px 0;text-align:center}#documentation_content p{font-size:14px;line-height:20px;color:#333}#documentation_content h3{padding:7px 0;font-size:22px}#documentation_content h4{padding:7px 0;font-size:18px}#documentation_content img.size-full{border:10px #f6f6f6 solid}#wpfooter #footer-left,#wpfooter #footer-right{overflow:hidden}#wpfooter #footer-left #footer-thankyou{clear:both;display:block;padding-top:0.5em}#wpfooter #footer-left .backwpup-get-pro{display:inline-block;line-height:25px}#wpfooter #footer-upgrade .backwpup-update-footer{display:block;line-height:25px}#wpfooter .inpsyde_logo{background:url('../images/inpsyde.png') no-repeat;display:inline-block;margin-right:15px;margin-top:5px;line-height:25px;height:25px;width:80px;text-indent:-9999em;text-decoration:none}
\ No newline at end of file
+@charset "UTF-8";.backwpup-max-width{max-width:800px}@font-face{font-family:'backwpup';src:url('../fonts/backwpup.eot');src:url('../fonts/backwpup.eot?#iefix') format('embedded-opentype'), url('../fonts/backwpup.ttf') format('truetype'), url('../fonts/backwpup.woff') format('woff'), url('../fonts/backwpup.svg#backwpup') format('svg');font-weight:normal;font-style:normal;}.error{color:#f00}.warning{color:#ffba00}.success{color:#86cf6f}.notice-inpsyde{border-left-color:#9dc55d}.notice-inpsyde .button--inpsyde{background-color:#9dc55d;color:#fff;border-color:#92be4a;box-shadow:0 1px 0 #92be4a}.notice-inpsyde .button--inpsyde:hover,.notice-inpsyde .button--inpsyde:focus{background-color:#92be4a;border-color:#85b03f;box-shadow:0 1px 0 #92be4a, 0 0 3px #9dc55d;color:#fff}#wp-admin-bar-backwpup .ab-icon{font:normal 20px/1 'backwpup' !important}#wp-admin-bar-backwpup .ab-icon::before{content:"\e600";top:2px}@media screen and (max-width:48.875em){#wp-admin-bar-backwpup .ab-icon{font:normal 32px/1 'backwpup' !important;display:block;text-indent:0;speak:none;top:7px;width:50px;text-align:center;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}#wp-admin-bar-backwpup::before{top:0}}#adminmenu #toplevel_page_backwpup div.wp-menu-image:before{font:normal 20px/1 'backwpup' !important;content:"\e600"}#adminmenu #toplevel_page_backwpup a[href$="backwpuprestore"]::after{content:'New';font-size:0.55rem;color:#fff;padding:0.18rem 0.33rem;background:#85b03f;border-radius:0.23rem;line-height:1;position:relative;bottom:5px;left:1em}#backwpup-page hr{border:0;border-top:none;border-bottom:1px solid #eee}#backwpup-page .backwpup-floated-postbox{margin:25px 0 0;max-width:100%;overflow:hidden;padding:15px;position:relative}#backwpup-page .backwpup-floated-postbox h3 a{font-size:14px;text-decoration:none;font-weight:600}#backwpup-page .backwpup-cleared-postbox{clear:both;margin:25px 0 0;padding:10px}#backwpup-page .postbox ul{padding-left:10px}#backwpup-page .postbox table{caption-side:top;margin-bottom:25px}#backwpup-page .postbox table caption{color:#222;font-size:14px;font-weight:600;padding:8px 12px;margin:0;line-height:1.4;text-align:left}#backwpup-page .postbox .hndle{cursor:auto}#backwpup-page .postbox .backwpup-bullet-list{list-style:disc;padding-left:16px}#backwpup-page .postbox ol.backwpup-bullet-list{list-style:decimal}#backwpup-page .wizardbox{color:#fff;background:#1d94cf url('../images/hgbox.png') no-repeat right bottom;min-height:20em}#backwpup-page .wizardbox:hover{background-color:#0f79ae}#backwpup-page .wizardbox .wizardbox_name{color:#fff;margin-top:0}#backwpup-page .wizardbox .wizardbox_start{position:absolute;bottom:10px;left:10px}#backwpup-page .wizardbox select{max-width:100%;width:100%}#backwpup-page .button-bwp,#backwpup-page .button-primary-bwp{border-radius:0;-webkit-box-shadow:none;box-shadow:none}#backwpup-page .button-primary-bwp{border:none;background:#38b0eb;color:#fff;min-width:8em}#backwpup-page .button-primary-bwp:hover{background:#064565}#backwpup-page .backwpup-table-wrap{overflow-x:auto}#backwpup-page .backwpup-banner-img{display:block;height:auto;margin:26px auto;max-width:100%}#backwpup-page .backwpup-text-center{text-align:center}#backwpup-page ul.backwpup-text-center{padding-left:0}#backwpup-page .backwpup-message{background-color:#fff;border:none;border-left:4px solid #ccc;box-shadow:0px 1px 1px 0px rgba(0, 0, 0, 0.1);margin:5px 0 15px;padding:1px 12px;-webkit-box-shadow:0px 1px 1px 0px rgba(0, 0, 0, 0.1)}#backwpup-page .backwpup-message p{margin:0.5em 0;padding:2px}#backwpup-page .backwpup-info{border-left:4px solid #38b0eb;}#backwpup-page .backwpup-warning{border-left:4px solid #ffba00;}#backwpup-page .backwpup-full-width{max-width:100%}#backwpup-page .backwpup-full-width.action{margin-bottom:20px}#backwpup-page .notice ul{list-style-type:disc;margin-left:2em}@media screen and (min-width:45em){#backwpup-page .backwpup-floated-postbox{float:left;margin:25px 25px 25px 0;width:290px}#backwpup-page #backwpup-one-click-backup,#backwpup-page #wizard-jobimport,#backwpup-page #backwpup-thank-you,#backwpup-page #backwpup-stats{margin-right:0}#backwpup-page #backwpup-one-click-backup + .backwpup-floated-postbox,#backwpup-page #backwpup-thank-you,#backwpup-page #backwpup-stats{clear:left}}@media screen and (min-width:64em){#backwpup-page .backwpup-floated-postbox{width:362px}#backwpup-page .wizardbox{width:225px;min-height:225px}#backwpup-page .backwpup-max-width{max-width:800px}body[class*="_backwpupabout"] #backwpup-page .backwpup-welcome{max-width:none}}.progressbar{margin-top:10px;height:auto;background:#f6f6f6 url('../../assets/images/progressbarhg.jpg')}.progressbar #progresssteps{background-color:#007fb6}.progressbar .bwpu-progress{background-color:#1d94cf;color:#fff;padding:5px 0;text-align:center}#documentation_content p{font-size:14px;line-height:20px;color:#333}#documentation_content h3{padding:7px 0;font-size:22px}#documentation_content h4{padding:7px 0;font-size:18px}#documentation_content img.size-full{border:10px #f6f6f6 solid}#wpfooter #footer-left,#wpfooter #footer-right{overflow:hidden}#wpfooter #footer-left #footer-thankyou{clear:both;display:block;padding-top:0.5em}#wpfooter #footer-left .backwpup-get-pro{display:inline-block;line-height:25px}#wpfooter #footer-upgrade .backwpup-update-footer{display:block;line-height:25px}#wpfooter .inpsyde_logo{display:block;margin-right:15px;margin-top:5px;line-height:25px;height:25px;width:80px;text-decoration:none}#wpfooter .inpsyde_logo svg{display:block}
\ No newline at end of file
diff --git a/assets/css/main.css.map b/assets/css/main.css.map
new file mode 100644
index 000000000..ead87393a
--- /dev/null
+++ b/assets/css/main.css.map
@@ -0,0 +1,7 @@
+{
+"version": 3,
+"mappings": "AAIA,mBAAoB,CAClB,SAAS,CAAE,KAAK,CCDlB,UASC,CARC,WAAW,CAAE,UAAU,CACvB,GAAG,CAAC,4BAA4B,CAChC,GAAG,CAAC,gNAG4D,CAChE,WAAW,CAAE,MAAM,CACnB,UAAU,CAAE,MAAM,CAGpB,MAAO,CACL,KAAK,CCRK,GAAI,CDWhB,QAAS,CACP,KAAK,CCbQ,OAAO,CDgBtB,QAAS,CACP,KAAK,CCfO,OAAO,CCJrB,eAAgB,CACd,iBAAiB,CDIL,OAAO,CCDnB,gCAAiB,CACf,gBAAgB,CDAN,OAAO,CCCjB,KAAK,CDLK,IAAI,CCMd,YAAY,CATK,OAAwB,CAUzC,UAAU,CAAQ,eAA2B,CAE7C,6EACQ,CACN,gBAAgB,CAdD,OAAwB,CAevC,YAAY,CAAM,OAA+B,CACjD,UAAU,CAAQ,+BAAiD,CACnE,KAAK,CDdG,IAAI,CEDhB,+BAAS,CACP,IAAI,CAAE,mCAAmC,CAEzC,uCAAU,CACR,OAAO,CAAE,OAAO,CAChB,GAAG,CAAE,GAAG,CAUd,uCAAwC,CAGpC,+BAAS,CACP,IAAI,CAAE,mCAAmC,CACzC,OAAO,CAAE,KAAK,CACd,WAAW,CAAE,CAAC,CACd,KAAK,CAAE,IAAI,CACX,GAAG,CAAE,GAAG,CACR,KAAK,CAAE,IAAI,CACX,UAAU,CAAE,MAAM,CAClB,sBAAsB,CAAE,WAAW,CACnC,uBAAuB,CAAE,SAAS,CAGpC,8BAAU,CACR,GAAG,CAAE,CAAC,EC/BV,2DAAiD,CAC/C,IAAI,CAAK,mCAAmC,CAC5C,OAAO,CAAE,OAAO,CAGlB,oEAA0D,CACxD,OAAO,CAAQ,KAAK,CACpB,SAAS,CAAM,MAAM,CACrB,KAAK,CHPK,IAAI,CGQd,OAAO,CAAQ,aAAa,CAC5B,UAAU,CAAK,OAAyB,CACxC,aAAa,CAAE,MAAM,CACrB,WAAW,CAAI,CAAC,CAChB,QAAQ,CAAO,QAAQ,CACvB,MAAM,CAAS,GAAG,CAClB,IAAI,CAAW,GAAG,CCdpB,iBAAG,CACD,MAAM,CAAS,CAAC,CAChB,UAAU,CAAK,IAAI,CACnB,aAAa,CAAE,cAAc,CAI/B,wCAA0B,CACxB,MAAM,CAAK,QAAQ,CACnB,SAAS,CAAE,IAAI,CACf,QAAQ,CAAG,MAAM,CACjB,OAAO,CAAI,IAAI,CACf,QAAQ,CAAG,QAAQ,CAEnB,6CAAK,CACH,SAAS,CAAQ,IAAI,CACrB,eAAe,CAAE,IAAI,CACrB,WAAW,CAAM,GAAG,CAIxB,wCAA0B,CACxB,KAAK,CAAI,IAAI,CACb,MAAM,CAAG,QAAQ,CACjB,OAAO,CAAE,IAAI,CAKb,0BAAG,CACD,YAAY,CAAE,IAAI,CAGpB,6BAAM,CACJ,YAAY,CAAG,GAAG,CAClB,aAAa,CAAE,IAAI,CAEnB,qCAAQ,CACN,KAAK,CAAQ,IAAI,CACjB,SAAS,CAAI,IAAI,CACjB,WAAW,CAAE,GAAG,CAChB,OAAO,CAAM,QAAQ,CACrB,MAAM,CAAO,CAAC,CACd,WAAW,CAAE,GAAG,CAChB,UAAU,CAAG,IAAI,CAIrB,8BAAO,CACL,MAAM,CAAE,IAAI,CAGd,6CAAsB,CACpB,UAAU,CAAI,IAAI,CAClB,YAAY,CAAE,IAAI,CAGpB,+CAAwB,CACtB,UAAU,CAAE,OAAO,CAKvB,yBAAW,CACT,KAAK,CAAO,IAAI,CAChB,UAAU,CAAE,yDAAyD,CACrE,UAAU,CAAE,IAAI,CAEhB,+BAAQ,CACN,gBAAgB,CAAE,OAAO,CAG3B,yCAAgB,CACd,KAAK,CAAO,IAAI,CAChB,UAAU,CAAE,CAAC,CAGf,0CAAiB,CACf,QAAQ,CAAE,QAAQ,CAClB,MAAM,CAAI,IAAI,CACd,IAAI,CAAM,IAAI,CAGhB,gCAAO,CACL,SAAS,CAAE,IAAI,CACf,KAAK,CAAM,IAAI,CAKnB,6DACoB,CAClB,aAAa,CAAO,CAAC,CACrB,kBAAkB,CAAE,IAAI,CACxB,UAAU,CAAU,IAAI,CAG1B,kCAAoB,CAClB,MAAM,CAAM,IAAI,CAChB,UAAU,CAAE,OAAO,CACnB,KAAK,CAAO,IAAI,CAChB,SAAS,CAAG,GAAG,CAEf,wCAAQ,CACN,UAAU,CAAE,OAAO,CAIvB,mCAAqB,CACnB,UAAU,CAAE,IAAI,CAGlB,mCAAqB,CACnB,OAAO,CAAI,KAAK,CAChB,MAAM,CAAK,IAAI,CACf,MAAM,CAAK,SAAS,CACpB,SAAS,CAAE,IAAI,CAGjB,oCAAsB,CACpB,UAAU,CAAE,MAAM,CAEpB,sCAAwB,CACtB,YAAY,CAAE,CAAC,CAKjB,gCAAkB,CAChB,gBAAgB,CAAI,IAAI,CACxB,MAAM,CAAc,IAAI,CACxB,WAAW,CAAS,cAAc,CAClC,UAAU,CAAU,+BAAkC,CACtD,MAAM,CAAc,UAAU,CAC9B,OAAO,CAAa,QAAQ,CAC5B,kBAAkB,CAAE,+BAAkC,CAEtD,kCAAE,CACA,MAAM,CAAG,OAAO,CAChB,OAAO,CAAE,GAAG,CAIhB,6BAAe,CACb,WAAW,CAAE,iBAAiB,CAGhC,gCAAkB,CAChB,WAAW,CAAE,iBAAiB,CAGhC,mCAAqB,CACnB,SAAS,CAAE,IAAI,CAEf,0CAAS,CACP,aAAa,CAAE,IAAI,CAMrB,yBAAG,CACD,eAAe,CAAE,IAAI,CACrB,WAAW,CAAM,GAAG,CAU1B,mCAAoC,CAIhC,wCAA0B,CACxB,KAAK,CAAG,IAAI,CACZ,MAAM,CAAE,gBAAgB,CACxB,KAAK,CAAG,KAAK,CAIf,4IAGgB,CACd,YAAY,CAAE,CAAC,CAGjB,qIAEgB,CACd,KAAK,CAAE,IAAI,EAOjB,mCAAoC,CAIhC,wCAA0B,CACxB,KAAK,CAAE,KAAK,CAId,yBAAW,CACT,KAAK,CAAO,KAAK,CACjB,UAAU,CAAE,KAAK,CAGnB,kCAAoB,CAClB,SAAS,CAAE,KAAK,CAGlB,8DAAkD,CAChD,SAAS,CAAE,IAAI,EC9NrB,YAAa,CACX,UAAU,CAAE,IAAI,CAChB,MAAM,CAAE,IAAI,CACZ,UAAU,CAAE,oDAAoD,CAEhE,2BAAe,CACb,gBAAgB,CAAE,OAAO,CAG3B,2BAAe,CACb,gBAAgB,CAAE,OAAO,CACzB,KAAK,CAAE,IAAI,CACX,OAAO,CAAE,KAAK,CACd,UAAU,CAAE,MAAM,CCbpB,wBAAE,CACA,SAAS,CAAI,IAAI,CACjB,WAAW,CAAE,IAAI,CACjB,KAAK,CAAQ,IAAI,CAEnB,yBAAG,CACD,OAAO,CAAI,KAAK,CAChB,SAAS,CAAE,IAAI,CAEjB,yBAAG,CACD,OAAO,CAAI,KAAK,CAChB,SAAS,CAAE,IAAI,CAEjB,oCAAc,CACZ,MAAM,CAAE,kBAAkB,CCb5B,8CACc,CACZ,QAAQ,CAAE,MAAM,CAIhB,uCAAiB,CACf,KAAK,CAAQ,IAAI,CACjB,OAAO,CAAM,KAAK,CAClB,WAAW,CAAE,IAAI,CAGnB,wCAAkB,CAChB,OAAO,CAAM,YAAY,CACzB,WAAW,CAAE,IAAI,CAKnB,iDAAwB,CACtB,OAAO,CAAM,KAAK,CAClB,WAAW,CAAE,IAAI,CAIrB,uBAAc,CACZ,OAAO,CAAU,KAAK,CACtB,YAAY,CAAK,IAAI,CACrB,UAAU,CAAO,GAAG,CACpB,WAAW,CAAM,IAAI,CACrB,MAAM,CAAW,IAAI,CACrB,KAAK,CAAY,IAAI,CACrB,eAAe,CAAE,IAAI,CAErB,2BAAI,CACF,OAAO,CAAE,KAAK",
+"sources": ["../../resources/scss/utils/_classes.scss","../../resources/scss/core/_typography.scss","../../resources/scss/settings/_colors.scss","../../resources/scss/components/_notice.scss","../../resources/scss/components/_admin-bar.scss","../../resources/scss/components/_admin-menu.scss","../../resources/scss/components/_backwpup-page.scss","../../resources/scss/components/_progress-bar.scss","../../resources/scss/components/_documentation.scss","../../resources/scss/components/_footer.scss"],
+"names": [],
+"file": "main.css"
+}
\ No newline at end of file
diff --git a/assets/css/main.min.css b/assets/css/main.min.css
index 440e55aec..a7bdc32a0 100644
--- a/assets/css/main.min.css
+++ b/assets/css/main.min.css
@@ -1 +1 @@
-@charset "UTF-8";.backwpup-max-width{max-width:800px}@font-face{font-family:'backwpup';src:url('../fonts/backwpup.eot');src:url('../fonts/backwpup.eot?#iefix') format('embedded-opentype'), url('../fonts/backwpup.ttf') format('truetype'), url('../fonts/backwpup.woff') format('woff'), url('../fonts/backwpup.svg#backwpup') format('svg');font-weight:normal;font-style:normal}.error{color:#f00}.warning{color:#ffba00}.success{color:#86cf6f}#wp-admin-bar-backwpup .ab-icon{font:normal 20px/1 'backwpup' !important}#wp-admin-bar-backwpup .ab-icon::before{content:"\e600";top:2px}@media screen and (max-width:48.875em){#wp-admin-bar-backwpup .ab-icon{font:normal 32px/1 'backwpup' !important;display:block;text-indent:0;speak:none;top:7px;width:50px;text-align:center;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}#wp-admin-bar-backwpup::before{top:0}}#adminmenu #toplevel_page_backwpup div.wp-menu-image:before{font:normal 20px/1 'backwpup' !important;content:"\e600"}#adminmenu #toplevel_page_backwpup a[href$="backwpuprestore"]::after{content:'New';font-size:0.55rem;color:#fff;padding:0.18rem 0.33rem;background:#97c24f;border-radius:0.23rem;line-height:1;position:relative;bottom:5px;left:1em}#backwpup-page hr{border:0;border-top:none;border-bottom:1px solid #eee}#backwpup-page .backwpup-floated-postbox{margin:25px 0 0;max-width:100%;overflow:hidden;padding:15px;position:relative}#backwpup-page .backwpup-floated-postbox h3 a{font-size:14px;text-decoration:none;font-weight:600}#backwpup-page .backwpup-cleared-postbox{clear:both;margin:25px 0 0;padding:10px}#backwpup-page .postbox ul{padding-left:10px}#backwpup-page .postbox table{caption-side:top;margin-bottom:25px}#backwpup-page .postbox table caption{color:#222;font-size:14px;font-weight:600;padding:8px 12px;margin:0;line-height:1.4;text-align:left}#backwpup-page .postbox .hndle{cursor:auto}#backwpup-page .postbox .backwpup-bullet-list{list-style:disc;padding-left:16px}#backwpup-page .postbox ol.backwpup-bullet-list{list-style:decimal}#backwpup-page .wizardbox{color:#fff;background:#1d94cf url('../images/hgbox.png') no-repeat right bottom;min-height:20em}#backwpup-page .wizardbox:hover{background-color:#0f79ae}#backwpup-page .wizardbox .wizardbox_name{color:#fff;margin-top:0}#backwpup-page .wizardbox .wizardbox_start{position:absolute;bottom:10px;left:10px}#backwpup-page .wizardbox select{max-width:100%;width:100%}#backwpup-page .button-bwp,#backwpup-page .button-primary-bwp{border-radius:0;-webkit-box-shadow:none;box-shadow:none}#backwpup-page .button-primary-bwp{border:none;background:#38b0eb;color:#fff;min-width:8em}#backwpup-page .button-primary-bwp:hover{background:#064565}#backwpup-page .backwpup-table-wrap{overflow-x:auto}#backwpup-page .backwpup-banner-img{display:block;height:auto;margin:26px auto;max-width:100%}#backwpup-page .backwpup-text-center{text-align:center}#backwpup-page ul.backwpup-text-center{padding-left:0}#backwpup-page .backwpup-message{background-color:#fff;border:none;border-left:4px solid #ccc;box-shadow:0px 1px 1px 0px rgba(0, 0, 0, 0.1);margin:5px 0 15px;padding:1px 12px;-webkit-box-shadow:0px 1px 1px 0px rgba(0, 0, 0, 0.1)}#backwpup-page .backwpup-message p{margin:0.5em 0;padding:2px}#backwpup-page .backwpup-info{border-left:4px solid #38b0eb}#backwpup-page .backwpup-warning{border-left:4px solid #ffba00}#backwpup-page .backwpup-full-width{max-width:100%}#backwpup-page .backwpup-full-width.action{margin-bottom:20px}#backwpup-page .notice ul{list-style-type:disc;margin-left:2em}@media screen and (min-width:45em){#backwpup-page .backwpup-floated-postbox{float:left;margin:25px 25px 25px 0;width:290px}#backwpup-page #backwpup-one-click-backup,#backwpup-page #wizard-jobimport,#backwpup-page #backwpup-thank-you,#backwpup-page #backwpup-stats{margin-right:0}#backwpup-page #backwpup-one-click-backup + .backwpup-floated-postbox,#backwpup-page #backwpup-thank-you,#backwpup-page #backwpup-stats{clear:left}}@media screen and (min-width:64em){#backwpup-page .backwpup-floated-postbox{width:362px}#backwpup-page .wizardbox{width:225px;min-height:225px}#backwpup-page .backwpup-max-width{max-width:800px}body[class*="_backwpupabout"] #backwpup-page .backwpup-welcome{max-width:none}}.progressbar{margin-top:20px;height:auto;background:#f6f6f6 url('../../assets/images/progressbarhg.jpg')}.progressbar #progresssteps{background-color:#007fb6}.progressbar .bwpu-progress{background-color:#1d94cf;color:#fff;padding:5px 0;text-align:center}#documentation_content p{font-size:14px;line-height:20px;color:#333}#documentation_content h3{padding:7px 0;font-size:22px}#documentation_content h4{padding:7px 0;font-size:18px}#documentation_content img.size-full{border:10px #f6f6f6 solid}#wpfooter #footer-left,#wpfooter #footer-right{overflow:hidden}#wpfooter #footer-left #footer-thankyou{clear:both;display:block;padding-top:0.5em}#wpfooter #footer-left .backwpup-get-pro{display:inline-block;line-height:25px}#wpfooter #footer-upgrade .backwpup-update-footer{display:block;line-height:25px}#wpfooter .inpsyde_logo{background:url('../images/inpsyde.png') no-repeat;display:inline-block;margin-right:15px;margin-top:5px;line-height:25px;height:25px;width:80px;text-indent:-9999em;text-decoration:none}
\ No newline at end of file
+@charset "UTF-8";.backwpup-max-width{max-width:800px}@font-face{font-family:'backwpup';src:url('../fonts/backwpup.eot');src:url('../fonts/backwpup.eot?#iefix') format('embedded-opentype'), url('../fonts/backwpup.ttf') format('truetype'), url('../fonts/backwpup.woff') format('woff'), url('../fonts/backwpup.svg#backwpup') format('svg');font-weight:normal;font-style:normal}.error{color:#f00}.warning{color:#ffba00}.success{color:#86cf6f}.notice-inpsyde{border-left-color:#9dc55d}.notice-inpsyde .button--inpsyde{background-color:#9dc55d;color:#fff;border-color:#92be4a;box-shadow:0 1px 0 #92be4a}.notice-inpsyde .button--inpsyde:hover,.notice-inpsyde .button--inpsyde:focus{background-color:#92be4a;border-color:#85b03f;box-shadow:0 1px 0 #92be4a, 0 0 3px #9dc55d;color:#fff}#wp-admin-bar-backwpup .ab-icon{font:normal 20px/1 'backwpup' !important}#wp-admin-bar-backwpup .ab-icon::before{content:"\e600";top:2px}@media screen and (max-width:48.875em){#wp-admin-bar-backwpup .ab-icon{font:normal 32px/1 'backwpup' !important;display:block;text-indent:0;speak:none;top:7px;width:50px;text-align:center;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}#wp-admin-bar-backwpup::before{top:0}}#adminmenu #toplevel_page_backwpup div.wp-menu-image:before{font:normal 20px/1 'backwpup' !important;content:"\e600"}#adminmenu #toplevel_page_backwpup a[href$="backwpuprestore"]::after{content:'New';font-size:0.55rem;color:#fff;padding:0.18rem 0.33rem;background:#85b03f;border-radius:0.23rem;line-height:1;position:relative;bottom:5px;left:1em}#backwpup-page hr{border:0;border-top:none;border-bottom:1px solid #eee}#backwpup-page .backwpup-floated-postbox{margin:25px 0 0;max-width:100%;overflow:hidden;padding:15px;position:relative}#backwpup-page .backwpup-floated-postbox h3 a{font-size:14px;text-decoration:none;font-weight:600}#backwpup-page .backwpup-cleared-postbox{clear:both;margin:25px 0 0;padding:10px}#backwpup-page .postbox ul{padding-left:10px}#backwpup-page .postbox table{caption-side:top;margin-bottom:25px}#backwpup-page .postbox table caption{color:#222;font-size:14px;font-weight:600;padding:8px 12px;margin:0;line-height:1.4;text-align:left}#backwpup-page .postbox .hndle{cursor:auto}#backwpup-page .postbox .backwpup-bullet-list{list-style:disc;padding-left:16px}#backwpup-page .postbox ol.backwpup-bullet-list{list-style:decimal}#backwpup-page .wizardbox{color:#fff;background:#1d94cf url('../images/hgbox.png') no-repeat right bottom;min-height:20em}#backwpup-page .wizardbox:hover{background-color:#0f79ae}#backwpup-page .wizardbox .wizardbox_name{color:#fff;margin-top:0}#backwpup-page .wizardbox .wizardbox_start{position:absolute;bottom:10px;left:10px}#backwpup-page .wizardbox select{max-width:100%;width:100%}#backwpup-page .button-bwp,#backwpup-page .button-primary-bwp{border-radius:0;-webkit-box-shadow:none;box-shadow:none}#backwpup-page .button-primary-bwp{border:none;background:#38b0eb;color:#fff;min-width:8em}#backwpup-page .button-primary-bwp:hover{background:#064565}#backwpup-page .backwpup-table-wrap{overflow-x:auto}#backwpup-page .backwpup-banner-img{display:block;height:auto;margin:26px auto;max-width:100%}#backwpup-page .backwpup-text-center{text-align:center}#backwpup-page ul.backwpup-text-center{padding-left:0}#backwpup-page .backwpup-message{background-color:#fff;border:none;border-left:4px solid #ccc;box-shadow:0px 1px 1px 0px rgba(0, 0, 0, 0.1);margin:5px 0 15px;padding:1px 12px;-webkit-box-shadow:0px 1px 1px 0px rgba(0, 0, 0, 0.1)}#backwpup-page .backwpup-message p{margin:0.5em 0;padding:2px}#backwpup-page .backwpup-info{border-left:4px solid #38b0eb}#backwpup-page .backwpup-warning{border-left:4px solid #ffba00}#backwpup-page .backwpup-full-width{max-width:100%}#backwpup-page .backwpup-full-width.action{margin-bottom:20px}#backwpup-page .notice ul{list-style-type:disc;margin-left:2em}@media screen and (min-width:45em){#backwpup-page .backwpup-floated-postbox{float:left;margin:25px 25px 25px 0;width:290px}#backwpup-page #backwpup-one-click-backup,#backwpup-page #wizard-jobimport,#backwpup-page #backwpup-thank-you,#backwpup-page #backwpup-stats{margin-right:0}#backwpup-page #backwpup-one-click-backup + .backwpup-floated-postbox,#backwpup-page #backwpup-thank-you,#backwpup-page #backwpup-stats{clear:left}}@media screen and (min-width:64em){#backwpup-page .backwpup-floated-postbox{width:362px}#backwpup-page .wizardbox{width:225px;min-height:225px}#backwpup-page .backwpup-max-width{max-width:800px}body[class*="_backwpupabout"] #backwpup-page .backwpup-welcome{max-width:none}}.progressbar{margin-top:10px;height:auto;background:#f6f6f6 url('../../assets/images/progressbarhg.jpg')}.progressbar #progresssteps{background-color:#007fb6}.progressbar .bwpu-progress{background-color:#1d94cf;color:#fff;padding:5px 0;text-align:center}#documentation_content p{font-size:14px;line-height:20px;color:#333}#documentation_content h3{padding:7px 0;font-size:22px}#documentation_content h4{padding:7px 0;font-size:18px}#documentation_content img.size-full{border:10px #f6f6f6 solid}#wpfooter #footer-left,#wpfooter #footer-right{overflow:hidden}#wpfooter #footer-left #footer-thankyou{clear:both;display:block;padding-top:0.5em}#wpfooter #footer-left .backwpup-get-pro{display:inline-block;line-height:25px}#wpfooter #footer-upgrade .backwpup-update-footer{display:block;line-height:25px}#wpfooter .inpsyde_logo{display:block;margin-right:15px;margin-top:5px;line-height:25px;height:25px;width:80px;text-decoration:none}#wpfooter .inpsyde_logo svg{display:block}
\ No newline at end of file
diff --git a/assets/css/pro.css.map b/assets/css/pro.css.map
new file mode 100644
index 000000000..01cd16b28
--- /dev/null
+++ b/assets/css/pro.css.map
@@ -0,0 +1,7 @@
+{
+"version": 3,
+"mappings": "AAME,6BAAK,CACH,OAAO,CAAE,KAAK,CACd,OAAO,CAAE,GAAG,CAIZ,0CAAM,CACJ,OAAO,CAAQ,KAAK,CACpB,WAAW,CAAI,IAAI,CACnB,aAAa,CAAE,GAAG,CAGpB,gEAA4B,CAC1B,OAAO,CAAK,KAAK,CACjB,UAAU,CAAE,SAAS,CAGvB,wDAAoB,CAClB,UAAU,CAAE,GAAG,CAGjB,gFAA8C,CAC5C,UAAU,CAAE,GAAG,CAGjB,2DAAuB,CACrB,WAAW,CAAE,KAAK,CAGpB,6DAAyB,CACvB,MAAM,CAAE,OAAO,CAOjB,sHACW,CACT,OAAO,CAAE,KAAK,CACd,KAAK,CAAI,IAAI,CAGf,+DAAa,CACX,OAAO,CAAQ,KAAK,CACpB,aAAa,CAAE,GAAG,CAClB,OAAO,CAAQ,GAAG,CAMtB,mCAAM,CACJ,OAAO,CAAQ,KAAK,CACpB,WAAW,CAAI,IAAI,CACnB,aAAa,CAAE,GAAG,CAGpB,wDAA2B,CACzB,KAAK,CAAM,IAAI,CACf,SAAS,CAAE,IAAI,CAInB,mBAAoB,CAClB,WAAW,CAAG,CAAC,CACf,YAAY,CAAE,CAAC,CCpEjB,2BACoB,CAClB,SAAS,CAAE,KAAK,CAChB,KAAK,CAAM,IAAI,CAGjB,kBAAmB,CACjB,QAAQ,CAAE,MAAM,CAEhB,qBAAG,CACD,UAAU,CAAE,IAAI,CAChB,MAAM,CAAM,CAAC,CAEb,wBAAG,CACD,OAAO,CAAG,YAAY,CACtB,KAAK,CAAK,IAAI,CACd,OAAO,CAAG,UAAU,CACpB,QAAQ,CAAE,QAAQ,CAGpB,+BAAU,CACR,OAAO,CAAM,OAAO,CACpB,OAAO,CAAM,YAAY,CACzB,SAAS,CAAI,IAAI,CACjB,WAAW,CAAE,IAAI,CACjB,MAAM,CAAO,UAAU,CACvB,QAAQ,CAAK,QAAQ,CACrB,GAAG,CAAU,CAAC,CAGhB,0CAAqB,CACnB,OAAO,CAAE,EAAE,CACX,OAAO,CAAE,IAAI,CAGf,8BAAS,CACP,WAAW,CAAE,IAAI,CAGnB,0BAAK,CACH,eAAe,CAAE,IAAI,CAK3B,gBAAiB,CACf,KAAK,CAAM,IAAI,CACf,SAAS,CAAE,KAAK,CAEhB,mBAAG,CACD,UAAU,CAAE,CAAC,CAOb,iDAAa,CACX,SAAS,CAAE,KAAK,CAGlB,uCAAG,CACD,aAAa,CAAE,eAAe,CAC9B,UAAU,CAAK,IAAI,CAGrB,uCAAG,CACD,aAAa,CAAE,eAAe,CAGhC,uCAAG,CACD,WAAW,CAAE,IAAI,CAIrB,yBAAI,CACF,MAAM,CAAI,KAAK,CACf,QAAQ,CAAE,MAAM,CAIpB,kBAAmB,CACjB,KAAK,CAAK,IAAI,CACd,QAAQ,CAAE,QAAQ,CAClB,GAAG,CAAO,IAAI,CCnFd,kBAAM,CACJ,OAAO,CAAQ,KAAK,CACpB,WAAW,CAAI,IAAI,CACnB,aAAa,CAAE,GAAG,CAGpB,0BAAc,CACZ,MAAM,CAAM,CAAC,CACb,UAAU,CAAE,GAAG,CCTnB,iBAAkB,CAChB,KAAK,CAAE,WAAW,CAGpB,eAAgB,CACd,KAAK,CAAE,GAAG,CCNZ,eAAgB,CACd,UAAU,CAAK,OAAO,CACtB,MAAM,CAAS,eAAe,CAC9B,KAAK,CAAU,IAAI,CACnB,OAAO,CAAQ,MAAM,CACrB,UAAU,CAAK,MAAM,CACrB,KAAK,CAAU,IAAI,CAEnB,iCAAkB,CAChB,WAAW,CAAM,MAAM,CACvB,OAAO,CAAU,IAAI,CACrB,eAAe,CAAE,MAAM,CAGzB,0BAAW,CACT,SAAS,CAAI,IAAI,CACjB,WAAW,CAAE,OAAO,CAEtB,0BAAW,CACT,SAAS,CAAI,QAAQ,CACrB,WAAW,CAAE,OAAO,CAIxB,iBAAkB,CAChB,MAAM,CAAE,6BAAkC,CCvB1C,mCAAQ,CACN,UAAU,CAAE,MAAM,CAClB,MAAM,CAAM,CAAC,CACb,KAAK,CAAO,IAAI,CAGlB,6CAAkB,CAChB,MAAM,CAAE,MAAM,CAGhB,wCAAa,CACX,OAAO,CAAE,IAAI,CCTjB,aAAc,CACZ,OAAO,CAAE,cAAc,CAEvB,oBAAO,CACL,aAAa,CAAG,GAAG,CACnB,UAAU,CAAM,CAAC,CACjB,OAAO,CAAS,CAAC,CACjB,cAAc,CAAE,GAAG",
+"sources": ["../../resources/scss/components/_settings-encryption.scss","../../resources/scss/components/_pro-wizard.scss","../../resources/scss/components/_decrypter.scss","../../resources/scss/restore/_commons.scss","../../resources/scss/restore/_drag-drop-area.scss","../../resources/scss/restore/_progress-bar.scss","../../resources/scss/restore/_restore.scss"],
+"names": [],
+"file": "pro.css"
+}
\ No newline at end of file
diff --git a/assets/images/backwpupbanner.png b/assets/images/backwpupbanner.png
deleted file mode 100644
index b80ca2a4c..000000000
Binary files a/assets/images/backwpupbanner.png and /dev/null differ
diff --git a/assets/images/inpsyde.png b/assets/images/inpsyde.png
deleted file mode 100644
index 981fbb49f..000000000
Binary files a/assets/images/inpsyde.png and /dev/null differ
diff --git a/assets/images/inpsyde.svg b/assets/images/inpsyde.svg
new file mode 100644
index 000000000..e69b8a90a
--- /dev/null
+++ b/assets/images/inpsyde.svg
@@ -0,0 +1 @@
+
diff --git a/assets/js/backup-downloader.js b/assets/js/backup-downloader.js
new file mode 100644
index 000000000..c12d0be18
--- /dev/null
+++ b/assets/js/backup-downloader.js
@@ -0,0 +1,393 @@
+window.BWU = window.BWU || {};
+
+( function ( $, _, BWU, ajaxurl, tbRemove )
+{
+ var downloader;
+ var decrypter;
+ var Downloader;
+
+ BWU.Restore = BWU.Restore || {};
+ BWU.Restore.Functions = BWU.Restore.Functions || {
+
+ /**
+ * Remove previously printed messages
+ */
+ removeMessages: function ()
+ {
+ $( document.body )
+ .find( '#bwu_response' )
+ .remove();
+ },
+
+ /**
+ * Print Error Messages
+ *
+ * @param {string} message The message to print.
+ *
+ * @return {void}
+ */
+ printMessageError: function ( message, container )
+ {
+
+ var $container = $( container );
+
+ if ( !message ) {
+ return;
+ }
+
+ this.removeMessages();
+
+ $container
+ .append( '
' + message + '
' );
+ },
+
+ /**
+ * Print Success Messages
+ *
+ * @param {string} message The message to print.
+ *
+ * @return {void}
+ */
+ printMessageSuccess: function ( message, container )
+ {
+ var $container = $( container );
+
+ if ( !message ) {
+ return;
+ }
+
+ this.removeMessages();
+
+ $container
+ .append( '' + message + '
' );
+ },
+
+ /**
+ * Load Site
+ *
+ * @param {number} id The step to point to.
+ * @param {string} nonce The value for the nonce.
+ */
+ loadNextStep: function ( id, nonce )
+ {
+ var search = 'step=' + id;
+ location.replace(
+ location.origin + location.pathname + '?' + search + '&page=backwpuprestore&backwpup_action_nonce=' + nonce );
+ },
+
+ /**
+ * Calculate Percentage
+ *
+ * @param {number} index The current index of the file extracted.
+ * @param {number} total The total count of files to extract.
+ *
+ * @returns {number} The percentage value
+ */
+ calculatePercentage: function ( index, total )
+ {
+ var value = index / total;
+
+ return Math.round( value * 100 );
+ },
+
+ /**
+ * Create a constant property
+ * @param value
+ * @returns {{value: *, writable: boolean, configurable: boolean, enumerable: boolean}}
+ */
+ makeConstant: function ( value )
+ {
+ return {
+ value: value,
+ writable: false,
+ configurable: false,
+ enumerable: false
+ };
+ }
+ };
+ BWU.States = BWU.States || Object.create( {}, {
+
+ DONE: BWU.Restore.Functions.makeConstant( 'done' ),
+
+ DOWNLOADING: BWU.Restore.Functions.makeConstant( 'downloading' ),
+
+ NEED_DECRYPTION_KEY: BWU.Restore.Functions.makeConstant( 'need_decryption_key' )
+ } );
+
+ if ( !ajaxurl ) {
+ // eslint-disable-line
+ console.warn( 'Missing ajaxurl value.' );
+
+ return;
+ }
+ if ( !( 'EventSource' in window ) ) {
+ // eslint-disable-line
+ console.warn( 'Event Source does not exist in this browser' );
+
+ return;
+ }
+
+ function destruct ()
+ {
+ this.closeEventSource();
+ this.cleanUi();
+ this.decrypter && this.decrypter.destruct();
+ }
+
+ function hideElement ( el )
+ {
+ if ( !el ) {
+ return;
+ }
+
+ el.style.display = 'none';
+ }
+
+ function showElement ( el )
+ {
+ if ( !el ) {
+ return;
+ }
+
+ el.style.display = 'block';
+ }
+
+ Downloader = {
+
+ showWaitingMessage: function ()
+ {
+ showElement( this.waitingUi );
+ },
+
+ showProgressUi: function ()
+ {
+ showElement( this.progressUi );
+ },
+
+ showSuccessMsg: function ()
+ {
+ showElement( this.successUi );
+ },
+
+ hideWaitingMessage: function ()
+ {
+ hideElement( this.waitingUi );
+ },
+
+ hideProgressUi: function ()
+ {
+ hideElement( this.progressUi );
+ },
+
+ hideNotice: function ()
+ {
+ BWU.Restore.Functions.removeMessages( this.containerUi );
+ },
+
+ hideSuccessMsg: function ()
+ {
+ hideElement( this.successUi );
+ },
+
+ cleanUi: function ()
+ {
+ this.hideWaitingMessage();
+ this.hideProgressUi();
+ this.hideNotice();
+ this.hideSuccessMsg();
+ this.decrypter && this.decrypter.hide();
+ },
+
+ done: function ()
+ {
+ this.showSuccessMsg();
+ window.location.href = this.currentTarget.dataset.url;
+
+ setTimeout( tbRemove, 3000 );
+ },
+
+ onMessage: function ( message )
+ {
+ var data;
+
+ try {
+ data = JSON.parse( message.data );
+
+ switch ( data.state ) {
+ case BWU.States.DOWNLOADING:
+ this.cleanUi();
+ this.showProgressUi();
+
+ $( '#progresssteps' )
+ .css( {
+ width: data.download_percent + '%'
+ } )
+ .text( data.download_percent + '%' );
+ break;
+
+ case BWU.States.DONE:
+ this.done( data.message );
+ break;
+ }
+ } catch ( exc ) {
+ BWU.Restore.Functions.printMessageError(
+ exc.message,
+ this.containerUi
+ );
+ destruct.call( this );
+ }
+ },
+
+ onError: function ( message )
+ {
+ var data = JSON.parse( message.data );
+
+ this.closeEventSource();
+
+ switch ( data.message ) {
+ case BWU.States.NEED_DECRYPTION_KEY:
+ this.cleanUi();
+ this.decrypter && this.decrypter.needDecryption( data.status );
+ break;
+ default:
+ BWU.Restore.Functions.printMessageError( data.message, this.containerUi );
+ destruct.call( this );
+ break;
+ }
+
+ return this;
+ },
+
+ initializeEventSource: function ()
+ {
+ if ( !_.isUndefined( this.eventSource ) ) {
+ return;
+ }
+
+ this.eventSource = new EventSource(
+ ajaxurl
+ + '?action=download_backup_file&destination=' + this.currentTarget.dataset.destination
+ + '&jobid=' + this.currentTarget.dataset.jobid
+ + '&file=' + this.currentTarget.dataset.file
+ + '&local_file=' + this.currentTarget.dataset.localFile
+ + '&backwpup_action_nonce=' + this.currentTarget.dataset.nonce
+ );
+
+ this.eventSource.onmessage = this.onMessage;
+ this.eventSource.addEventListener( 'log', this.onError );
+ },
+
+ closeEventSource: function ()
+ {
+ if ( _.isUndefined( this.eventSource ) ) {
+ return;
+ }
+
+ this.eventSource.close();
+ this.eventSource = undefined;
+ },
+
+ startDownload: function ( evt )
+ {
+ evt.preventDefault();
+
+ this.currentTarget = evt.target;
+
+ this.showWaitingMessage();
+ this.initializeEventSource();
+ },
+
+ decrypt: function ()
+ {
+ this.cleanUi();
+ this.decrypter && this.decrypter.decrypt( {
+ backwpup_action_nonce: this.currentTarget.dataset.nonce,
+ encrypted_file_path: this.currentTarget.dataset.localFile
+ } );
+ },
+
+ construct: function ( decrypter )
+ {
+
+ var containerUi = document.querySelector( '#tb_container' );
+ if ( !containerUi ) {
+ return false;
+ }
+
+ _.bindAll(
+ this,
+ 'showWaitingMessage',
+ 'hideWaitingMessage',
+ 'showProgressUi',
+ 'hideSuccessMsg',
+ 'showSuccessMsg',
+ 'done',
+ 'onMessage',
+ 'onError',
+ 'initializeEventSource',
+ 'closeEventSource',
+ 'startDownload',
+ 'addListeners',
+ 'decrypt',
+ 'hideNotice',
+ 'cleanUi',
+ 'init'
+ );
+
+ this.containerUi = containerUi;
+ this.waitingUi = this.containerUi.querySelector( '#download-file-waiting' );
+ this.progressUi = this.containerUi.querySelector( '.progressbar' );
+ this.successUi = this.containerUi.querySelector( '#download-file-success' );
+
+ this.currentTarget = undefined;
+ this.eventSource = undefined;
+ this.decrypter = decrypter;
+
+ return this;
+ },
+
+ addListeners: function ()
+ {
+ _.forEach( document.querySelectorAll( '.backup-download-link' ), function ( downloadLink )
+ {
+ downloadLink.addEventListener( 'click', this.startDownload );
+ }.bind( this ) );
+
+ $( '#submit_decrypt_key' ).on( 'click', this.decrypt );
+ $( 'body' ).on( 'thickbox:removed', function ()
+ {
+ destruct.call( this );
+ }.bind( this ) );
+
+ if ( this.decrypter ) {
+ $( 'body' ).on( this.decrypter.ACTION_DECRYPTION_SUCCESS, this.done );
+ } else {
+
+ }
+
+ return this;
+ },
+
+ init: function ()
+ {
+ this.addListeners();
+
+ return this;
+ }
+ };
+
+ downloader = Object.create( Downloader );
+
+ if ( !_.isUndefined( BWU.DecrypterFactory ) ) {
+ decrypter = BWU.DecrypterFactory(
+ ajaxurl,
+ document.querySelector( '#decrypt_key' ),
+ document.querySelector( '#decryption_key' )
+ );
+ }
+
+ if ( downloader.construct( decrypter ) ) {
+ downloader.init();
+ }
+
+}( window.jQuery, window._, window.BWU, window.ajaxurl, window.tb_remove ) );
diff --git a/assets/js/backup-downloader.min.js b/assets/js/backup-downloader.min.js
new file mode 100644
index 000000000..7a7db32cf
--- /dev/null
+++ b/assets/js/backup-downloader.min.js
@@ -0,0 +1,2 @@
+;window.BWU=window.BWU||{};(function(e,s,t,i,d){var n,a,u;t.Restore=t.Restore||{};t.Restore.Functions=t.Restore.Functions||{removeMessages:function(){e(document.body).find('#bwu_response').remove()},printMessageError:function(t,s){var i=e(s);if(!t){return};this.removeMessages();i.append(''+t+'
')},printMessageSuccess:function(t,s){var i=e(s);if(!t){return};this.removeMessages();i.append(''+t+'
')},loadNextStep:function(e,t){var s='step='+e;location.replace(location.origin+location.pathname+'?'+s+'&page=backwpuprestore&backwpup_action_nonce='+t)},calculatePercentage:function(e,t){var s=e/t;return Math.round(s*100)},makeConstant:function(e){return{value:e,writable:!1,configurable:!1,enumerable:!1}}};t.States=t.States||Object.create({},{DONE:t.Restore.Functions.makeConstant('done'),DOWNLOADING:t.Restore.Functions.makeConstant('downloading'),NEED_DECRYPTION_KEY:t.Restore.Functions.makeConstant('need_decryption_key')});if(!i){console.warn('Missing ajaxurl value.');return};if(!('EventSource' in window)){console.warn('Event Source does not exist in this browser');return};function r(){this.closeEventSource();this.cleanUi();this.decrypter&&this.decrypter.destruct()};function o(e){if(!e){return};e.style.display='none'};function c(e){if(!e){return};e.style.display='block'};u={showWaitingMessage:function(){c(this.waitingUi)},showProgressUi:function(){c(this.progressUi)},showSuccessMsg:function(){c(this.successUi)},hideWaitingMessage:function(){o(this.waitingUi)},hideProgressUi:function(){o(this.progressUi)},hideNotice:function(){t.Restore.Functions.removeMessages(this.containerUi)},hideSuccessMsg:function(){o(this.successUi)},cleanUi:function(){this.hideWaitingMessage();this.hideProgressUi();this.hideNotice();this.hideSuccessMsg();this.decrypter&&this.decrypter.hide()},done:function(){this.showSuccessMsg();window.location.href=this.currentTarget.dataset.url;setTimeout(d,3000)},onMessage:function(s){var i;try{i=JSON.parse(s.data);switch(i.state){case t.States.DOWNLOADING:this.cleanUi();this.showProgressUi();e('#progresssteps').css({width:i.download_percent+'%'}).text(i.download_percent+'%');break;case t.States.DONE:this.done(i.message);break}}catch(n){t.Restore.Functions.printMessageError(n.message,this.containerUi);r.call(this)}},onError:function(e){var s=JSON.parse(e.data);this.closeEventSource();switch(s.message){case t.States.NEED_DECRYPTION_KEY:this.cleanUi();this.decrypter&&this.decrypter.needDecryption(s.status);break;default:t.Restore.Functions.printMessageError(s.message,this.containerUi);r.call(this);break};return this},initializeEventSource:function(){if(!s.isUndefined(this.eventSource)){return};this.eventSource=new EventSource(i+'?action=download_backup_file&destination='+this.currentTarget.dataset.destination+'&jobid='+this.currentTarget.dataset.jobid+'&file='+this.currentTarget.dataset.file+'&local_file='+this.currentTarget.dataset.localFile+'&backwpup_action_nonce='+this.currentTarget.dataset.nonce);this.eventSource.onmessage=this.onMessage;this.eventSource.addEventListener('log',this.onError)},closeEventSource:function(){if(s.isUndefined(this.eventSource)){return};this.eventSource.close();this.eventSource=undefined},startDownload:function(e){e.preventDefault();this.currentTarget=e.target;this.showWaitingMessage();this.initializeEventSource()},decrypt:function(){this.cleanUi();this.decrypter&&this.decrypter.decrypt({backwpup_action_nonce:this.currentTarget.dataset.nonce,encrypted_file_path:this.currentTarget.dataset.localFile})},construct:function(e){var t=document.querySelector('#tb_container');if(!t){return!1};s.bindAll(this,'showWaitingMessage','hideWaitingMessage','showProgressUi','hideSuccessMsg','showSuccessMsg','done','onMessage','onError','initializeEventSource','closeEventSource','startDownload','addListeners','decrypt','hideNotice','cleanUi','init');this.containerUi=t;this.waitingUi=this.containerUi.querySelector('#download-file-waiting');this.progressUi=this.containerUi.querySelector('.progressbar');this.successUi=this.containerUi.querySelector('#download-file-success');this.currentTarget=undefined;this.eventSource=undefined;this.decrypter=e;return this},addListeners:function(){s.forEach(document.querySelectorAll('.backup-download-link'),function(e){e.addEventListener('click',this.startDownload)}.bind(this));e('#submit_decrypt_key').on('click',this.decrypt);e('body').on('thickbox:removed',function(){r.call(this)}.bind(this));if(this.decrypter){e('body').on(this.decrypter.ACTION_DECRYPTION_SUCCESS,this.done)}
+else{};return this},init:function(){this.addListeners();return this}};n=Object.create(u);if(!s.isUndefined(t.DecrypterFactory)){a=t.DecrypterFactory(i,document.querySelector('#decrypt_key'),document.querySelector('#decryption_key'))};if(n.construct(a)){n.init()}}(window.jQuery,window._,window.BWU,window.ajaxurl,window.tb_remove));
\ No newline at end of file
diff --git a/assets/js/notice.js b/assets/js/notice.js
new file mode 100644
index 000000000..e8fc1e8c1
--- /dev/null
+++ b/assets/js/notice.js
@@ -0,0 +1,53 @@
+( function ( _, $, adminpage ) {
+
+ var PromoterNotice = {
+
+ dismiss: function ( evt ) {
+ evt.preventDefault();
+ evt.stopImmediatePropagation();
+
+ $.post( $( evt.target ).attr( 'href' ), { isAjax: 1 } );
+ this.container.remove();
+ },
+
+ construct: function () {
+
+ var container;
+
+ _.bindAll(
+ this,
+ 'dismiss',
+ 'init',
+ 'addListeners'
+ );
+
+ container = document.querySelector( '#backwpup_notice_promoter_notice', {
+ useCapture: true
+ } );
+
+ if ( !container ) {
+ return false;
+ }
+
+ this.container = container;
+
+ return this;
+ },
+
+ addListeners: function () {
+ var dismisser = this.container.querySelector( '#backwpup_notice_promoter_dismiss' );
+ dismisser && dismisser.addEventListener( 'click', this.dismiss );
+ },
+
+ init: function () {
+ this.addListeners();
+
+ return this;
+ },
+ };
+
+ if ( adminpage === 'toplevel_page_backwpup' ) {
+ var promoterNotice = Object.create( PromoterNotice );
+ promoterNotice.construct() && promoterNotice.init();
+ }
+}( window._, window.jQuery, window.adminpage ) );
diff --git a/assets/js/notice.min.js b/assets/js/notice.min.js
new file mode 100644
index 000000000..b0eefda48
--- /dev/null
+++ b/assets/js/notice.min.js
@@ -0,0 +1 @@
+(function(t,i,n){var r={dismiss:function(t){t.preventDefault();t.stopImmediatePropagation();i.post(i(t.target).attr('href'),{isAjax:1});this.container.remove()},construct:function(){var i;t.bindAll(this,'dismiss','init','addListeners');i=document.querySelector('#backwpup_notice_promoter_notice',{useCapture:!0});if(!i){return!1};this.container=i;return this},addListeners:function(){var t=this.container.querySelector('#backwpup_notice_promoter_dismiss');t&&t.addEventListener('click',this.dismiss)},init:function(){this.addListeners();return this},};if(n==='toplevel_page_backwpup'){var e=Object.create(r);e.construct()&&e.init()}}(window._,window.jQuery,window.adminpage));
\ No newline at end of file
diff --git a/assets/js/page_backups.js b/assets/js/page_backups.js
deleted file mode 100644
index 045ce9851..000000000
--- a/assets/js/page_backups.js
+++ /dev/null
@@ -1,115 +0,0 @@
-( function ( $, ajaxurl, tbRemove ) {
-
- var link;
- var eventsource;
- var $waiting;
- var $generating;
- var $privateKey;
- var $done;
- var $privateKeyInput;
- var $privateKeyInvalid;
- var $privateKeySubmit;
-
- if ( !ajaxurl ) {
- console.warn( 'Missing ajaxurl value.' ); // eslint-disable-line
-
- return;
- }
- if ( !( 'EventSource' in window ) ) {
- console.warn( 'Event Source does not exist in this browser' ); // eslint-disable-line
-
- return;
- }
-
- window.addEventListener( 'load', function () {
- $waiting = $( '#download-file-waiting' );
- $generating = $( '#download-file-generating' );
- $privateKey = $( '#download-file-private-key' );
- $done = $( '#download-file-done' );
- $privateKeyInput = $( '#download-file-private-key-input' );
- $privateKeyInvalid = $( '#download-file-private-key-invalid' );
- $privateKeySubmit = $( '#download-file-private-key-button' );
-
- $( '.backup-download-link' ).click( function () {
- $waiting.show();
- $generating.hide();
- $privateKey.hide();
- $done.hide();
-
- link = this;
- eventsource = new EventSource(
- ajaxurl
- + '?action=download_file&destination=' + $( this ).data( 'destination' )
- + '&jobid=' + $( this ).data( 'jobid' )
- + '&file=' + $( this ).data( 'file' )
- + '&local_file=' + $( this ).data( 'localFile' )
- + '&_wpnonce=' + $( this ).data( 'nonce' )
- );
-
- eventsource.onmessage = function ( message ) {
- var data = JSON.parse( message.data );
-
- if ( 'downloading' === data.state ) {
- $waiting.hide();
- $generating.show();
- $privateKey.hide();
- $done.hide();
-
- // Progress bar
- $( '#progresssteps' )
- .css( {
- width: data.download_percent + '%'
- } )
- .text( data.download_percent + '%' );
- }
-
- if ( 'need-private-key' === data.state ) {
- $waiting.hide();
- $generating.hide();
- $privateKey.show();
- $done.hide();
- $privateKeyInput.focus();
-
- if ( 'invalid' === data.status ) {
- $privateKeyInvalid.show();
-
- return;
- }
-
- $privateKeyInvalid.hide();
- }
-
- if ( 'done' === data.state ) {
- $waiting.hide();
- $generating.hide();
- $privateKey.hide();
- $done.show();
-
- eventsource.close();
-
- window.location.href = $( link ).data( 'url' );
-
- setTimeout( tbRemove, 3000 );
- }
- };
-
- } );
-
- $privateKeySubmit.click( function () {
- var data = {
- action: 'send_private_key',
- privatekey: $privateKeyInput.val(),
- };
-
- $.post( ajaxurl, data, function ( response ) {
- if ( true === response.success ) {
- $privateKeyInput.val( '' );
- $privateKeyInvalid.hide();
- $privateKey.hide();
- $generating.show();
- }
- } );
- } );
- } );
-
-}( window.jQuery, window.ajaxurl, window.tb_remove ) );
diff --git a/assets/js/page_backups.min.js b/assets/js/page_backups.min.js
deleted file mode 100644
index 379a2cac4..000000000
--- a/assets/js/page_backups.min.js
+++ /dev/null
@@ -1 +0,0 @@
-(function(e,s,c){var w,l,n,i,o,d,t,a,r;if(!s){console.warn('Missing ajaxurl value.');return};if(!('EventSource' in window)){console.warn('Event Source does not exist in this browser');return};window.addEventListener('load',function(){n=e('#download-file-waiting');i=e('#download-file-generating');o=e('#download-file-private-key');d=e('#download-file-done');t=e('#download-file-private-key-input');a=e('#download-file-private-key-invalid');r=e('#download-file-private-key-button');e('.backup-download-link').click(function(){n.show();i.hide();o.hide();d.hide();w=this;l=new EventSource(s+'?action=download_file&destination='+e(this).data('destination')+'&jobid='+e(this).data('jobid')+'&file='+e(this).data('file')+'&local_file='+e(this).data('localFile')+'&_wpnonce='+e(this).data('nonce'));l.onmessage=function(r){var s=JSON.parse(r.data);if('downloading'===s.state){n.hide();i.show();o.hide();d.hide();e('#progresssteps').css({width:s.download_percent+'%'}).text(s.download_percent+'%')};if('need-private-key'===s.state){n.hide();i.hide();o.show();d.hide();t.focus();if('invalid'===s.status){a.show();return};a.hide()};if('done'===s.state){n.hide();i.hide();o.hide();d.show();l.close();window.location.href=e(w).data('url');setTimeout(c,3000)}}});r.click(function(){var n={action:'send_private_key',privatekey:t.val(),};e.post(s,n,function(e){if(!0===e.success){t.val('');a.hide();o.hide();i.show()}})})})}(window.jQuery,window.ajaxurl,window.tb_remove));
\ No newline at end of file
diff --git a/assets/js/page_settings.js b/assets/js/page_settings.js
index 046640948..5e267c723 100644
--- a/assets/js/page_settings.js
+++ b/assets/js/page_settings.js
@@ -66,130 +66,4 @@ jQuery( document ).ready( function ( $ ) {
$( '.authentication_user' ).show();
}
} );
-
- if ( $( '#encryption-symmetric' ).is( ':checked' ) ) {
- $( '#encryption-key-row' ).show();
- $( '#public-key-row' ).hide();
- } else if ( $( '#encryption-asymmetric' ).is( ':checked' ) ) {
- $( '#encryption-key-row' ).hide();
- $( '#public-key-row' ).show();
- }
-
- $( 'input:radio[name="encryption"]' ).change( function () {
- if ( $( this ).val() === "symmetric" ) {
- $( '#encryption-key-row' ).show();
- $( '#public-key-row' ).hide();
- } else if ( $( this ).val() === "asymmetric" ) {
- $( '#encryption-key-row' ).hide();
- $( '#public-key-row' ).show();
- }
- } );
-
- $( '#generate-key-button' ).click( function ( e ) {
- e.preventDefault();
- e.stopPropagation();
-
- // Only run if key is not already set
- if ( $( '#encryptionkey' ).val() !== '' ) {
- return;
- }
-
- $( '#generate-key-button' ).attr( 'disabled', 'disabled' );
-
- var data = {
- action : 'generate_key',
- _ajax_nonce: $( '#backwpupajaxnonce' ).val(),
- };
-
- $.post( ajaxurl, data, function ( response ) {
- $( '#encryptionkey' ).val( response );
- $( '#encryptionkey' ).focus();
- $( '#key-generation' ).hide();
- } );
- } );
-
- $( '#validate-key-button' ).click( function ( e ) {
- if ( $( '#publickey' ).val() === '' ) {
- e.preventDefault();
- alert( backwpup_vars.no_public_key );
- $( '#publickey' ).focus();
- return false;
- }
-
- // Put focus on private key field after a time, to give time for opening dialog.
- setTimeout( function () {
- $( '#privatekey' ).focus();
- }, 100 );
-
- } );
-
- $( '#do-validate' ).click( function () {
- if ( $( '#privatekey' ).val() === '' ) {
- alert( backwpup_vars.no_private_key );
- $( '#privatekey' ).focus();
- return false;
- }
-
- var data = {
- action : 'validate_key',
- publickey : $( '#publickey' ).val(),
- privatekey : $( '#privatekey' ).val(),
- _ajax_nonce: $( '#backwpupajaxnonce' ).val(),
- };
-
- $.post( ajaxurl, data, function ( response ) {
- if ( response === 'valid' ) {
- alert( backwpup_vars.public_key_valid );
- tb_remove();
- $( '#publickey' ).focus();
- } else {
- alert( backwpup_vars.public_key_invalid );
- }
- $( '#privatekey' ).val( '' );
- } )
- .fail( function ( xhr, status, error ) {
- alert( error );
- } );
- } );
-
- $( '#generate-key-pair-button' ).click( function () {
- $( '#key-pair-generating-progress' ).show();
- $( '#key-pair-generating-done' ).hide();
-
- var data = {
- action : 'generate_key_pair',
- _ajax_nonce: $( '#backwpupajaxnonce' ).val()
- };
-
- $.post( ajaxurl, data, function ( response ) {
- $( '#generated-public-key' ).val( response.public_key );
- $( '#generated-public-key-link' ).attr( 'href', 'data:text/plain;base64,' + btoa( response.public_key ) );
- $( '#generated-private-key' ).val( response.private_key );
- $( '#generated-private-key-link' ).attr( 'href', 'data:text/plain;base64,' + btoa( response.private_key ) );
- $( '#key-pair-generating-progress' ).hide();
- $( '#key-pair-generating-done' ).show();
- $( '#generated-public-key' ).focus();
- } );
-
- } );
-
- var private_key_downloaded = false;
- $( '#generated-private-key-link' ).click( function () {
- private_key_downloaded = true;
- } );
-
- $( '#use-key-pair-button' ).click( function () {
- if ( private_key_downloaded === false ) {
- alert( backwpup_vars.must_download_private_key );
- return false;
- }
- $( '#publickey' ).val( $( '#generated-public-key' ).val() );
- tb_remove();
- $( '#publickey' ).focus();
- } );
-
- setTimeout( function () {
- window.scrollTo( 0, 0 );
- }, 1 );
-
} );
diff --git a/assets/js/page_settings.min.js b/assets/js/page_settings.min.js
index e65b712fd..5360bd6d2 100644
--- a/assets/js/page_settings.min.js
+++ b/assets/js/page_settings.min.js
@@ -1,8 +1,5 @@
-;jQuery(document).ready(function(e){var a=e('input[name="anchor"]'),t=e('.nav-tab-wrapper>a'),i=window.location.hash;if(i!==''){i='#'+i.replace('#','')};if(i!==''){a.val(i)};e('.table').addClass('ui-tabs-hide');e(a.val()).removeClass('ui-tabs-hide');if(a.val()==='#backwpup-tab-information'){e('#submit').hide();e('#default_settings').hide()};t.removeClass('nav-tab-active');t.each(function(){if(e(this).attr('href')===a.val()){e(this).addClass('nav-tab-active')}});t.on('click',function(){var i=e(this).attr('href');t.removeClass('nav-tab-active');e(this).addClass('nav-tab-active');e('.table').addClass('ui-tabs-hide');e(i).removeClass('ui-tabs-hide');e('#message').hide();a.val(i);if(i==='#backwpup-tab-information'){e('#submit').hide();e('#default_settings').hide()}
-else{e('#submit').show();e('#default_settings').show()};window.location.hash=i;window.scrollTo(0,0);return!1});e('#authentication_method').change(function(){var a=e('#authentication_method').val();if(''===a){e('.authentication_basic').hide();e('.authentication_query_arg').hide();e('.authentication_user').hide()}
-else if('basic'===a){e('.authentication_basic').show();e('.authentication_query_arg').hide();e('.authentication_user').hide()}
-else if('query_arg'===a){e('.authentication_basic').hide();e('.authentication_query_arg').show();e('.authentication_user').hide()}
-else if('user'===a){e('.authentication_basic').hide();e('.authentication_query_arg').hide();e('.authentication_user').show()}});if(e('#encryption-symmetric').is(':checked')){e('#encryption-key-row').show();e('#public-key-row').hide()}
-else if(e('#encryption-asymmetric').is(':checked')){e('#encryption-key-row').hide();e('#public-key-row').show()};e('input:radio[name="encryption"]').change(function(){if(e(this).val()==='symmetric'){e('#encryption-key-row').show();e('#public-key-row').hide()}
-else if(e(this).val()==='asymmetric'){e('#encryption-key-row').hide();e('#public-key-row').show()}});e('#generate-key-button').click(function(a){a.preventDefault();a.stopPropagation();if(e('#encryptionkey').val()!==''){return};e('#generate-key-button').attr('disabled','disabled');var i={action:'generate_key',_ajax_nonce:e('#backwpupajaxnonce').val(),};e.post(ajaxurl,i,function(a){e('#encryptionkey').val(a);e('#encryptionkey').focus();e('#key-generation').hide()})});e('#validate-key-button').click(function(a){if(e('#publickey').val()===''){a.preventDefault();alert(backwpup_vars.no_public_key);e('#publickey').focus();return!1};setTimeout(function(){e('#privatekey').focus()},100)});e('#do-validate').click(function(){if(e('#privatekey').val()===''){alert(backwpup_vars.no_private_key);e('#privatekey').focus();return!1};var a={action:'validate_key',publickey:e('#publickey').val(),privatekey:e('#privatekey').val(),_ajax_nonce:e('#backwpupajaxnonce').val(),};e.post(ajaxurl,a,function(a){if(a==='valid'){alert(backwpup_vars.public_key_valid);tb_remove();e('#publickey').focus()}
-else{alert(backwpup_vars.public_key_invalid)};e('#privatekey').val('')}).fail(function(e,i,a){alert(a)})});e('#generate-key-pair-button').click(function(){e('#key-pair-generating-progress').show();e('#key-pair-generating-done').hide();var a={action:'generate_key_pair',_ajax_nonce:e('#backwpupajaxnonce').val()};e.post(ajaxurl,a,function(a){e('#generated-public-key').val(a.public_key);e('#generated-public-key-link').attr('href','data:text/plain;base64,'+btoa(a.public_key));e('#generated-private-key').val(a.private_key);e('#generated-private-key-link').attr('href','data:text/plain;base64,'+btoa(a.private_key));e('#key-pair-generating-progress').hide();e('#key-pair-generating-done').show();e('#generated-public-key').focus()})});var n=!1;e('#generated-private-key-link').click(function(){n=!0});e('#use-key-pair-button').click(function(){if(n===!1){alert(backwpup_vars.must_download_private_key);return!1};e('#publickey').val(e('#generated-public-key').val());tb_remove();e('#publickey').focus()});setTimeout(function(){window.scrollTo(0,0)},1)});
\ No newline at end of file
+;jQuery(document).ready(function(a){var i=a('input[name="anchor"]'),e=a('.nav-tab-wrapper>a'),t=window.location.hash;if(t!==''){t='#'+t.replace('#','')};if(t!==''){i.val(t)};a('.table').addClass('ui-tabs-hide');a(i.val()).removeClass('ui-tabs-hide');if(i.val()==='#backwpup-tab-information'){a('#submit').hide();a('#default_settings').hide()};e.removeClass('nav-tab-active');e.each(function(){if(a(this).attr('href')===i.val()){a(this).addClass('nav-tab-active')}});e.on('click',function(){var t=a(this).attr('href');e.removeClass('nav-tab-active');a(this).addClass('nav-tab-active');a('.table').addClass('ui-tabs-hide');a(t).removeClass('ui-tabs-hide');a('#message').hide();i.val(t);if(t==='#backwpup-tab-information'){a('#submit').hide();a('#default_settings').hide()}
+else{a('#submit').show();a('#default_settings').show()};window.location.hash=t;window.scrollTo(0,0);return!1});a('#authentication_method').change(function(){var i=a('#authentication_method').val();if(''===i){a('.authentication_basic').hide();a('.authentication_query_arg').hide();a('.authentication_user').hide()}
+else if('basic'===i){a('.authentication_basic').show();a('.authentication_query_arg').hide();a('.authentication_user').hide()}
+else if('query_arg'===i){a('.authentication_basic').hide();a('.authentication_query_arg').show();a('.authentication_user').hide()}
+else if('user'===i){a('.authentication_basic').hide();a('.authentication_query_arg').hide();a('.authentication_user').show()}})});
\ No newline at end of file
diff --git a/backwpup.php b/backwpup.php
index d9a21be35..e564c1e78 100644
--- a/backwpup.php
+++ b/backwpup.php
@@ -5,7 +5,7 @@
* Description: WordPress Backup Plugin
* Author: Inpsyde GmbH
* Author URI: http://inpsyde.com
- * Version: 3.6.3
+ * Version: 3.6.4
* Text Domain: backwpup
* Domain Path: /languages/
* Network: true
@@ -67,12 +67,12 @@ private function __construct() {
$this->set_autoloader();
- self::$is_pro = class_exists('BackWPup_Pro', true);
+ self::$is_pro = class_exists( 'BackWPup_Pro', true );
// Start upgrade if needed
if ( get_site_option( 'backwpup_version' ) !== self::get_plugin_data( 'Version' )
- || ! wp_next_scheduled( 'backwpup_check_cleanup' )
- || ! wp_next_scheduled( 'backwpup_update_message' ) ) {
+ || ! wp_next_scheduled( 'backwpup_check_cleanup' )
+ ) {
BackWPup_Install::activate();
}
@@ -92,7 +92,6 @@ private function __construct() {
// Add cron actions
add_action( 'backwpup_cron', array( 'BackWPup_Cron', 'run' ) );
add_action( 'backwpup_check_cleanup', array( 'BackWPup_Cron', 'check_cleanup' ) );
- add_action( 'backwpup_update_message', array( 'BackWPup_Cron', 'update_message' ) );
}
// If in cron the rest is not needed
@@ -117,14 +116,13 @@ private function __construct() {
WP_CLI::add_command( 'backwpup', 'BackWPup_WP_CLI' );
}
- // Notices and messages in admin
- if ( is_admin() && current_user_can( 'backwpup' ) ) {
-
- $admin_notice = new BackWPup_Admin_Notice();
- $admin_notice->initiate();
- }
-
if ( ! self::$is_pro ) {
+ $promoter = new \Inpsyde\BackWPup\Notice\Promoter(
+ new \Inpsyde\BackWPup\Notice\PromoterUpdater(),
+ new \Inpsyde\BackWPup\Notice\PromoterView()
+ );
+ $promoter->init();
+
$this->home_phone_client_init();
}
}
@@ -141,8 +139,11 @@ public static function get_instance() {
return self::$instance;
}
- public static function is_pro()
- {
+ /**
+ * @return bool
+ */
+ public static function is_pro() {
+
return self::$is_pro;
}
@@ -176,47 +177,53 @@ public static function get_plugin_data( $name = null ) {
}
if ( empty( self::$plugin_data ) ) {
- self::$plugin_data = get_file_data(
- __FILE__, array(
- 'name' => 'Plugin Name',
- 'version' => 'Version',
- ), 'plugin'
+ self::$plugin_data = get_file_data(
+ __FILE__,
+ array(
+ 'name' => 'Plugin Name',
+ 'version' => 'Version',
+ ),
+ 'plugin'
);
self::$plugin_data['name'] = trim( self::$plugin_data['name'] );
//set some extra vars
- self::$plugin_data['basename'] = plugin_basename( dirname( __FILE__ ) );
- self::$plugin_data['mainfile'] = __FILE__;
+ self::$plugin_data['basename'] = plugin_basename( dirname( __FILE__ ) );
+ self::$plugin_data['mainfile'] = __FILE__;
self::$plugin_data['plugindir'] = untrailingslashit( dirname( __FILE__ ) );
- self::$plugin_data['hash'] = get_site_option( 'backwpup_cfg_hash' );
+ self::$plugin_data['hash'] = get_site_option( 'backwpup_cfg_hash' );
if ( empty( self::$plugin_data['hash'] ) || strlen( self::$plugin_data['hash'] ) < 6
- || strlen(
- self::$plugin_data['hash']
- ) > 12 ) {
+ || strlen(
+ self::$plugin_data['hash']
+ ) > 12 ) {
self::$plugin_data['hash'] = substr( md5( md5( __FILE__ ) ), 14, 6 );
update_site_option( 'backwpup_cfg_hash', self::$plugin_data['hash'] );
}
if ( defined( 'WP_TEMP_DIR' ) && is_dir( WP_TEMP_DIR ) ) {
self::$plugin_data['temp'] = str_replace(
- '\\', '/', get_temp_dir()
- ) . 'backwpup-' . self::$plugin_data['hash'] . '/';
+ '\\',
+ '/',
+ get_temp_dir()
+ ) . 'backwpup-' . self::$plugin_data['hash'] . '/';
} else {
- $upload_dir = wp_upload_dir();
+ $upload_dir = wp_upload_dir();
self::$plugin_data['temp'] = str_replace(
- '\\', '/', $upload_dir['basedir']
- ) . '/backwpup-' . self::$plugin_data['hash'] . '-temp/';
+ '\\',
+ '/',
+ $upload_dir['basedir']
+ ) . '/backwpup-' . self::$plugin_data['hash'] . '-temp/';
}
self::$plugin_data['running_file'] = self::$plugin_data['temp'] . 'backwpup-working.php';
- self::$plugin_data['url'] = plugins_url( '', __FILE__ );
- self::$plugin_data['cacert'] = apply_filters(
- 'backwpup_cacert_bundle', ABSPATH . WPINC . '/certificates/ca-bundle.crt'
+ self::$plugin_data['url'] = plugins_url( '', __FILE__ );
+ self::$plugin_data['cacert'] = apply_filters(
+ 'backwpup_cacert_bundle',
+ ABSPATH . WPINC . '/certificates/ca-bundle.crt'
);
//get unmodified WP Versions
include ABSPATH . WPINC . '/version.php';
/** @var $wp_version string */
self::$plugin_data['wp_version'] = $wp_version;
//Build User Agent
- self::$plugin_data['user-agent'] = self::$plugin_data['name'] . '/' . self::$plugin_data['version'] . '; WordPress/' . self::$plugin_data['wp_version'] . '; ' . home_url(
- );
+ self::$plugin_data['user-agent'] = self::$plugin_data['name'] . '/' . self::$plugin_data['version'] . '; WordPress/' . self::$plugin_data['wp_version'] . '; ' . home_url();
}
if ( ! empty( $name ) ) {
@@ -280,145 +287,146 @@ public static function get_registered_destinations() {
//add BackWPup Destinations
// to folder
self::$registered_destinations['FOLDER'] = array(
- 'class' => 'BackWPup_Destination_Folder',
- 'info' => array(
- 'ID' => 'FOLDER',
- 'name' => __( 'Folder', 'backwpup' ),
+ 'class' => 'BackWPup_Destination_Folder',
+ 'info' => array(
+ 'ID' => 'FOLDER',
+ 'name' => __( 'Folder', 'backwpup' ),
'description' => __( 'Backup to Folder', 'backwpup' ),
),
'can_sync' => false,
- 'needed' => array(
+ 'needed' => array(
'php_version' => '',
- 'functions' => array(),
- 'classes' => array(),
+ 'functions' => array(),
+ 'classes' => array(),
),
'autoload' => array(),
);
// backup with mail
self::$registered_destinations['EMAIL'] = array(
- 'class' => 'BackWPup_Destination_Email',
- 'info' => array(
- 'ID' => 'EMAIL',
- 'name' => __( 'Email', 'backwpup' ),
+ 'class' => 'BackWPup_Destination_Email',
+ 'info' => array(
+ 'ID' => 'EMAIL',
+ 'name' => __( 'Email', 'backwpup' ),
'description' => __( 'Backup sent via email', 'backwpup' ),
),
'can_sync' => false,
- 'needed' => array(
+ 'needed' => array(
'php_version' => '',
- 'functions' => array(),
- 'classes' => array(),
+ 'functions' => array(),
+ 'classes' => array(),
),
'autoload' => array(),
);
// backup to ftp
self::$registered_destinations['FTP'] = array(
- 'class' => 'BackWPup_Destination_Ftp',
- 'info' => array(
- 'ID' => 'FTP',
- 'name' => __( 'FTP', 'backwpup' ),
+ 'class' => 'BackWPup_Destination_Ftp',
+ 'info' => array(
+ 'ID' => 'FTP',
+ 'name' => __( 'FTP', 'backwpup' ),
'description' => __( 'Backup to FTP', 'backwpup' ),
),
'can_sync' => false,
- 'needed' => array(
+ 'needed' => array(
'mphp_version' => '',
- 'functions' => array( 'ftp_nb_fput' ),
- 'classes' => array(),
+ 'functions' => array( 'ftp_nb_fput' ),
+ 'classes' => array(),
),
'autoload' => array(),
);
// backup to dropbox
self::$registered_destinations['DROPBOX'] = array(
- 'class' => 'BackWPup_Destination_Dropbox',
- 'info' => array(
- 'ID' => 'DROPBOX',
- 'name' => __( 'Dropbox', 'backwpup' ),
+ 'class' => 'BackWPup_Destination_Dropbox',
+ 'info' => array(
+ 'ID' => 'DROPBOX',
+ 'name' => __( 'Dropbox', 'backwpup' ),
'description' => __( 'Backup to Dropbox', 'backwpup' ),
),
'can_sync' => false,
- 'needed' => array(
+ 'needed' => array(
'php_version' => '',
- 'functions' => array( 'curl_exec' ),
- 'classes' => array(),
+ 'functions' => array( 'curl_exec' ),
+ 'classes' => array(),
),
'autoload' => array(),
);
// Backup to S3
self::$registered_destinations['S3'] = array(
- 'class' => 'BackWPup_Destination_S3',
- 'info' => array(
- 'ID' => 'S3',
- 'name' => __( 'S3 Service', 'backwpup' ),
+ 'class' => 'BackWPup_Destination_S3',
+ 'info' => array(
+ 'ID' => 'S3',
+ 'name' => __( 'S3 Service', 'backwpup' ),
'description' => __( 'Backup to an S3 Service', 'backwpup' ),
),
'can_sync' => false,
- 'needed' => array(
+ 'needed' => array(
'php_version' => '5.3.3',
- 'functions' => array( 'curl_exec' ),
- 'classes' => array( 'XMLWriter' ),
+ 'functions' => array( 'curl_exec' ),
+ 'classes' => array( 'XMLWriter' ),
),
'autoload' => array(
- 'Aws\\Common' => dirname( __FILE__ ) . '/vendor',
- 'Aws\\S3' => dirname( __FILE__ ) . '/vendor',
+ 'Aws\\Common' => dirname( __FILE__ ) . '/vendor',
+ 'Aws\\S3' => dirname( __FILE__ ) . '/vendor',
'Symfony\\Component\\EventDispatcher' => dirname( __FILE__ ) . '/vendor',
- 'Guzzle' => dirname( __FILE__ ) . '/vendor',
+ 'Guzzle' => dirname( __FILE__ ) . '/vendor',
),
);
// backup to MS Azure
self::$registered_destinations['MSAZURE'] = array(
- 'class' => 'BackWPup_Destination_MSAzure',
- 'info' => array(
- 'ID' => 'MSAZURE',
- 'name' => __( 'MS Azure', 'backwpup' ),
+ 'class' => 'BackWPup_Destination_MSAzure',
+ 'info' => array(
+ 'ID' => 'MSAZURE',
+ 'name' => __( 'MS Azure', 'backwpup' ),
'description' => __( 'Backup to Microsoft Azure (Blob)', 'backwpup' ),
),
'can_sync' => false,
- 'needed' => array(
+ 'needed' => array(
'php_version' => '5.3.2',
- 'functions' => array(),
- 'classes' => array(),
+ 'functions' => array(),
+ 'classes' => array(),
),
'autoload' => array( 'WindowsAzure' => dirname( __FILE__ ) . '/vendor' ),
);
// backup to Rackspace Cloud
self::$registered_destinations['RSC'] = array(
- 'class' => 'BackWPup_Destination_RSC',
- 'info' => array(
- 'ID' => 'RSC',
- 'name' => __( 'RSC', 'backwpup' ),
+ 'class' => 'BackWPup_Destination_RSC',
+ 'info' => array(
+ 'ID' => 'RSC',
+ 'name' => __( 'RSC', 'backwpup' ),
'description' => __( 'Backup to Rackspace Cloud Files', 'backwpup' ),
),
'can_sync' => false,
- 'needed' => array(
+ 'needed' => array(
'php_version' => '5.4',
- 'functions' => array( 'curl_exec' ),
- 'classes' => array(),
+ 'functions' => array( 'curl_exec' ),
+ 'classes' => array(),
),
'autoload' => array(
'OpenCloud' => dirname( __FILE__ ) . '/vendor',
- 'Guzzle' => dirname( __FILE__ ) . '/vendor',
- 'Psr' => dirname( __FILE__ ) . '/vendor',
+ 'Guzzle' => dirname( __FILE__ ) . '/vendor',
+ 'Psr' => dirname( __FILE__ ) . '/vendor',
),
);
// backup to Sugarsync
self::$registered_destinations['SUGARSYNC'] = array(
- 'class' => 'BackWPup_Destination_SugarSync',
- 'info' => array(
- 'ID' => 'SUGARSYNC',
- 'name' => __( 'SugarSync', 'backwpup' ),
+ 'class' => 'BackWPup_Destination_SugarSync',
+ 'info' => array(
+ 'ID' => 'SUGARSYNC',
+ 'name' => __( 'SugarSync', 'backwpup' ),
'description' => __( 'Backup to SugarSync', 'backwpup' ),
),
'can_sync' => false,
- 'needed' => array(
+ 'needed' => array(
'php_version' => '',
- 'functions' => array( 'curl_exec' ),
- 'classes' => array(),
+ 'functions' => array( 'curl_exec' ),
+ 'classes' => array(),
),
'autoload' => array(),
);
//Hook for adding Destinations like above
self::$registered_destinations = apply_filters(
- 'backwpup_register_destination', self::$registered_destinations
+ 'backwpup_register_destination',
+ self::$registered_destinations
);
//check BackWPup Destinations
@@ -426,13 +434,17 @@ public static function get_registered_destinations() {
self::$registered_destinations[ $dest_key ]['error'] = '';
// check PHP Version
if ( ! empty( $dest['needed']['php_version'] )
- && version_compare(
- PHP_VERSION, $dest['needed']['php_version'], '<'
- ) ) {
+ && version_compare(
+ PHP_VERSION,
+ $dest['needed']['php_version'],
+ '<'
+ ) ) {
self::$registered_destinations[ $dest_key ]['error'] .= sprintf(
- __( 'PHP Version %1$s is to low, you need Version %2$s or above.', 'backwpup' ),
- PHP_VERSION, $dest['needed']['php_version']
- ) . ' ';
+ __( 'PHP Version %1$s is to low, you need Version %2$s or above.',
+ 'backwpup' ),
+ PHP_VERSION,
+ $dest['needed']['php_version']
+ ) . ' ';
self::$registered_destinations[ $dest_key ]['class'] = null;
}
//check functions exists
@@ -440,8 +452,10 @@ public static function get_registered_destinations() {
foreach ( $dest['needed']['functions'] as $function_need ) {
if ( ! function_exists( $function_need ) ) {
self::$registered_destinations[ $dest_key ]['error'] .= sprintf(
- __( 'Missing function "%s".', 'backwpup' ), $function_need
- ) . ' ';
+ __( 'Missing function "%s".',
+ 'backwpup' ),
+ $function_need
+ ) . ' ';
self::$registered_destinations[ $dest_key ]['class'] = null;
}
}
@@ -451,8 +465,10 @@ public static function get_registered_destinations() {
foreach ( $dest['needed']['classes'] as $class_need ) {
if ( ! class_exists( $class_need ) ) {
self::$registered_destinations[ $dest_key ]['error'] .= sprintf(
- __( 'Missing class "%s".', 'backwpup' ), $class_need
- ) . ' ';
+ __( 'Missing class "%s".',
+ 'backwpup' ),
+ $class_need
+ ) . ' ';
self::$registered_destinations[ $dest_key ]['class'] = null;
}
}
@@ -473,11 +489,11 @@ public static function get_job_types() {
return self::$job_types;
}
- self::$job_types['DBDUMP'] = new BackWPup_JobType_DBDump;
- self::$job_types['FILE'] = new BackWPup_JobType_File;
- self::$job_types['WPEXP'] = new BackWPup_JobType_WPEXP;
+ self::$job_types['DBDUMP'] = new BackWPup_JobType_DBDump;
+ self::$job_types['FILE'] = new BackWPup_JobType_File;
+ self::$job_types['WPEXP'] = new BackWPup_JobType_WPEXP;
self::$job_types['WPPLUGIN'] = new BackWPup_JobType_WPPlugin;
- self::$job_types['DBCHECK'] = new BackWPup_JobType_DBCheck;
+ self::$job_types['DBCHECK'] = new BackWPup_JobType_DBCheck;
self::$job_types = apply_filters( 'backwpup_job_types', self::$job_types );
@@ -549,11 +565,11 @@ private function home_phone_client_init() {
dirname( __FILE__ ) . '/assets/templates/phpnotice',
'backwpup',
array(
- Inpsyde_PhoneHome_Configuration::ANONYMIZE => true,
+ Inpsyde_PhoneHome_Configuration::ANONYMIZE => true,
Inpsyde_PhoneHome_Configuration::MINIMUM_CAPABILITY => 'manage_options',
- Inpsyde_PhoneHome_Configuration::COLLECT_PHP => true,
- Inpsyde_PhoneHome_Configuration::COLLECT_WP => true,
- Inpsyde_PhoneHome_Configuration::SERVER_ADDRESS => 'https://backwpup.com/wp-json',
+ Inpsyde_PhoneHome_Configuration::COLLECT_PHP => true,
+ Inpsyde_PhoneHome_Configuration::COLLECT_WP => true,
+ Inpsyde_PhoneHome_Configuration::SERVER_ADDRESS => 'https://backwpup.com/wp-json',
)
);
}
@@ -562,7 +578,7 @@ private function home_phone_client_init() {
require_once __DIR__ . '/inc/class-system-requirements.php';
require_once __DIR__ . '/inc/class-system-tests.php';
$system_requirements = new BackWPup_System_Requirements();
- $system_tests = new BackWPup_System_Tests( $system_requirements );
+ $system_tests = new BackWPup_System_Tests( $system_requirements );
// Don't activate on anything less than PHP 5.3 or WordPress 3.9
if ( ! $system_tests->is_php_version_compatible() || ! $system_tests->is_wp_version_compatible() ) {
diff --git a/changelog.txt b/changelog.txt
index e1f4d9066..ded537e3b 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -1,4 +1,19 @@
== Changelog ==
+= Version 3.6.4 =
+Release Date: Nov, 22, 2018
+
+* Fixed: Encrypted backup must force users to download the encryption keys
+* Fixed: Warning mime type when a backup is going to be downloaded
+* Fixed: Admin Notice in free version is sometimes empty
+* Fixed: Random restore error about SQL syntax when restoring a database
+* Fixed: Exclude restore directories to be copied during a restore phase
+* Fixed: Standalone App has no encryption support
+* Fixed: Open basedir, backup dir is not within the allowed path
+* Fixed: Unable to download backup file because of mime_content_type function missing in some enviroment
+* Tweak: Encryption Settings UI
+* Tweak: Minor translations issues
+* Tweak: Remove languages files from the free version, the plugin will use translation.wordpress.org
+
= Version 3.6.3 =
Release Date: Nov, 5, 2018
diff --git a/inc/Helper/MimeType.php b/inc/Helper/MimeType.php
new file mode 100644
index 000000000..c40c6d222
--- /dev/null
+++ b/inc/Helper/MimeType.php
@@ -0,0 +1,222 @@
+ 'application/zip',
+ 'gz' => 'application/gzip',
+ 'bz2' => 'application/x-bzip',
+ 'tar' => 'application/x-tar',
+ '3gp' => 'video/3gpp',
+ 'ai' => 'application/postscript',
+ 'aif' => 'audio/x-aiff',
+ 'aifc' => 'audio/x-aiff',
+ 'aiff' => 'audio/x-aiff',
+ 'asc' => 'text/plain',
+ 'atom' => 'application/atom+xml',
+ 'au' => 'audio/basic',
+ 'avi' => 'video/x-msvideo',
+ 'bcpio' => 'application/x-bcpio',
+ 'bin' => 'application/octet-stream',
+ 'bmp' => 'image/bmp',
+ 'cdf' => 'application/x-netcdf',
+ 'cgm' => 'image/cgm',
+ 'class' => 'application/octet-stream',
+ 'cpio' => 'application/x-cpio',
+ 'cpt' => 'application/mac-compactpro',
+ 'csh' => 'application/x-csh',
+ 'css' => 'text/css',
+ 'dcr' => 'application/x-director',
+ 'dif' => 'video/x-dv',
+ 'dir' => 'application/x-director',
+ 'djv' => 'image/vnd.djvu',
+ 'djvu' => 'image/vnd.djvu',
+ 'dll' => 'application/octet-stream',
+ 'dmg' => 'application/octet-stream',
+ 'dms' => 'application/octet-stream',
+ 'doc' => 'application/msword',
+ 'dtd' => 'application/xml-dtd',
+ 'dv' => 'video/x-dv',
+ 'dvi' => 'application/x-dvi',
+ 'dxr' => 'application/x-director',
+ 'eps' => 'application/postscript',
+ 'etx' => 'text/x-setext',
+ 'exe' => 'application/octet-stream',
+ 'ez' => 'application/andrew-inset',
+ 'flv' => 'video/x-flv',
+ 'gif' => 'image/gif',
+ 'gram' => 'application/srgs',
+ 'grxml' => 'application/srgs+xml',
+ 'gtar' => 'application/x-gtar',
+ 'hdf' => 'application/x-hdf',
+ 'hqx' => 'application/mac-binhex40',
+ 'htm' => 'text/html',
+ 'html' => 'text/html',
+ 'ice' => 'x-conference/x-cooltalk',
+ 'ico' => 'image/x-icon',
+ 'ics' => 'text/calendar',
+ 'ief' => 'image/ief',
+ 'ifb' => 'text/calendar',
+ 'iges' => 'model/iges',
+ 'igs' => 'model/iges',
+ 'jnlp' => 'application/x-java-jnlp-file',
+ 'jp2' => 'image/jp2',
+ 'jpe' => 'image/jpeg',
+ 'jpeg' => 'image/jpeg',
+ 'jpg' => 'image/jpeg',
+ 'js' => 'application/x-javascript',
+ 'kar' => 'audio/midi',
+ 'latex' => 'application/x-latex',
+ 'lha' => 'application/octet-stream',
+ 'lzh' => 'application/octet-stream',
+ 'm3u' => 'audio/x-mpegurl',
+ 'm4a' => 'audio/mp4a-latm',
+ 'm4p' => 'audio/mp4a-latm',
+ 'm4u' => 'video/vnd.mpegurl',
+ 'm4v' => 'video/x-m4v',
+ 'mac' => 'image/x-macpaint',
+ 'man' => 'application/x-troff-man',
+ 'mathml' => 'application/mathml+xml',
+ 'me' => 'application/x-troff-me',
+ 'mesh' => 'model/mesh',
+ 'mid' => 'audio/midi',
+ 'midi' => 'audio/midi',
+ 'mif' => 'application/vnd.mif',
+ 'mov' => 'video/quicktime',
+ 'movie' => 'video/x-sgi-movie',
+ 'mp2' => 'audio/mpeg',
+ 'mp3' => 'audio/mpeg',
+ 'mp4' => 'video/mp4',
+ 'mpe' => 'video/mpeg',
+ 'mpeg' => 'video/mpeg',
+ 'mpg' => 'video/mpeg',
+ 'mpga' => 'audio/mpeg',
+ 'ms' => 'application/x-troff-ms',
+ 'msh' => 'model/mesh',
+ 'mxu' => 'video/vnd.mpegurl',
+ 'nc' => 'application/x-netcdf',
+ 'oda' => 'application/oda',
+ 'ogg' => 'application/ogg',
+ 'ogv' => 'video/ogv',
+ 'pbm' => 'image/x-portable-bitmap',
+ 'pct' => 'image/pict',
+ 'pdb' => 'chemical/x-pdb',
+ 'pdf' => 'application/pdf',
+ 'pgm' => 'image/x-portable-graymap',
+ 'pgn' => 'application/x-chess-pgn',
+ 'pic' => 'image/pict',
+ 'pict' => 'image/pict',
+ 'png' => 'image/png',
+ 'pnm' => 'image/x-portable-anymap',
+ 'pnt' => 'image/x-macpaint',
+ 'pntg' => 'image/x-macpaint',
+ 'ppm' => 'image/x-portable-pixmap',
+ 'ppt' => 'application/vnd.ms-powerpoint',
+ 'ps' => 'application/postscript',
+ 'qt' => 'video/quicktime',
+ 'qti' => 'image/x-quicktime',
+ 'qtif' => 'image/x-quicktime',
+ 'ra' => 'audio/x-pn-realaudio',
+ 'ram' => 'audio/x-pn-realaudio',
+ 'ras' => 'image/x-cmu-raster',
+ 'rdf' => 'application/rdf+xml',
+ 'rgb' => 'image/x-rgb',
+ 'rm' => 'application/vnd.rn-realmedia',
+ 'roff' => 'application/x-troff',
+ 'rtf' => 'text/rtf',
+ 'rtx' => 'text/richtext',
+ 'sgm' => 'text/sgml',
+ 'sgml' => 'text/sgml',
+ 'sh' => 'application/x-sh',
+ 'shar' => 'application/x-shar',
+ 'silo' => 'model/mesh',
+ 'sit' => 'application/x-stuffit',
+ 'skd' => 'application/x-koan',
+ 'skm' => 'application/x-koan',
+ 'skp' => 'application/x-koan',
+ 'skt' => 'application/x-koan',
+ 'smi' => 'application/smil',
+ 'smil' => 'application/smil',
+ 'snd' => 'audio/basic',
+ 'so' => 'application/octet-stream',
+ 'spl' => 'application/x-futuresplash',
+ 'src' => 'application/x-wais-source',
+ 'sv4cpio' => 'application/x-sv4cpio',
+ 'sv4crc' => 'application/x-sv4crc',
+ 'svg' => 'image/svg+xml',
+ 'swf' => 'application/x-shockwave-flash',
+ 't' => 'application/x-troff',
+ 'tcl' => 'application/x-tcl',
+ 'tex' => 'application/x-tex',
+ 'texi' => 'application/x-texinfo',
+ 'texinfo' => 'application/x-texinfo',
+ 'tif' => 'image/tiff',
+ 'tiff' => 'image/tiff',
+ 'tr' => 'application/x-troff',
+ 'tsv' => 'text/tab-separated-values',
+ 'txt' => 'text/plain',
+ 'ustar' => 'application/x-ustar',
+ 'vcd' => 'application/x-cdlink',
+ 'vrml' => 'model/vrml',
+ 'vxml' => 'application/voicexml+xml',
+ 'wav' => 'audio/x-wav',
+ 'wbmp' => 'image/vnd.wap.wbmp',
+ 'wbxml' => 'application/vnd.wap.wbxml',
+ 'webm' => 'video/webm',
+ 'wml' => 'text/vnd.wap.wml',
+ 'wmlc' => 'application/vnd.wap.wmlc',
+ 'wmls' => 'text/vnd.wap.wmlscript',
+ 'wmlsc' => 'application/vnd.wap.wmlscriptc',
+ 'wmv' => 'video/x-ms-wmv',
+ 'wrl' => 'model/vrml',
+ 'xbm' => 'image/x-xbitmap',
+ 'xht' => 'application/xhtml+xml',
+ 'xhtml' => 'application/xhtml+xml',
+ 'xls' => 'application/vnd.ms-excel',
+ 'xml' => 'application/xml',
+ 'xpm' => 'image/x-xpixmap',
+ 'xsl' => 'application/xml',
+ 'xslt' => 'application/xslt+xml',
+ 'xul' => 'application/vnd.mozilla.xul+xml',
+ 'xwd' => 'image/x-xwindowdump',
+ 'xyz' => 'chemical/x-xyz',
+ );
+
+ public static function from_file_path( $file ) {
+
+ if ( is_dir( $file ) || is_link( $file ) ) {
+ return self::DEFAULT_MIME_TYPE;
+ }
+ if ( ! is_readable( $file ) ) {
+ return self::DEFAULT_MIME_TYPE;
+ }
+
+ $filesuffix = pathinfo( $file, PATHINFO_EXTENSION );
+ $suffix = strtolower( $filesuffix );
+
+ if ( isset( self::$mime_types[ $suffix ] ) ) {
+ return self::$mime_types[ $suffix ];
+ }
+
+ $mime_type = '';
+ if ( function_exists( 'fileinfo' ) ) {
+ $finfo = finfo_open( FILEINFO_MIME_TYPE );
+ $mime_type = finfo_file( $finfo, $file );
+ }
+ if ( ! $mime_type && function_exists( 'mime_content_type' ) ) {
+ $mime_type = mime_content_type( $file );
+ }
+ if ( $mime_type ) {
+ return $mime_type;
+ }
+
+ return self::DEFAULT_MIME_TYPE;
+ }
+}
diff --git a/inc/class-dismissible-notice-option.php b/inc/Notice/DismissibleNoticeOption.php
similarity index 82%
rename from inc/class-dismissible-notice-option.php
rename to inc/Notice/DismissibleNoticeOption.php
index 2213be2ed..2fd04e890 100644
--- a/inc/class-dismissible-notice-option.php
+++ b/inc/Notice/DismissibleNoticeOption.php
@@ -1,9 +1,8 @@
array(), 'blog' => array() );
+ private static $setup = array(
+ 'sitewide' => array(),
+ 'blog' => array(),
+ );
- private static $all_actions = array( self::FOR_GOOD_ACTION, self::FOR_NOW_ACTION, self::FOR_USER_FOR_GOOD_ACTION );
+ private static $all_actions = array(
+ self::FOR_GOOD_ACTION,
+ self::FOR_NOW_ACTION,
+ self::FOR_USER_FOR_GOOD_ACTION,
+ );
/**
* @var bool
@@ -21,7 +27,7 @@ class BackWPup_Dismissible_Notice_Option {
private $sitewide;
/**
- * @param bool $sitewide
+ * @param bool $sitewide
* @param string $notice_id
* @param string $capability
*/
@@ -40,7 +46,7 @@ public static function setup_actions( $sitewide, $notice_id, $capability = 'read
}
if ( self::$setup[ $key ] === array() ) {
- $option = new BackWPup_Dismissible_Notice_Option( $sitewide );
+ $option = new self( $sitewide );
add_action( 'admin_post_' . self::FOR_GOOD_ACTION, array( $option, 'dismiss' ) );
add_action( 'admin_post_' . self::FOR_NOW_ACTION, array( $option, 'dismiss' ) );
add_action( 'admin_post_' . self::FOR_USER_FOR_GOOD_ACTION, array( $option, 'dismiss' ) );
@@ -63,8 +69,8 @@ public static function dismiss_action_url( $notice_id, $action ) {
array(
'action' => $action,
'notice' => $notice_id,
- 'blog' => get_current_blog_id(),
- $action => wp_create_nonce( $action ),
+ 'blog' => get_current_blog_id(),
+ $action => wp_create_nonce( $action ),
),
admin_url( 'admin-post.php' )
);
@@ -74,6 +80,7 @@ public static function dismiss_action_url( $notice_id, $action ) {
* @param bool $sitewide
*/
public function __construct( $sitewide = false ) {
+
$this->sitewide = $sitewide;
}
@@ -101,7 +108,7 @@ public function is_dismissed( $notice_id ) {
// Dismissed for now for user?
$transient_name = self::OPTION_PREFIX . $notice_id . get_current_user_id();
- $transient = $this->sitewide ? get_site_transient( $transient_name ) : get_transient( $transient_name );
+ $transient = $this->sitewide ? get_site_transient( $transient_name ) : get_transient( $transient_name );
return (bool) $transient;
}
@@ -116,16 +123,16 @@ public function dismiss() {
$end_request = true;
switch ( $action ) {
- case self::FOR_GOOD_ACTION :
+ case self::FOR_GOOD_ACTION:
$this->dismiss_for_good( $notice_id );
break;
- case self::FOR_USER_FOR_GOOD_ACTION :
+ case self::FOR_USER_FOR_GOOD_ACTION:
$this->dismiss_for_user_for_good( $notice_id );
break;
- case self::FOR_NOW_ACTION :
+ case self::FOR_NOW_ACTION:
$this->dismiss_for_now( $notice_id );
break;
- case self::SKIP :
+ case self::SKIP:
$end_request = false;
break;
}
@@ -170,7 +177,7 @@ private function dismiss_for_user_for_good( $notice_id ) {
private function dismiss_for_now( $notice_id ) {
$transient_name = self::OPTION_PREFIX . $notice_id . get_current_user_id();
- $expiration = 12 * HOUR_IN_SECONDS;
+ $expiration = 12 * HOUR_IN_SECONDS;
$this->sitewide
? set_site_transient( $transient_name, 1, $expiration )
@@ -209,7 +216,7 @@ private function assert_allowed() {
$definition = array(
'action' => FILTER_SANITIZE_STRING,
'notice' => FILTER_SANITIZE_STRING,
- 'blog' => FILTER_SANITIZE_NUMBER_INT,
+ 'blog' => FILTER_SANITIZE_NUMBER_INT,
'isAjax' => FILTER_VALIDATE_BOOLEAN,
);
@@ -218,9 +225,9 @@ private function assert_allowed() {
array_filter( (array) filter_input_array( INPUT_POST, $definition ) )
);
- $is_ajax = ! empty( $data[ 'isAjax' ] );
- $action = empty( $data[ 'action' ] ) ? '' : $data[ 'action' ];
- $notice = empty( $data[ 'notice' ] ) ? '' : $data[ 'notice' ];
+ $is_ajax = ! empty( $data['isAjax'] );
+ $action = empty( $data['action'] ) ? '' : $data['action'];
+ $notice = empty( $data['notice'] ) ? '' : $data['notice'];
if (
! $action
@@ -231,8 +238,8 @@ private function assert_allowed() {
$this->end_request( $is_ajax );
}
- $key = $this->sitewide ? 'sitewide' : 'blog';
- $swap_key = $this->sitewide ? 'blog' : 'sitewide';
+ $key = $this->sitewide ? 'sitewide' : 'blog';
+ $swap_key = $this->sitewide ? 'blog' : 'sitewide';
$capability = empty( self::$setup[ $key ][ $notice ] ) ? '' : self::$setup[ $key ][ $notice ];
if ( ! $capability && ! empty( self::$setup[ $swap_key ][ $notice ] ) ) {
@@ -252,7 +259,7 @@ private function assert_allowed() {
if (
! $this->sitewide
- && ( empty( $data[ 'blog' ] ) || (int) get_current_blog_id() !== (int) $data[ 'blog' ] )
+ && ( empty( $data['blog'] ) || get_current_blog_id() !== (int) $data['blog'] )
) {
$this->end_request( $is_ajax );
}
@@ -260,4 +267,4 @@ private function assert_allowed() {
return array( $action, $notice, $is_ajax );
}
-}
\ No newline at end of file
+}
diff --git a/inc/Notice/Promoter.php b/inc/Notice/Promoter.php
new file mode 100644
index 000000000..3d726eaba
--- /dev/null
+++ b/inc/Notice/Promoter.php
@@ -0,0 +1,146 @@
+updater = $updater;
+ $this->view = $view;
+ }
+
+ /**
+ * Initialize
+ */
+ public function init() {
+
+ if ( ! is_admin() || ! current_user_can( self::CAPABILITY ) ) {
+ return;
+ }
+
+ add_action( 'backwpup_admin_messages', array( $this, 'notice' ), 20 );
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
+ DismissibleNoticeOption::setup_actions( true, self::ID, self::CAPABILITY );
+ }
+
+ /**
+ * Enqueue Scripts
+ */
+ public function enqueue_scripts() {
+
+ $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
+
+ wp_enqueue_script(
+ 'backwpup-notice-promoter',
+ untrailingslashit( \BackWPup::get_plugin_data( 'URL' ) ) . "/assets/js/notice{$suffix}.js",
+ array( 'underscore', 'jquery' ),
+ filemtime( untrailingslashit( \BackWPup::get_plugin_data( 'plugindir' ) . "/assets/js/notice{$suffix}.js" ) ),
+ true
+ );
+ }
+
+ /**
+ * Print Notice
+ */
+ public function notice() {
+
+ $screen_id = get_current_screen()->id;
+ if ( ! in_array( $screen_id, self::$main_admin_page_ids, true ) || ! $this->should_display() ) {
+ return;
+ }
+
+ $message = $this->message();
+ if ( ! $message->content() ) {
+ return;
+ }
+
+ $dismiss_action_url = DismissibleNoticeOption::dismiss_action_url(
+ Promoter::ID,
+ DismissibleNoticeOption::FOR_USER_FOR_GOOD_ACTION
+ );
+
+ $this->view->notice( $message, $dismiss_action_url );
+ }
+
+ /**
+ * @return bool|string
+ */
+ private function locale_code() {
+
+ return substr( get_locale(), 0, 2 );
+ }
+
+ /**
+ * @return \Inpsyde\BackWPup\Notice\PromoterMessage
+ */
+ private function message() {
+
+ $language = self::DEFAULT_LANGUAGE;
+ $locale_code = $this->locale_code();
+
+ $data_message = is_multisite()
+ ? get_site_transient( self::OPTION_NAME )
+ : get_transient( self::OPTION_NAME );
+
+ $data_message = array_filter( (array) $data_message );
+
+ if ( ! $data_message ) {
+ add_action( 'shutdown', array( $this->updater, 'update' ) );
+ }
+
+ if ( isset( $data_message[ $locale_code ] ) ) {
+ $language = $locale_code;
+ }
+
+ $data_message = isset( $data_message[ $language ] ) ? $data_message[ $language ] : array();
+
+ return new PromoterMessage( $data_message );
+ }
+
+ /**
+ * @return bool
+ */
+ private function should_display() {
+
+ $option = new DismissibleNoticeOption( true );
+
+ return false === (bool) $option->is_dismissed( self::ID );
+ }
+}
diff --git a/inc/Notice/PromoterMessage.php b/inc/Notice/PromoterMessage.php
new file mode 100644
index 000000000..6e5d42157
--- /dev/null
+++ b/inc/Notice/PromoterMessage.php
@@ -0,0 +1,70 @@
+ '',
+ 'button-text' => '',
+ 'url' => '',
+ );
+ }
+
+ /**
+ * PromoterMessage constructor
+ *
+ * @see defaults()
+ * @param array $data
+ */
+ public function __construct( array $data ) {
+
+ $data = wp_parse_args( $data, self::defaults() );
+
+ $this->content = $data['content'];
+ $this->button_label = $data['button-text'];
+ $this->cta_url = $data['url'];
+ }
+
+ /**
+ * @param $name
+ * @param $args
+ *
+ * @return string
+ */
+ public function __call( $name, $args ) {
+
+ if ( ! property_exists( $this, $name ) ) {
+ return '';
+ }
+
+ return $this->$name;
+ }
+}
diff --git a/inc/Notice/PromoterUpdater.php b/inc/Notice/PromoterUpdater.php
new file mode 100644
index 000000000..41536141f
--- /dev/null
+++ b/inc/Notice/PromoterUpdater.php
@@ -0,0 +1,49 @@
+ $remote_data ) {
+ $data[ $language ] = wp_parse_args(
+ $remote_data,
+ PromoterMessage::defaults()
+ );
+ }
+
+ is_multisite() ?
+ set_site_transient(
+ Promoter::OPTION_NAME,
+ $data,
+ DAY_IN_SECONDS
+ ) :
+ set_transient(
+ Promoter::OPTION_NAME,
+ $data,
+ DAY_IN_SECONDS
+ );
+ }
+}
diff --git a/inc/Notice/PromoterView.php b/inc/Notice/PromoterView.php
new file mode 100644
index 000000000..47e8033f5
--- /dev/null
+++ b/inc/Notice/PromoterView.php
@@ -0,0 +1,46 @@
+
+
+
+ has_displayed = false;
- $language = substr( get_locale(), 0, 2 );
-
- // Check if message exists in given language
- if ( ! get_site_option( "backwpup_message_id_$language" ) ) {
- // Default to English
- $language = 'en';
- }
- $this->id = get_site_option( "backwpup_message_id_$language" );
- $this->content = get_site_option( "backwpup_message_content_$language" );
- $this->button_text = get_site_option( "backwpup_message_button_text_$language" );
- $this->button_url = get_site_option( "backwpup_message_url_$language" );
- }
-
- public function initiate() {
- add_action( 'backwpup_admin_messages', array( $this, 'dashboard_message' ), 20 );
- BackWPup_Dismissible_Notice_Option::setup_actions(
- false,
- $this->id,
- 'backwpup'
- );
- }
-
- /**
- * Display a notice in BackWPup admin dashboard.
- */
- public function dashboard_message() {
-
- $screen_id = get_current_screen()->id;
- if ( ! $this->has_displayed && in_array( $screen_id, self::$main_admin_page_ids, true )
- && $this->should_display() ) {
- $done = true;
- ?>
-
-
- widget_markup() ?>
-
-
- should_show ) ) {
- if ( class_exists( 'BackWPup_Pro', false ) ) {
- $this->should_show = false;
- } else {
- $option = new BackWPup_Dismissible_Notice_Option( true );
- $this->should_show = ! $option->is_dismissed( $this->id );
- }
- }
-
- return $this->should_show;
- }
-
- /**
- * The markup for the admin page message.
- *
- * @return string
- */
- private function widget_markup() {
-
- $dismiss_url = BackWPup_Dismissible_Notice_Option::dismiss_action_url(
- $this->id,
- BackWPup_Dismissible_Notice_Option::FOR_USER_FOR_GOOD_ACTION
- );
-
- ob_start();
- ?>
-
- settings = new BackWPup_Page_Settings(
+ $settings_views,
+ $settings_updaters
+ );
+
//Load text domain
BackWPup::load_text_domain();
@@ -118,7 +146,7 @@ public static function init_general() {
* Add Message (across site loadings)
*
* @param string $message string Message test.
- * @param bool $error bool ist it a error message.
+ * @param bool $error bool ist it a error message.
*/
public static function message( $message, $error = false ) {
@@ -162,9 +190,9 @@ public static function display_messages( $echo = true ) {
do_action( 'backwpup_admin_messages' );
$message_updated = '';
- $message_error = '';
- $saved_message = self::get_messages();
- $message_id = ' id="message"';
+ $message_error = '';
+ $saved_message = self::get_messages();
+ $message_id = ' id="message"';
if ( empty( $saved_message ) ) {
return '';
@@ -185,7 +213,7 @@ public static function display_messages( $echo = true ) {
if ( ! empty( $message_updated ) ) {
$message_updated = '' . $message_updated . '
';
- $message_id = '';
+ $message_id = '';
}
if ( ! empty( $message_error ) ) {
$message_error = '' . $message_error . '
';
@@ -203,53 +231,49 @@ public static function display_messages( $echo = true ) {
*/
public function admin_init() {
- //only add action if ajax call
- if ( defined( 'DOING_AJAX' ) && DOING_AJAX && defined( 'WP_ADMIN' ) && WP_ADMIN ) {
- //ajax calls
- add_action( 'wp_ajax_backwpup_working', array( 'BackWPup_Page_Jobs', 'ajax_working' ) );
- add_action( 'wp_ajax_backwpup_cron_text', array( 'BackWPup_Page_Editjob', 'ajax_cron_text' ) );
- //ajax or view logs
- add_action( 'wp_ajax_backwpup_view_log', array( 'BackWPup_Page_Logs', 'ajax_view_log' ) );
- // Ajax for encryption
- add_action(
- 'wp_ajax_generate_key',
- array( 'BackWPup_Page_Settings', 'ajax_generate_key' )
- );
- add_action(
- 'wp_ajax_validate_key',
- array( 'BackWPup_Page_Settings', 'ajax_validate_key' )
- );
- add_action(
- 'wp_ajax_generate_key_pair',
- array( 'BackWPup_Page_Settings', 'ajax_generate_key_pair' )
- );
- add_action(
- 'wp_ajax_download_file',
- array( 'BackWPup_Page_Backups', 'ajax_download_file' )
- );
- add_action(
- 'wp_ajax_send_private_key',
- array( 'BackWPup_Page_Backups', 'ajax_send_private_key' )
- );
- //ajax calls for job types
- if ( $jobtypes = BackWPup::get_job_types() ) {
- foreach ( $jobtypes as $id => $jobtypeclass ) {
- add_action( 'wp_ajax_backwpup_jobtype_' . strtolower( $id ), array( $jobtypeclass, 'edit_ajax' ) );
- }
- }
- //ajax calls for destinations
- if ( $dests = BackWPup::get_registered_destinations() ) {
- foreach ( $dests as $id => $dest ) {
- if ( ! empty( $dest['class'] ) ) {
- add_action( 'wp_ajax_backwpup_dest_' . strtolower( $id ), array(
- BackWPup::get_destination( $id ),
- 'edit_ajax',
- ) );
- }
- }
+ if ( ! is_admin() ) {
+ return;
+ }
+ if ( ! defined( 'DOING_AJAX' ) || ( defined( 'DOING_AJAX' ) && ! DOING_AJAX ) ) {
+ return;
+ }
+
+ $jobtypes = BackWPup::get_job_types();
+ $destinations = BackWPup::get_registered_destinations();
+
+ add_action( 'wp_ajax_backwpup_working', array( 'BackWPup_Page_Jobs', 'ajax_working' ) );
+ add_action( 'wp_ajax_backwpup_cron_text', array( 'BackWPup_Page_Editjob', 'ajax_cron_text' ) );
+ add_action( 'wp_ajax_backwpup_view_log', array( 'BackWPup_Page_Logs', 'ajax_view_log' ) );
+ add_action( 'wp_ajax_download_backup_file', array( 'BackWPup_Destination_Downloader', 'download_by_ajax' ) );
+
+ foreach ( $jobtypes as $id => $jobtypeclass ) {
+ add_action( 'wp_ajax_backwpup_jobtype_' . strtolower( $id ), array( $jobtypeclass, 'edit_ajax' ) );
+ }
+
+ foreach ( $destinations as $id => $dest ) {
+ if ( ! empty( $dest['class'] ) ) {
+ add_action(
+ 'wp_ajax_backwpup_dest_' . strtolower( $id ),
+ array(
+ BackWPup::get_destination( $id ),
+ 'edit_ajax',
+ )
+ );
}
}
+ if ( \BackWPup::is_pro() ) {
+ $this->admin_init_pro();
+ }
+ }
+
+ private function admin_init_pro() {
+
+ $ajax_encryption_key_handler = new Settings\AjaxEncryptionKeyHandler(
+ new \phpseclib\Crypt\RSA()
+ );
+
+ add_action( 'wp_ajax_encrypt_key_handler', array( $ajax_encryption_key_handler, 'handle' ) );
}
/**
@@ -264,7 +288,8 @@ public function admin_init() {
public function plugin_links( $links, $file ) {
if ( $file == plugin_basename( BackWPup::get_plugin_data( 'MainFile' ) ) ) {
- $links[] = '' . __( 'Documentation', 'backwpup' ) . ' ';
+ $links[] = '' . __( 'Documentation',
+ 'backwpup' ) . ' ';
}
return $links;
@@ -275,20 +300,31 @@ public function plugin_links( $links, $file ) {
*/
public function admin_menu() {
- add_menu_page( BackWPup::get_plugin_data( 'name' ), BackWPup::get_plugin_data( 'name' ), 'backwpup', 'backwpup', array(
- 'BackWPup_Page_BackWPup',
- 'page',
- ), 'div' );
- $this->page_hooks['backwpup'] = add_submenu_page( 'backwpup', __( 'BackWPup Dashboard', 'backwpup' ), __( 'Dashboard', 'backwpup' ), 'backwpup', 'backwpup', array(
- 'BackWPup_Page_BackWPup',
- 'page',
- ) );
+ add_menu_page( BackWPup::get_plugin_data( 'name' ),
+ BackWPup::get_plugin_data( 'name' ),
+ 'backwpup',
+ 'backwpup',
+ array(
+ 'BackWPup_Page_BackWPup',
+ 'page',
+ ),
+ 'div' );
+ $this->page_hooks['backwpup'] = add_submenu_page( 'backwpup',
+ __( 'BackWPup Dashboard', 'backwpup' ),
+ __( 'Dashboard', 'backwpup' ),
+ 'backwpup',
+ 'backwpup',
+ array(
+ 'BackWPup_Page_BackWPup',
+ 'page',
+ ) );
add_action( 'load-' . $this->page_hooks['backwpup'], array( 'BackWPup_Admin', 'init_general' ) );
add_action( 'load-' . $this->page_hooks['backwpup'], array( 'BackWPup_Page_BackWPup', 'load' ) );
- add_action( 'admin_print_scripts-' . $this->page_hooks['backwpup'], array(
- 'BackWPup_Page_BackWPup',
- 'admin_print_scripts',
- ) );
+ add_action( 'admin_print_scripts-' . $this->page_hooks['backwpup'],
+ array(
+ 'BackWPup_Page_BackWPup',
+ 'admin_print_scripts',
+ ) );
//Add pages form plugins
$this->page_hooks = apply_filters( 'backwpup_admin_pages', $this->page_hooks );
@@ -302,20 +338,27 @@ public function admin_menu() {
*/
public function admin_page_jobs( $page_hooks ) {
- $this->page_hooks['backwpupjobs'] = add_submenu_page( 'backwpup', __( 'Jobs', 'backwpup' ), __( 'Jobs', 'backwpup' ), 'backwpup_jobs', 'backwpupjobs', array(
- 'BackWPup_Page_Jobs',
- 'page',
- ) );
+ $this->page_hooks['backwpupjobs'] = add_submenu_page( 'backwpup',
+ __( 'Jobs', 'backwpup' ),
+ __( 'Jobs', 'backwpup' ),
+ 'backwpup_jobs',
+ 'backwpupjobs',
+ array(
+ 'BackWPup_Page_Jobs',
+ 'page',
+ ) );
add_action( 'load-' . $this->page_hooks['backwpupjobs'], array( 'BackWPup_Admin', 'init_general' ) );
add_action( 'load-' . $this->page_hooks['backwpupjobs'], array( 'BackWPup_Page_Jobs', 'load' ) );
- add_action( 'admin_print_styles-' . $this->page_hooks['backwpupjobs'], array(
- 'BackWPup_Page_Jobs',
- 'admin_print_styles',
- ) );
- add_action( 'admin_print_scripts-' . $this->page_hooks['backwpupjobs'], array(
- 'BackWPup_Page_Jobs',
- 'admin_print_scripts',
- ) );
+ add_action( 'admin_print_styles-' . $this->page_hooks['backwpupjobs'],
+ array(
+ 'BackWPup_Page_Jobs',
+ 'admin_print_styles',
+ ) );
+ add_action( 'admin_print_scripts-' . $this->page_hooks['backwpupjobs'],
+ array(
+ 'BackWPup_Page_Jobs',
+ 'admin_print_scripts',
+ ) );
return $page_hooks;
}
@@ -327,20 +370,27 @@ public function admin_page_jobs( $page_hooks ) {
*/
public function admin_page_editjob( $page_hooks ) {
- $this->page_hooks['backwpupeditjob'] = add_submenu_page( 'backwpup', __( 'Add new job', 'backwpup' ), __( 'Add new job', 'backwpup' ), 'backwpup_jobs_edit', 'backwpupeditjob', array(
- 'BackWPup_Page_Editjob',
- 'page',
- ) );
+ $this->page_hooks['backwpupeditjob'] = add_submenu_page( 'backwpup',
+ __( 'Add new job', 'backwpup' ),
+ __( 'Add new job', 'backwpup' ),
+ 'backwpup_jobs_edit',
+ 'backwpupeditjob',
+ array(
+ 'BackWPup_Page_Editjob',
+ 'page',
+ ) );
add_action( 'load-' . $this->page_hooks['backwpupeditjob'], array( 'BackWPup_Admin', 'init_general' ) );
add_action( 'load-' . $this->page_hooks['backwpupeditjob'], array( 'BackWPup_Page_Editjob', 'auth' ) );
- add_action( 'admin_print_styles-' . $this->page_hooks['backwpupeditjob'], array(
- 'BackWPup_Page_Editjob',
- 'admin_print_styles',
- ) );
- add_action( 'admin_print_scripts-' . $this->page_hooks['backwpupeditjob'], array(
- 'BackWPup_Page_Editjob',
- 'admin_print_scripts',
- ) );
+ add_action( 'admin_print_styles-' . $this->page_hooks['backwpupeditjob'],
+ array(
+ 'BackWPup_Page_Editjob',
+ 'admin_print_styles',
+ ) );
+ add_action( 'admin_print_scripts-' . $this->page_hooks['backwpupeditjob'],
+ array(
+ 'BackWPup_Page_Editjob',
+ 'admin_print_scripts',
+ ) );
return $page_hooks;
}
@@ -352,20 +402,27 @@ public function admin_page_editjob( $page_hooks ) {
*/
public function admin_page_logs( $page_hooks ) {
- $this->page_hooks['backwpuplogs'] = add_submenu_page( 'backwpup', __( 'Logs', 'backwpup' ), __( 'Logs', 'backwpup' ), 'backwpup_logs', 'backwpuplogs', array(
- 'BackWPup_Page_Logs',
- 'page',
- ) );
+ $this->page_hooks['backwpuplogs'] = add_submenu_page( 'backwpup',
+ __( 'Logs', 'backwpup' ),
+ __( 'Logs', 'backwpup' ),
+ 'backwpup_logs',
+ 'backwpuplogs',
+ array(
+ 'BackWPup_Page_Logs',
+ 'page',
+ ) );
add_action( 'load-' . $this->page_hooks['backwpuplogs'], array( 'BackWPup_Admin', 'init_general' ) );
add_action( 'load-' . $this->page_hooks['backwpuplogs'], array( 'BackWPup_Page_Logs', 'load' ) );
- add_action( 'admin_print_styles-' . $this->page_hooks['backwpuplogs'], array(
- 'BackWPup_Page_Logs',
- 'admin_print_styles',
- ) );
- add_action( 'admin_print_scripts-' . $this->page_hooks['backwpuplogs'], array(
- 'BackWPup_Page_Logs',
- 'admin_print_scripts',
- ) );
+ add_action( 'admin_print_styles-' . $this->page_hooks['backwpuplogs'],
+ array(
+ 'BackWPup_Page_Logs',
+ 'admin_print_styles',
+ ) );
+ add_action( 'admin_print_scripts-' . $this->page_hooks['backwpuplogs'],
+ array(
+ 'BackWPup_Page_Logs',
+ 'admin_print_scripts',
+ ) );
return $page_hooks;
}
@@ -377,20 +434,27 @@ public function admin_page_logs( $page_hooks ) {
*/
public function admin_page_backups( $page_hooks ) {
- $this->page_hooks['backwpupbackups'] = add_submenu_page( 'backwpup', __( 'Backups', 'backwpup' ), __( 'Backups', 'backwpup' ), 'backwpup_backups', 'backwpupbackups', array(
- 'BackWPup_Page_Backups',
- 'page',
- ) );
+ $this->page_hooks['backwpupbackups'] = add_submenu_page( 'backwpup',
+ __( 'Backups', 'backwpup' ),
+ __( 'Backups', 'backwpup' ),
+ 'backwpup_backups',
+ 'backwpupbackups',
+ array(
+ 'BackWPup_Page_Backups',
+ 'page',
+ ) );
add_action( 'load-' . $this->page_hooks['backwpupbackups'], array( 'BackWPup_Admin', 'init_general' ) );
add_action( 'load-' . $this->page_hooks['backwpupbackups'], array( 'BackWPup_Page_Backups', 'load' ) );
- add_action( 'admin_print_styles-' . $this->page_hooks['backwpupbackups'], array(
- 'BackWPup_Page_Backups',
- 'admin_print_styles',
- ) );
- add_action( 'admin_print_scripts-' . $this->page_hooks['backwpupbackups'], array(
- 'BackWPup_Page_Backups',
- 'admin_print_scripts',
- ) );
+ add_action( 'admin_print_styles-' . $this->page_hooks['backwpupbackups'],
+ array(
+ 'BackWPup_Page_Backups',
+ 'admin_print_styles',
+ ) );
+ add_action( 'admin_print_scripts-' . $this->page_hooks['backwpupbackups'],
+ array(
+ 'BackWPup_Page_Backups',
+ 'admin_print_scripts',
+ ) );
return $page_hooks;
}
@@ -402,15 +466,19 @@ public function admin_page_backups( $page_hooks ) {
*/
public function admin_page_settings( $page_hooks ) {
- $this->page_hooks['backwpupsettings'] = add_submenu_page( 'backwpup', __( 'Settings', 'backwpup' ), __( 'Settings', 'backwpup' ), 'backwpup_settings', 'backwpupsettings', array(
- 'BackWPup_Page_Settings',
- 'page',
- ) );
+ $this->page_hooks['backwpupsettings'] = add_submenu_page(
+ 'backwpup',
+ esc_html__( 'Settings', 'backwpup' ),
+ esc_html__( 'Settings', 'backwpup' ),
+ 'backwpup_settings',
+ 'backwpupsettings',
+ array( $this->settings, 'page' )
+ );
add_action( 'load-' . $this->page_hooks['backwpupsettings'], array( 'BackWPup_Admin', 'init_general' ) );
- add_action( 'admin_print_scripts-' . $this->page_hooks['backwpupsettings'], array(
- 'BackWPup_Page_Settings',
- 'admin_print_scripts',
- ) );
+ add_action(
+ 'admin_print_scripts-' . $this->page_hooks['backwpupsettings'],
+ array( $this->settings, 'admin_print_scripts' )
+ );
return $page_hooks;
}
@@ -422,19 +490,26 @@ public function admin_page_settings( $page_hooks ) {
*/
public function admin_page_about( $page_hooks ) {
- $this->page_hooks['backwpupabout'] = add_submenu_page( 'backwpup', __( 'About', 'backwpup' ), __( 'About', 'backwpup' ), 'backwpup', 'backwpupabout', array(
- 'BackWPup_Page_About',
- 'page',
- ) );
+ $this->page_hooks['backwpupabout'] = add_submenu_page( 'backwpup',
+ __( 'About', 'backwpup' ),
+ __( 'About', 'backwpup' ),
+ 'backwpup',
+ 'backwpupabout',
+ array(
+ 'BackWPup_Page_About',
+ 'page',
+ ) );
add_action( 'load-' . $this->page_hooks['backwpupabout'], array( 'BackWPup_Admin', 'init_general' ) );
- add_action( 'admin_print_styles-' . $this->page_hooks['backwpupabout'], array(
- 'BackWPup_Page_About',
- 'admin_print_styles',
- ) );
- add_action( 'admin_print_scripts-' . $this->page_hooks['backwpupabout'], array(
- 'BackWPup_Page_About',
- 'admin_print_scripts',
- ) );
+ add_action( 'admin_print_styles-' . $this->page_hooks['backwpupabout'],
+ array(
+ 'BackWPup_Page_About',
+ 'admin_print_styles',
+ ) );
+ add_action( 'admin_print_scripts-' . $this->page_hooks['backwpupabout'],
+ array(
+ 'BackWPup_Page_About',
+ 'admin_print_scripts',
+ ) );
return $page_hooks;
}
@@ -444,20 +519,21 @@ public function admin_page_about( $page_hooks ) {
*/
public function save_post_form() {
- //Allowed Pages
- if ( ! in_array( $_POST['page'], array(
+ $allowed_pages = array(
'backwpupeditjob',
'backwpupinformation',
'backwpupsettings',
- ), true ) ) {
- wp_die( __( 'Cheating, huh?', 'backwpup' ) );
+ );
+
+ if ( ! in_array( $_POST['page'], $allowed_pages, true ) ) {
+ wp_die( esc_html__( 'Cheating, huh?', 'backwpup' ) );
}
//nonce check
check_admin_referer( $_POST['page'] . '_page' );
if ( ! current_user_can( 'backwpup' ) ) {
- wp_die( __( 'Cheating, huh?', 'backwpup' ) );
+ wp_die( esc_html__( 'Cheating, huh?', 'backwpup' ) );
}
//build query for redirect
@@ -471,21 +547,21 @@ public function save_post_form() {
if ( isset( $_POST['tab'] ) ) {
$query_args['tab'] = $_POST['tab'];
}
- if ( isset( $_POST['tab'] ) && isset( $_POST['nexttab'] ) && $_POST['tab'] != $_POST['nexttab'] ) {
+ if ( isset( $_POST['tab'] ) && isset( $_POST['nexttab'] ) && $_POST['tab'] !== $_POST['nexttab'] ) {
$query_args['tab'] = $_POST['nexttab'];
}
$jobid = null;
if ( isset( $_POST['jobid'] ) ) {
- $jobid = (int) $_POST['jobid'];
+ $jobid = (int) $_POST['jobid'];
$query_args['jobid'] = $jobid;
}
- //Call method to save data
- if ( $_POST['page'] == 'backwpupeditjob' ) {
+ // Call method to save data
+ if ( $_POST['page'] === 'backwpupeditjob' ) {
BackWPup_Page_Editjob::save_post_form( $_POST['tab'], $jobid );
- } elseif ( $_POST['page'] == 'backwpupsettings' ) {
- BackWPup_Page_Settings::save_post_form();
+ } elseif ( $_POST['page'] === 'backwpupsettings' ) {
+ $this->settings->save_post_form();
}
//Back to topic
@@ -503,11 +579,17 @@ public function save_post_form() {
public function admin_footer_text( $admin_footer_text ) {
$default_text = $admin_footer_text;
-
if ( isset( $_REQUEST['page'] ) && strstr( $_REQUEST['page'], 'backwpup' ) ) {
- $admin_footer_text = 'Inpsyde GmbH ';
+
+ $admin_footer_text = sprintf(
+ '%s Inpsyde GmbH ',
+ ' '
+ );
+
if ( ! class_exists( 'BackWPup_Pro', false ) ) {
- $admin_footer_text .= sprintf( __( 'Get BackWPup Pro now. ', 'backwpup' ), __( 'http://backwpup.com', 'backwpup' ) );
+ $admin_footer_text .= sprintf( __( 'Get BackWPup Pro now. ',
+ 'backwpup' ),
+ __( 'http://backwpup.com', 'backwpup' ) );
}
return $admin_footer_text . $default_text;
@@ -528,7 +610,10 @@ public function update_footer( $update_footer_text ) {
$default_text = $update_footer_text;
if ( isset( $_REQUEST['page'] ) && strstr( $_REQUEST['page'], 'backwpup' ) ) {
- $update_footer_text = '';
+ $update_footer_text = '';
return $update_footer_text . $default_text;
}
@@ -578,10 +663,13 @@ public function user_profile_fields( $user ) {
+ value="">
$role_value ) {
- echo 'has_cap( $role ), true, false ) . '>' . $role_value['name'] . ' ';
+ echo 'has_cap( $role ),
+ true,
+ false ) . '>' . $role_value['name'] . ' ';
}
?>
@@ -651,7 +739,7 @@ public function save_profile_update( $user_id ) {
}
/**
- * @param bool $show
+ * @param bool $show
* @param null|WP_Screen $screen
*
* @return bool
diff --git a/inc/class-become-inpsyder-widget.php b/inc/class-become-inpsyder-widget.php
deleted file mode 100644
index 91e9a45ef..000000000
--- a/inc/class-become-inpsyder-widget.php
+++ /dev/null
@@ -1,176 +0,0 @@
-should_display() ) {
- wp_add_dashboard_widget(
- 'backwpup_become_inpsyder',
- esc_html__( 'Make BackWPup better!', 'backwpup' ),
- array( $this, 'print_widget_markup' )
- );
- }
- }
-
- public function print_plugin_widget_markup() {
-
- static $done;
- $screen_id = get_current_screen()->id;
- if ( ! $done && in_array( $screen_id, self::$main_admin_page_ids, true ) && $this->should_display() ) {
- $done = true;
- ?>
-
-
-
- widget_markup( 'left' ) ?>
-
-
- should_display() ) {
- $done = true;
- echo $this->widget_markup();
- }
- }
-
- /**
- * We don't display widget if it was dismissed for good.
- *
- * @return bool
- */
- private function should_display() {
-
- // If already checked, don't check again
- if ( is_bool( self::$should_show ) ) {
- return self::$should_show;
- }
-
- if ( class_exists( 'BackWPup_Pro', false ) ) {
- self::$should_show = false;
- } else {
- $option = new BackWPup_Dismissible_Notice_Option( false );
-
- // If notice is dismissed for good, don't show it
- self::$should_show = ! $option->is_dismissed( self::NOTICE_ID );
- }
-
- return self::$should_show;
- }
-
- /**
- * The markup for the admin notice.
- *
- * @param string $btn_float
- *
- * @return string
- */
- private function widget_markup( $btn_float = 'right' ) {
-
- $dismiss_url = BackWPup_Dismissible_Notice_Option::dismiss_action_url(
- self::NOTICE_ID,
- BackWPup_Dismissible_Notice_Option::FOR_USER_FOR_GOOD_ACTION
- );
-
- $plugin_file = dirname( dirname( __FILE__ ) ) . '/backwpup.php';
- $logo_url = plugins_url( '/assets/images/inpsyde.png', $plugin_file );
-
- $job_url = __(
- 'https://inpsyde.com/en/jobs/?utm_source=BackWPup&utm_medium=Link&utm_campaign=BecomeAnInpsyder',
- 'backwpup'
- );
-
- ob_start();
- ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- file = trim( $file );
// TAR.GZ
- if ( ! $this->filehandler && '.tar.gz' === strtolower( substr( $this->file, - 7 ) ) ) {
+ if (
+ (! $this->filehandler && '.tar.gz' === strtolower( substr( $this->file, - 7 ) ))
+ || ( ! $this->filehandler && '.tar.bz2' === strtolower( substr( $this->file, - 8 ) ) )
+ ) {
if ( ! function_exists( 'gzencode' ) ) {
throw new BackWPup_Create_Archive_Exception(
__( 'Functions for gz compression not available', 'backwpup' )
@@ -107,19 +110,6 @@ public function __construct( $file ) {
$this->filehandler = $this->fopen( $this->file, 'ab' );
}
- // TAR.BZ2
- if ( ! $this->filehandler && '.tar.bz2' === strtolower( substr( $this->file, - 8 ) ) ) {
- if ( ! function_exists( 'bzcompress' ) ) {
- throw new BackWPup_Create_Archive_Exception(
- esc_html__( 'Functions for bz2 compression not available.', 'backwpup' )
- );
- }
-
- $this->method = 'TarBz2';
- $this->handlertype = 'bz';
- $this->filehandler = $this->fopen( $this->file, 'ab' );
- }
-
// .TAR
if ( ! $this->filehandler && '.tar' === strtolower( substr( $this->file, - 4 ) ) ) {
$this->method = 'Tar';
@@ -176,7 +166,10 @@ public function __construct( $file ) {
}
// .GZ
- if ( ! $this->filehandler && '.gz' === strtolower( substr( $this->file, - 3 ) ) ) {
+ if (
+ ( ! $this->filehandler && '.gz' === strtolower( substr( $this->file, - 3 ) ) )
+ || ( ! $this->filehandler && '.bz2' === strtolower( substr( $this->file, - 4 ) ) )
+ ) {
if ( ! function_exists( 'gzencode' ) ) {
throw new BackWPup_Create_Archive_Exception(
__( 'Functions for gz compression not available', 'backwpup' )
@@ -188,19 +181,6 @@ public function __construct( $file ) {
$this->filehandler = $this->fopen( $this->file, 'w' );
}
- // .BZ2
- if ( ! $this->filehandler && '.bz2' === strtolower( substr( $this->file, - 4 ) ) ) {
- if ( ! function_exists( 'bzcompress' ) ) {
- throw new BackWPup_Create_Archive_Exception(
- __( 'Functions for bz2 compression not available', 'backwpup' )
- );
- }
-
- $this->method = 'bz2';
- $this->handlertype = 'bz';
- $this->filehandler = $this->fopen( $this->file, 'w' );
- }
-
if ( '' === $this->method ) {
throw new BackWPup_Create_Archive_Exception(
sprintf(
@@ -275,7 +255,7 @@ public function close() {
}
// Write tar file end.
- if ( in_array( $this->method, array( 'Tar', 'TarGz', 'TarBz2' ), true ) ) {
+ if ( in_array( $this->method, array( 'Tar', 'TarGz' ), true ) ) {
$this->fwrite( pack( 'a1024', '' ) );
}
@@ -364,36 +344,8 @@ public function add_file( $file_name, $name_in_archive = '' ) {
$this->file_count ++;
break;
- case 'bz2':
- if ( ! is_resource( $this->filehandler ) ) {
- return false;
- }
-
- if ( $this->file_count > 0 ) {
- trigger_error(
- esc_html__( 'This archive method can only add one file', 'backwpup' ),
- E_USER_WARNING
- );
-
- return false;
- }
-
- $fd = fopen( $file_name, 'rb' ); // phpcs:ignore
- if ( ! $fd ) {
- return false;
- }
-
- while ( ! feof( $fd ) ) {
- $this->fwrite( fread( $fd, 8192 ) ); // phpcs:ignore
- }
- fclose( $fd ); // phpcs:ignore
-
- $this->file_count ++;
- break;
-
case 'Tar':
case 'TarGz':
- case 'TarBz2':
// Convert chars for archives file names
if ( function_exists( 'iconv' ) && stripos( PHP_OS, 'win' ) === 0 ) {
$test = @iconv( 'ISO-8859-1', 'UTF-8', $name_in_archive );
@@ -582,18 +534,8 @@ public function add_empty_folder( $folder_name, $name_in_archive ) {
return false;
break;
- case 'bz2':
- trigger_error(
- esc_html__( 'This archive method can only add one file', 'backwpup' ),
- E_USER_ERROR
- );
-
- return false;
- break;
-
case 'Tar':
case 'TarGz':
- case 'TarBz2':
$this->tar_empty_folder( $folder_name, $name_in_archive );
return false;
diff --git a/inc/class-cron.php b/inc/class-cron.php
index 8fc4205e8..55cd81710 100644
--- a/inc/class-cron.php
+++ b/inc/class-cron.php
@@ -1,7 +1,5 @@
'cronrun',
+ 'run' => 'cronrun',
'jobid' => $arg,
) );
@@ -130,53 +128,6 @@ public static function check_cleanup() {
}
- /**
- * Update the backend message.
- *
- * @return void
- */
- public static function update_message() {
-
- // Fetch message from API
- $api_request = esc_url( 'http://backwpup.com/wp-json/inpsyde-messages/v1/message/' );
- $api_response = wp_remote_get( $api_request ); // phpcs:ignore
- $api_data = json_decode( wp_remote_retrieve_body( $api_response ), true );
-
- if ( is_wp_error( $api_response ) ) {
- return;
- }
- if ( 200 !== $api_response['response']['code'] ) {
- return;
- }
-
- // Add messages to options
- foreach ( $api_data as $lang => $value ) {
- $content = $value['content'];
- $button = $value['button-text'];
- $url = $value['url'];
-
- // Calculate ID based on button text and URL
- $id = "$button|$url";
-
- // Pad to nearest 5 bytes for base32
- $pad = strlen( $id );
-
- if ( $pad % 5 > 0 ) {
- $pad += 5 - ( $pad % 5 );
- $id = str_pad( $id, $pad, '|' );
- }
-
- // Encode $id so it will be unique
- $id = Base32::encode( $id );
-
- // Save in site options
- update_site_option( "backwpup_message_id_$lang", $id );
- update_site_option( "backwpup_message_content_$lang", $content );
- update_site_option( "backwpup_message_button_text_$lang", $button );
- update_site_option( "backwpup_message_url_$lang", $url );
- }
- }
-
/**
* Start job if in cron and run query args are set.
*/
@@ -204,7 +155,7 @@ public static function cron_active( $args = array() ) {
}
$args = array_merge( array(
- 'run' => '',
+ 'run' => '',
'nonce' => '',
'jobid' => 0,
),
@@ -260,7 +211,7 @@ public static function cron_active( $args = array() ) {
//check runext is allowed for job
if ( $args['run'] === 'runext' ) {
- $jobids_link = BackWPup_Option::get_job_ids( 'activetype', 'link' );
+ $jobids_link = BackWPup_Option::get_job_ids( 'activetype', 'link' );
$jobids_easycron = BackWPup_Option::get_job_ids( 'activetype', 'easycron' );
$jobids_external = array_merge( $jobids_link, $jobids_easycron );
if ( ! in_array( $args['jobid'], $jobids_external, true ) ) {
@@ -282,7 +233,7 @@ public static function cron_active( $args = array() ) {
*/
public static function cron_next( $cronstring ) {
- $cron = array();
+ $cron = array();
$cronarray = array();
//Cron string
list( $cronstr['minutes'], $cronstr['hours'], $cronstr['mday'], $cronstr['mon'], $cronstr['wday'] ) = explode( ' ',
@@ -397,5 +348,4 @@ public static function cron_next( $cronstring ) {
return PHP_INT_MAX;
}
-
}
diff --git a/inc/class-decrypter.php b/inc/class-decrypter.php
deleted file mode 100644
index b403427ca..000000000
--- a/inc/class-decrypter.php
+++ /dev/null
@@ -1,198 +0,0 @@
-local_file_path = $local_file_path;
- }
-
- /**
- * @return bool
- * @throws \Exception
- */
- public function decrypt() {
-
- $aes = new AES( AES::MODE_CBC );
- $source_file_handler = fopen( $this->local_file_path, 'rb' );
-
- if ( ! is_resource( $source_file_handler ) ) {
- throw new \Exception( __( 'Cannot open the archive for reading.', 'backwpup' ) );
- }
-
- // Read first byte to know what encryption method was used
- $key = '';
- $type = fread( $source_file_handler, 1 );
-
- // Symmetric mode
- if ( $type === chr( 0 ) ) {
- $key = pack( 'H*', get_site_option( self::ENCRYPTION_KEY_OPTION ) );
- }
- // Asymmetric mode
- if ( $type === chr( 1 ) ) {
- $key = $this->get_rsa_decrypted_key( $source_file_handler );
- }
-
- if ( $key === '' ) {
- return false;
- }
-
- if ( file_exists( $this->local_file_path . '.encrypted' ) ) {
- unlink( $this->local_file_path . '.encrypted' );
- }
-
- $local_file_handler = fopen( $this->local_file_path . '.encrypted', 'a+b' );
- if ( ! is_resource( $local_file_handler ) ) {
- throw new \Exception( __( 'Cannot write the encrypted archive.', 'backwpup' ) );
- }
-
- $aes->setKey( $key );
- $aes->enableContinuousBuffer();
- $aes->disablePadding();
-
- $block_size = 128 * 1024;
- $bytes_read = 0;
-
- while ( ! feof( $source_file_handler ) ) {
- $data = fread( $source_file_handler, $block_size );
- $packet = $aes->decrypt( $data );
- $bytes_read += strlen( $data );
-
- if ( feof( $source_file_handler ) ) {
- // This is the last chunk, so strip padding
- $padding_length = ord( $packet[ strlen( $packet ) - 1 ] );
- if ( $padding_length <= 16 ) {
- $packet = substr( $packet, 0, - $padding_length );
- }
- }
- fwrite( $local_file_handler, $packet );
- }
-
- $file_in = null;
- $file_out = null;
-
- unlink( $this->local_file_path );
- rename( $this->local_file_path . '.encrypted', $this->local_file_path );
-
- return true;
- }
-
- /**
- * @param $source_file_handler
- *
- * @return bool|string
- */
- private function get_rsa_decrypted_key( $source_file_handler ) {
-
- $rsa = new RSA();
- $private_key = '';
- $verified = false;
- $status = self::PRIVATE_KEY_STATUS_NOT_FOUND;
- $length = unpack( 'H*', fread( $source_file_handler, 1 ) );
- $length = hexdec( $length[1] );
- $key = fread( $source_file_handler, $length );
- $private_key_file = dirname( $this->local_file_path ) . '/' . self::PRIVATE_RSA_ID_FILE;
-
- if ( ! file_exists( $private_key_file ) ) {
- self::send_message( array(
- 'state' => 'need-private-key',
- 'status' => $status,
- ) );
-
- return '';
- }
-
- if ( file_exists( $private_key_file ) ) {
- $private_key = file_get_contents( $private_key_file );
- unlink( $private_key_file );
-
- $verified = $this->verify_private_key( $rsa, $private_key );
- }
-
- if ( ! $verified ) {
- self::send_message( array(
- 'state' => 'need-private-key',
- 'status' => self::PRIVATE_KEY_STATUS_INVALID,
- ) );
-
- return '';
- }
-
- $private_key and $rsa->loadKey( $private_key );
-
- $key = $rsa->decrypt( $key );
-
- if ( $key === '' ) {
- throw new \RuntimeException( __( 'Private key invalid.', 'backwpup' ) );
- }
-
- return $key;
- }
-
- /**
- * @param \phpseclib\Crypt\RSA $rsa
- * @param $private_key
- *
- * @return bool
- */
- private function verify_private_key( RSA $rsa, $private_key ) {
-
- $rsa->setSignatureMode( RSA::SIGNATURE_PKCS1 );
-
- if ( ! $rsa->loadKey( $private_key ) ) {
- return false;
- }
-
- $signature = $rsa->sign( 'test' );
- $rsa->loadKey( get_site_option( self::PUBLIC_KEY_OPTION ) );
-
- return $rsa->verify( 'test', $signature );
- }
-
- /**
- * @param $data
- * @param string $event
- */
- private static function send_message( $data, $event = 'message' ) {
-
- echo "event: {$event}\n";
- echo "data: " . wp_json_encode( $data ) . "\n\n";
- flush();
- }
-}
diff --git a/inc/class-destination-downloader-factory.php b/inc/class-destination-downloader-factory.php
index 52e29b7d4..76040ef01 100644
--- a/inc/class-destination-downloader-factory.php
+++ b/inc/class-destination-downloader-factory.php
@@ -31,9 +31,9 @@ class BackWPup_Destination_Downloader_Factory {
*/
public function create( $service_name, $job_id, $source_file_path, $local_file_path, $base_url = '' ) {
- $destination = null;
+ $destination = null;
$service_name = ucwords( $service_name );
- $class = self::CLASS_PREFIX . $service_name . self::CLASS_SUFFIX;
+ $class = self::CLASS_PREFIX . $service_name . self::CLASS_SUFFIX;
// If class doesn't exists, try within the Pro directory.
if ( BackWPup::is_pro() && ! class_exists( $class ) ) {
@@ -57,7 +57,9 @@ public function create( $service_name, $job_id, $source_file_path, $local_file_p
}
/** @var \BackWPup_Destination_Downloader_Interface $destination */
- ! $destination and $destination = new $class( $data );
+ if ( ! $destination ) {
+ $destination = new $class( $data );
+ }
return new BackWPup_Destination_Downloader( $data, $destination );
}
diff --git a/inc/class-destination-downloader.php b/inc/class-destination-downloader.php
index 47bb362f2..48ee3495a 100644
--- a/inc/class-destination-downloader.php
+++ b/inc/class-destination-downloader.php
@@ -6,6 +6,9 @@
* @package Inpsyde\BackWPup
*/
+use Inpsyde\Restore\Api\Controller\DecryptController;
+use Inpsyde\Restore\Api\Exception\DecryptException;
+
/**
* Class BackWPup_Destination_Downloader
*
@@ -17,6 +20,10 @@ class BackWPup_Destination_Downloader {
const ARCHIVE_ENCRYPT_OPTION = 'archiveencryption';
const CAPABILITY = 'backwpup_backups_download';
+ const STATE_DOWNLOADING = 'downloading';
+ const STATE_ERROR = 'error';
+ const STATE_DONE = 'done';
+
/**
* @var \BackWpUp_Destination_Downloader_Data
*/
@@ -27,10 +34,54 @@ class BackWPup_Destination_Downloader {
*/
private $destination;
+ /**
+ * Download file via ajax
+ */
+ public static function download_by_ajax() {
+
+ $dest = (string) filter_input( INPUT_GET, 'destination', FILTER_SANITIZE_STRING );
+ if ( ! $dest ) {
+ return;
+ }
+
+ $job_id = (int) filter_input( INPUT_GET, 'jobid', FILTER_SANITIZE_NUMBER_INT );
+ if ( ! $job_id ) {
+ return;
+ }
+
+ $file = (string) filter_input( INPUT_GET, 'file', FILTER_SANITIZE_STRING );
+ $file_local = (string) filter_input( INPUT_GET, 'local_file', FILTER_SANITIZE_STRING );
+ if ( ! $file || ! $file_local ) {
+ return;
+ }
+
+ set_time_limit( 0 );
+ // Set up eventsource headers
+ header( 'Content-Type: text/event-stream' );
+ header( 'Cache-Control: no-cache' );
+ header( 'X-Accel-Buffering: no' );
+ header( 'Content-Encoding: none' );
+
+ // 2KB padding for IE
+ echo ':' . str_repeat( ' ', 2048 ) . "\n\n"; // phpcs:ignore
+
+ // Ensure we're not buffered.
+ wp_ob_end_flush_all();
+ flush();
+
+ /** @var \BackWPup_Destinations $dest_class */
+ $dest_class = BackWPup::get_destination( $dest );
+ $dest_class->file_download(
+ $job_id,
+ trim( sanitize_text_field( $file ) ),
+ trim( sanitize_text_field( $file_local ) )
+ );
+ }
+
/**
* BackWPup_Downloader constructor
*
- * @param \BackWpUp_Destination_Downloader_Data $data
+ * @param \BackWpUp_Destination_Downloader_Data $data
* @param \BackWPup_Destination_Downloader_Interface $destination
*/
public function __construct(
@@ -38,7 +89,7 @@ public function __construct(
BackWPup_Destination_Downloader_Interface $destination
) {
- $this->data = $data;
+ $this->data = $data;
$this->destination = $destination;
}
@@ -49,16 +100,12 @@ public function download_by_chunks() {
$this->ensure_user_can_download();
- $decripted = false;
- $need_to_be_decripted = BackWPup_Option::get( $this->data->job_id(), self::ARCHIVE_ENCRYPT_OPTION );
-
$source_file_path = $this->data->source_file_path();
- $local_file_path = $this->data->local_file_path();
-
- $size = $this->destination->calculate_size();
+ $local_file_path = $this->data->local_file_path();
+ $size = $this->destination->calculate_size();
$start_byte = 0;
$chunk_size = 2 * 1024 * 1024;
- $end_byte = $start_byte + $chunk_size - 1;
+ $end_byte = $start_byte + $chunk_size - 1;
if ( $end_byte >= $size ) {
$end_byte = $size - 1;
@@ -69,12 +116,12 @@ public function download_by_chunks() {
$this->destination->download_chunk( $start_byte, $end_byte );
self::send_message(
array(
- 'state' => 'downloading',
- 'start_byte' => $start_byte,
- 'end_byte' => $end_byte,
- 'size' => $size,
+ 'state' => self::STATE_DOWNLOADING,
+ 'start_byte' => $start_byte,
+ 'end_byte' => $end_byte,
+ 'size' => $size,
'download_percent' => round( ( $end_byte + 1 ) / $size * 100 ),
- 'filename' => basename( $source_file_path ),
+ 'filename' => basename( $source_file_path ),
)
);
@@ -83,30 +130,23 @@ public function download_by_chunks() {
}
$start_byte = $end_byte + 1;
- $end_byte = $start_byte + $chunk_size - 1;
+ $end_byte = $start_byte + $chunk_size - 1;
if ( $start_byte < $size && $end_byte >= $size ) {
$end_byte = $size - 1;
}
}
- // Decrypt
- if ( $need_to_be_decripted ) {
- $decrypter = new BackWPup_Decrypter( $local_file_path );
- $decripted = $decrypter->decrypt();
- }
-
- if ( ! $decripted && $need_to_be_decripted ) {
- throw new \BackWPup_Destination_Download_Exception();
+ if ( BackWPup::is_pro() ) {
+ $decrypter = \Inpsyde\BackWPup\Pro\Restore\Functions\restore_container( 'decrypter' );
+ if ( $decrypter->maybe_decrypted( $local_file_path ) ) {
+ throw new DecryptException( DecryptController::STATE_NEED_DECRYPTION_KEY );
+ }
}
-
- self::send_message( array(
- 'state' => 'done',
- ) );
} catch ( \Exception $e ) {
self::send_message(
array(
- 'state' => 'error',
+ 'state' => self::STATE_ERROR,
'message' => $e->getMessage(),
),
'log'
@@ -115,6 +155,11 @@ public function download_by_chunks() {
return false;
}
+ self::send_message( array(
+ 'state' => self::STATE_DONE,
+ 'message' => esc_html__( 'Your download is being generated …', 'backwpup' ),
+ ) );
+
return true;
}
diff --git a/inc/class-destination-email.php b/inc/class-destination-email.php
index 373367112..d46f85c54 100644
--- a/inc/class-destination-email.php
+++ b/inc/class-destination-email.php
@@ -3,6 +3,8 @@
// http://swiftmailer.org/
// https://github.com/swiftmailer/swiftmailer
+use Inpsyde\BackWPup\Helper;
+
/**
*
*/
@@ -334,7 +336,7 @@ public function job_run_archive( BackWPup_Job $job_object ) {
$message->setFrom( array( $job_object->job['emailsndemail'] => $job_object->job['emailsndemailname'] ) );
$message->setTo( $this->get_email_array( $job_object->job['emailaddress'] ) );
$message->setBody( sprintf( __( 'Backup archive: %s', 'backwpup' ), $job_object->backup_file ), 'text/plain', strtolower( get_bloginfo( 'charset' ) ) );
- $message->attach( Swift_Attachment::fromPath( $job_object->backup_folder . $job_object->backup_file, $job_object->get_mime_type( $job_object->backup_folder . $job_object->backup_file ) ) );
+ $message->attach( Swift_Attachment::fromPath( $job_object->backup_folder . $job_object->backup_file, Helper\MimeType::from_file_path( $job_object->backup_folder . $job_object->backup_file ) ) );
// Send the message
$result = $emailer->send( $message );
} catch ( Exception $e ) {
diff --git a/inc/class-destination-factory.php b/inc/class-destination-factory.php
deleted file mode 100644
index ee532d26a..000000000
--- a/inc/class-destination-factory.php
+++ /dev/null
@@ -1,78 +0,0 @@
-destination = $destination;
- }
-
- /**
- * Create
- *
- * Creates the specified destination object
- *
- * @return BackWPup_Destinations
- */
- public function create() {
-
- // Build the class name.
- $class = self::$prefix . $this->destination;
-
- // If class doesn't exists, try within the Pro directory.
- if ( ! class_exists( $class ) ) {
- $class = str_replace( self::$prefix, self::$pro_prefix, $class );
- }
-
- if ( ! class_exists( $class ) ) {
- throw new BackWPup_Factory_Exception(
- sprintf(
- 'No way to instantiate class %s. Class doesn\'t exists.',
- $class
- )
- );
- }
-
- return new $class();
- }
-}
diff --git a/inc/class-destination-folder.php b/inc/class-destination-folder.php
index e11283759..b11685279 100644
--- a/inc/class-destination-folder.php
+++ b/inc/class-destination-folder.php
@@ -10,10 +10,12 @@ class BackWPup_Destination_Folder extends BackWPup_Destinations {
*/
public function option_defaults() {
- $upload_dir = wp_upload_dir( null, false, true );
- $backups_dir = trailingslashit( str_replace( '\\', '/', $upload_dir['basedir'] ) ) . 'backwpup-' . BackWPup::get_plugin_data( 'hash' ) . '-backups/';
+ $upload_dir = wp_upload_dir( null, false, true );
+ $backups_dir = trailingslashit( str_replace( '\\',
+ '/',
+ $upload_dir['basedir'] ) ) . 'backwpup-' . BackWPup::get_plugin_data( 'hash' ) . '-backups/';
$content_path = trailingslashit( str_replace( '\\', '/', WP_CONTENT_DIR ) );
- $backups_dir = str_replace( $content_path, '', $backups_dir );
+ $backups_dir = str_replace( $content_path, '', $backups_dir );
return array( 'maxbackups' => 15, 'backupdir' => $backups_dir, 'backupsyncnodelete' => true );
}
@@ -25,38 +27,64 @@ public function edit_tab( $jobid ) {
?>
-
@@ -68,13 +96,13 @@ class="small-text"/>
*/
public function edit_form_post_save( $jobid ) {
- $_POST['backupdir'] = trailingslashit( str_replace( array(
- '//',
- '\\',
- ), '/', trim( sanitize_text_field( $_POST['backupdir'] ) ) ) );
- BackWPup_Option::update( $jobid, 'backupdir', $_POST['backupdir'] );
+ $to_replace = array( '//', '\\' );
+ $backup_dir = trim( sanitize_text_field( $_POST['backupdir'] ) );
+ $_POST['backupdir'] = trailingslashit( str_replace( $to_replace, '/', $backup_dir ) );
+ $max_backups = isset( $_POST['maxbackups'] ) ? absint( $_POST['maxbackups'] ) : 0;
- BackWPup_Option::update( $jobid, 'maxbackups', ! empty( $_POST['maxbackups'] ) ? absint( $_POST['maxbackups'] ) : 0 );
+ BackWPup_Option::update( $jobid, 'backupdir', $_POST['backupdir'] );
+ BackWPup_Option::update( $jobid, 'maxbackups', $max_backups );
BackWPup_Option::update( $jobid, 'backupsyncnodelete', ! empty( $_POST['backupsyncnodelete'] ) );
}
@@ -106,10 +134,10 @@ public function file_get_list( $jobdest ) {
list( $jobid, $dest ) = explode( '_', $jobdest, 2 );
- $filecounter = 0;
- $files = array();
- $backup_folder = BackWPup_Option::get( $jobid, 'backupdir' );
- $backup_folder = BackWPup_File::get_absolute_path( $backup_folder );
+ $filecounter = 0;
+ $files = array();
+ $backup_folder = BackWPup_Option::get( $jobid, 'backupdir' );
+ $backup_folder = BackWPup_File::get_absolute_path( $backup_folder );
$not_allowed_files = array(
'index.php',
'.htaccess',
@@ -121,29 +149,32 @@ public function file_get_list( $jobdest ) {
$dir = new BackWPup_Directory( $backup_folder );
foreach ( $dir as $file ) {
- if ( $file->isDot()
- || in_array( $file->getFilename(), $not_allowed_files, true )
- || $file->isDir()
- || $file->isLink()
+ if (
+ $file->isDot()
+ || $file->isDir()
+ || $file->isLink()
+ || in_array( $file->getFilename(), $not_allowed_files, true )
) {
continue;
}
if ( $file->isReadable() ) {
//file list for backups
- $files[ $filecounter ]['folder'] = $backup_folder;
- $files[ $filecounter ]['file'] = str_replace( '\\', '/', $file->getPathname() );
- $files[ $filecounter ]['filename'] = $file->getFilename();
- $files[ $filecounter ]['downloadurl'] = add_query_arg( array(
- 'page' => 'backwpupbackups',
- 'action' => 'downloadfolder',
- 'file' => $file->getFilename(),
- 'local_file' => $file->getFilename(),
- 'jobid' => $jobid,
- ),
- network_admin_url( 'admin.php' ) );
- $files[ $filecounter ]['filesize'] = $file->getSize();
- $files[ $filecounter ]['time'] = $file->getMTime() + ( get_option( 'gmt_offset' ) * 3600 );
+ $files[ $filecounter ]['folder'] = $backup_folder;
+ $files[ $filecounter ]['file'] = str_replace( '\\', '/', $file->getPathname() );
+ $files[ $filecounter ]['filename'] = $file->getFilename();
+ $files[ $filecounter ]['downloadurl'] = add_query_arg(
+ array(
+ 'page' => 'backwpupbackups',
+ 'action' => 'downloadfolder',
+ 'file' => $file->getFilename(),
+ 'local_file' => $file->getFilename(),
+ 'jobid' => $jobid,
+ ),
+ network_admin_url( 'admin.php' )
+ );
+ $files[ $filecounter ]['filesize'] = $file->getSize();
+ $files[ $filecounter ]['time'] = $file->getMTime() + ( get_option( 'gmt_offset' ) * 3600 );
$filecounter ++;
}
}
@@ -164,35 +195,45 @@ public function job_run_archive( BackWPup_Job $job_object ) {
BackWPup_Option::update(
$job_object->job['jobid'],
'lastbackupdownloadurl',
- add_query_arg( array(
- 'page' => 'backwpupbackups',
- 'action' => 'downloadfolder',
- 'file' => basename( $job_object->backup_file ),
- 'jobid' => $job_object->job['jobid'],
- ),
- network_admin_url( 'admin.php' ) ) );
+ add_query_arg(
+ array(
+ 'page' => 'backwpupbackups',
+ 'action' => 'downloadfolder',
+ 'file' => basename( $job_object->backup_file ),
+ 'jobid' => $job_object->job['jobid'],
+ ),
+ network_admin_url( 'admin.php' )
+ )
+ );
}
// Delete old Backupfiles.
$backupfilelist = array();
- $files = array();
+ $files = array();
if ( is_writable( $job_object->backup_folder ) ) { //make file list
try {
$dir = new BackWPup_Directory( $job_object->backup_folder );
foreach ( $dir as $file ) {
- if ( $file->isWritable() && ! $file->isDir() && ! $file->isLink() ) {
- //list for deletion
- if ( $this->is_backup_archive( $file->getFilename() )
- && $this->is_backup_owned_by_job( $file->getFilename(), $job_object->job['jobid'] )
- ) {
- $backupfilelist[ $file->getMTime() ] = clone $file;
- }
+ if ( $file->isDot() || $file->isDir() || $file->isLink() || ! $file->isWritable() ) {
+ continue;
+ }
+
+ $is_backup_archive = $this->is_backup_archive( $file->getFilename() );
+ $is_owned_by_job = $this->is_backup_owned_by_job( $file->getFilename(), $job_object->job['jobid'] );
+ if ( $is_backup_archive && $is_owned_by_job ) {
+ $backupfilelist[ $file->getMTime() ] = clone $file;
}
}
} catch ( UnexpectedValueException $e ) {
- $job_object->log( sprintf( __( "Could not open path: %s", 'backwpup' ), $e->getMessage() ), E_USER_WARNING );
+ $job_object->log(
+ sprintf(
+ esc_html__( 'Could not open path: %s', 'backwpup' ),
+ $e->getMessage()
+ ),
+ E_USER_WARNING
+ );
}
}
@@ -207,7 +248,7 @@ public function job_run_archive( BackWPup_Job $job_object ) {
}
unlink( $file->getPathname() );
foreach ( $files as $key => $filedata ) {
- if ( $filedata['file'] == $file->getPathname() ) {
+ if ( $filedata['file'] === $file->getPathname() ) {
unset( $files[ $key ] );
}
}
@@ -218,7 +259,8 @@ public function job_run_archive( BackWPup_Job $job_object ) {
$job_object->log( sprintf(
_n( 'One backup file deleted', '%d backup files deleted', $numdeltefiles, 'backwpup' ),
$numdeltefiles
- ), E_USER_NOTICE );
+ ),
+ E_USER_NOTICE );
}
}
}
diff --git a/inc/class-destination-msazure.php b/inc/class-destination-msazure.php
index db2a298ad..beed250d8 100644
--- a/inc/class-destination-msazure.php
+++ b/inc/class-destination-msazure.php
@@ -3,6 +3,8 @@
// http://www.windowsazure.com/en-us/develop/php/
// https://github.com/WindowsAzure/azure-sdk-for-php
+use Inpsyde\BackWPup\Helper;
+
/**
* Documentation: http://www.windowsazure.com/en-us/develop/php/how-to-guides/blob-service/
*/
@@ -180,7 +182,7 @@ public function file_download( $jobid, $get_file, $local_file_path = null ) {
@set_time_limit( 300 );
nocache_headers();
header( 'Content-Description: File Transfer' );
- header( 'Content-Type: ' . BackWPup_Job::get_mime_type( $get_file ) );
+ header( 'Content-Type: ' . Helper\MimeType::from_file_path( $get_file ) );
header( 'Content-Disposition: attachment; filename="' . basename( $get_file ) . '"' );
header( 'Content-Transfer-Encoding: binary' );
header( 'Content-Length: ' . $blob->getProperties()->getContentLength() );
diff --git a/inc/class-destination-rsc.php b/inc/class-destination-rsc.php
index 164d35fca..c5cd7cd25 100644
--- a/inc/class-destination-rsc.php
+++ b/inc/class-destination-rsc.php
@@ -3,6 +3,8 @@
// http://www.rackspace.com/cloud/files/
// https://github.com/rackspace/php-opencloud
+use Inpsyde\BackWPup\Helper;
+
/**
*
*/
@@ -226,7 +228,7 @@ public function file_download( $jobid, $get_file, $local_file_path = null ) {
@set_time_limit( 300 );
nocache_headers();
header( 'Content-Description: File Transfer' );
- header( 'Content-Type: ' . BackWPup_Job::get_mime_type( $get_file ) );
+ header( 'Content-Type: ' . Helper\MimeType::from_file_path( $get_file ) );
header( 'Content-Disposition: attachment; filename="' . basename( $get_file ) . '"' );
header( 'Content-Transfer-Encoding: binary' );
header( 'Content-Length: ' . $backupfile->getContentLength() );
diff --git a/inc/class-destination-s3.php b/inc/class-destination-s3.php
index 58f458ada..dae4e5cce 100644
--- a/inc/class-destination-s3.php
+++ b/inc/class-destination-s3.php
@@ -4,6 +4,8 @@
// https://github.com/aws/aws-sdk-php
// http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region
+use Inpsyde\BackWPup\Helper;
+
/**
* Documentation: http://docs.amazonwebservices.com/aws-sdk-php-2/latest/class-Aws.S3.S3Client.html
*/
@@ -591,7 +593,6 @@ public function file_download( $jobid, $file_path, $local_file_path = null ) {
$downloader = new BackWpup_Download_Handler(
new BackWPup_Download_File(
$filename,
- mime_content_type( $filename ),
function ( \BackWPup_Download_File_Interface $obj ) use ( $self, $filename, $file_path, $job_id ) {
$base_url = $self->get_s3_base_url(
@@ -612,9 +613,9 @@ function ( \BackWPup_Download_File_Interface $obj ) use ( $self, $filename, $fil
},
$capability
),
- "download-backup_{$job_id}",
+ 'backwpup_action_nonce',
$capability,
- 'download_file'
+ 'download_backup_file'
);
// Download the file.
@@ -859,7 +860,7 @@ public function job_run_archive( BackWPup_Job $job_object ) {
$create_args['Body'] = $up_file_handle;
$create_args['Key'] = $job_object->job['s3dir'] . $job_object->backup_file;
- $create_args['ContentType'] = $job_object->get_mime_type( $job_object->backup_folder . $job_object->backup_file );
+ $create_args['ContentType'] = Helper\MimeType::from_file_path( $job_object->backup_folder . $job_object->backup_file );
try {
$s3->putObject( $create_args );
@@ -882,7 +883,7 @@ public function job_run_archive( BackWPup_Job $job_object ) {
$args = array(
'ACL' => 'private',
'Bucket' => $job_object->job['s3bucket'],
- 'ContentType' => $job_object->get_mime_type( $job_object->backup_folder . $job_object->backup_file ),
+ 'ContentType' => Helper\MimeType::from_file_path( $job_object->backup_folder . $job_object->backup_file ),
'Key' => $job_object->job['s3dir'] . $job_object->backup_file,
);
if ( ! empty( $job_object->job['s3ssencrypt'] ) ) {
diff --git a/inc/class-destination-sugarsync.php b/inc/class-destination-sugarsync.php
index 19e5596c7..3560d0b64 100644
--- a/inc/class-destination-sugarsync.php
+++ b/inc/class-destination-sugarsync.php
@@ -1,4 +1,7 @@
displayName ) );
+ header( 'Content-Type: ' . Helper\MimeType::from_file_path( (string) $response->displayName ) );
header( 'Content-Disposition: attachment; filename="' . (string) $response->displayName . '"' );
header( 'Content-Transfer-Encoding: binary' );
header( 'Content-Length: ' . (int) $response->size );
@@ -852,7 +855,7 @@ public function upload( $file, $name = '' ) {
$name = basename( $file );
}
- $content_type = BackWPup_Job::get_mime_type( $file );
+ $content_type = Helper\MimeType::from_file_path( $file );
$xmlrequest = '';
$xmlrequest .= '';
diff --git a/inc/class-destinations.php b/inc/class-destinations.php
index a88d3d6b5..671191f53 100644
--- a/inc/class-destinations.php
+++ b/inc/class-destinations.php
@@ -3,10 +3,8 @@
/**
* Base class for adding BackWPup destinations.
*
- * @package BackWPup
- * @subpackage BackWPup_Destinations
- * @since 3.0.0
- * @access private
+ * @package BackWPup
+ * @since 3.0.0
*/
abstract class BackWPup_Destinations {
@@ -117,18 +115,17 @@ public function file_delete( $jobdest, $backupfile ) {
public function file_download( $jobid, $file_path, $local_file_path = null ) {
$capability = 'backwpup_backups_download';
- $filename = untrailingslashit( BackWPup::get_plugin_data( 'temp' ) ) . '/' . basename( $local_file_path ?: $file_path );
- $job_id = filter_var( $_GET['jobid'], FILTER_SANITIZE_NUMBER_INT );
+ $filename = untrailingslashit( BackWPup::get_plugin_data( 'temp' ) ) . '/' . basename( $local_file_path ?: $file_path );
+ $job_id = filter_var( $_GET['jobid'], FILTER_SANITIZE_NUMBER_INT );
// Dynamically get downloader class
- $class_name = get_class( $this );
- $parts = explode( '_', $class_name );
+ $class_name = get_class( $this );
+ $parts = explode( '_', $class_name );
$destination = array_pop( $parts );
$downloader = new BackWpup_Download_Handler(
new BackWPup_Download_File(
$filename,
- mime_content_type( $filename ),
function ( \BackWPup_Download_File_Interface $obj ) use (
$filename,
$file_path,
@@ -137,7 +134,7 @@ function ( \BackWPup_Download_File_Interface $obj ) use (
) {
// Setup Destination service and download file.
- $factory = new BackWPup_Destination_Downloader_Factory();
+ $factory = new BackWPup_Destination_Downloader_Factory();
$downloader = $factory->create(
$destination,
$job_id,
@@ -149,9 +146,9 @@ function ( \BackWPup_Download_File_Interface $obj ) use (
},
$capability
),
- "download-backup_{$job_id}",
+ 'backwpup_action_nonce',
$capability,
- 'download_file'
+ 'download_backup_file'
);
// Download the file.
@@ -214,12 +211,11 @@ public function is_backup_archive( $file ) {
$extensions = array(
'.tar.gz',
- '.tar.bz2',
'.tar',
'.zip',
);
- $file = trim( basename( $file ) );
+ $file = trim( basename( $file ) );
$filename = '';
foreach ( $extensions as $extension ) {
@@ -254,7 +250,7 @@ public function is_backup_owned_by_job( $file, $jobid ) {
$data = array();
if ( substr( $file, 0, 8 ) == 'backwpup' ) {
$parts = explode( '_', $file );
- $data = BackWPup_Option::decode_hash( $parts[1] );
+ $data = BackWPup_Option::decode_hash( $parts[1] );
if ( ! $data ) {
return false;
}
diff --git a/inc/class-download-file-interface.php b/inc/class-download-file-interface.php
index e4b13dbaa..cf9c921d8 100644
--- a/inc/class-download-file-interface.php
+++ b/inc/class-download-file-interface.php
@@ -33,11 +33,4 @@ public function clean_ob();
* @return string The file path to download
*/
public function filepath();
-
- /**
- * Check File Name
- *
- * @return $this For concatenation
- */
- public function check_filename();
}
diff --git a/inc/class-download-file.php b/inc/class-download-file.php
index 9eb2fed98..2ea534ab0 100644
--- a/inc/class-download-file.php
+++ b/inc/class-download-file.php
@@ -1,16 +1,11 @@
type = $type;
$this->filepath = $filepath;
$this->filename = basename( $filepath );
$this->callback = $callback;
-
- // Calculate the length of the file.
$this->length = file_exists( $filepath ) ? filesize( $filepath ) : 0;
-
- // Set the capability.
$this->capability = $capability;
}
@@ -95,8 +84,7 @@ public function download() {
wp_die( 'Cheating Uh?' );
}
- $this->check_filename()
- ->perform_download_callback();
+ $this->perform_download_callback();
}
/**
@@ -106,7 +94,7 @@ public function clean_ob() {
$level = ob_get_level();
if ( $level ) {
- for ( $i = 0; $i < $level; $i++ ) {
+ for ( $i = 0; $i < $level; $i ++ ) {
ob_end_clean();
}
}
@@ -122,30 +110,16 @@ public function filepath() {
return $this->filepath;
}
- /**
- * @inheritdoc
- */
- public function check_filename() {
-
- // Sanitize filename, avoid wrong files.
- $filename = sanitize_file_name( basename( $this->filename ) );
-
- // Die if filename contains invalid characters.
- if ( $filename !== $this->filename ) {
- wp_die( esc_html__( 'Invalid file name, seems file include invalid characters.', 'backwpup' ) );
- }
-
- return $this;
- }
-
/**
* @inheritdoc
*/
public function headers() {
+ $mime = Helper\MimeType::from_file_path( $this->filepath );
+
$level = ob_get_level();
if ( $level ) {
- for ( $i = 0; $i < $level; $i++ ) {
+ for ( $i = 0; $i < $level; $i ++ ) {
ob_end_clean();
}
}
@@ -156,7 +130,7 @@ public function headers() {
// Set headers.
header( 'Content-Description: File Transfer' );
- header( "Content-Type: {$this->type}" );
+ header( "Content-Type: {$mime}" );
header( "Content-Disposition: attachment; filename={$this->filename}" );
header( 'Content-Transfer-Encoding: ' . self::$encoding );
header( "Content-Length: {$this->length}" );
diff --git a/inc/class-download-handler.php b/inc/class-download-handler.php
index aecd0f42a..5b8a9d9ec 100644
--- a/inc/class-download-handler.php
+++ b/inc/class-download-handler.php
@@ -36,17 +36,17 @@ class BackWpup_Download_Handler {
/**
* DownloadLogHandler constructor
*
- * @param \BackWPup_Download_File_Interface $downloader The instance used to download the file.
- * @param string $nonce_action The nonce to verify.
- * @param string $capability The capability needed to download the file.
- * @param string $action The action to perform.
+ * @param \BackWPup_Download_File_Interface $downloader The instance used to download the file.
+ * @param string $nonce_action The nonce to verify.
+ * @param string $capability The capability needed to download the file.
+ * @param string $action The action to perform.
*/
public function __construct( \BackWPup_Download_File_Interface $downloader, $nonce_action, $capability, $action ) {
- $this->downloader = $downloader;
+ $this->downloader = $downloader;
$this->nonce_action = $nonce_action;
- $this->capability = $capability;
- $this->action = $action;
+ $this->capability = $capability;
+ $this->action = $action;
}
/**
@@ -75,7 +75,7 @@ private function verify_request() {
return false;
}
- check_admin_referer( $this->nonce_action );
+ check_admin_referer( $this->nonce_action, $this->nonce_action );
if ( ! current_user_can( $this->capability ) ) {
wp_die( 'Cheating Uh?' );
diff --git a/inc/class-install.php b/inc/class-install.php
index 4d2ea12ac..1e7bfd2b5 100644
--- a/inc/class-install.php
+++ b/inc/class-install.php
@@ -65,11 +65,6 @@ public static function activate() {
wp_schedule_event( time(), 'twicedaily', 'backwpup_check_cleanup' );
}
- // Add schedule to update backend message
- if ( ! wp_next_scheduled( 'backwpup_update_message' ) ) {
- wp_schedule_event( time(), 'twicedaily', 'backwpup_update_message' );
- }
-
//add capabilities to administrator role
$role = get_role( 'administrator' );
if ( is_object( $role ) && method_exists( $role, 'add_cap' ) ) {
@@ -324,7 +319,6 @@ public static function deactivate() {
}
}
wp_clear_scheduled_hook( 'backwpup_check_cleanup' );
- wp_clear_scheduled_hook( 'backwpup_update_message' );
$activejobs = BackWPup_Option::get_job_ids( 'activetype', 'easycron' );
if ( ! empty( $activejobs ) ) {
diff --git a/inc/class-job.php b/inc/class-job.php
index f6d86b343..2edb0bfe3 100644
--- a/inc/class-job.php
+++ b/inc/class-job.php
@@ -5,6 +5,9 @@
*/
final class BackWPup_Job {
+ const ENCRYPTION_SYMMETRIC = 'symmetric';
+ const ENCRYPTION_ASYMMETRIC = 'asymmetric';
+
/**
* @var array of the job settings
*/
@@ -19,148 +22,120 @@ final class BackWPup_Job {
* @var string the logfile
*/
public $logfile = '';
-
/**
* @var array for temp values
*/
public $temp = array();
-
/**
* @var string Folder where is Backup files in
*/
public $backup_folder = '';
-
/**
* @var string the name of the Backup archive file
*/
public $backup_file = '';
-
/**
* @var int The size of the Backup archive file
*/
public $backup_filesize = 0;
-
/**
* @var int PID of script
*/
public $pid = 0;
-
/**
* @var float Timestamp of last update off .running file
*/
public $timestamp_last_update = 0;
-
/**
* @var int Number of warnings
*/
public $warnings = 0;
-
/**
* @var int Number of errors
*/
public $errors = 0;
-
/**
* @var string the last log notice message
*/
public $lastmsg = '';
-
/**
* @var string the last log error/waring message
*/
public $lasterrormsg = '';
-
/**
* @var array of steps to do
*/
public $steps_todo = array( 'CREATE' );
-
/**
* @var array of done steps
*/
public $steps_done = array();
-
/**
* @var array of steps data
*/
public $steps_data = array();
-
/**
* @var string working on step
*/
public $step_working = 'CREATE';
-
/**
* @var int Number of sub steps must do in step
*/
public $substeps_todo = 0;
-
/**
* @var int Number of sub steps done in step
*/
public $substeps_done = 0;
-
/**
* @var int Percent of steps done
*/
public $step_percent = 1;
-
/**
* @var int Percent of sub steps done
*/
public $substep_percent = 1;
-
/**
* @var array of files to additional to backup
*/
public $additional_files_to_backup = array();
-
/**
* @var array of files/folder to exclude from backup
*/
public $exclude_from_backup = array();
-
/**
* @var int count of affected files
*/
public $count_files = 0;
-
/**
* @var int count of affected file sizes
*/
public $count_files_size = 0;
-
/**
* @var int count of affected folders
*/
public $count_folder = 0;
-
/**
* If job aborted from user
*
* @var bool
*/
public $user_abort = false;
-
/**
* A uniqid ID uniqid('', true); to identify process
*
* @var string
*/
public $uniqid = '';
-
/**
* @var float Timestamp of script start
*/
private $timestamp_script_start = 0;
-
/**
* Stores data that will only used in a single run
*
* @var array
*/
private $run = array();
-
/**
* @var string logging level (normal|normal_untranslated|debug|debug_untranslated)
*/
@@ -184,17 +159,16 @@ public static function start_http( $starttype, $jobid = 0 ) {
add_filter( 'override_load_textdomain', '__return_true' );
$GLOBALS['l10n'] = array();
}
-
if ( $starttype !== 'restart' ) {
//check job id exists
- if ( $jobid !== BackWPup_Option::get( $jobid, 'jobid' ) ) {
+ if ( (int) $jobid !== (int) BackWPup_Option::get( $jobid, 'jobid' ) ) {
return false;
}
//check folders
- $log_folder = get_site_option( 'backwpup_cfg_logfolder' );
- $folder_message_log = BackWPup_File::check_folder( BackWPup_File::get_absolute_path( $log_folder ) );
+ $log_folder = get_site_option( 'backwpup_cfg_logfolder' );
+ $folder_message_log = BackWPup_File::check_folder( BackWPup_File::get_absolute_path( $log_folder ) );
$folder_message_temp = BackWPup_File::check_folder( BackWPup::get_plugin_data( 'TEMP' ), true );
if ( ! empty( $folder_message_log ) || ! empty( $folder_message_temp ) ) {
BackWPup_Admin::message( $folder_message_log, true );
@@ -274,8 +248,8 @@ public static function get_working_data() {
*
* This starts or restarts the job working
*
- * @param string $start_type Start types are 'runnow', 'runnowalt', 'cronrun', 'runext', 'runcli'
- * @param array|int $job_id The id of job of a job to start
+ * @param string $start_type Start types are 'runnow', 'runnowalt', 'cronrun', 'runext', 'runcli'
+ * @param array|int $job_id The id of job of a job to start
*/
private function create( $start_type, $job_id = 0 ) {
@@ -294,24 +268,23 @@ private function create( $start_type, $job_id = 0 ) {
}
$this->start_time = current_time( 'timestamp' );
- $this->lastmsg = __( 'Starting job', 'backwpup' );
+ $this->lastmsg = __( 'Starting job', 'backwpup' );
//set Logfile
- $log_folder = get_site_option( 'backwpup_cfg_logfolder' );
- $log_folder = BackWPup_File::get_absolute_path( $log_folder );
- $this->logfile = $log_folder . 'backwpup_log_' . BackWPup::get_plugin_data( 'hash' ) . '_' . date(
- 'Y-m-d_H-i-s', current_time( 'timestamp' )
- ) . '.html';
+ $log_folder = get_site_option( 'backwpup_cfg_logfolder' );
+ $log_folder = BackWPup_File::get_absolute_path( $log_folder );
+ $this->logfile = $log_folder . 'backwpup_log_' . BackWPup::get_plugin_data( 'hash' ) . '_' . date( 'Y-m-d_H-i-s',
+ current_time( 'timestamp' ) ) . '.html';
//write settings to job
BackWPup_Option::update( $this->job['jobid'], 'lastrun', $this->start_time );
BackWPup_Option::update( $this->job['jobid'], 'logfile', $this->logfile ); //Set current logfile
BackWPup_Option::update( $this->job['jobid'], 'lastbackupdownloadurl', '' );
//Set needed job values
$this->timestamp_last_update = microtime( true );
- $this->exclude_from_backup = explode( ',', trim( $this->job['fileexclude'] ) );
- $this->exclude_from_backup = array_unique( $this->exclude_from_backup );
+ $this->exclude_from_backup = explode( ',', trim( $this->job['fileexclude'] ) );
+ $this->exclude_from_backup = array_unique( $this->exclude_from_backup );
//setup job steps
$this->steps_data['CREATE']['CALLBACK'] = '';
- $this->steps_data['CREATE']['NAME'] = __( 'Job Start', 'backwpup' );
+ $this->steps_data['CREATE']['NAME'] = __( 'Job Start', 'backwpup' );
$this->steps_data['CREATE']['STEP_TRY'] = 0;
//ADD Job types file
/* @var $job_type_class BackWPup_JobTypes */
@@ -319,20 +292,20 @@ private function create( $start_type, $job_id = 0 ) {
if ( $job_types = BackWPup::get_job_types() ) {
foreach ( $job_types as $id => $job_type_class ) {
if ( in_array( $id, $this->job['type'], true ) && $job_type_class->creates_file() ) {
- $this->steps_todo[] = 'JOB_' . $id;
- $this->steps_data[ 'JOB_' . $id ]['NAME'] = $job_type_class->info['description'];
- $this->steps_data[ 'JOB_' . $id ]['STEP_TRY'] = 0;
+ $this->steps_todo[] = 'JOB_' . $id;
+ $this->steps_data[ 'JOB_' . $id ]['NAME'] = $job_type_class->info['description'];
+ $this->steps_data[ 'JOB_' . $id ]['STEP_TRY'] = 0;
$this->steps_data[ 'JOB_' . $id ]['SAVE_STEP_TRY'] = 0;
- $job_need_dest = true;
+ $job_need_dest = true;
}
}
}
//add destinations and create archive if a job where files to backup
if ( $job_need_dest ) {
//Create manifest file
- $this->steps_todo[] = 'CREATE_MANIFEST';
- $this->steps_data['CREATE_MANIFEST']['NAME'] = __( 'Creates manifest file', 'backwpup' );
- $this->steps_data['CREATE_MANIFEST']['STEP_TRY'] = 0;
+ $this->steps_todo[] = 'CREATE_MANIFEST';
+ $this->steps_data['CREATE_MANIFEST']['NAME'] = __( 'Creates manifest file', 'backwpup' );
+ $this->steps_data['CREATE_MANIFEST']['STEP_TRY'] = 0;
$this->steps_data['CREATE_MANIFEST']['SAVE_STEP_TRY'] = 0;
//Add archive creation and backup filename on backup type archive
if ( $this->job['backuptype'] == 'archive' ) {
@@ -341,7 +314,7 @@ private function create( $start_type, $job_id = 0 ) {
$this->backup_folder = $this->job['backupdir'];
//check backup folder
if ( ! empty( $this->backup_folder ) ) {
- $this->backup_folder = BackWPup_File::get_absolute_path( $this->backup_folder );
+ $this->backup_folder = BackWPup_File::get_absolute_path( $this->backup_folder );
$this->job['backupdir'] = $this->backup_folder;
}
}
@@ -352,15 +325,15 @@ private function create( $start_type, $job_id = 0 ) {
//Create backup archive full file name
$this->backup_file = $this->generate_filename( $this->job['archivename'], $this->job['archiveformat'] );
//add archive create
- $this->steps_todo[] = 'CREATE_ARCHIVE';
- $this->steps_data['CREATE_ARCHIVE']['NAME'] = __( 'Creates archive', 'backwpup' );
- $this->steps_data['CREATE_ARCHIVE']['STEP_TRY'] = 0;
+ $this->steps_todo[] = 'CREATE_ARCHIVE';
+ $this->steps_data['CREATE_ARCHIVE']['NAME'] = __( 'Creates archive', 'backwpup' );
+ $this->steps_data['CREATE_ARCHIVE']['STEP_TRY'] = 0;
$this->steps_data['CREATE_ARCHIVE']['SAVE_STEP_TRY'] = 0;
// Encrypt archive
if ( BackWPup_Option::get( $this->job['jobid'], 'archiveencryption' ) ) {
- $this->steps_todo[] = 'ENCRYPT_ARCHIVE';
- $this->steps_data['ENCRYPT_ARCHIVE']['NAME'] = __( 'Encrypts the archive', 'backwpup' );
- $this->steps_data['ENCRYPT_ARCHIVE']['STEP_TRY'] = 0;
+ $this->steps_todo[] = 'ENCRYPT_ARCHIVE';
+ $this->steps_data['ENCRYPT_ARCHIVE']['NAME'] = __( 'Encrypts the archive', 'backwpup' );
+ $this->steps_data['ENCRYPT_ARCHIVE']['STEP_TRY'] = 0;
$this->steps_data['ENCRYPT_ARCHIVE']['SAVE_STEP_TRY'] = 0;
}
}
@@ -374,15 +347,15 @@ private function create( $start_type, $job_id = 0 ) {
if ( $dest_class->can_run( $this->job ) ) {
if ( $this->job['backuptype'] == 'sync' ) {
if ( $dest['can_sync'] ) {
- $this->steps_todo[] = 'DEST_SYNC_' . $id;
- $this->steps_data[ 'DEST_SYNC_' . $id ]['NAME'] = $dest['info']['description'];
- $this->steps_data[ 'DEST_SYNC_' . $id ]['STEP_TRY'] = 0;
+ $this->steps_todo[] = 'DEST_SYNC_' . $id;
+ $this->steps_data[ 'DEST_SYNC_' . $id ]['NAME'] = $dest['info']['description'];
+ $this->steps_data[ 'DEST_SYNC_' . $id ]['STEP_TRY'] = 0;
$this->steps_data[ 'DEST_SYNC_' . $id ]['SAVE_STEP_TRY'] = 0;
}
} else {
- $this->steps_todo[] = 'DEST_' . $id;
- $this->steps_data[ 'DEST_' . $id ]['NAME'] = $dest['info']['description'];
- $this->steps_data[ 'DEST_' . $id ]['STEP_TRY'] = 0;
+ $this->steps_todo[] = 'DEST_' . $id;
+ $this->steps_data[ 'DEST_' . $id ]['NAME'] = $dest['info']['description'];
+ $this->steps_data[ 'DEST_' . $id ]['STEP_TRY'] = 0;
$this->steps_data[ 'DEST_' . $id ]['SAVE_STEP_TRY'] = 0;
}
}
@@ -392,77 +365,68 @@ private function create( $start_type, $job_id = 0 ) {
if ( $job_types = BackWPup::get_job_types() ) {
foreach ( $job_types as $id => $job_type_class ) {
if ( in_array( $id, $this->job['type'], true ) && ! $job_type_class->creates_file() ) {
- $this->steps_todo[] = 'JOB_' . $id;
- $this->steps_data[ 'JOB_' . $id ]['NAME'] = $job_type_class->info['description'];
- $this->steps_data[ 'JOB_' . $id ]['STEP_TRY'] = 0;
+ $this->steps_todo[] = 'JOB_' . $id;
+ $this->steps_data[ 'JOB_' . $id ]['NAME'] = $job_type_class->info['description'];
+ $this->steps_data[ 'JOB_' . $id ]['STEP_TRY'] = 0;
$this->steps_data[ 'JOB_' . $id ]['SAVE_STEP_TRY'] = 0;
}
}
}
- $this->steps_todo[] = 'END';
- $this->steps_data['END']['NAME'] = __( 'End of Job', 'backwpup' );
+ $this->steps_todo[] = 'END';
+ $this->steps_data['END']['NAME'] = __( 'End of Job', 'backwpup' );
$this->steps_data['END']['STEP_TRY'] = 1;
//must write working data
$this->write_running_file();
//set log level
$this->log_level = get_site_option( 'backwpup_cfg_loglevel', 'normal_translated' );
- if ( ! in_array(
- $this->log_level, array(
- 'normal_translated',
- 'normal',
- 'debug_translated',
- 'debug',
- ), true
- ) ) {
+ if ( ! in_array( $this->log_level,
+ array(
+ 'normal_translated',
+ 'normal',
+ 'debug_translated',
+ 'debug',
+ ),
+ true ) ) {
$this->log_level = 'normal_translated';
}
//create log file
- $head = '';
- $info = '';
- $head .= "" . PHP_EOL;
- $head .= "" . PHP_EOL;
- $head .= "" . PHP_EOL;
- $head .= " " . PHP_EOL;
- $head .= "" . sprintf(
- __( 'BackWPup log for %1$s from %2$s at %3$s', 'backwpup' ), $this->job['name'],
- date_i18n( get_option( 'date_format' ) ), date_i18n( get_option( 'time_format' ) )
- ) . " " . PHP_EOL;
- $head .= " " . PHP_EOL;
- $head .= " " . PHP_EOL;
- $head .= " " . PHP_EOL;
- $head .= " " . PHP_EOL;
- $head .= " " . PHP_EOL;
- $head .= " " . PHP_EOL;
- $head .= " " . PHP_EOL;
- $head .= str_pad( ' ', 100 ) . PHP_EOL;
- $head .= str_pad( ' ', 100 ) . PHP_EOL;
- $head .= " job['jobid'] . "\" />" . PHP_EOL;
- $head .= " job['name']
- ) . "\" />" . PHP_EOL;
- $head .= " job['type']
- ) . "\" />" . PHP_EOL;
- $head .= str_pad( ' ', 100 ) . PHP_EOL;
- $head .= str_pad( ' ', 100 ) . PHP_EOL;
- $head .= '' . PHP_EOL;
- $head .= '' . PHP_EOL;
- $info .= sprintf(
- _x(
- '[INFO] %1$s %2$s; A project of Inpsyde GmbH', 'Plugin name; Plugin Version; plugin url', 'backwpup'
- ), BackWPup::get_plugin_data( 'name' ), BackWPup::get_plugin_data( 'Version' ),
- __( 'http://backwpup.com', 'backwpup' )
- ) . ' ' . PHP_EOL;
- $info .= sprintf(
- _x( '[INFO] WordPress %1$s on %2$s', 'WordPress Version; Blog url', 'backwpup' ),
- BackWPup::get_plugin_data( 'wp_version' ), esc_attr( site_url( '/' ) )
- ) . ' ' . PHP_EOL;
- $level = __( 'Normal', 'backwpup' );
+ $head = '';
+ $info = '';
+ $head .= "" . PHP_EOL;
+ $head .= "" . PHP_EOL;
+ $head .= "" . PHP_EOL;
+ $head .= " " . PHP_EOL;
+ $head .= "" . sprintf( __( 'BackWPup log for %1$s from %2$s at %3$s', 'backwpup' ),
+ $this->job['name'],
+ date_i18n( get_option( 'date_format' ) ),
+ date_i18n( get_option( 'time_format' ) ) ) . " " . PHP_EOL;
+ $head .= " " . PHP_EOL;
+ $head .= " " . PHP_EOL;
+ $head .= " " . PHP_EOL;
+ $head .= " " . PHP_EOL;
+ $head .= " " . PHP_EOL;
+ $head .= " " . PHP_EOL;
+ $head .= " " . PHP_EOL;
+ $head .= str_pad( ' ', 100 ) . PHP_EOL;
+ $head .= str_pad( ' ', 100 ) . PHP_EOL;
+ $head .= " job['jobid'] . "\" />" . PHP_EOL;
+ $head .= " job['name'] ) . "\" />" . PHP_EOL;
+ $head .= " job['type'] ) . "\" />" . PHP_EOL;
+ $head .= str_pad( ' ', 100 ) . PHP_EOL;
+ $head .= str_pad( ' ', 100 ) . PHP_EOL;
+ $head .= '' . PHP_EOL;
+ $head .= '' . PHP_EOL;
+ $info .= sprintf( _x( '[INFO] %1$s %2$s; A project of Inpsyde GmbH',
+ 'Plugin name; Plugin Version; plugin url',
+ 'backwpup' ),
+ BackWPup::get_plugin_data( 'name' ),
+ BackWPup::get_plugin_data( 'Version' ),
+ __( 'http://backwpup.com', 'backwpup' ) ) . ' ' . PHP_EOL;
+ $info .= sprintf( _x( '[INFO] WordPress %1$s on %2$s', 'WordPress Version; Blog url', 'backwpup' ),
+ BackWPup::get_plugin_data( 'wp_version' ),
+ esc_attr( site_url( '/' ) ) ) . ' ' . PHP_EOL;
+ $level = __( 'Normal', 'backwpup' );
$translated = '';
if ( $this->is_debug() ) {
$level = __( 'Debug', 'backwpup' );
@@ -470,9 +434,7 @@ private function create( $start_type, $job_id = 0 ) {
if ( is_textdomain_loaded( 'backwpup' ) ) {
$translated = __( '(translated)', 'backwpup' );
}
- $info .= sprintf(
- __( '[INFO] Log Level: %1$s %2$s', 'backwpup' ), $level, $translated
- ) . ' ' . PHP_EOL;
+ $info .= sprintf( __( '[INFO] Log Level: %1$s %2$s', 'backwpup' ), $level, $translated ) . ' ' . PHP_EOL;
$job_name = esc_attr( $this->job['name'] );
if ( $this->is_debug() ) {
$job_name .= '; ' . implode( '+', $this->job['type'] );
@@ -480,10 +442,9 @@ private function create( $start_type, $job_id = 0 ) {
$info .= sprintf( __( '[INFO] BackWPup job: %1$s', 'backwpup' ), $job_name ) . ' ' . PHP_EOL;
if ( $this->is_debug() ) {
$current_user = wp_get_current_user();
- $info .= sprintf(
- __( '[INFO] Runs with user: %1$s (%2$d) ', 'backwpup' ), $current_user->user_login,
- $current_user->ID
- ) . ' ' . PHP_EOL;
+ $info .= sprintf( __( '[INFO] Runs with user: %1$s (%2$d) ', 'backwpup' ),
+ $current_user->user_login,
+ $current_user->ID ) . ' ' . PHP_EOL;
}
if ( $this->job['activetype'] === 'wpcron' ) {
//check next run
@@ -499,13 +460,13 @@ private function create( $start_type, $job_id = 0 ) {
if ( ! $cron_next ) {
$cron_next = __( 'Not scheduled!', 'backwpup' );
} else {
- $cron_next = date_i18n(
- 'D, j M Y @ H:i', $cron_next + ( get_option( 'gmt_offset' ) * 3600 ), true
- );
+ $cron_next = date_i18n( 'D, j M Y @ H:i',
+ $cron_next + ( get_option( 'gmt_offset' ) * 3600 ),
+ true );
}
- $info .= sprintf(
- __( '[INFO] Cron: %s; Next: %s ', 'backwpup' ), $this->job['cron'], $cron_next
- ) . ' ' . PHP_EOL;
+ $info .= sprintf( __( '[INFO] Cron: %s; Next: %s ', 'backwpup' ),
+ $this->job['cron'],
+ $cron_next ) . ' ' . PHP_EOL;
}
} elseif ( $this->job['activetype'] == 'link' && $this->is_debug() ) {
$info .= __( '[INFO] BackWPup job start with link is active', 'backwpup' ) . ' ' . PHP_EOL;
@@ -515,9 +476,9 @@ private function create( $start_type, $job_id = 0 ) {
if ( $this->is_debug() ) {
$cron_next = BackWPup_Cron::cron_next( $this->job['cron'] );
$cron_next = date_i18n( 'D, j M Y @ H:i', $cron_next + ( get_option( 'gmt_offset' ) * 3600 ), true );
- $info .= sprintf(
- __( '[INFO] Cron: %s; Next: %s ', 'backwpup' ), $this->job['cron'], $cron_next
- ) . ' ' . PHP_EOL;
+ $info .= sprintf( __( '[INFO] Cron: %s; Next: %s ', 'backwpup' ),
+ $this->job['cron'],
+ $cron_next ) . ' ' . PHP_EOL;
}
} elseif ( $this->is_debug() ) {
$info .= __( '[INFO] BackWPup no automatic job start configured', 'backwpup' ) . ' ' . PHP_EOL;
@@ -530,9 +491,8 @@ private function create( $start_type, $job_id = 0 ) {
} elseif ( $start_type == 'runext' ) {
$info .= __( '[INFO] BackWPup job started from external url', 'backwpup' ) . ' ' . PHP_EOL;
} elseif ( $start_type == 'runcli' ) {
- $info .= __(
- '[INFO] BackWPup job started form commandline interface', 'backwpup'
- ) . ' ' . PHP_EOL;
+ $info .= __( '[INFO] BackWPup job started form commandline interface',
+ 'backwpup' ) . ' ' . PHP_EOL;
}
$bit = '';
if ( PHP_INT_SIZE === 4 ) {
@@ -541,40 +501,31 @@ private function create( $start_type, $job_id = 0 ) {
if ( PHP_INT_SIZE === 8 ) {
$bit = ' (64bit)';
}
- $info .= __(
- '[INFO] PHP ver.:', 'backwpup'
- ) . ' ' . PHP_VERSION . $bit . '; ' . PHP_SAPI . '; ' . PHP_OS . ' ' . PHP_EOL;
- $info .= sprintf(
- __( '[INFO] Maximum PHP script execution time is %1$d seconds', 'backwpup' ),
- ini_get( 'max_execution_time' )
- ) . ' ' . PHP_EOL;
+ $info .= __( '[INFO] PHP ver.:',
+ 'backwpup' ) . ' ' . PHP_VERSION . $bit . '; ' . PHP_SAPI . '; ' . PHP_OS . ' ' . PHP_EOL;
+ $info .= sprintf( __( '[INFO] Maximum PHP script execution time is %1$d seconds', 'backwpup' ),
+ ini_get( 'max_execution_time' ) ) . ' ' . PHP_EOL;
if ( php_sapi_name() != 'cli' ) {
$job_max_execution_time = get_site_option( 'backwpup_cfg_jobmaxexecutiontime' );
if ( ! empty( $job_max_execution_time ) ) {
- $info .= sprintf(
- __( '[INFO] Script restart time is configured to %1$d seconds', 'backwpup' ),
- $job_max_execution_time
- ) . ' ' . PHP_EOL;
+ $info .= sprintf( __( '[INFO] Script restart time is configured to %1$d seconds', 'backwpup' ),
+ $job_max_execution_time ) . ' ' . PHP_EOL;
}
}
- $info .= sprintf(
- __( '[INFO] MySQL ver.: %s', 'backwpup' ), $wpdb->get_var( "SELECT VERSION() AS version" )
- ) . ' ' . PHP_EOL;
+ $info .= sprintf( __( '[INFO] MySQL ver.: %s', 'backwpup' ),
+ $wpdb->get_var( "SELECT VERSION() AS version" ) ) . ' ' . PHP_EOL;
if ( isset( $_SERVER['SERVER_SOFTWARE'] ) ) {
- $info .= sprintf(
- __( '[INFO] Web Server: %s', 'backwpup' ), $_SERVER['SERVER_SOFTWARE']
- ) . ' ' . PHP_EOL;
+ $info .= sprintf( __( '[INFO] Web Server: %s', 'backwpup' ),
+ $_SERVER['SERVER_SOFTWARE'] ) . ' ' . PHP_EOL;
}
if ( function_exists( 'curl_init' ) ) {
$curlversion = curl_version();
- $info .= sprintf(
- __( '[INFO] curl ver.: %1$s; %2$s', 'backwpup' ), $curlversion['version'],
- $curlversion['ssl_version']
- ) . ' ' . PHP_EOL;
+ $info .= sprintf( __( '[INFO] curl ver.: %1$s; %2$s', 'backwpup' ),
+ $curlversion['version'],
+ $curlversion['ssl_version'] ) . ' ' . PHP_EOL;
}
- $info .= sprintf(
- __( '[INFO] Temp folder is: %s', 'backwpup' ), BackWPup::get_plugin_data( 'TEMP' )
- ) . ' ' . PHP_EOL;
+ $info .= sprintf( __( '[INFO] Temp folder is: %s', 'backwpup' ),
+ BackWPup::get_plugin_data( 'TEMP' ) ) . ' ' . PHP_EOL;
}
if ( $this->is_debug() ) {
$logfile = $this->logfile;
@@ -590,9 +541,8 @@ private function create( $start_type, $job_id = 0 ) {
}
$info .= sprintf( __( '[INFO] Backup file is: %s', 'backwpup' ), $backupfile ) . ' ' . PHP_EOL;
} else {
- $info .= sprintf(
- __( '[INFO] Backup type is: %s', 'backwpup' ), $this->job['backuptype']
- ) . ' ' . PHP_EOL;
+ $info .= sprintf( __( '[INFO] Backup type is: %s', 'backwpup' ),
+ $this->job['backuptype'] ) . ' ' . PHP_EOL;
}
//output info on cli
if ( php_sapi_name() == 'cli' && defined( 'STDOUT' ) ) {
@@ -612,10 +562,9 @@ private function create( $start_type, $job_id = 0 ) {
}
}
if ( ! $desttest ) {
- $this->log(
- __( 'No destination correctly defined for backup! Please correct job settings.', 'backwpup' ),
- E_USER_ERROR
- );
+ $this->log( __( 'No destination correctly defined for backup! Please correct job settings.',
+ 'backwpup' ),
+ E_USER_ERROR );
$this->steps_todo = array( 'END' );
}
}
@@ -635,7 +584,7 @@ private function create( $start_type, $job_id = 0 ) {
/**
* @param $name
* @param string $suffix
- * @param bool $delete_temp_file
+ * @param bool $delete_temp_file
*
* @return string
*/
@@ -647,11 +596,7 @@ public function generate_filename( $name, $suffix = '', $delete_temp_file = true
$name = BackWPup_Option::substitute_date_vars( $name );
$name .= $suffix;
- if ( $delete_temp_file && is_writeable( BackWPup::get_plugin_data( 'TEMP' ) . $name )
- && ! is_dir(
- BackWPup::get_plugin_data( 'TEMP' ) . $name
- )
- && ! is_link( BackWPup::get_plugin_data( 'TEMP' ) . $name ) ) {
+ if ( $delete_temp_file && is_writeable( BackWPup::get_plugin_data( 'TEMP' ) . $name ) && ! is_dir( BackWPup::get_plugin_data( 'TEMP' ) . $name ) && ! is_link( BackWPup::get_plugin_data( 'TEMP' ) . $name ) ) {
unlink( BackWPup::get_plugin_data( 'TEMP' ) . $name );
}
@@ -710,7 +655,7 @@ public static function sanitize_file_name( $filename ) {
private function write_running_file() {
$clone = clone $this;
- $data = 'is_debug() ) {
if ( empty( $file ) || empty( $line ) ) {
$debug_info = debug_backtrace();
- $file = $debug_info[0]['file'];
- $line = $debug_info[0]['line'];
+ $file = $debug_info[0]['file'];
+ $line = $debug_info[0]['line'];
}
}
- $error = false;
+ $error = false;
$warning = false;
switch ( $type ) {
@@ -798,7 +742,7 @@ public function log( $message, $type = E_USER_NOTICE, $file = '', $line = 0 ) {
case E_COMPILE_ERROR:
case E_USER_ERROR:
$this->errors ++;
- $error = true;
+ $error = true;
$message = __( 'ERROR:', 'backwpup' ) . ' ' . $message;
break;
case 8192: //E_DEPRECATED comes with php 5.3
@@ -810,7 +754,7 @@ public function log( $message, $type = E_USER_NOTICE, $file = '', $line = 0 ) {
break;
case E_RECOVERABLE_ERROR:
$this->errors ++;
- $error = true;
+ $error = true;
$message = __( 'RECOVERABLE ERROR:', 'backwpup' ) . ' ' . $message;
break;
default:
@@ -834,49 +778,41 @@ public function log( $message, $type = E_USER_NOTICE, $file = '', $line = 0 ) {
}
WP_CLI::line( $output_message );
} elseif ( php_sapi_name() == 'cli' && defined( 'STDOUT' ) ) {
- $output_message = str_replace(
- array( '…', ' ' ), array(
- '...',
- ' ',
- ), esc_html( $message )
- ) . PHP_EOL;
+ $output_message = str_replace( array( '…', ' ' ),
+ array(
+ '...',
+ ' ',
+ ),
+ esc_html( $message ) ) . PHP_EOL;
fwrite( STDOUT, $output_message );
}
//timestamp for log file
$debug_info = '';
if ( $this->is_debug() ) {
- $debug_info = ' title="[Type: ' . $type . '|Line: ' . $line . '|File: ' . $in_file . '|Mem: ' . size_format(
- @memory_get_usage( true ), 2
- ) . '|Mem Max: ' . size_format( @memory_get_peak_usage( true ), 2 ) . '|Mem Limit: ' . ini_get(
- 'memory_limit'
- ) . '|PID: ' . self::get_pid() . ' | UniqID: ' . $this->uniqid . '|Queries: ' . get_num_queries(
- ) . ']"';
+ $debug_info = ' title="[Type: ' . $type . '|Line: ' . $line . '|File: ' . $in_file . '|Mem: ' . size_format( @memory_get_usage( true ),
+ 2 ) . '|Mem Max: ' . size_format( @memory_get_peak_usage( true ),
+ 2 ) . '|Mem Limit: ' . ini_get( 'memory_limit' ) . '|PID: ' . self::get_pid() . ' | UniqID: ' . $this->uniqid . '|Queries: ' . get_num_queries() . ']"';
}
- $timestamp = '[' . date(
- 'd-M-Y H:i:s', current_time( 'timestamp' )
- ) . '] ';
+ $timestamp = '[' . date( 'd-M-Y H:i:s',
+ current_time( 'timestamp' ) ) . '] ';
//set last Message
if ( $error ) {
- $output_message = '' . esc_html(
- $message
- ) . ' ';
+ $output_message = '' . esc_html( $message ) . ' ';
$this->lasterrormsg = $output_message;
} elseif ( $warning ) {
- $output_message = '' . esc_html(
- $message
- ) . ' ';
+ $output_message = '' . esc_html( $message ) . ' ';
$this->lasterrormsg = $output_message;
} else {
$output_message = esc_html( $message );
- $this->lastmsg = $output_message;
+ $this->lastmsg = $output_message;
}
//write log file
if ( $this->logfile ) {
- if ( ! file_put_contents(
- $this->logfile, $timestamp . $output_message . ' ' . PHP_EOL, FILE_APPEND
- ) ) {
+ if ( ! file_put_contents( $this->logfile,
+ $timestamp . $output_message . ' ' . PHP_EOL,
+ FILE_APPEND ) ) {
$this->logfile = '';
restore_error_handler();
trigger_error( esc_html( $message ), $type );
@@ -890,20 +826,16 @@ public function log( $message, $type = E_USER_NOTICE, $file = '', $line = 0 ) {
$line = fgets( $fd );
if ( $error && stripos( $line, ' ', 100
- ) . PHP_EOL
- );
+ fwrite( $fd,
+ str_pad( ' ',
+ 100 ) . PHP_EOL );
break;
}
if ( $warning && stripos( $line, ' ', 100
- ) . PHP_EOL
- );
+ fwrite( $fd,
+ str_pad( ' ',
+ 100 ) . PHP_EOL );
break;
}
$file_pos = ftell( $fd );
@@ -984,10 +916,7 @@ public function update_working_data( $must = false ) {
global $wpdb;
//to reduce server load
- if ( get_site_option( 'backwpup_cfg_jobwaittimems' ) > 0
- && get_site_option(
- 'backwpup_cfg_jobwaittimems'
- ) <= 500000 ) {
+ if ( get_site_option( 'backwpup_cfg_jobwaittimems' ) > 0 && get_site_option( 'backwpup_cfg_jobwaittimems' ) <= 500000 ) {
usleep( get_site_option( 'backwpup_cfg_jobwaittimems' ) );
}
@@ -1064,7 +993,7 @@ public function need_free_memory( $memneed ) {
*/
public static function convert_hr_to_bytes( $size ) {
- $size = strtolower( $size );
+ $size = strtolower( $size );
$bytes = (int) $size;
if ( strpos( $size, 'k' ) !== false ) {
$bytes = intval( $size ) * 1024;
@@ -1084,7 +1013,7 @@ public static function convert_hr_to_bytes( $size ) {
*/
private function end() {
- $this->step_working = 'END';
+ $this->step_working = 'END';
$this->substeps_todo = 1;
if ( ! file_exists( BackWPup::get_plugin_data( 'running_file' ) ) ) {
@@ -1094,16 +1023,14 @@ private function end() {
//delete old logs
if ( get_site_option( 'backwpup_cfg_maxlogs' ) ) {
$log_file_list = array();
- $log_folder = trailingslashit( dirname( $this->logfile ) );
+ $log_folder = trailingslashit( dirname( $this->logfile ) );
if ( is_readable( $log_folder ) ) { //make file list
try {
$dir = new BackWPup_Directory( $log_folder );
foreach ( $dir as $file ) {
- if ( ! $file->isDot() && strpos( $file->getFilename(), 'backwpup_log_' ) === 0
- && strpos(
- $file->getFilename(), '.html'
- ) !== false ) {
+ if ( ! $file->isDot() && strpos( $file->getFilename(),
+ 'backwpup_log_' ) === 0 && strpos( $file->getFilename(), '.html' ) !== false ) {
$log_file_list[ $file->getMTime() ] = clone $file;
}
}
@@ -1114,7 +1041,7 @@ private function end() {
if ( count( $log_file_list ) > 0 ) {
krsort( $log_file_list, SORT_NUMERIC );
$num_delete_files = 0;
- $i = - 1;
+ $i = - 1;
foreach ( $log_file_list as $log_file ) {
$i ++;
if ( $i < get_site_option( 'backwpup_cfg_maxlogs' ) ) {
@@ -1124,71 +1051,56 @@ private function end() {
$num_delete_files ++;
}
if ( $num_delete_files > 0 ) {
- $this->log(
- sprintf(
- _n( 'One old log deleted', '%d old logs deleted', $num_delete_files, 'backwpup' ),
- $num_delete_files
- )
- );
+ $this->log( sprintf( _n( 'One old log deleted',
+ '%d old logs deleted',
+ $num_delete_files,
+ 'backwpup' ),
+ $num_delete_files ) );
}
}
}
//Display job working time
if ( $this->errors > 0 ) {
- $this->log(
- sprintf(
- __(
- 'Job has ended with errors in %s seconds. You must resolve the errors for correct execution.',
- 'backwpup'
- ), current_time( 'timestamp' ) - $this->start_time
- ), E_USER_ERROR
- );
+ $this->log( sprintf( __( 'Job has ended with errors in %s seconds. You must resolve the errors for correct execution.',
+ 'backwpup' ),
+ current_time( 'timestamp' ) - $this->start_time ),
+ E_USER_ERROR );
} elseif ( $this->warnings > 0 ) {
- $this->log(
- sprintf(
- __(
- 'Job finished with warnings in %s seconds. Please resolve them for correct execution.',
- 'backwpup'
- ), current_time( 'timestamp' ) - $this->start_time
- ), E_USER_WARNING
- );
+ $this->log( sprintf( __( 'Job finished with warnings in %s seconds. Please resolve them for correct execution.',
+ 'backwpup' ),
+ current_time( 'timestamp' ) - $this->start_time ),
+ E_USER_WARNING );
} else {
- $this->log(
- sprintf( __( 'Job done in %s seconds.', 'backwpup' ), current_time( 'timestamp' ) - $this->start_time )
- );
+ $this->log( sprintf( __( 'Job done in %s seconds.', 'backwpup' ),
+ current_time( 'timestamp' ) - $this->start_time ) );
}
//Update job options
$this->job['lastruntime'] = current_time( 'timestamp' ) - $this->start_time;
BackWPup_Option::update( $this->job['jobid'], 'lastruntime', $this->job['lastruntime'] );
+
//write header info
if ( ! empty( $this->logfile ) ) {
if ( $fd = fopen( $this->logfile, 'r+' ) ) {
$filepos = ftell( $fd );
- $found = 0;
+ $found = 0;
while ( ! feof( $fd ) ) {
$line = fgets( $fd );
if ( stripos( $line, ' ',
- 100
- ) . PHP_EOL
- );
+ fwrite( $fd,
+ str_pad( ' ',
+ 100 ) . PHP_EOL );
$found ++;
}
if ( stripos( $line, ' ',
- 100
- ) . PHP_EOL
- );
+ fwrite( $fd,
+ str_pad( ' ',
+ 100 ) . PHP_EOL );
$found ++;
}
if ( $found >= 2 ) {
@@ -1217,29 +1129,29 @@ private function end() {
$status = __( 'ERROR', 'backwpup' );
}
- $subject = sprintf(
- __( '[%3$s] BackWPup log %1$s: %2$s', 'backwpup' ),
- date_i18n( 'd-M-Y H:i', $this->start_time, true ), esc_attr( $this->job['name'] ), $status
- );
- $headers = array();
+ $subject = sprintf( __( '[%3$s] BackWPup log %1$s: %2$s', 'backwpup' ),
+ date_i18n( 'd-M-Y H:i', $this->start_time, true ),
+ esc_attr( $this->job['name'] ),
+ $status );
+ $headers = array();
$headers[] = 'Content-Type: text/html; charset=' . get_bloginfo( 'charset' );
if ( $this->job['mailaddresssenderlog'] ) {
- $this->job['mailaddresssenderlog'] = str_replace(
- array( '<', '>' ), array(
- '<',
- '>',
- ), $this->job['mailaddresssenderlog']
- );
+ $this->job['mailaddresssenderlog'] = str_replace( array( '<', '>' ),
+ array(
+ '<',
+ '>',
+ ),
+ $this->job['mailaddresssenderlog'] );
$bracket_pos = strpos( $this->job['mailaddresssenderlog'], '<' );
- $at_pos = strpos( $this->job['mailaddresssenderlog'], '@' );
+ $at_pos = strpos( $this->job['mailaddresssenderlog'], '@' );
if ( $bracket_pos === false || $at_pos === false ) {
- $this->job['mailaddresssenderlog'] = str_replace(
- array(
- '<',
- '>',
- ), '', $this->job['mailaddresssenderlog']
- ) . ' <' . get_bloginfo( 'admin_email' ) . '>';
+ $this->job['mailaddresssenderlog'] = str_replace( array(
+ '<',
+ '>',
+ ),
+ '',
+ $this->job['mailaddresssenderlog'] ) . ' <' . get_bloginfo( 'admin_email' ) . '>';
}
$headers[] = 'From: ' . $this->job['mailaddresssenderlog'];
@@ -1250,7 +1162,7 @@ private function end() {
//set done
$this->substeps_done = 1;
- $this->steps_done[] = 'END';
+ $this->steps_done[] = 'END';
//clean up temp
self::clean_temp_folder();
@@ -1273,17 +1185,17 @@ private function end() {
*/
public static function clean_temp_folder() {
- $instance = new self();
- $temp_dir = BackWPup::get_plugin_data( 'TEMP' );
+ $instance = new self();
+ $temp_dir = BackWPup::get_plugin_data( 'TEMP' );
$do_not_delete_files = array( '.htaccess', 'nginx.conf', 'index.php', '.', '..', '.donotbackup' );
if ( is_writable( $temp_dir ) ) {
try {
$dir = new BackWPup_Directory( $temp_dir );
foreach ( $dir as $file ) {
- if ( in_array( $file->getFilename(), $do_not_delete_files, true )
- || $file->isDir()
- || $file->isLink() ) {
+ if ( in_array( $file->getFilename(),
+ $do_not_delete_files,
+ true ) || $file->isDir() || $file->isLink() ) {
continue;
}
if ( $file->isWritable() ) {
@@ -1345,7 +1257,7 @@ public function do_restart( $must = false ) {
}
//do things for a clean restart
- $this->pid = 0;
+ $this->pid = 0;
$this->uniqid = '';
$this->write_running_file();
remove_action( 'shutdown', array( $this, 'shutdown' ) );
@@ -1363,28 +1275,25 @@ public function do_restart( $must = false ) {
*
* @param string $starttype Start types are 'runnow', 'runnowlink', 'cronrun', 'runext', 'restart', 'restartalt',
* 'test'
- * @param int $jobid The id of job to start else 0
+ * @param int $jobid The id of job to start else 0
*
* @return array|object [url] is the job url [header] for auth header or object form wp_remote_get()
*/
public static function get_jobrun_url( $starttype, $jobid = 0 ) {
- $authentication = get_site_option(
- 'backwpup_cfg_authentication', array(
- 'method' => '',
- 'basic_user' => '',
- 'basic_password' => '',
- 'user_id' => 0,
- 'query_arg' => '',
- )
- );
- $url = site_url( 'wp-cron.php' );
- $header = array( 'Cache-Control' => 'no-cache' );
- $authurl = '';
- $query_args = array(
- '_nonce' => substr(
- wp_hash( wp_nonce_tick() . 'backwpup_job_run-' . $starttype, 'nonce' ), - 12, 10
- ),
+ $authentication = get_site_option( 'backwpup_cfg_authentication',
+ array(
+ 'method' => '',
+ 'basic_user' => '',
+ 'basic_password' => '',
+ 'user_id' => 0,
+ 'query_arg' => '',
+ ) );
+ $url = site_url( 'wp-cron.php' );
+ $header = array( 'Cache-Control' => 'no-cache' );
+ $authurl = '';
+ $query_args = array(
+ '_nonce' => substr( wp_hash( wp_nonce_tick() . 'backwpup_job_run-' . $starttype, 'nonce' ), - 12, 10 ),
'doing_wp_cron' => sprintf( '%.22F', microtime( true ) ),
);
@@ -1397,14 +1306,8 @@ public static function get_jobrun_url( $starttype, $jobid = 0 ) {
}
if ( ! empty( $authentication['basic_user'] ) && ! empty( $authentication['basic_password'] ) && $authentication['method'] == 'basic' ) {
- $header['Authorization'] = 'Basic ' . base64_encode(
- $authentication['basic_user'] . ':' . BackWPup_Encryption::decrypt(
- $authentication['basic_password']
- )
- );
- $authurl = urlencode( $authentication['basic_user'] ) . ':' . urlencode(
- BackWPup_Encryption::decrypt( $authentication['basic_password'] )
- ) . '@';
+ $header['Authorization'] = 'Basic ' . base64_encode( $authentication['basic_user'] . ':' . BackWPup_Encryption::decrypt( $authentication['basic_password'] ) );
+ $authurl = urlencode( $authentication['basic_user'] ) . ':' . urlencode( BackWPup_Encryption::decrypt( $authentication['basic_password'] ) ) . '@';
}
if ( ! empty( $authentication['query_arg'] ) && $authentication['method'] == 'query_arg' ) {
@@ -1412,7 +1315,7 @@ public static function get_jobrun_url( $starttype, $jobid = 0 ) {
}
if ( $starttype === 'runext' ) {
- $query_args['_nonce'] = get_site_option( 'backwpup_cfg_jobrunauthkey' );
+ $query_args['_nonce'] = get_site_option( 'backwpup_cfg_jobrunauthkey' );
$query_args['doing_wp_cron'] = null;
if ( ! empty( $authurl ) ) {
$url = str_replace( 'https://', 'https://' . $authurl, $url );
@@ -1421,26 +1324,24 @@ public static function get_jobrun_url( $starttype, $jobid = 0 ) {
}
if ( $starttype === 'runnowlink' && ( ! defined( 'ALTERNATE_WP_CRON' ) || ! ALTERNATE_WP_CRON ) ) {
- $url = wp_nonce_url(
- network_admin_url( 'admin.php' ), 'backwpup_job_run-' . $starttype
- );
- $query_args['page'] = 'backwpupjobs';
- $query_args['action'] = 'runnow';
+ $url = wp_nonce_url( network_admin_url( 'admin.php' ), 'backwpup_job_run-' . $starttype );
+ $query_args['page'] = 'backwpupjobs';
+ $query_args['action'] = 'runnow';
$query_args['doing_wp_cron'] = null;
unset( $query_args['_nonce'] );
}
if ( $starttype === 'runnowlink' && defined( 'ALTERNATE_WP_CRON' ) && ALTERNATE_WP_CRON ) {
- $query_args['backwpup_run'] = 'runnowalt';
- $query_args['_nonce'] = substr(
- wp_hash( wp_nonce_tick() . 'backwpup_job_run-runnowalt', 'nonce' ), - 12, 10
- );
+ $query_args['backwpup_run'] = 'runnowalt';
+ $query_args['_nonce'] = substr( wp_hash( wp_nonce_tick() . 'backwpup_job_run-runnowalt', 'nonce' ),
+ - 12,
+ 10 );
$query_args['doing_wp_cron'] = null;
}
if ( $starttype === 'restartalt' && defined( 'ALTERNATE_WP_CRON' ) && ALTERNATE_WP_CRON ) {
$query_args['backwpup_run'] = 'restart';
- $query_args['_nonce'] = null;
+ $query_args['_nonce'] = null;
}
if ( $starttype === 'restart' || $starttype === 'test' ) {
@@ -1456,12 +1357,13 @@ public static function get_jobrun_url( $starttype, $jobid = 0 ) {
$wp_admin_user = get_users( array( 'role' => 'backwpup_admin', 'number' => 1 ) );
}
if ( ! empty( $wp_admin_user[0]->ID ) ) {
- $expiration = time() + ( 2 * DAY_IN_SECONDS );
- $manager = WP_Session_Tokens::get_instance( $wp_admin_user[0]->ID );
- $token = $manager->create( $expiration );
- $cookies[ LOGGED_IN_COOKIE ] = wp_generate_auth_cookie(
- $wp_admin_user[0]->ID, $expiration, 'logged_in', $token
- );
+ $expiration = time() + ( 2 * DAY_IN_SECONDS );
+ $manager = WP_Session_Tokens::get_instance( $wp_admin_user[0]->ID );
+ $token = $manager->create( $expiration );
+ $cookies[ LOGGED_IN_COOKIE ] = wp_generate_auth_cookie( $wp_admin_user[0]->ID,
+ $expiration,
+ 'logged_in',
+ $token );
}
set_site_transient( 'backwpup_cookies', $cookies, 2 * DAY_IN_SECONDS );
}
@@ -1470,13 +1372,13 @@ public static function get_jobrun_url( $starttype, $jobid = 0 ) {
}
$cron_request = array(
- 'url' => add_query_arg( $query_args, $url ),
- 'key' => $query_args['doing_wp_cron'],
+ 'url' => add_query_arg( $query_args, $url ),
+ 'key' => $query_args['doing_wp_cron'],
'args' => array(
- 'blocking' => false,
- 'sslverify' => false,
- 'timeout' => 0.01,
- 'headers' => $header,
+ 'blocking' => false,
+ 'sslverify' => false,
+ 'timeout' => 0.01,
+ 'headers' => $header,
'user-agent' => BackWPup::get_plugin_data( 'User-Agent' ),
),
);
@@ -1490,7 +1392,7 @@ public static function get_jobrun_url( $starttype, $jobid = 0 ) {
$cron_request = apply_filters( 'cron_request', $cron_request );
if ( $starttype === 'test' ) {
- $cron_request['args']['timeout'] = 15;
+ $cron_request['args']['timeout'] = 15;
$cron_request['args']['blocking'] = true;
}
@@ -1538,7 +1440,7 @@ public function run() {
// set timestamp of script start
$this->timestamp_script_start = microtime( true );
//set Pid
- $this->pid = self::get_pid();
+ $this->pid = self::get_pid();
$this->uniqid = uniqid( '', true );
//Early write new working file
$this->write_running_file();
@@ -1622,20 +1524,17 @@ public function run() {
}
//calc step percent
if ( count( $this->steps_done ) > 0 ) {
- $this->step_percent = min(
- round( count( $this->steps_done ) / count( $this->steps_todo ) * 100 ), 100
- );
+ $this->step_percent = min( round( count( $this->steps_done ) / count( $this->steps_todo ) * 100 ),
+ 100 );
} else {
$this->step_percent = 1;
}
// do step tries
while ( true ) {
- if ( $this->steps_data[ $this->step_working ]['STEP_TRY'] >= get_site_option(
- 'backwpup_cfg_jobstepretry'
- ) ) {
+ if ( $this->steps_data[ $this->step_working ]['STEP_TRY'] >= get_site_option( 'backwpup_cfg_jobstepretry' ) ) {
$this->log( __( 'Step aborted: too many attempts!', 'backwpup' ), E_USER_ERROR );
- $this->temp = array();
- $this->steps_done[] = $this->step_working;
+ $this->temp = array();
+ $this->steps_done[] = $this->step_working;
$this->substeps_done = 0;
$this->substeps_todo = 0;
$this->do_restart();
@@ -1659,18 +1558,18 @@ public function run() {
$done = $job_types[ str_replace( 'JOB_', '', $this->step_working ) ]->job_run( $this );
} elseif ( strstr( $this->step_working, 'DEST_SYNC_' ) ) {
$done = BackWPup::get_destination( str_replace( 'DEST_SYNC_', '', $this->step_working ) )
- ->job_run_sync( $this );
+ ->job_run_sync( $this );
} elseif ( strstr( $this->step_working, 'DEST_' ) ) {
$done = BackWPup::get_destination( str_replace( 'DEST_', '', $this->step_working ) )
- ->job_run_archive( $this );
+ ->job_run_archive( $this );
} elseif ( ! empty( $this->steps_data[ $this->step_working ]['CALLBACK'] ) ) {
$done = $this->steps_data[ $this->step_working ]['CALLBACK']( $this );
}
// set step as done
if ( $done === true ) {
- $this->temp = array();
- $this->steps_done[] = $this->step_working;
+ $this->temp = array();
+ $this->steps_done[] = $this->step_working;
$this->substeps_done = 0;
$this->substeps_todo = 0;
$this->update_working_data( true );
@@ -1703,20 +1602,14 @@ private function create_archive() {
$this->steps_data[ $this->step_working ]['on_folder'] = '';
}
- if ( $this->steps_data[ $this->step_working ]['on_folder'] == '' && $this->steps_data[ $this->step_working ]['on_file'] == ''
- && is_file(
- $this->backup_folder . $this->backup_file
- ) ) {
+ if ( $this->steps_data[ $this->step_working ]['on_folder'] == '' && $this->steps_data[ $this->step_working ]['on_file'] == '' && is_file( $this->backup_folder . $this->backup_file ) ) {
unlink( $this->backup_folder . $this->backup_file );
}
if ( $this->steps_data[ $this->step_working ]['SAVE_STEP_TRY'] != $this->steps_data[ $this->step_working ]['STEP_TRY'] ) {
- $this->log(
- sprintf(
- __( '%d. Trying to create backup archive …', 'backwpup' ),
- $this->steps_data[ $this->step_working ]['STEP_TRY']
- ), E_USER_NOTICE
- );
+ $this->log( sprintf( __( '%d. Trying to create backup archive …', 'backwpup' ),
+ $this->steps_data[ $this->step_working ]['STEP_TRY'] ),
+ E_USER_NOTICE );
}
try {
@@ -1724,20 +1617,15 @@ private function create_archive() {
//show method for creation
if ( $this->substeps_done == 0 ) {
- $this->log(
- sprintf(
- _x(
- 'Compressing files as %s. Please be patient, this may take a moment.',
- 'Archive compression method', 'backwpup'
- ), $backup_archive->get_method()
- )
- );
+ $this->log( sprintf( _x( 'Compressing files as %s. Please be patient, this may take a moment.',
+ 'Archive compression method',
+ 'backwpup' ),
+ $backup_archive->get_method() ) );
}
//add extra files
if ( $this->substeps_done == 0 ) {
if ( ! empty( $this->additional_files_to_backup ) && $this->substeps_done == 0 ) {
- $this->log( print_r( $this->additional_files_to_backup, true ) );
if ( $this->is_debug() ) {
$this->log( __( 'Adding Extra files to Archive', 'backwpup' ) );
}
@@ -1748,12 +1636,10 @@ private function create_archive() {
$this->update_working_data();
} else {
$backup_archive->close();
- $this->steps_data[ $this->step_working ]['on_file'] = '';
+ $this->steps_data[ $this->step_working ]['on_file'] = '';
$this->steps_data[ $this->step_working ]['on_folder'] = '';
- $this->log(
- __( 'Cannot create backup archive correctly. Aborting creation.', 'backwpup' ),
- E_USER_ERROR
- );
+ $this->log( __( 'Cannot create backup archive correctly. Aborting creation.', 'backwpup' ),
+ E_USER_ERROR );
return false;
}
@@ -1772,7 +1658,7 @@ private function create_archive() {
$this->log( sprintf( __( 'Archiving Folder: %s', 'backwpup' ), $folder ) );
}
$this->steps_data[ $this->step_working ]['on_folder'] = $folder;
- $files_in_folder = $this->get_files_in_folder( $folder );
+ $files_in_folder = $this->get_files_in_folder( $folder );
//add empty folders
if ( empty( $files_in_folder ) ) {
$folder_name_in_archive = trim( ltrim( $this->get_destination_path_replacement( $folder ), '/' ) );
@@ -1791,6 +1677,17 @@ private function create_archive() {
continue;
}
+ // Check if the file matches a filename in $this->additional_files_to_backup
+ // This prevents .sql files from being overwritten,
+ // as well as manifest.json, etc.
+ $alreadyAdded = count( array_filter( $this->additional_files_to_backup,
+ function ( $value ) use ( $file ) {
+
+ return strstr( $value, basename( $file ) );
+ } ) ) > 0;
+ if ( $alreadyAdded ) {
+ continue;
+ }
$this->steps_data[ $this->step_working ]['on_file'] = $file;
//restart if needed
$restart_time = $this->get_restart_time();
@@ -1810,18 +1707,15 @@ private function create_archive() {
} else {
$backup_archive->close();
unset( $backup_archive );
- $this->steps_data[ $this->step_working ]['on_file'] = '';
+ $this->steps_data[ $this->step_working ]['on_file'] = '';
$this->steps_data[ $this->step_working ]['on_folder'] = '';
- $this->substeps_done = 0;
- $this->backup_filesize = filesize(
- $this->backup_folder . $this->backup_file
- );
+ $this->substeps_done = 0;
+ $this->backup_filesize = filesize( $this->backup_folder . $this->backup_file );
if ( $this->backup_filesize === false ) {
$this->backup_filesize = PHP_INT_MAX;
}
- $this->log(
- __( 'Cannot create backup archive correctly. Aborting creation.', 'backwpup' ), E_USER_ERROR
- );
+ $this->log( __( 'Cannot create backup archive correctly. Aborting creation.', 'backwpup' ),
+ E_USER_ERROR );
return false;
}
@@ -1845,26 +1739,19 @@ private function create_archive() {
}
if ( $this->backup_filesize >= PHP_INT_MAX ) {
- $this->log(
- __(
- 'The Backup archive will be too large for file operations with this PHP Version. You might want to consider splitting the backup job in multiple jobs with less files each.',
- 'backwpup'
- ), E_USER_ERROR
- );
+ $this->log( __( 'The Backup archive will be too large for file operations with this PHP Version. You might want to consider splitting the backup job in multiple jobs with less files each.',
+ 'backwpup' ),
+ E_USER_ERROR );
$this->end();
} else {
- $this->log(
- sprintf( __( 'Archive size is %s.', 'backwpup' ), size_format( $this->backup_filesize, 2 ) ),
- E_USER_NOTICE
- );
+ $this->log( sprintf( __( 'Archive size is %s.', 'backwpup' ), size_format( $this->backup_filesize, 2 ) ),
+ E_USER_NOTICE );
}
- $this->log(
- sprintf(
- __( '%1$d Files with %2$s in Archive.', 'backwpup' ), $this->count_files,
- size_format( $this->count_files_size, 2 )
- ), E_USER_NOTICE
- );
+ $this->log( sprintf( __( '%1$d Files with %2$s in Archive.', 'backwpup' ),
+ $this->count_files,
+ size_format( $this->count_files_size, 2 ) ),
+ E_USER_NOTICE );
return true;
}
@@ -1878,8 +1765,9 @@ private function create_archive() {
*/
private function encrypt_archive() {
+ $encryptionType = get_site_option( 'backwpup_cfg_encryption' );
// Substeps is number of 128 KB chunks
- $block_size = 128 * 1024;
+ $block_size = 128 * 1024;
$this->substeps_todo = ceil( $this->backup_filesize / $block_size );
if ( ! isset( $this->steps_data[ $this->step_working ]['encrypted_filename'] ) ) {
@@ -1890,14 +1778,16 @@ private function encrypt_archive() {
}
if ( ! isset( $this->steps_data[ $this->step_working ]['key'] ) ) {
- if ( get_site_option( 'backwpup_cfg_encryption' ) == 'symmetric' ) {
- $this->steps_data[ $this->step_working ]['key'] = pack(
- 'H*', get_site_option( 'backwpup_cfg_encryptionkey' )
- );
- } elseif ( get_site_option( 'backwpup_cfg_encryption' ) == 'asymmetric' ) {
- // Generate random symmetric key
- $this->steps_data[ $this->step_working ]['key'] = \phpseclib\Crypt\Random::string( 32 );
+ switch ( $encryptionType ) {
+ case self::ENCRYPTION_SYMMETRIC:
+ $key = get_site_option( 'backwpup_cfg_encryptionkey' );
+ $this->steps_data[ $this->step_working ]['key'] = pack( 'H*', $key );
+ break;
+ case self::ENCRYPTION_ASYMMETRIC:
+ $this->steps_data[ $this->step_working ]['key'] = \phpseclib\Crypt\Random::string( 32 );
+ break;
}
+
if ( empty( $this->steps_data[ $this->step_working ]['key'] ) ) {
$this->log( __( 'No encryption key was provided. Aborting encryption.', 'backwpup' ), E_USER_WARNING );
@@ -1907,12 +1797,9 @@ private function encrypt_archive() {
if ( $this->steps_data[ $this->step_working ]['SAVE_STEP_TRY'] != $this->steps_data[ $this->step_working ]['STEP_TRY'] ) {
// Show initial log message
- $this->log(
- sprintf(
- __( '%d. Trying to encrypt archive …', 'backwpup' ),
- $this->steps_data[ $this->step_working ]['STEP_TRY']
- ), E_USER_NOTICE
- );
+ $this->log( sprintf( __( '%d. Trying to encrypt archive …', 'backwpup' ),
+ $this->steps_data[ $this->step_working ]['STEP_TRY'] ),
+ E_USER_NOTICE );
}
$aes = new \phpseclib\Crypt\AES( \phpseclib\Crypt\AES::MODE_CBC );
@@ -1934,24 +1821,23 @@ private function encrypt_archive() {
return false;
}
- if ( $this->substeps_done == 0 ) {
- // First byte: 0 if symmetric, 1 otherwise
- if ( get_site_option( 'backwpup_cfg_encryption' ) == 'symmetric' ) {
- fwrite( $file_out, "\x00" );
- } elseif ( get_site_option( 'backwpup_cfg_encryption' ) == 'asymmetric' ) {
- fwrite( $file_out, "\x01" );
+ if ( $this->substeps_done === 0 ) {
+ switch ( $encryptionType ) {
+ case self::ENCRYPTION_SYMMETRIC:
+ fwrite( $file_out, "\x00" );
+ break;
+ case self::ENCRYPTION_ASYMMETRIC:
+ fwrite( $file_out, "\x01" );
- // Next, encode random symmetric key
- $rsa = new \phpseclib\Crypt\RSA();
- $rsa->loadKey( get_site_option( 'backwpup_cfg_publickey' ) );
- $key = $rsa->encrypt( $this->steps_data[ $this->step_working ]['key'] );
- $length = strlen( $key );
+ $rsa = new \phpseclib\Crypt\RSA();
+ $rsa->loadKey( get_site_option( 'backwpup_cfg_publickey' ) );
- // Second byte is the length of the encrypted symmetric key
- fwrite( $file_out, pack( 'H*', dechex( $length ) ) );
+ $key = $rsa->encrypt( $this->steps_data[ $this->step_working ]['key'] );
+ $length = strlen( $key );
- // Then write the encrypted symmetric key
- fwrite( $file_out, $key );
+ fwrite( $file_out, pack( 'H*', dechex( $length ) ) );
+ fwrite( $file_out, $key );
+ break;
}
}
@@ -1964,7 +1850,7 @@ private function encrypt_archive() {
$length = strlen( $data );
if ( $this->substeps_done == $this->substeps_todo - 1 ) {
// Pad as necessary
- $pad = 16 - ( $length % 16 );
+ $pad = 16 - ( $length % 16 );
$data = str_pad( $data, $length + $pad, chr( $pad ) );
}
fwrite( $file_out, $aes->encrypt( $data ) );
@@ -1987,9 +1873,8 @@ private function encrypt_archive() {
fclose( $file_in );
fclose( $file_out );
- $this->log(
- sprintf( __( 'Encrypted %s of data.', 'backwpup' ), size_format( $bytes_read, 2 ) ), E_USER_NOTICE
- );
+ $this->log( sprintf( __( 'Encrypted %s of data.', 'backwpup' ), size_format( $bytes_read, 2 ) ),
+ E_USER_NOTICE );
// Remove the original file then rename the encrypted file
if ( ! unlink( $this->backup_folder . $this->backup_file ) ) {
@@ -1997,9 +1882,8 @@ private function encrypt_archive() {
return false;
}
- if ( ! rename(
- $this->steps_data[ $this->step_working ]['encrypted_filename'], $this->backup_folder . $this->backup_file
- ) ) {
+ if ( ! rename( $this->steps_data[ $this->step_working ]['encrypted_filename'],
+ $this->backup_folder . $this->backup_file ) ) {
$this->log( __( 'Unable to rename encrypted archive.', 'backwpup' ) );
return false;
@@ -2051,21 +1935,19 @@ public function get_folders_to_backup() {
*/
public function get_files_in_folder( $folder ) {
- $files = array();
+ $files = array();
$folder = trailingslashit( $folder );
if ( ! is_dir( $folder ) ) {
- $this->log(
- sprintf( _x( 'Folder %s does not exist', 'Folder name', 'backwpup' ), $folder ), E_USER_WARNING
- );
+ $this->log( sprintf( _x( 'Folder %s does not exist', 'Folder name', 'backwpup' ), $folder ),
+ E_USER_WARNING );
return $files;
}
if ( ! is_readable( $folder ) ) {
- $this->log(
- sprintf( _x( 'Folder %s is not readable', 'Folder name', 'backwpup' ), $folder ), E_USER_WARNING
- );
+ $this->log( sprintf( _x( 'Folder %s is not readable', 'Folder name', 'backwpup' ), $folder ),
+ E_USER_WARNING );
return $files;
}
@@ -2084,32 +1966,24 @@ public function get_files_in_folder( $folder ) {
continue 2;
}
}
- if ( $this->job['backupexcludethumbs']
- && strpos(
- $folder, BackWPup_File::get_upload_dir()
- ) !== false
- && preg_match( "/\-[0-9]{1,4}x[0-9]{1,4}.+\.(jpg|png|gif)$/i", $file->getFilename() ) ) {
+ if ( $this->job['backupexcludethumbs'] && strpos( $folder,
+ BackWPup_File::get_upload_dir() ) !== false && preg_match( "/\-[0-9]{1,4}x[0-9]{1,4}.+\.(jpg|png|gif)$/i",
+ $file->getFilename() ) ) {
continue;
}
if ( $file->isLink() ) {
- $this->log(
- sprintf( __( 'Link "%s" not following.', 'backwpup' ), $file->getPathname() ), E_USER_WARNING
- );
+ $this->log( sprintf( __( 'Link "%s" not following.', 'backwpup' ), $file->getPathname() ),
+ E_USER_WARNING );
} elseif ( ! $file->isReadable() ) {
- $this->log(
- sprintf( __( 'File "%s" is not readable!', 'backwpup' ), $file->getPathname() ), E_USER_WARNING
- );
+ $this->log( sprintf( __( 'File "%s" is not readable!', 'backwpup' ), $file->getPathname() ),
+ E_USER_WARNING );
} else {
$file_size = $file->getSize();
if ( ! is_int( $file_size ) || $file_size < 0 || $file_size > 2147483647 ) {
- $this->log(
- sprintf(
- __(
- 'File size of “%s” cannot be retrieved. File might be too large and will not be added to queue.',
- 'backwpup'
- ), $file->getPathname() . ' ' . $file_size
- ), E_USER_WARNING
- );
+ $this->log( sprintf( __( 'File size of “%s” cannot be retrieved. File might be too large and will not be added to queue.',
+ 'backwpup' ),
+ $file->getPathname() . ' ' . $file_size ),
+ E_USER_WARNING );
continue;
}
$files[] = BackWPup_Path_Fixer::slashify( realpath( $path ) );
@@ -2161,7 +2035,7 @@ public function do_restart_time( $do_restart_now = false ) {
//do restart after signal is send
if ( $this->signal !== 0 ) {
$this->steps_data[ $this->step_working ]['SAVE_STEP_TRY'] = $this->steps_data[ $this->step_working ]['STEP_TRY'];
- $this->steps_data[ $this->step_working ]['STEP_TRY'] -= 1;
+ $this->steps_data[ $this->step_working ]['STEP_TRY'] -= 1;
$this->do_restart( true );
}
@@ -2176,7 +2050,7 @@ public function do_restart_time( $do_restart_now = false ) {
// do restart 3 sec. before max. execution time
if ( $do_restart_now || $execution_time >= ( $job_max_execution_time - 3 ) ) {
$this->steps_data[ $this->step_working ]['SAVE_STEP_TRY'] = $this->steps_data[ $this->step_working ]['STEP_TRY'];
- $this->steps_data[ $this->step_working ]['STEP_TRY'] -= 1;
+ $this->steps_data[ $this->step_working ]['STEP_TRY'] -= 1;
$this->do_restart( true );
}
@@ -2192,37 +2066,33 @@ public function create_manifest() {
$this->substeps_todo = 3;
- $this->log(
- sprintf(
- __( '%d. Trying to generate a manifest file …', 'backwpup' ),
- $this->steps_data[ $this->step_working ]['STEP_TRY']
- )
- );
+ $this->log( sprintf( __( '%d. Trying to generate a manifest file …', 'backwpup' ),
+ $this->steps_data[ $this->step_working ]['STEP_TRY'] ) );
//build manifest
$manifest = array();
// add blog information
- $manifest['blog_info']['url'] = home_url();
- $manifest['blog_info']['wpurl'] = site_url();
- $manifest['blog_info']['prefix'] = $GLOBALS['wpdb']->prefix;
- $manifest['blog_info']['description'] = get_option( 'blogdescription' );
+ $manifest['blog_info']['url'] = home_url();
+ $manifest['blog_info']['wpurl'] = site_url();
+ $manifest['blog_info']['prefix'] = $GLOBALS['wpdb']->prefix;
+ $manifest['blog_info']['description'] = get_option( 'blogdescription' );
$manifest['blog_info']['stylesheet_directory'] = get_template_directory_uri();
- $manifest['blog_info']['activate_plugins'] = wp_get_active_and_valid_plugins();
- $manifest['blog_info']['activate_theme'] = wp_get_theme()->get( 'Name' );
- $manifest['blog_info']['admin_email'] = get_option( 'admin_email' );
- $manifest['blog_info']['charset'] = get_bloginfo( 'charset' );
- $manifest['blog_info']['version'] = BackWPup::get_plugin_data( 'wp_version' );
- $manifest['blog_info']['backwpup_version'] = BackWPup::get_plugin_data( 'version' );
- $manifest['blog_info']['language'] = get_bloginfo( 'language' );
- $manifest['blog_info']['name'] = get_bloginfo( 'name' );
- $manifest['blog_info']['abspath'] = ABSPATH;
- $manifest['blog_info']['uploads'] = wp_upload_dir( null, false, true );
- $manifest['blog_info']['contents']['basedir'] = WP_CONTENT_DIR;
- $manifest['blog_info']['contents']['baseurl'] = WP_CONTENT_URL;
- $manifest['blog_info']['plugins']['basedir'] = WP_PLUGIN_DIR;
- $manifest['blog_info']['plugins']['baseurl'] = WP_PLUGIN_URL;
- $manifest['blog_info']['themes']['basedir'] = get_theme_root();
- $manifest['blog_info']['themes']['baseurl'] = get_theme_root_uri();
+ $manifest['blog_info']['activate_plugins'] = wp_get_active_and_valid_plugins();
+ $manifest['blog_info']['activate_theme'] = wp_get_theme()->get( 'Name' );
+ $manifest['blog_info']['admin_email'] = get_option( 'admin_email' );
+ $manifest['blog_info']['charset'] = get_bloginfo( 'charset' );
+ $manifest['blog_info']['version'] = BackWPup::get_plugin_data( 'wp_version' );
+ $manifest['blog_info']['backwpup_version'] = BackWPup::get_plugin_data( 'version' );
+ $manifest['blog_info']['language'] = get_bloginfo( 'language' );
+ $manifest['blog_info']['name'] = get_bloginfo( 'name' );
+ $manifest['blog_info']['abspath'] = ABSPATH;
+ $manifest['blog_info']['uploads'] = wp_upload_dir( null, false, true );
+ $manifest['blog_info']['contents']['basedir'] = WP_CONTENT_DIR;
+ $manifest['blog_info']['contents']['baseurl'] = WP_CONTENT_URL;
+ $manifest['blog_info']['plugins']['basedir'] = WP_PLUGIN_DIR;
+ $manifest['blog_info']['plugins']['baseurl'] = WP_PLUGIN_URL;
+ $manifest['blog_info']['themes']['basedir'] = get_theme_root();
+ $manifest['blog_info']['themes']['baseurl'] = get_theme_root_uri();
// add job settings
$manifest['job_settings'] = $this->job;
// add archive info
@@ -2234,24 +2104,16 @@ public function create_manifest() {
$manifest['archive']['abspath'] = trailingslashit( $this->get_destination_path_replacement( ABSPATH ) );
}
if ( $this->job['backupuploads'] ) {
- $manifest['archive']['uploads'] = trailingslashit(
- $this->get_destination_path_replacement( BackWPup_File::get_upload_dir() )
- );
+ $manifest['archive']['uploads'] = trailingslashit( $this->get_destination_path_replacement( BackWPup_File::get_upload_dir() ) );
}
if ( $this->job['backupcontent'] ) {
- $manifest['archive']['contents'] = trailingslashit(
- $this->get_destination_path_replacement( WP_CONTENT_DIR )
- );
+ $manifest['archive']['contents'] = trailingslashit( $this->get_destination_path_replacement( WP_CONTENT_DIR ) );
}
if ( $this->job['backupplugins'] ) {
- $manifest['archive']['plugins'] = trailingslashit(
- $this->get_destination_path_replacement( WP_PLUGIN_DIR )
- );
+ $manifest['archive']['plugins'] = trailingslashit( $this->get_destination_path_replacement( WP_PLUGIN_DIR ) );
}
if ( $this->job['backupthemes'] ) {
- $manifest['archive']['themes'] = trailingslashit(
- $this->get_destination_path_replacement( get_theme_root() )
- );
+ $manifest['archive']['themes'] = trailingslashit( $this->get_destination_path_replacement( get_theme_root() ) );
}
}
@@ -2262,12 +2124,10 @@ public function create_manifest() {
//Create backwpup_readme.txt
$readme_text = __( 'You may have noticed the manifest.json file in this archive.', 'backwpup' ) . PHP_EOL;
- $readme_text .= __(
- 'manifest.json might be needed for later restoring a backup from this archive.', 'backwpup'
- ) . PHP_EOL;
- $readme_text .= __(
- 'Please leave manifest.json untouched and in place. Otherwise it is safe to be ignored.', 'backwpup'
- ) . PHP_EOL;
+ $readme_text .= __( 'manifest.json might be needed for later restoring a backup from this archive.',
+ 'backwpup' ) . PHP_EOL;
+ $readme_text .= __( 'Please leave manifest.json untouched and in place. Otherwise it is safe to be ignored.',
+ 'backwpup' ) . PHP_EOL;
if ( ! file_put_contents( BackWPup::get_plugin_data( 'TEMP' ) . 'backwpup_readme.txt', $readme_text ) ) {
return false;
}
@@ -2277,12 +2137,8 @@ public function create_manifest() {
if ( is_readable( BackWPup::get_plugin_data( 'TEMP' ) . 'manifest.json' ) ) {
$this->additional_files_to_backup[] = BackWPup::get_plugin_data( 'TEMP' ) . 'manifest.json';
$this->additional_files_to_backup[] = BackWPup::get_plugin_data( 'TEMP' ) . 'backwpup_readme.txt';
- $this->log(
- sprintf(
- __( 'Added manifest.json file with %1$s to backup file list.', 'backwpup' ),
- size_format( filesize( BackWPup::get_plugin_data( 'TEMP' ) . 'manifest.json' ), 2 )
- )
- );
+ $this->log( sprintf( __( 'Added manifest.json file with %1$s to backup file list.', 'backwpup' ),
+ size_format( filesize( BackWPup::get_plugin_data( 'TEMP' ) . 'manifest.json' ), 2 ) ) );
}
$this->substeps_done = 3;
@@ -2372,14 +2228,14 @@ public static function disable_caches() {
public static function read_logheader( $logfile ) {
$usedmetas = array(
- "date" => "logtime",
- "backwpup_logtime" => "logtime", //old value of date
- "backwpup_errors" => "errors",
- "backwpup_warnings" => "warnings",
- "backwpup_jobid" => "jobid",
- "backwpup_jobname" => "name",
- "backwpup_jobtype" => "type",
- "backwpup_jobruntime" => "runtime",
+ "date" => "logtime",
+ "backwpup_logtime" => "logtime", //old value of date
+ "backwpup_errors" => "errors",
+ "backwpup_warnings" => "warnings",
+ "backwpup_jobid" => "jobid",
+ "backwpup_jobname" => "name",
+ "backwpup_jobtype" => "type",
+ "backwpup_jobruntime" => "runtime",
"backwpup_backupfilesize" => "backupfilesize",
);
@@ -2424,7 +2280,7 @@ public static function user_abort() {
//if job not working currently abort it this way for message
$not_worked_time = microtime( true ) - $job_object->timestamp_last_update;
- $restart_time = get_site_option( 'backwpup_cfg_jobmaxexecutiontime' );
+ $restart_time = get_site_option( 'backwpup_cfg_jobmaxexecutiontime' );
if ( empty( $restart_time ) ) {
$restart_time = 60;
}
@@ -2435,226 +2291,6 @@ public static function user_abort() {
}
- /**
- *
- * Get the mime type of a file
- *
- * @param string $file The full file name
- *
- * @return bool|string the mime type or false
- */
- public static function get_mime_type( $file ) {
-
- if ( is_dir( $file ) || is_link( $file ) ) {
- return 'application/octet-stream';
- }
-
- $mime_types = array(
- 'zip' => 'application/zip',
- 'gz' => 'application/gzip',
- 'bz2' => 'application/x-bzip',
- 'tar' => 'application/x-tar',
- '3gp' => 'video/3gpp',
- 'ai' => 'application/postscript',
- 'aif' => 'audio/x-aiff',
- 'aifc' => 'audio/x-aiff',
- 'aiff' => 'audio/x-aiff',
- 'asc' => 'text/plain',
- 'atom' => 'application/atom+xml',
- 'au' => 'audio/basic',
- 'avi' => 'video/x-msvideo',
- 'bcpio' => 'application/x-bcpio',
- 'bin' => 'application/octet-stream',
- 'bmp' => 'image/bmp',
- 'cdf' => 'application/x-netcdf',
- 'cgm' => 'image/cgm',
- 'class' => 'application/octet-stream',
- 'cpio' => 'application/x-cpio',
- 'cpt' => 'application/mac-compactpro',
- 'csh' => 'application/x-csh',
- 'css' => 'text/css',
- 'dcr' => 'application/x-director',
- 'dif' => 'video/x-dv',
- 'dir' => 'application/x-director',
- 'djv' => 'image/vnd.djvu',
- 'djvu' => 'image/vnd.djvu',
- 'dll' => 'application/octet-stream',
- 'dmg' => 'application/octet-stream',
- 'dms' => 'application/octet-stream',
- 'doc' => 'application/msword',
- 'dtd' => 'application/xml-dtd',
- 'dv' => 'video/x-dv',
- 'dvi' => 'application/x-dvi',
- 'dxr' => 'application/x-director',
- 'eps' => 'application/postscript',
- 'etx' => 'text/x-setext',
- 'exe' => 'application/octet-stream',
- 'ez' => 'application/andrew-inset',
- 'flv' => 'video/x-flv',
- 'gif' => 'image/gif',
- 'gram' => 'application/srgs',
- 'grxml' => 'application/srgs+xml',
- 'gtar' => 'application/x-gtar',
- 'hdf' => 'application/x-hdf',
- 'hqx' => 'application/mac-binhex40',
- 'htm' => 'text/html',
- 'html' => 'text/html',
- 'ice' => 'x-conference/x-cooltalk',
- 'ico' => 'image/x-icon',
- 'ics' => 'text/calendar',
- 'ief' => 'image/ief',
- 'ifb' => 'text/calendar',
- 'iges' => 'model/iges',
- 'igs' => 'model/iges',
- 'jnlp' => 'application/x-java-jnlp-file',
- 'jp2' => 'image/jp2',
- 'jpe' => 'image/jpeg',
- 'jpeg' => 'image/jpeg',
- 'jpg' => 'image/jpeg',
- 'js' => 'application/x-javascript',
- 'kar' => 'audio/midi',
- 'latex' => 'application/x-latex',
- 'lha' => 'application/octet-stream',
- 'lzh' => 'application/octet-stream',
- 'm3u' => 'audio/x-mpegurl',
- 'm4a' => 'audio/mp4a-latm',
- 'm4p' => 'audio/mp4a-latm',
- 'm4u' => 'video/vnd.mpegurl',
- 'm4v' => 'video/x-m4v',
- 'mac' => 'image/x-macpaint',
- 'man' => 'application/x-troff-man',
- 'mathml' => 'application/mathml+xml',
- 'me' => 'application/x-troff-me',
- 'mesh' => 'model/mesh',
- 'mid' => 'audio/midi',
- 'midi' => 'audio/midi',
- 'mif' => 'application/vnd.mif',
- 'mov' => 'video/quicktime',
- 'movie' => 'video/x-sgi-movie',
- 'mp2' => 'audio/mpeg',
- 'mp3' => 'audio/mpeg',
- 'mp4' => 'video/mp4',
- 'mpe' => 'video/mpeg',
- 'mpeg' => 'video/mpeg',
- 'mpg' => 'video/mpeg',
- 'mpga' => 'audio/mpeg',
- 'ms' => 'application/x-troff-ms',
- 'msh' => 'model/mesh',
- 'mxu' => 'video/vnd.mpegurl',
- 'nc' => 'application/x-netcdf',
- 'oda' => 'application/oda',
- 'ogg' => 'application/ogg',
- 'ogv' => 'video/ogv',
- 'pbm' => 'image/x-portable-bitmap',
- 'pct' => 'image/pict',
- 'pdb' => 'chemical/x-pdb',
- 'pdf' => 'application/pdf',
- 'pgm' => 'image/x-portable-graymap',
- 'pgn' => 'application/x-chess-pgn',
- 'pic' => 'image/pict',
- 'pict' => 'image/pict',
- 'png' => 'image/png',
- 'pnm' => 'image/x-portable-anymap',
- 'pnt' => 'image/x-macpaint',
- 'pntg' => 'image/x-macpaint',
- 'ppm' => 'image/x-portable-pixmap',
- 'ppt' => 'application/vnd.ms-powerpoint',
- 'ps' => 'application/postscript',
- 'qt' => 'video/quicktime',
- 'qti' => 'image/x-quicktime',
- 'qtif' => 'image/x-quicktime',
- 'ra' => 'audio/x-pn-realaudio',
- 'ram' => 'audio/x-pn-realaudio',
- 'ras' => 'image/x-cmu-raster',
- 'rdf' => 'application/rdf+xml',
- 'rgb' => 'image/x-rgb',
- 'rm' => 'application/vnd.rn-realmedia',
- 'roff' => 'application/x-troff',
- 'rtf' => 'text/rtf',
- 'rtx' => 'text/richtext',
- 'sgm' => 'text/sgml',
- 'sgml' => 'text/sgml',
- 'sh' => 'application/x-sh',
- 'shar' => 'application/x-shar',
- 'silo' => 'model/mesh',
- 'sit' => 'application/x-stuffit',
- 'skd' => 'application/x-koan',
- 'skm' => 'application/x-koan',
- 'skp' => 'application/x-koan',
- 'skt' => 'application/x-koan',
- 'smi' => 'application/smil',
- 'smil' => 'application/smil',
- 'snd' => 'audio/basic',
- 'so' => 'application/octet-stream',
- 'spl' => 'application/x-futuresplash',
- 'src' => 'application/x-wais-source',
- 'sv4cpio' => 'application/x-sv4cpio',
- 'sv4crc' => 'application/x-sv4crc',
- 'svg' => 'image/svg+xml',
- 'swf' => 'application/x-shockwave-flash',
- 't' => 'application/x-troff',
- 'tcl' => 'application/x-tcl',
- 'tex' => 'application/x-tex',
- 'texi' => 'application/x-texinfo',
- 'texinfo' => 'application/x-texinfo',
- 'tif' => 'image/tiff',
- 'tiff' => 'image/tiff',
- 'tr' => 'application/x-troff',
- 'tsv' => 'text/tab-separated-values',
- 'txt' => 'text/plain',
- 'ustar' => 'application/x-ustar',
- 'vcd' => 'application/x-cdlink',
- 'vrml' => 'model/vrml',
- 'vxml' => 'application/voicexml+xml',
- 'wav' => 'audio/x-wav',
- 'wbmp' => 'image/vnd.wap.wbmp',
- 'wbxml' => 'application/vnd.wap.wbxml',
- 'webm' => 'video/webm',
- 'wml' => 'text/vnd.wap.wml',
- 'wmlc' => 'application/vnd.wap.wmlc',
- 'wmls' => 'text/vnd.wap.wmlscript',
- 'wmlsc' => 'application/vnd.wap.wmlscriptc',
- 'wmv' => 'video/x-ms-wmv',
- 'wrl' => 'model/vrml',
- 'xbm' => 'image/x-xbitmap',
- 'xht' => 'application/xhtml+xml',
- 'xhtml' => 'application/xhtml+xml',
- 'xls' => 'application/vnd.ms-excel',
- 'xml' => 'application/xml',
- 'xpm' => 'image/x-xpixmap',
- 'xsl' => 'application/xml',
- 'xslt' => 'application/xslt+xml',
- 'xul' => 'application/vnd.mozilla.xul+xml',
- 'xwd' => 'image/x-xwindowdump',
- 'xyz' => 'chemical/x-xyz',
- );
-
- $filesuffix = pathinfo( $file, PATHINFO_EXTENSION );
- $suffix = strtolower( $filesuffix );
- if ( isset( $mime_types[ $suffix ] ) ) {
- return $mime_types[ $suffix ];
- }
-
- if ( ! is_readable( $file ) ) {
- return 'application/octet-stream';
- }
-
- if ( function_exists( 'fileinfo' ) ) {
- $finfo = finfo_open( FILEINFO_MIME_TYPE );
- $mime = finfo_file( $finfo, $file );
- }
-
- if ( empty( $mime ) && function_exists( 'mime_content_type' ) ) {
- $mime = mime_content_type( $file );
- }
-
- if ( ! empty( $mime ) ) {
- return $mime;
- }
-
- return 'application/octet-stream';
- }
-
/**
* Check whether exec has been disabled.
*
@@ -2736,7 +2372,7 @@ public static function mysqldump_error_message( $dbdumpmysqlfolder ) {
public function __clone() {
$this->temp = array();
- $this->run = array();
+ $this->run = array();
}
/**
@@ -2748,134 +2384,116 @@ public function signal_handler( $signal_send ) {
//known signals
$signals = array(
- 'SIGHUP' => array(
- 'description' => _x(
- 'Hangup detected on controlling terminal or death of controlling process',
- 'SIGHUP: Please see http://man7.org/linux/man-pages/man7/signal.7.html for details', 'backwpup'
- ),
- 'error' => E_USER_ERROR,
+ 'SIGHUP' => array(
+ 'description' => _x( 'Hangup detected on controlling terminal or death of controlling process',
+ 'SIGHUP: Please see http://man7.org/linux/man-pages/man7/signal.7.html for details',
+ 'backwpup' ),
+ 'error' => E_USER_ERROR,
),
- 'SIGINT' => array(
- 'description' => _x(
- 'Interrupt from keyboard',
- 'SIGINT: Please see http://man7.org/linux/man-pages/man7/signal.7.html for details', 'backwpup'
- ),
- 'error' => E_USER_ERROR,
+ 'SIGINT' => array(
+ 'description' => _x( 'Interrupt from keyboard',
+ 'SIGINT: Please see http://man7.org/linux/man-pages/man7/signal.7.html for details',
+ 'backwpup' ),
+ 'error' => E_USER_ERROR,
),
- 'SIGQUIT' => array(
- 'description' => _x(
- 'Quit from keyboard',
- 'SIGQUIT: Please see http://man7.org/linux/man-pages/man7/signal.7.html for details', 'backwpup'
- ),
- 'error' => E_USER_ERROR,
+ 'SIGQUIT' => array(
+ 'description' => _x( 'Quit from keyboard',
+ 'SIGQUIT: Please see http://man7.org/linux/man-pages/man7/signal.7.html for details',
+ 'backwpup' ),
+ 'error' => E_USER_ERROR,
),
- 'SIGILL' => array(
- 'description' => _x(
- 'Illegal Instruction',
- 'SIGILL: Please see http://man7.org/linux/man-pages/man7/signal.7.html for details', 'backwpup'
- ),
- 'error' => E_USER_ERROR,
+ 'SIGILL' => array(
+ 'description' => _x( 'Illegal Instruction',
+ 'SIGILL: Please see http://man7.org/linux/man-pages/man7/signal.7.html for details',
+ 'backwpup' ),
+ 'error' => E_USER_ERROR,
),
- 'SIGABRT' => array(
- 'description' => _x(
- 'Abort signal from abort(3)',
- 'SIGABRT: Please see http://man7.org/linux/man-pages/man7/signal.7.html for details', 'backwpup'
- ),
- 'error' => E_USER_NOTICE,
+ 'SIGABRT' => array(
+ 'description' => _x( 'Abort signal from abort(3)',
+ 'SIGABRT: Please see http://man7.org/linux/man-pages/man7/signal.7.html for details',
+ 'backwpup' ),
+ 'error' => E_USER_NOTICE,
),
- 'SIGBUS' => array(
- 'description' => _x(
- 'Bus error (bad memory access)',
- 'SIGBUS: Please see http://man7.org/linux/man-pages/man7/signal.7.html for details', 'backwpup'
- ),
- 'error' => E_USER_ERROR,
+ 'SIGBUS' => array(
+ 'description' => _x( 'Bus error (bad memory access)',
+ 'SIGBUS: Please see http://man7.org/linux/man-pages/man7/signal.7.html for details',
+ 'backwpup' ),
+ 'error' => E_USER_ERROR,
),
- 'SIGFPE' => array(
- 'description' => _x(
- 'Floating point exception',
- 'SIGFPE: Please see http://man7.org/linux/man-pages/man7/signal.7.html for details', 'backwpup'
- ),
- 'error' => E_USER_ERROR,
+ 'SIGFPE' => array(
+ 'description' => _x( 'Floating point exception',
+ 'SIGFPE: Please see http://man7.org/linux/man-pages/man7/signal.7.html for details',
+ 'backwpup' ),
+ 'error' => E_USER_ERROR,
),
- 'SIGSEGV' => array(
- 'description' => _x(
- 'Invalid memory reference',
- 'SIGSEGV: Please see http://man7.org/linux/man-pages/man7/signal.7.html for details', 'backwpup'
- ),
- 'error' => E_USER_ERROR,
+ 'SIGSEGV' => array(
+ 'description' => _x( 'Invalid memory reference',
+ 'SIGSEGV: Please see http://man7.org/linux/man-pages/man7/signal.7.html for details',
+ 'backwpup' ),
+ 'error' => E_USER_ERROR,
),
- 'SIGTERM' => array(
- 'description' => _x(
- 'Termination signal',
- 'SIGTERM: Please see http://man7.org/linux/man-pages/man7/signal.7.html for details', 'backwpup'
- ),
- 'error' => E_USER_WARNING,
+ 'SIGTERM' => array(
+ 'description' => _x( 'Termination signal',
+ 'SIGTERM: Please see http://man7.org/linux/man-pages/man7/signal.7.html for details',
+ 'backwpup' ),
+ 'error' => E_USER_WARNING,
),
'SIGSTKFLT' => array(
- 'description' => _x(
- 'Stack fault on coprocessor',
- 'SIGSTKFLT: Please see http://man7.org/linux/man-pages/man7/signal.7.html for details', 'backwpup'
- ),
- 'error' => E_USER_ERROR,
+ 'description' => _x( 'Stack fault on coprocessor',
+ 'SIGSTKFLT: Please see http://man7.org/linux/man-pages/man7/signal.7.html for details',
+ 'backwpup' ),
+ 'error' => E_USER_ERROR,
),
- 'SIGUSR1' => array(
- 'description' => _x(
- 'User-defined signal 1',
- 'SIGUSR1: Please see http://man7.org/linux/man-pages/man7/signal.7.html for details', 'backwpup'
- ),
- 'error' => E_USER_NOTICE,
+ 'SIGUSR1' => array(
+ 'description' => _x( 'User-defined signal 1',
+ 'SIGUSR1: Please see http://man7.org/linux/man-pages/man7/signal.7.html for details',
+ 'backwpup' ),
+ 'error' => E_USER_NOTICE,
),
- 'SIGUSR2' => array(
- 'description' => _x(
- 'User-defined signal 2',
- 'SIGUSR2: Please see http://man7.org/linux/man-pages/man7/signal.7.html for details', 'backwpup'
- ),
- 'error' => E_USER_NOTICE,
+ 'SIGUSR2' => array(
+ 'description' => _x( 'User-defined signal 2',
+ 'SIGUSR2: Please see http://man7.org/linux/man-pages/man7/signal.7.html for details',
+ 'backwpup' ),
+ 'error' => E_USER_NOTICE,
),
- 'SIGURG' => array(
- 'description' => _x(
- 'Urgent condition on socket',
- 'SIGURG: Please see http://man7.org/linux/man-pages/man7/signal.7.html for details', 'backwpup'
- ),
- 'error' => E_USER_NOTICE,
+ 'SIGURG' => array(
+ 'description' => _x( 'Urgent condition on socket',
+ 'SIGURG: Please see http://man7.org/linux/man-pages/man7/signal.7.html for details',
+ 'backwpup' ),
+ 'error' => E_USER_NOTICE,
),
- 'SIGXCPU' => array(
- 'description' => _x(
- 'CPU time limit exceeded',
- 'SIGXCPU: Please see http://man7.org/linux/man-pages/man7/signal.7.html for details', 'backwpup'
- ),
- 'error' => E_USER_ERROR,
+ 'SIGXCPU' => array(
+ 'description' => _x( 'CPU time limit exceeded',
+ 'SIGXCPU: Please see http://man7.org/linux/man-pages/man7/signal.7.html for details',
+ 'backwpup' ),
+ 'error' => E_USER_ERROR,
),
- 'SIGXFSZ' => array(
- 'description' => _x(
- 'File size limit exceeded',
- 'SIGXFSZ: Please see http://man7.org/linux/man-pages/man7/signal.7.html for details', 'backwpup'
- ),
- 'error' => E_USER_ERROR,
+ 'SIGXFSZ' => array(
+ 'description' => _x( 'File size limit exceeded',
+ 'SIGXFSZ: Please see http://man7.org/linux/man-pages/man7/signal.7.html for details',
+ 'backwpup' ),
+ 'error' => E_USER_ERROR,
),
- 'SIGPWR' => array(
- 'description' => _x(
- 'Power failure',
- 'SIGPWR: Please see http://man7.org/linux/man-pages/man7/signal.7.html for details', 'backwpup'
- ),
- 'error' => E_USER_ERROR,
+ 'SIGPWR' => array(
+ 'description' => _x( 'Power failure',
+ 'SIGPWR: Please see http://man7.org/linux/man-pages/man7/signal.7.html for details',
+ 'backwpup' ),
+ 'error' => E_USER_ERROR,
),
- 'SIGSYS' => array(
- 'description' => _x(
- 'Bad argument to routine',
- 'SIGSYS: Please see http://man7.org/linux/man-pages/man7/signal.7.html for details', 'backwpup'
- ),
- 'error' => E_USER_ERROR,
+ 'SIGSYS' => array(
+ 'description' => _x( 'Bad argument to routine',
+ 'SIGSYS: Please see http://man7.org/linux/man-pages/man7/signal.7.html for details',
+ 'backwpup' ),
+ 'error' => E_USER_ERROR,
),
);
foreach ( $signals as $signal => $config ) {
if ( defined( $signal ) && $signal_send === constant( $signal ) ) {
- $this->log(
- sprintf(
- __( 'Signal "%1$s" (%2$s) is sent to script!', 'backwpup' ), $signal, $config['description']
- ), $config['error']
- );
+ $this->log( sprintf( __( 'Signal "%1$s" (%2$s) is sent to script!', 'backwpup' ),
+ $signal,
+ $config['description'] ),
+ $config['error'] );
$this->signal = $signal_send;
break;
}
@@ -2937,11 +2555,12 @@ public function shutdown() {
*/
public function exception_handler( $exception ) {
- $this->log(
- sprintf(
- __( 'Exception caught in %1$s: %2$s', 'backwpup' ), get_class( $exception ), $exception->getMessage()
- ), E_USER_ERROR, $exception->getFile(), $exception->getLine()
- );
+ $this->log( sprintf( __( 'Exception caught in %1$s: %2$s', 'backwpup' ),
+ get_class( $exception ),
+ $exception->getMessage() ),
+ E_USER_ERROR,
+ $exception->getFile(),
+ $exception->getLine() );
}
/**
@@ -2967,7 +2586,7 @@ public function curl_read_callback( $curl_handle, $file_handle, $read_count ) {
return $data;
}
- $length = ( is_numeric( $read_count ) ) ? $read_count : strlen( $read_count );
+ $length = ( is_numeric( $read_count ) ) ? $read_count : strlen( $read_count );
$this->substeps_done = $this->substeps_done + $length;
$this->update_working_data();
@@ -2978,7 +2597,7 @@ public function curl_read_callback( $curl_handle, $file_handle, $read_count ) {
* For storing and getting data in/from a extra temp file
*
* @param string $storage The name of the storage
- * @param array $data data to save in storage
+ * @param array $data data to save in storage
*
* @return array|mixed|null data from storage
*/
@@ -2990,9 +2609,7 @@ public function data_storage( $storage = null, $data = null ) {
$storage = strtolower( $storage );
- $file = BackWPup::get_plugin_data( 'temp' ) . 'backwpup-' . BackWPup::get_plugin_data(
- 'hash'
- ) . '-' . $storage . '.json';
+ $file = BackWPup::get_plugin_data( 'temp' ) . 'backwpup-' . BackWPup::get_plugin_data( 'hash' ) . '-' . $storage . '.json';
if ( ! empty( $data ) ) {
file_put_contents( $file, json_encode( $data ) );
@@ -3008,7 +2625,7 @@ public function data_storage( $storage = null, $data = null ) {
* Add a Folders to Folder list that should be backup
*
* @param array $folders folder to add
- * @param bool $new overwrite existing file
+ * @param bool $new overwrite existing file
*/
public function add_folders_to_backup( $folders = array(), $new = false ) {
diff --git a/inc/class-jobtype-wpexp.php b/inc/class-jobtype-wpexp.php
index fcbe6254d..1692b8ee4 100644
--- a/inc/class-jobtype-wpexp.php
+++ b/inc/class-jobtype-wpexp.php
@@ -75,10 +75,6 @@ class="medium-text code"/>.xml
echo ' ' . esc_html__( 'GZip', 'backwpup' ). ' ';
else
echo ' ' . esc_html__( 'GZip', 'backwpup' ). ' ';
- if ( function_exists( 'bzopen' ) )
- echo ' ' . esc_html__( 'BZip2', 'backwpup' ). ' ';
- else
- echo ' ' . esc_html__( 'BZip2', 'backwpup' ). ' ';
?>
diff --git a/inc/class-jobtype-wpplugin.php b/inc/class-jobtype-wpplugin.php
index cefd49891..6b7d17fbb 100644
--- a/inc/class-jobtype-wpplugin.php
+++ b/inc/class-jobtype-wpplugin.php
@@ -60,11 +60,6 @@ class="medium-text code"/>.txt
} else {
echo ' ' . esc_html__( 'GZip', 'backwpup' ). ' ';
}
- if ( function_exists( 'bzopen' ) ) {
- echo ' ' . esc_html__( 'BZip2', 'backwpup' ). ' ';
- } else {
- echo ' ' . esc_html__( 'BZip2', 'backwpup' ). ' ';
- }
?>
@@ -100,8 +95,6 @@ public function job_run( BackWPup_Job $job_object ) {
if ( $job_object->job[ 'pluginlistfilecompression' ] == '.gz' )
$handle = fopen( 'compress.zlib://' . BackWPup::get_plugin_data( 'TEMP' ) . $job_object->temp[ 'pluginlistfile' ], 'w' );
- elseif ( $job_object->job[ 'pluginlistfilecompression' ] == '.bz2' )
- $handle = fopen( 'compress.bzip2://' . BackWPup::get_plugin_data( 'TEMP' ) . $job_object->temp[ 'pluginlistfile' ], 'w' );
else
$handle = fopen( BackWPup::get_plugin_data( 'TEMP' ) . $job_object->temp[ 'pluginlistfile' ], 'w' );
diff --git a/inc/class-option.php b/inc/class-option.php
index 9bd63233c..32d373098 100644
--- a/inc/class-option.php
+++ b/inc/class-option.php
@@ -1,4 +1,5 @@
id;
- $cache_key = "$network_id:backwpup_jobs";
+ $cache_key = "$network_id:backwpup_jobs";
wp_cache_delete( $cache_key, 'site-options' );
} else {
wp_cache_delete( 'backwpup_jobs', 'options' );
@@ -125,7 +129,7 @@ private static function update_jobs_options( $options ) {
*/
public static function get( $jobid, $option, $default = null, $use_cache = true ) {
- $jobid = (int) $jobid;
+ $jobid = (int) $jobid;
$option = sanitize_key( trim( $option ) );
if ( empty( $jobid ) || empty( $option ) ) {
@@ -133,27 +137,49 @@ public static function get( $jobid, $option, $default = null, $use_cache = true
}
$jobs_options = self::jobs_options( $use_cache );
+
if ( isset( $jobs_options[ $jobid ] ) && isset( $jobs_options[ $jobid ]['archivename'] ) ) {
$jobs_options[ $jobid ]['archivenamenohash'] = $jobs_options[ $jobid ]['archivename'];
}
- if ( ! isset( $jobs_options[ $jobid ][ $option ] ) && isset( $default ) ) {
+
+ if ( ! isset( $jobs_options[ $jobid ][ $option ] ) && $default !== null ) {
return $default;
- } elseif ( ! isset( $jobs_options[ $jobid ][ $option ] ) ) {
- if ( $option == 'archivename' ) {
+ }
+
+ if ( ! isset( $jobs_options[ $jobid ][ $option ] ) ) {
+ if ( $option === 'archivename' ) {
return self::normalize_archive_name( self::defaults_job( $option ), $jobid );
- } else {
- return self::defaults_job( $option );
- }
- } else {
- // Ensure archive name formatted properly
- if ( $option == 'archivename' ) {
- return self::normalize_archive_name( $jobs_options[ $jobid ][ $option ], $jobid, true );
- } elseif ( $option == 'archivenamenohash' ) {
- return self::normalize_archive_name( $jobs_options[ $jobid ]['archivename'], $jobid, false );
- } else {
- return $jobs_options[ $jobid ][ $option ];
}
+
+ return self::defaults_job( $option );
+ }
+
+ // Ensure archive name formatted properly
+ if ( $option === 'archivename' ) {
+ return self::normalize_archive_name( $jobs_options[ $jobid ][ $option ], $jobid, true );
}
+
+ if ( $option === 'archivenamenohash' ) {
+ return self::normalize_archive_name( $jobs_options[ $jobid ]['archivename'], $jobid, false );
+ }
+
+ $option_value = $jobs_options[ $jobid ][ $option ];
+
+ switch ( $option ) {
+ case 'archiveformat':
+ if ( $option_value === '.tar.bz2' ) {
+ $option_value = '.tar.gz';
+ }
+ break;
+ case 'pluginlistfilecompression':
+ case 'wpexportfilecompression':
+ if ( $option_value === '.bz2' ) {
+ $option_value = '.gz';
+ }
+ break;
+ }
+
+ return $option_value;
}
/**
@@ -171,26 +197,26 @@ public static function defaults_job( $key = '' ) {
$key = sanitize_key( trim( $key ) );
//set defaults
- $default['type'] = array( 'DBDUMP', 'FILE', 'WPPLUGIN' );
- $default['destinations'] = array();
- $default['name'] = __( 'New Job', 'backwpup' );
- $default['activetype'] = '';
- $default['logfile'] = '';
+ $default['type'] = array( 'DBDUMP', 'FILE', 'WPPLUGIN' );
+ $default['destinations'] = array();
+ $default['name'] = __( 'New Job', 'backwpup' );
+ $default['activetype'] = '';
+ $default['logfile'] = '';
$default['lastbackupdownloadurl'] = '';
- $default['cronselect'] = 'basic';
- $default['cron'] = '0 3 * * *';
- $default['mailaddresslog'] = sanitize_email( get_bloginfo( 'admin_email' ) );
- $default['mailaddresssenderlog'] = 'BackWPup ' . get_bloginfo( 'name' ) . ' <' . sanitize_email( get_bloginfo( 'admin_email' ) ) . '>';
- $default['mailerroronly'] = true;
- $default['backuptype'] = 'archive';
- $default['archiveformat'] = '.zip';
- $default['archivename'] = '%Y-%m-%d_%H-%i-%s_%hash%';
- $default['archivenamenohash'] = '%Y-%m-%d_%H-%i-%s_%hash%';
+ $default['cronselect'] = 'basic';
+ $default['cron'] = '0 3 * * *';
+ $default['mailaddresslog'] = sanitize_email( get_bloginfo( 'admin_email' ) );
+ $default['mailaddresssenderlog'] = 'BackWPup ' . get_bloginfo( 'name' ) . ' <' . sanitize_email( get_bloginfo( 'admin_email' ) ) . '>';
+ $default['mailerroronly'] = true;
+ $default['backuptype'] = 'archive';
+ $default['archiveformat'] = '.zip';
+ $default['archivename'] = '%Y-%m-%d_%H-%i-%s_%hash%';
+ $default['archivenamenohash'] = '%Y-%m-%d_%H-%i-%s_%hash%';
//defaults vor destinations
foreach ( BackWPup::get_registered_destinations() as $dest_key => $dest ) {
if ( ! empty( $dest['class'] ) ) {
$dest_object = BackWPup::get_destination( $dest_key );
- $default = array_merge( $default, $dest_object->option_defaults() );
+ $default = array_merge( $default, $dest_object->option_defaults() );
}
}
//defaults vor job types
@@ -225,13 +251,29 @@ public static function get_job( $id, $use_cache = true ) {
return false;
}
- $id = intval( $id );
+ $id = intval( $id );
$jobs_options = self::jobs_options( $use_cache );
if ( isset( $jobs_options[ $id ]['archivename'] ) ) {
- $jobs_options[ $id ]['archivename'] = self::normalize_archive_name( $jobs_options[ $id ]['archivename'], $id, true );
+ $jobs_options[ $id ]['archivename'] = self::normalize_archive_name(
+ $jobs_options[ $id ]['archivename'],
+ $id,
+ true
+ );
+ }
+
+ $options = wp_parse_args( $jobs_options[ $id ], self::defaults_job() );
+
+ if ( isset( $options['archiveformat'] ) && $options['archiveformat'] === '.tar.bz2' ) {
+ $options['archiveformat'] = '.tar.gz';
+ }
+ if ( isset($options['pluginlistfilecompression'] ) && $options['pluginlistfilecompression'] === '.bz2' ) {
+ $options['pluginlistfilecompression'] = '.gz';
+ }
+ if ( isset($options['wpexportfilecompression'] ) && $options['wpexportfilecompression'] === '.bz2' ) {
+ $options['wpexportfilecompression'] = '.gz';
}
- return wp_parse_args( $jobs_options[ $id ], self::defaults_job() );
+ return $options;
}
@@ -246,7 +288,7 @@ public static function get_job( $id, $use_cache = true ) {
*/
public static function delete( $jobid, $option ) {
- $jobid = (int) $jobid;
+ $jobid = (int) $jobid;
$option = sanitize_key( trim( $option ) );
if ( empty( $jobid ) || empty( $option ) ) {
@@ -274,7 +316,7 @@ public static function delete_job( $id ) {
return false;
}
- $id = intval( $id );
+ $id = intval( $id );
$jobs_options = self::jobs_options( false );
unset( $jobs_options[ $id ] );
@@ -292,7 +334,7 @@ public static function delete_job( $id ) {
*/
public static function get_job_ids( $key = null, $value = false ) {
- $key = sanitize_key( trim( $key ) );
+ $key = sanitize_key( trim( $key ) );
$jobs_options = self::jobs_options( false );
if ( empty( $jobs_options ) ) {
@@ -322,8 +364,10 @@ public static function get_job_ids( $key = null, $value = false ) {
* @return int
*/
public static function next_job_id() {
+
$ids = self::get_job_ids();
sort( $ids );
+
return end( $ids ) + 1;
}
@@ -335,14 +379,15 @@ public static function next_job_id() {
* This allows backup files belonging to this job to be tracked.
*
* @param string $archive_name
- * @param int $jobid
+ * @param int $jobid
*
* @return string The normalized archive name
*/
public static function normalize_archive_name( $archive_name, $jobid, $substitute_hash = true ) {
+
$hash = BackWPup::get_plugin_data( 'hash' );
$generated_hash = self::get_generated_hash( $jobid );
-
+
// Does the string contain %hash%?
if ( strpos( $archive_name, '%hash%' ) !== false ) {
if ( $substitute_hash == true ) {
@@ -356,12 +401,12 @@ public static function normalize_archive_name( $archive_name, $jobid, $substitut
// If name starts with 'backwpup', then we can try to parse
if ( substr( $archive_name, 0, 8 ) == 'backwpup' ) {
$parts = explode( '_', $archive_name );
-
+
// Decode hash part if hash not found (from 3.4.2)
if ( strpos( $parts[1], $hash ) === false ) {
- $parts[1] = base_convert($parts[1], 36, 16);
+ $parts[1] = base_convert( $parts[1], 36, 16 );
}
-
+
// Search again
if ( strpos( $parts[1], $hash ) !== false ) {
$parts[1] = '%hash%';
@@ -383,7 +428,7 @@ public static function normalize_archive_name( $archive_name, $jobid, $substitut
return $archive_name . '_%hash%';
}
}
-
+
}
}
@@ -394,57 +439,78 @@ public static function normalize_archive_name( $archive_name, $jobid, $substitut
* @return string
*/
public static function get_generated_hash( $jobid ) {
- return Base32::encode( pack( 'H*', sprintf( '%02x%06s%02x', mt_rand( 0, 255 ),
- BackWPup::get_plugin_data( 'hash' ), mt_rand( 0, 255 ) ) ) ) .
- sprintf( '%02d', $jobid );
+
+ return Base32::encode( pack( 'H*',
+ sprintf( '%02x%06s%02x',
+ mt_rand( 0, 255 ),
+ BackWPup::get_plugin_data( 'hash' ),
+ mt_rand( 0, 255 ) ) ) ) .
+ sprintf( '%02d', $jobid );
}
-
+
/**
- * Return the decoded hash and the job ID.
- *
- * If the hash is not found in the given code, then false is returned.
- *
- * @param string $code The string to decode
- *
- * @return array|bool An array with hash and job ID, or false otherwise
- */
+ * Return the decoded hash and the job ID.
+ *
+ * If the hash is not found in the given code, then false is returned.
+ *
+ * @param string $code The string to decode
+ *
+ * @return array|bool An array with hash and job ID, or false otherwise
+ */
public static function decode_hash( $code ) {
+
$hash = BackWPup::get_plugin_data( 'hash' );
-
+
// Try base 32 first
$decoded = bin2hex( Base32::decode( substr( $code, 0, 8 ) ) );
if ( substr( $decoded, 2, 6 ) == $hash ) {
- return array( substr( $decoded, 2, 6 ), intval( substr( $code, -2 ) ) );
+ return array( substr( $decoded, 2, 6 ), intval( substr( $code, - 2 ) ) );
}
-
+
// Try base 36
$decoded = base_convert( $code, 36, 16 );
if ( substr( $decoded, 2, 6 ) == $hash ) {
- return array( substr( $decoded, 2, 6 ), intval( substr( $decoded, -2 ) ) );
+ return array( substr( $decoded, 2, 6 ), intval( substr( $decoded, - 2 ) ) );
}
-
+
// Check style prior to 3.4.1
if ( substr( $code, 0, 6 ) == $hash ) {
- return array( substr( $code, 0, 6 ), intval( substr( $code, -2 ) ) );
+ return array( substr( $code, 0, 6 ), intval( substr( $code, - 2 ) ) );
}
-
+
// Tried everything, now return failure
return false;
}
-
+
/**
- * Substitute date variables in archive name.
- *
- * @param string $archivename The name of the archive.
- *
- * @return string The archive name with substituted variables.
- */
+ * Substitute date variables in archive name.
+ *
+ * @param string $archivename The name of the archive.
+ *
+ * @return string The archive name with substituted variables.
+ */
public static function substitute_date_vars( $archivename ) {
+
$current_time = current_time( 'timestamp' );
- $datevars = array( '%d', '%j', '%m', '%n', '%Y', '%y', '%a', '%A', '%B', '%g', '%G',
- '%h', '%H', '%i', '%s' );
- $datevalues = array(
+ $datevars = array(
+ '%d',
+ '%j',
+ '%m',
+ '%n',
+ '%Y',
+ '%y',
+ '%a',
+ '%A',
+ '%B',
+ '%g',
+ '%G',
+ '%h',
+ '%H',
+ '%i',
+ '%s',
+ );
+ $datevalues = array(
date( 'd', $current_time ),
date( 'j', $current_time ),
date( 'm', $current_time ),
@@ -459,13 +525,15 @@ public static function substitute_date_vars( $archivename ) {
date( 'h', $current_time ),
date( 'H', $current_time ),
date( 'i', $current_time ),
- date( 's', $current_time )
+ date( 's', $current_time ),
);
// Temporarily replace %hash% with [hash]
$archivename = str_replace( '%hash%', '[hash]', $archivename );
- $archivename = str_replace( $datevars, $datevalues,
+ $archivename = str_replace( $datevars,
+ $datevalues,
$archivename );
$archivename = str_replace( '[hash]', '%hash%', $archivename );
+
return BackWPup_Job::sanitize_file_name( $archivename );
}
diff --git a/inc/class-page-backups.php b/inc/class-page-backups.php
index 671377b02..afed36d72 100644
--- a/inc/class-page-backups.php
+++ b/inc/class-page-backups.php
@@ -13,9 +13,9 @@ final class BackWPup_Page_Backups extends WP_List_Table {
public function __construct() {
parent::__construct( array(
- 'plural' => 'backups',
+ 'plural' => 'backups',
'singular' => 'backup',
- 'ajax' => true,
+ 'ajax' => true,
) );
$this->destinations = BackWPup::get_registered_destinations();
@@ -47,8 +47,8 @@ public function prepare_items() {
if ( empty( $jobdests ) ) {
$jobdests = array( '_' );
}
- $jobdest = $jobdests[0];
- $_GET['jobdest-top'] = $jobdests[0];
+ $jobdest = $jobdests[0];
+ $_GET['jobdest-top'] = $jobdests[0];
$_GET['jobdets-button-top'] = 'empty';
}
@@ -67,9 +67,9 @@ public function prepare_items() {
}
// Sorting.
- $order = filter_input( INPUT_GET, 'order', FILTER_SANITIZE_STRING ) ?: 'desc';
+ $order = filter_input( INPUT_GET, 'order', FILTER_SANITIZE_STRING ) ?: 'desc';
$orderby = filter_input( INPUT_GET, 'orderby', FILTER_SANITIZE_STRING ) ?: 'time';
- $tmp = array();
+ $tmp = array();
if ( $orderby === 'time' ) {
if ( $order === 'asc' ) {
@@ -123,20 +123,20 @@ public function prepare_items() {
$this->set_pagination_args( array(
'total_items' => count( $this->items ),
- 'per_page' => $per_page,
- 'jobdest' => $jobdest,
- 'orderby' => $orderby,
- 'order' => $order,
+ 'per_page' => $per_page,
+ 'jobdest' => $jobdest,
+ 'orderby' => $orderby,
+ 'order' => $order,
) );
// Only display items on page.
$start = intval( ( $this->get_pagenum() - 1 ) * $per_page );
- $end = $start + $per_page;
+ $end = $start + $per_page;
if ( $end > count( $this->items ) ) {
$end = count( $this->items );
}
- $i = - 1;
+ $i = - 1;
$paged_items = array();
foreach ( $this->items as $item ) {
$i ++;
@@ -164,7 +164,7 @@ public function get_bulk_actions() {
return array();
}
- $actions = array();
+ $actions = array();
$actions['delete'] = __( 'Delete', 'backwpup' );
return $actions;
@@ -209,10 +209,37 @@ public function extra_tablenav( $which ) {
';
+ $posts_columns['time'] = __( 'Time', 'backwpup' );
+ $posts_columns['file'] = __( 'File', 'backwpup' );
+ $posts_columns['folder'] = __( 'Folder', 'backwpup' );
+ $posts_columns['size'] = __( 'Size', 'backwpup' );
+
+ return $posts_columns;
+ }
+
+ public function get_sortable_columns() {
+
+ return array(
+ 'file' => array( 'file', false ),
+ 'folder' => 'folder',
+ 'size' => 'size',
+ 'time' => array( 'time', false ),
+ );
+ }
+
+ public function column_cb( $item ) {
+
+ return ' ';
+ }
+
public function get_destinations_list() {
$jobdest = array();
- $jobids = BackWPup_Option::get_job_ids();
+ $jobids = BackWPup_Option::get_job_ids();
foreach ( $jobids as $jobid ) {
if ( BackWPup_Option::get( $jobid, 'backuptype' ) === 'sync' ) {
@@ -223,7 +250,7 @@ public function get_destinations_list() {
if ( ! $this->destinations[ $dest ]['class'] ) {
continue;
}
- $dest_class = BackWPup::get_destination( $dest );
+ $dest_class = BackWPup::get_destination( $dest );
$can_do_dest = $dest_class->file_get_list( $jobid . '_' . $dest );
if ( ! empty( $can_do_dest ) ) {
$jobdest[] = $jobid . '_' . $dest;
@@ -234,63 +261,46 @@ public function get_destinations_list() {
return $jobdest;
}
- public function get_columns() {
-
- $posts_columns = array();
- $posts_columns['cb'] = ' ';
- $posts_columns['time'] = __( 'Time', 'backwpup' );
- $posts_columns['file'] = __( 'File', 'backwpup' );
- $posts_columns['folder'] = __( 'Folder', 'backwpup' );
- $posts_columns['size'] = __( 'Size', 'backwpup' );
-
- return $posts_columns;
- }
-
- public function get_sortable_columns() {
-
- return array(
- 'file' => array( 'file', false ),
- 'folder' => 'folder',
- 'size' => 'size',
- 'time' => array( 'time', false ),
- );
- }
-
- public function column_cb( $item ) {
-
- return ' ';
- }
-
public function column_file( $item ) {
+ $actions = array();
+
$r = '' . esc_attr( $item['filename'] ) . ' ';
if ( ! empty( $item['info'] ) ) {
$r .= esc_attr( $item['info'] ) . ' ';
}
- $actions = array();
+
if ( current_user_can( 'backwpup_backups_delete' ) ) {
- $actions['delete'] = "jobid . '_' . $this->dest . '&paged=' . $this->get_pagenum() . '&backupfiles[]=' . esc_attr( $item['file'] ),
- 'bulk-backups' ) . "\" onclick=\"if ( confirm('" . esc_js( __( "You are about to delete this backup archive. \n 'Cancel' to stop, 'OK' to delete.",
- "backwpup" ) ) . "') ) { return true;}return false;\">" . __( 'Delete', 'backwpup' ) . " ";
+ $actions['delete'] = $this->delete_item_action( $item );
}
- if ( current_user_can( 'backwpup_backups_download' ) && ! empty( $item['downloadurl'] ) ) {
- // Check if downloader class exists
+
+ if ( ! empty( $item['downloadurl'] ) && current_user_can( 'backwpup_backups_download' ) ) {
try {
- // If we're still here, the downloader exists
- $actions['download'] = "jobid . "\" data-destination=\"" . esc_attr( $this->dest ) . "\" data-file=\"" . esc_attr( $item['file'] ) . "\" data-local-file=\"" . esc_attr( $item['filename'] ) . "\" data-nonce=\"" . wp_create_nonce( 'download-backup_' . $this->jobid ) . "\" data-url=\"" . wp_nonce_url( $item['downloadurl'],
- 'download-backup_' . $this->jobid ) . "\" class=\"backup-download-link thickbox\">" . __( 'Download',
- 'backwpup' ) . " ";
+ $actions['download'] = $this->download_item_action( $item );
} catch ( BackWPup_Factory_Exception $e ) {
- $actions['download'] = "jobid ) . "\">" . __( 'Download', 'backwpup' ) . " ";
+ $actions['download'] = sprintf(
+ '%2$s ',
+ wp_nonce_url( $item['downloadurl'], 'backwpup_action_nonce' ),
+ __( 'Download', 'backwpup' )
+ );
}
}
// Add restore url to link list
if ( current_user_can( 'backwpup_restore' ) && ! empty( $item['restoreurl'] ) ) {
- $item['restoreurl'] = add_query_arg( array( 'step' => 1, 'trigger_download' => 1 ), $item['restoreurl'] );
- $actions['restore'] = "jobid ) . "\">" . __( 'Restore', 'backwpup' ) . " ";
+
+ $item['restoreurl'] = add_query_arg(
+ array(
+ 'step' => 1,
+ 'trigger_download' => 1,
+ ),
+ $item['restoreurl']
+ );
+ $actions['restore'] = sprintf(
+ '%2$s ',
+ wp_nonce_url( $item['restoreurl'], 'restore-backup_' . $this->jobid ),
+ __( 'Restore', 'backwpup' )
+ );
}
$r .= $this->row_actions( $actions );
@@ -339,7 +349,7 @@ public static function load() {
$jobdest = sanitize_text_field( $_GET['jobdest-top'] );
}
- $_GET['jobdest-top'] = $jobdest;
+ $_GET['jobdest-top'] = $jobdest;
$_GET['jobdets-button-top'] = 'submit';
if ( $jobdest === '' ) {
@@ -349,7 +359,7 @@ public static function load() {
list( $jobid, $dest ) = explode( '_', $jobdest );
/** @var BackWPup_Destinations $dest_class */
$dest_class = BackWPup::get_destination( $dest );
- $files = $dest_class->file_get_list( $jobdest );
+ $files = $dest_class->file_get_list( $jobdest );
foreach ( $_GET['backupfiles'] as $backupfile ) {
foreach ( $files as $file ) {
if ( is_array( $file ) && $file['file'] == $backupfile ) {
@@ -368,13 +378,12 @@ public static function load() {
if ( ! current_user_can( 'backwpup_backups_download' ) ) {
wp_die( __( 'Sorry, you don\'t have permissions to do that.', 'backwpup' ) );
}
- check_admin_referer( 'download-backup_' . $jobid );
+ check_admin_referer( 'backwpup_action_nonce' );
$filename = untrailingslashit( BackWPup::get_plugin_data( 'temp' ) ) . '/' . basename( isset( $_GET['local_file'] ) ? $_GET['local_file'] : $_GET['file'] );
if ( file_exists( $filename ) ) {
$downloader = new BackWPup_Download_File(
$filename,
- mime_content_type( $filename ),
function ( \BackWPup_Download_File_Interface $obj ) use ( $filename ) {
$obj->clean_ob()
@@ -430,9 +439,9 @@ function ( \BackWPup_Download_File_Interface $obj ) use ( $filename ) {
add_screen_option( 'per_page',
array(
- 'label' => __( 'Backup Files', 'backwpup' ),
+ 'label' => __( 'Backup Files', 'backwpup' ),
'default' => 20,
- 'option' => 'backwpupbackups_per_page',
+ 'option' => 'backwpupbackups_per_page',
) );
self::$listtable->prepare_items();
@@ -461,24 +470,30 @@ public static function admin_print_styles() {
public static function admin_print_scripts() {
- wp_enqueue_script( 'backwpupgeneral' );
+ $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
+ $plugin_url = BackWPup::get_plugin_data( 'url' );
+ $plugin_dir = BackWPup::get_plugin_data( 'plugindir' );
+ $plugin_scripts_url = "{$plugin_url}/assets/js";
+ $plugin_scripts_dir = "{$plugin_dir}/assets/js";
- if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
- wp_enqueue_script(
- 'backwpuppagebackups',
- BackWPup::get_plugin_data( 'URL' ) . '/assets/js/page_backups.js',
- array( 'jquery' ),
- time(),
- true
- );
- } else {
- wp_enqueue_script(
- 'backwpuppagebackups',
- BackWPup::get_plugin_data( 'URL' ) . '/assets/js/page_backups.min.js',
- array( 'jquery' ),
- BackWPup::get_plugin_data( 'Version' ),
- true
- );
+ $dependencies = array(
+ 'jquery',
+ 'underscore',
+ 'backwpupgeneral',
+ );
+ if ( \BackWPup::is_pro() ) {
+ $dependencies[] = 'decrypter';
+ }
+ wp_enqueue_script(
+ 'backwpup-backup-downloader',
+ "{$plugin_scripts_url}/backup-downloader{$suffix}.js",
+ $dependencies,
+ filemtime( "{$plugin_scripts_dir}/backup-downloader{$suffix}.js" ),
+ true
+ );
+
+ if ( \BackWPup::is_pro() ) {
+ self::admin_print_pro_scripts( $suffix, $plugin_url, $plugin_dir );
}
}
@@ -496,93 +511,115 @@ public static function page() {
-
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
-
-
-
+
+ decrypt_key_input();
+ }
+ ?>
file_download(
- $_GET['jobid'],
- trim( sanitize_text_field( $_GET['file'] ) ),
- trim( sanitize_text_field( $_GET['local_file'] ) )
+ wp_register_script(
+ 'restore_functions',
+ "{$restore_scripts_path}/functions{$suffix}.js",
+ array( 'underscore', 'jquery' ),
+ filemtime( "{$restore_scripts_dir}/functions{$suffix}.js" ),
+ true
+ );
+ wp_register_script(
+ 'states',
+ "{$restore_scripts_path}/states{$suffix}.js",
+ array(
+ 'restore_functions',
+ ),
+ filemtime( "{$restore_scripts_dir}/states{$suffix}.js" ),
+ true
+ );
+ wp_register_script(
+ 'decrypter',
+ "{$restore_scripts_path}/decrypter{$suffix}.js",
+ array(
+ 'underscore',
+ 'jquery',
+ 'states',
+ 'restore_functions',
+ ),
+ filemtime( "{$restore_scripts_dir}/decrypter{$suffix}.js" ),
+ true
);
}
- public static function ajax_send_private_key() {
-
- $private_key = (string) filter_input( INPUT_POST, 'privatekey', FILTER_SANITIZE_STRING );
-
- if ( ! $private_key ) {
- return;
- }
+ private function delete_item_action( $item ) {
- $temporary_file_path = untrailingslashit( BackWPup::get_plugin_data( 'temp' ) );
- $private_key_filename = $temporary_file_path . '/' . BackWPup_Decrypter::PRIVATE_RSA_ID_FILE;
- $saved = file_put_contents( $private_key_filename, $private_key );
+ $query = sprintf(
+ '?page=backwpupbackups&action=delete&jobdest-top=%1$s&paged=%2$s&backupfiles[]=%3$s',
+ $this->jobid . '_' . $this->dest,
+ $this->get_pagenum(),
+ esc_attr( $item['file'] )
+ );
+ $url = wp_nonce_url( network_admin_url( 'admin.php' ) . $query, 'bulk-backups' );
+ $js = sprintf(
+ 'if ( confirm(\'%s\') ) { return true; } return false;',
+ esc_js(
+ __(
+ 'You are about to delete this backup archive. \'Cancel\' to stop, \'OK\' to delete.',
+ "backwpup"
+ )
+ )
+ );
- if ( ! $saved ) {
- wp_send_json_error( array(
- 'message' => sprintf(
- __(
- 'Seems is not possible to store your private key, be sure the directory %s is writable.',
- 'backwpup'
- ),
- dirname( $private_key_filename )
- ),
- ) );
- }
+ return sprintf(
+ '
%3$s ',
+ $url,
+ $js,
+ __( 'Delete', 'backwpup' )
+ );
+ }
- wp_send_json_success( array(
- 'message' => __( 'The key has been succesfull stored.' ),
- ) );
+ private function download_item_action( $item ) {
+
+ $local_file = untrailingslashit( BackWPup::get_plugin_data( 'TEMP' ) ) . "/{$item['filename']}";
+
+ return sprintf(
+ '
%7$s ',
+ intval( $this->jobid ),
+ esc_attr( $this->dest ),
+ esc_attr( $item['file'] ),
+ esc_attr( $local_file ),
+ wp_create_nonce( 'backwpup_action_nonce' ),
+ wp_nonce_url( $item['downloadurl'], 'backwpup_action_nonce' ),
+ __( 'Download', 'backwpup' )
+ );
}
}
diff --git a/inc/class-page-editjob.php b/inc/class-page-editjob.php
index f115d9868..1784b2a9b 100644
--- a/inc/class-page-editjob.php
+++ b/inc/class-page-editjob.php
@@ -117,8 +117,7 @@ public static function save_post_form($tab, $jobid) {
$archiveformat = in_array( $_POST['archiveformat'], array(
'.zip',
'.tar',
- '.tar.gz',
- '.tar.bz2'
+ '.tar.gz'
), true ) ? $_POST['archiveformat'] : '.zip';
BackWPup_Option::update( $jobid, 'archiveformat', $archiveformat );
BackWPup_Option::update( $jobid, 'archiveencryption', ! empty( $_POST['archiveencryption'] ) );
@@ -328,6 +327,7 @@ public static function page() {
$disable_encryption = false;
}
+ $archive_format_option = BackWPup_Option::get( $jobid, 'archiveformat' );
?>
' . esc_html__( 'Preview: ', 'backwpup' ) . '
' . esc_attr( $archivename ) . ' ' . esc_attr( BackWPup_Option::get( $jobid, 'archiveformat' ) ) . '
';
+ echo '
' . esc_html__( 'Preview: ', 'backwpup' ) . '' . esc_attr( $archivename ) . ' ' . esc_attr( $archive_format_option ) . '
';
echo '
';
echo "" . esc_attr__( 'Replacement patterns:', 'backwpup' ) . " ";
echo esc_attr__( '%d = Two digit day of the month, with leading zeros', 'backwpup' ) . ' ';
@@ -478,26 +478,20 @@ public static function page() {
' . esc_html__( 'Zip', 'backwpup' ) . '
';
+ echo '
' . esc_html__( 'Zip', 'backwpup' ) . '
';
} else {
- echo '
' . esc_html__( 'Zip', 'backwpup' ) . ' ';
+ echo '
' . esc_html__( 'Zip', 'backwpup' ) . ' ';
echo '' . esc_html(__( 'ZipArchive PHP class is missing, so BackWPUp will use PclZip instead.', 'backwpup' )) . '
';
}
- echo '
' . esc_html__( 'Tar', 'backwpup' ) . '
';
+ echo '
' . esc_html__( 'Tar', 'backwpup' ) . '
';
if ( function_exists( 'gzopen' ) ) {
- echo '
' . esc_html__( 'Tar GZip', 'backwpup' ) . '
';
+ echo '
' . esc_html__( 'Tar GZip', 'backwpup' ) . '
';
} else {
- echo '
' . esc_html__( 'Tar GZip', 'backwpup' ) . ' ';
+ echo '
' . esc_html__( 'Tar GZip', 'backwpup' ) . ' ';
echo '' . esc_html(sprintf( __( 'Disabled due to missing %s PHP function.', 'backwpup' ), 'gzopen()' )) . '
';
}
- if ( function_exists( 'bzopen' ) ) {
- echo '
' . esc_html__( 'Tar BZip2', 'backwpup' ) . ' ';
- echo BackWPup::is_pro() ? ' ' . __('Not supported yet by the automatic restore functionality', 'backwpup' ) . '
' : '';
- } else {
- echo '
' . esc_html__( 'Tar BZip2', 'backwpup' ) . ' ';
- echo '' . esc_html(sprintf( __( 'Disabled due to missing %s PHP function.', 'backwpup' ), 'bzopen()' )) . '
';
- }
- ?>
+ ?>
+
diff --git a/inc/class-page-jobs.php b/inc/class-page-jobs.php
index eaffe87f3..7d432eda7 100644
--- a/inc/class-page-jobs.php
+++ b/inc/class-page-jobs.php
@@ -10,11 +10,7 @@ class BackWPup_Page_Jobs extends WP_List_Table {
private $job_types = NULL;
private $destinations = NULL;
-
- /**
- *
- */
- function __construct() {
+ public function __construct() {
parent::__construct( array(
'plural' => 'jobs',
'singular' => 'job',
@@ -22,11 +18,10 @@ function __construct() {
) );
}
-
/**
* @return bool|void
*/
- function ajax_user_can() {
+ public function ajax_user_can() {
return current_user_can( 'backwpup' );
}
@@ -34,7 +29,7 @@ function ajax_user_can() {
/**
*
*/
- function prepare_items() {
+ public function prepare_items() {
$this->items = BackWPup_Option::get_job_ids();
$this->job_object = BackWPup_Job::get_working_data();
@@ -95,7 +90,7 @@ function prepare_items() {
/**
*
*/
- function no_items() {
+ public function no_items() {
_e( 'No Jobs.', 'backwpup' );
}
@@ -103,7 +98,7 @@ function no_items() {
/**
* @return array
*/
- function get_bulk_actions() {
+ public function get_bulk_actions() {
if ( ! $this->has_items() ) {
return array();
@@ -118,7 +113,7 @@ function get_bulk_actions() {
/**
* @return array
*/
- function get_columns() {
+ public function get_columns() {
$jobs_columns = array();
$jobs_columns[ 'cb' ] = '
';
@@ -134,7 +129,7 @@ function get_columns() {
/**
* @return array
*/
- function get_sortable_columns() {
+ public function get_sortable_columns() {
return array(
'jobname' => 'jobname',
@@ -151,7 +146,7 @@ function get_sortable_columns() {
* @param $item
* @return string
*/
- function column_cb( $item ) {
+ public function column_cb( $item ) {
return '
';
}
@@ -162,7 +157,7 @@ function column_cb( $item ) {
* @param $item
* @return string
*/
- function column_jobname( $item ) {
+ public function column_jobname( $item ) {
$job_normal_hide ='';
if ( is_object( $this->job_object ) ) {
@@ -205,7 +200,7 @@ function column_jobname( $item ) {
* @param $item
* @return string
*/
- function column_type( $item ) {
+ public function column_type( $item ) {
$r = '';
if ( $types = BackWPup_Option::get( $item, 'type' ) ) {
@@ -228,7 +223,7 @@ function column_type( $item ) {
* @param $item
* @return string
*/
- function column_dest( $item ) {
+ public function column_dest( $item ) {
$r = '';
$backup_to = FALSE;
@@ -260,7 +255,7 @@ function column_dest( $item ) {
* @param $item
* @return string
*/
- function column_next( $item ) {
+ public function column_next( $item ) {
$r = '';
@@ -309,7 +304,7 @@ function column_next( $item ) {
* @param $item
* @return string
*/
- function column_last( $item ) {
+ public function column_last( $item ) {
$r = '';
@@ -327,7 +322,7 @@ function column_last( $item ) {
if ( current_user_can( 'backwpup_backups_download' ) ) {
$download_url = BackWPup_Option::get( $item, 'lastbackupdownloadurl' );
if ( ! empty( $download_url ) ) {
- $r .= "
" . esc_html__( 'Download', 'backwpup' ) . " | ";
+ $r .= "
" . esc_html__( 'Download', 'backwpup' ) . " | ";
}
}
if ( current_user_can( 'backwpup_logs' ) && BackWPup_Option::get( $item, 'logfile' ) ) {
@@ -344,7 +339,6 @@ function column_last( $item ) {
return $r;
}
-
/**
*
*/
@@ -732,7 +726,6 @@ public static function page() {
$done
) );
}
-
}
diff --git a/inc/class-page-logs.php b/inc/class-page-logs.php
index 2f53dce23..012952252 100644
--- a/inc/class-page-logs.php
+++ b/inc/class-page-logs.php
@@ -231,7 +231,7 @@ function column_job( $item ) {
if ( current_user_can( 'backwpup_logs_delete' ) ) {
$actions['delete'] = "
get_pagenum() . '&logfiles[]=' . $item['file'], 'bulk-logs' ) . "\" onclick=\"return showNotice.warn();\">" . __( 'Delete', 'backwpup' ) . " ";
}
- $actions['download'] = "
" . __( 'Download', 'backwpup' ) . " ";
+ $actions['download'] = "
" . __( 'Download', 'backwpup' ) . " ";
$r .= $this->row_actions( $actions );
return $r;
@@ -334,7 +334,6 @@ public static function load() {
$download_handler = new BackWpup_Download_Handler(
new BackWPup_Download_File(
$log_file,
- BackWPup_Job::get_mime_type( $log_file ),
function ( \BackWPup_Download_File_Interface $obj ) {
$obj->clean_ob()
@@ -346,7 +345,7 @@ function ( \BackWPup_Download_File_Interface $obj ) {
},
$capability
),
- 'download-log_' . trim( $_GET['file'] ),
+ 'download_backwpup_logs',
$capability,
'download'
);
diff --git a/inc/class-page-settings.php b/inc/class-page-settings.php
index eb3a7e7df..5993376c9 100644
--- a/inc/class-page-settings.php
+++ b/inc/class-page-settings.php
@@ -1,226 +1,500 @@
__( 'Please enter a public key first, or generate a key pair.', 'backwpup' ),
- 'no_private_key' => __( 'Please enter your private key.', 'backwpup' ),
- 'public_key_valid' => __( 'Public key is valid.', 'backwpup' ),
- 'public_key_invalid' => __( 'Public key is invalid.', 'backwpup' ),
- 'must_download_private_key' => __( 'Please download the private key before continuing. If you do not save it locally, you cannot decrypt your backups later.', 'backwpup' ),
- );
-
- wp_localize_script( 'backwpuppagesettings', 'backwpup_vars', $data );
- }
+ private $settings_views;
/**
- * Save settings form data
+ * @var array
*/
- public static function save_post_form() {
+ private $settings_updaters;
- if ( ! current_user_can( 'backwpup_settings' ) ) {
- return;
- }
+ /**
+ * @return array
+ */
+ public static function get_information() {
- // Set default options if button clicked.
- if ( isset( $_POST['default_settings'] ) && $_POST['default_settings'] ) { // phpcs:ignore
- delete_site_option( 'backwpup_cfg_showadminbar' );
- delete_site_option( 'backwpup_cfg_showfoldersize' );
- delete_site_option( 'backwpup_cfg_jobstepretry' );
- delete_site_option( 'backwpup_cfg_jobmaxexecutiontime' );
- delete_site_option( 'backwpup_cfg_loglevel' );
- delete_site_option( 'backwpup_cfg_jobwaittimems' );
- delete_site_option( 'backwpup_cfg_jobrunauthkey' );
- delete_site_option( 'backwpup_cfg_jobdooutput' );
- delete_site_option( 'backwpup_cfg_windows' );
- delete_site_option( 'backwpup_cfg_encryption' );
- delete_site_option( 'backwpup_cfg_encryptionkey' );
- delete_site_option( 'backwpup_cfg_publickey' );
- delete_site_option( 'backwpup_cfg_maxlogs' );
- delete_site_option( 'backwpup_cfg_gzlogs' );
- delete_site_option( 'backwpup_cfg_protectfolders' );
- delete_site_option( 'backwpup_cfg_authentication' );
- delete_site_option( 'backwpup_cfg_logfolder' );
- delete_site_option( 'backwpup_cfg_dropboxappkey' );
- delete_site_option( 'backwpup_cfg_dropboxappsecret' );
- delete_site_option( 'backwpup_cfg_dropboxsandboxappkey' );
- delete_site_option( 'backwpup_cfg_dropboxsandboxappsecret' );
- delete_site_option( 'backwpup_cfg_sugarsynckey' );
- delete_site_option( 'backwpup_cfg_sugarsyncsecret' );
- delete_site_option( 'backwpup_cfg_sugarsyncappid' );
- delete_site_option( 'backwpup_cfg_hash' );
+ global $wpdb;
- BackWPup_Option::default_site_options();
+ $information = array();
- BackWPup_Admin::message( __( 'Settings reset to default', 'backwpup' ) );
+ // Wordpress version
+ $information['wpversion']['label'] = __( 'WordPress version', 'backwpup' );
+ $information['wpversion']['value'] = BackWPup::get_plugin_data( 'wp_version' );
- return;
+ // BackWPup version
+ if ( ! BackWPup::is_pro() ) {
+ $information['bwuversion']['label'] = esc_html__( 'BackWPup version', 'backwpup' );
+ $information['bwuversion']['value'] = BackWPup::get_plugin_data( 'Version' );
+ $information['bwuversion']['html'] = BackWPup::get_plugin_data( 'Version' ) .
+ '
' .
+ esc_html__( 'Get pro.', 'backwpup' ) . ' ';
+ } else {
+ $information['bwuversion']['label'] = __( 'BackWPup Pro version', 'backwpup' );
+ $information['bwuversion']['value'] = BackWPup::get_plugin_data( 'Version' );
}
- update_site_option( 'backwpup_cfg_showadminbar', ! empty( $_POST['showadminbarmenu'] ) );
- update_site_option( 'backwpup_cfg_showfoldersize', ! empty( $_POST['showfoldersize'] ) );
-
- if ( empty( $_POST['jobstepretry'] ) || 100 < $_POST['jobstepretry'] || 1 > $_POST['jobstepretry'] ) {
- $_POST['jobstepretry'] = 3;
+ // PHP version
+ $information['phpversion']['label'] = esc_html__( 'PHP version', 'backwpup' );
+ $bit = '';
+ if ( PHP_INT_SIZE === 4 ) {
+ $bit = ' (32bit)';
+ } elseif ( PHP_INT_SIZE === 8 ) {
+ $bit = ' (64bit)';
}
+ $information['phpversion']['value'] = PHP_VERSION . ' ' . $bit;
- update_site_option( 'backwpup_cfg_jobstepretry', absint( $_POST['jobstepretry'] ) );
+ // MySQL version
+ $information['mysqlversion']['label'] = esc_html__( 'MySQL version', 'backwpup' );
+ $information['mysqlversion']['value'] = $wpdb->get_var( "SELECT VERSION() AS version" );
- if ( (int) $_POST['jobmaxexecutiontime'] > 300 ) {
- $_POST['jobmaxexecutiontime'] = 300;
+ // Curl version
+ $information['curlversion']['label'] = esc_html__( 'cURL version', 'backwpup' );
+ if ( function_exists( 'curl_version' ) ) {
+ $curl_version = curl_version();
+ $information['curlversion']['value'] = $curl_version['version'];
+ $information['curlsslversion']['label'] = __( 'cURL SSL version', 'backwpup' );
+ $information['curlsslversion']['value'] = $curl_version['ssl_version'];
+ } else {
+ $information['curlversion']['value'] = esc_html__( 'unavailable', 'backwpup' );
}
- update_site_option( 'backwpup_cfg_jobmaxexecutiontime', absint( $_POST['jobmaxexecutiontime'] ) );
- update_site_option(
- 'backwpup_cfg_loglevel',
- in_array(
- $_POST['loglevel'],
- array( 'normal_translated', 'normal', 'debug_translated', 'debug' ),
- true
- ) ? $_POST['loglevel'] : 'normal_translated'
- );
- update_site_option( 'backwpup_cfg_jobwaittimems', absint( $_POST['jobwaittimems'] ) );
- update_site_option( 'backwpup_cfg_jobdooutput', ! empty( $_POST['jobdooutput'] ) );
- update_site_option( 'backwpup_cfg_windows', ! empty( $_POST['windows'] ));
- update_site_option(
- 'backwpup_cfg_encryption',
- filter_input( INPUT_POST, 'encryption', FILTER_CALLBACK, array(
- 'options' => function ( $value ) {
- return in_array(
- $value,
- array( 'symmetric', 'asymmetric' ),
- true
- ) ? $value : 'symmetric';
- }
- ) )
- );
+ // WP cron URL
+ $information['wpcronurl']['label'] = esc_html__( 'WP-Cron url', 'backwpup' );
+ $information['wpcronurl']['value'] = site_url( 'wp-cron.php' );
- // Ensure encryption key is hexadecimal
- $encryptionkey = filter_input( INPUT_POST, 'encryptionkey', FILTER_CALLBACK, array(
- 'options' => function ( $value ) {
- if ( ctype_xdigit( $value ) ) {
- return substr( $value, 0, 64 );
- }
- return false;
+ // Response test
+ $server_connect['label'] = __( 'Server self connect', 'backwpup' );
+
+ $raw_response = BackWPup_Job::get_jobrun_url( 'test' );
+ $response_code = wp_remote_retrieve_response_code( $raw_response );
+ $response_body = wp_remote_retrieve_body( $raw_response );
+ if ( strstr( $response_body, 'BackWPup test request' ) === false ) {
+ $server_connect['value'] = esc_html__( 'Not expected HTTP response:', 'backwpup' ) . "\n";
+ $server_connect['html'] = wp_kses( __( '
Not expected HTTP response: ', 'backwpup' ),
+ array( 'strong' => array() ) );
+ if ( ! $response_code ) {
+ $server_connect['value'] .= sprintf( wp_kses_post(
+ __( 'WP Http Error: %s', 'backwpup' ),
+ $raw_response->get_error_message()
+ ) ) . "\n";
+ $server_connect['html'] = sprintf(
+ __( 'WP Http Error:
%s
', 'backwpup' ),
+ esc_html( $raw_response->get_error_message() )
+ ) . '
';
+ } else {
+ $server_connect['value'] .= sprintf( __( 'Status-Code: %d', 'backwpup' ), $response_code ) . "\n";
+ $server_connect['html'] .= sprintf(
+ __( 'Status-Code:
%d
', 'backwpup' ),
+ esc_html( $response_code )
+ ) . '
';
+ }
+ $response_headers = wp_remote_retrieve_headers( $raw_response );
+ foreach ( $response_headers as $key => $value ) {
+ $server_connect['value'] .= ucfirst( $key ) . ": $value\n";
+ $server_connect['html'] .= esc_html( ucfirst( $key ) ) . ':
' . esc_html(
+ $value
+ ) . '
';
+ }
+ $content = wp_remote_retrieve_body( $raw_response );
+ if ( $content ) {
+ $server_connect['value'] .= sprintf( __( 'Content: %s', 'backwpup' ), $content );
+ $server_connect['html'] .= sprintf(
+ __( 'Content:
%s
', 'backwpup' ),
+ esc_html( $content )
+ );
}
- ) );
- if ( $encryptionkey ) {
- update_site_option( 'backwpup_cfg_encryptionkey', $encryptionkey );
+ } else {
+ $server_connect['value'] = __( 'Response Test O.K.', 'backwpup' );
}
+ $information['serverconnect'] = $server_connect;
+
+ // Document root
+ $information['docroot']['label'] = 'Document root';
+ $information['docroot']['value'] = $_SERVER['DOCUMENT_ROOT'];
- if ( isset( $_POST['publickey'] ) ) {
- update_site_option( 'backwpup_cfg_publickey', filter_input( INPUT_POST, 'publickey', FILTER_SANITIZE_STRING ) );
+ // Temp folder
+ $information['tmpfolder']['label'] = esc_html__( 'Temp folder', 'backwpup' );
+ if ( ! is_dir( BackWPup::get_plugin_data( 'TEMP' ) ) ) {
+ $information['tmpfolder']['value'] = sprintf(
+ esc_html__( 'Temp folder %s doesn\'t exist.', 'backwpup' ),
+ BackWPup::get_plugin_data( 'TEMP' )
+ );
+ } elseif ( ! is_writable( BackWPup::get_plugin_data( 'TEMP' ) ) ) {
+ $information['tmpfolder']['value'] = sprintf(
+ esc_html__( 'Temporary folder %s is not writable.', 'backwpup' ),
+ BackWPup::get_plugin_data( 'TEMP' )
+ );
+ } else {
+ $information['tmpfolder']['value'] = BackWPup::get_plugin_data( 'TEMP' );
}
- update_site_option( 'backwpup_cfg_maxlogs', absint( $_POST['maxlogs'] ) );
- update_site_option( 'backwpup_cfg_gzlogs', ! empty( $_POST['gzlogs'] ) );
- update_site_option( 'backwpup_cfg_protectfolders', ! empty( $_POST['protectfolders'] ) );
+ // Log folder
+ $information['logfolder']['label'] = esc_html__( 'Log folder', 'backwpup' );
+ $log_folder = BackWPup_File::get_absolute_path(
+ get_site_option( 'backwpup_cfg_logfolder' )
+ );
+ if ( ! is_dir( $log_folder ) ) {
+ $information['logfolder']['value'] = sprintf(
+ esc_html__( 'Log folder %s does not exist.', 'backwpup' ),
+ $log_folder
+ );
+ } elseif ( ! is_writable( $log_folder ) ) {
+ $information['logfolder']['value'] = sprintf(
+ esc_html__( 'Log folder %s is not writable.', 'backwpup' ),
+ $log_folder
+ );
+ } else {
+ $information['logfolder']['value'] = $log_folder;
+ }
- $_POST['jobrunauthkey'] = preg_replace( '/[^a-zA-Z0-9]/', '', trim( $_POST['jobrunauthkey'] ) );
+ // Server
+ $information['server']['label'] = esc_html__( 'Server', 'backwpup' );
+ $information['server']['value'] = $_SERVER['SERVER_SOFTWARE'];
- update_site_option( 'backwpup_cfg_jobrunauthkey', $_POST['jobrunauthkey'] );
+ // OS
+ $information['os']['label'] = esc_html__( 'Operating System', 'backwpup' );
+ $information['os']['value'] = PHP_OS;
- $_POST['logfolder'] = trailingslashit(
- str_replace( '\\', '/', trim( stripslashes( sanitize_text_field( $_POST['logfolder'] ) ) ) )
- );
+ // PHP SAPI
+ $information['phpsapi']['label'] = esc_html__( 'PHP SAPI', 'backwpup' );
+ $information['phpsapi']['value'] = PHP_SAPI;
- //set def. folders
- if ( empty( $_POST['logfolder'] ) || $_POST['logfolder'] === '/' ) {
- delete_site_option( 'backwpup_cfg_logfolder' );
- BackWPup_Option::default_site_options();
+ // PHP user
+ $information['phpuser']['label'] = esc_html__( 'Current PHP user', 'backwpup' );
+ if ( function_exists( 'get_current_user' ) ) {
+ $information['phpuser']['value'] = get_current_user();
} else {
- update_site_option( 'backwpup_cfg_logfolder', $_POST['logfolder'] );
+ $information['phpuser']['value'] = esc_html__( 'Function Disabled', 'backwpup' );
}
- $authentication = get_site_option(
- 'backwpup_cfg_authentication',
- array(
- 'method' => '',
- 'basic_user' => '',
- 'basic_password' => '',
- 'user_id' => 0,
- 'query_arg' => '',
- )
+ // Maximum execution time
+ $information['maxexectime']['label'] = esc_html__( 'Maximum execution time', 'backwpup' );
+ $information['maxexectime']['value'] = sprintf(
+ __( '%d seconds', 'backwpup' ),
+ ini_get( 'max_execution_time' )
);
- $authentication['method'] = ( in_array(
- $_POST['authentication_method'],
- array( 'user', 'basic', 'query_arg' ),
- true
- ) ) ? $_POST['authentication_method'] : '';
- $authentication['basic_user'] = sanitize_text_field( $_POST['authentication_basic_user'] );
- $authentication['basic_password'] = BackWPup_Encryption::encrypt(
- (string) $_POST['authentication_basic_password']
+
+ // BackWPup Maximum script execution time
+ $information['jobmaxexecutiontime']['label'] = esc_html__( 'BackWPup maximum script execution time',
+ 'backwpup' );
+ $information['jobmaxexecutiontime']['value'] = sprintf(
+ __( '%d seconds', 'backwpup' ),
+ absint( get_site_option( 'backwpup_cfg_jobmaxexecutiontime' ) )
);
- $authentication['query_arg'] = sanitize_text_field( $_POST['authentication_query_arg'] );
- $authentication['user_id'] = absint( $_POST['authentication_user_id'] );
- update_site_option( 'backwpup_cfg_authentication', $authentication );
- delete_site_transient( 'backwpup_cookies' );
- do_action( 'backwpup_page_settings_save' );
+ // Alternate WP cron
+ $information['altwpcron']['label'] = esc_html__( 'Alternative WP Cron', 'backwpup' );
+ if ( defined( 'ALTERNATE_WP_CRON' ) && ALTERNATE_WP_CRON ) {
+ $information['altwpcron']['value'] = esc_html__( 'On', 'backwpup' );
+ } else {
+ $information['altwpcron']['value'] = esc_html__( 'Off', 'backwpup' );
+ }
- BackWPup_Admin::message( __( 'Settings saved', 'backwpup' ) );
- }
+ // Disable WP cron
+ $information['disablewpcron']['label'] = esc_html__( 'Disabled WP Cron', 'backwpup' );
+ if ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ) {
+ $information['disablewpcron']['value'] = esc_html__( 'On', 'backwpup' );
+ } else {
+ $information['disablewpcron']['value'] = esc_html__( 'Off', 'backwpup' );
+ }
- /**
- * Page Output
- */
- public static function page() {
+ // CHMOD dir
+ $information['chmoddir']['label'] = esc_html__( 'CHMOD Dir', 'backwpup' );
+ if ( defined( 'FS_CHMOD_DIR' ) ) {
+ $information['chmoddir']['value'] = FS_CHMOD_DIR;
+ } else {
+ $information['chmoddir']['value'] = '0755';
+ }
- global $wpdb;
+ // Server time
+ $information['servertime']['label'] = esc_html__( 'Server Time', 'backwpup' );
+ $now = localtime( time(), true );
+ $information['servertime']['value'] = $now['tm_hour'] . ':' . $now['tm_min'];
- $encryption_textarea_readonly = get_site_option( 'backwpup_cfg_publickey' ) ? 'readonly="readonly"' : '';
+ // Blog time
+ $information['blogtime']['label'] = esc_html__( 'Blog Time', 'backwpup' );
+ $information['blogtime']['value'] = date( 'H:i', current_time( 'timestamp' ) );
- ?>
-
-
+ // Blog timezone
+ $information['blogtz']['label'] = esc_html__( 'Blog Timezone', 'backwpup' );
+ $information['blogtz']['value'] = get_option( 'timezone_string' );
+
+ // Blog time offset
+ $information['blogoffset']['label'] = esc_html__( 'Blog Time offset', 'backwpup' );
+ $information['blogoffset']['value'] = sprintf(
+ esc_html__( '%s hours', 'backwpup' ),
+ (int) get_option( 'gmt_offset' )
+ );
+
+ // Blog language
+ $information['bloglang']['label'] = esc_html__( 'Blog language', 'backwpup' );
+ $information['bloglang']['value'] = get_bloginfo( 'language' );
+
+ // MySQL encoding
+ $information['mysqlencoding']['label'] = esc_html__( 'MySQL Client encoding', 'backwpup' );
+ $information['mysqlencoding']['value'] = defined( 'DB_CHARSET' ) ? DB_CHARSET : '';
+
+ // PHP memory limitesc_html__
+ $information['phpmemlimit']['label'] = esc_html__( 'PHP Memory limit', 'backwpup' );
+ $information['phpmemlimit']['value'] = ini_get( 'memory_limit' );
+
+ // WP memory limit
+ $information['wpmemlimit']['label'] = esc_html__( 'WP memory limit', 'backwpup' );
+ $information['wpmemlimit']['value'] = WP_MEMORY_LIMIT;
+
+ // WP maximum memory limit
+ $information['wpmaxmemlimit']['label'] = esc_html__( 'WP maximum memory limit', 'backwpup' );
+ $information['wpmaxmemlimit']['value'] = WP_MAX_MEMORY_LIMIT;
+
+ // Memory in use
+ $information['memusage']['label'] = esc_html__( 'Memory in use', 'backwpup' );
+ $information['memusage']['value'] = size_format( @memory_get_usage( true ), 2 );
+
+ // Disabled PHP functions
+ $disabled = esc_html( ini_get( 'disable_functions' ) );
+ if ( ! empty( $disabled ) ) {
+ $information['disabledfunctions']['label'] = esc_html__( 'Disabled PHP Functions:', 'backwpup' );
+ $information['disabledfunctions']['value'] = implode( ', ', explode( ',', $disabled ) );
+ }
+
+ // Loaded PHP extensions
+ $information['loadedextensions']['label'] = esc_html__( 'Loaded PHP Extensions:', 'backwpup' );
+ $extensions = get_loaded_extensions();
+ sort( $extensions );
+ $information['loadedextensions']['value'] = implode( ', ', $extensions );
+
+ return $information;
+ }
+
+ /**
+ * BackWPup_Page_Settings constructor
+ *
+ * @param array $settings_views
+ * @param array $settings_updaters
+ */
+ public function __construct( array $settings_views, array $settings_updaters ) {
+
+ $this->settings_views = array_filter(
+ $settings_views,
+ function ( $setting ) {
+
+ return $setting instanceof Settings\SettingTab;
+ }
+ );
+ $this->settings_updaters = array_filter(
+ $settings_updaters,
+ function ( $setting ) {
+
+ return $setting instanceof Settings\SettingUpdatable;
+ }
+ );
+ }
+
+ public function admin_print_scripts() {
+
+ $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
+
+ wp_enqueue_script(
+ 'backwpuppagesettings',
+ untrailingslashit( BackWPup::get_plugin_data( 'URL' ) ) . "/assets/js/page_settings{$suffix}.js",
+ array(
+ 'jquery',
+ 'backwpupgeneral',
+ 'backwpup_clipboard',
+ ),
+ filemtime( untrailingslashit( BackWPup::get_plugin_data( 'plugindir' ) ) . "/assets/js/page_settings{$suffix}.js" ),
+ true
+ );
+
+ if ( \BackWPup::is_pro() ) {
+ wp_enqueue_script(
+ 'backwpuppagesettings-encryption',
+ untrailingslashit( BackWPup::get_plugin_data( 'URL' ) ) . "/assets/js/pro/settings-encryption{$suffix}.js",
+ array(
+ 'underscore',
+ 'jquery',
+ 'backwpuppagesettings',
+ 'thickbox',
+ ),
+ filemtime( untrailingslashit( BackWPup::get_plugin_data( 'plugindir' ) ) . "/assets/js/pro/settings-encryption{$suffix}.js" ),
+ true
+ );
+
+ wp_localize_script(
+ 'backwpuppagesettings-encryption',
+ 'settingsEncryptionVariables',
+ array(
+ 'validPublicKey' => esc_html__( 'Public key is valid.', 'backwpup' ),
+ 'invalidPublicKey' => esc_html__( 'Public key is invalid.', 'backwpup' ),
+ 'privateKeyMissed' => esc_html__( 'Please enter your private key.', 'backwpup' ),
+ 'publicKeyMissed' => esc_html__(
+ 'Please enter a public key first, or generate a key pair.',
+ 'backwpup'
+ ),
+ 'mustDownloadPrivateKey' => esc_html__(
+ 'Please download the private key before continuing. If you do not save it locally, you cannot decrypt your backups later.',
+ 'backwpup'
+ ),
+ 'mustDownloadSymmetricKey' => esc_html__(
+ 'Please download the key before continuing. If you do not save it locally, you cannot decrypt your backups later.',
+ 'backwpup'
+ ),
+ )
+ );
+ }
+ }
+
+ public function save_post_form() {
+
+ if ( ! current_user_can( 'backwpup_settings' ) ) {
+ return;
+ }
+
+ // Set default options if button clicked.
+ if ( isset( $_POST['default_settings'] ) && $_POST['default_settings'] ) { // phpcs:ignore
+ delete_site_option( 'backwpup_cfg_showadminbar' );
+ delete_site_option( 'backwpup_cfg_showfoldersize' );
+ delete_site_option( 'backwpup_cfg_jobstepretry' );
+ delete_site_option( 'backwpup_cfg_jobmaxexecutiontime' );
+ delete_site_option( 'backwpup_cfg_loglevel' );
+ delete_site_option( 'backwpup_cfg_jobwaittimems' );
+ delete_site_option( 'backwpup_cfg_jobrunauthkey' );
+ delete_site_option( 'backwpup_cfg_jobdooutput' );
+ delete_site_option( 'backwpup_cfg_windows' );
+ delete_site_option( 'backwpup_cfg_maxlogs' );
+ delete_site_option( 'backwpup_cfg_gzlogs' );
+ delete_site_option( 'backwpup_cfg_protectfolders' );
+ delete_site_option( 'backwpup_cfg_authentication' );
+ delete_site_option( 'backwpup_cfg_logfolder' );
+ delete_site_option( 'backwpup_cfg_dropboxappkey' );
+ delete_site_option( 'backwpup_cfg_dropboxappsecret' );
+ delete_site_option( 'backwpup_cfg_dropboxsandboxappkey' );
+ delete_site_option( 'backwpup_cfg_dropboxsandboxappsecret' );
+ delete_site_option( 'backwpup_cfg_sugarsynckey' );
+ delete_site_option( 'backwpup_cfg_sugarsyncsecret' );
+ delete_site_option( 'backwpup_cfg_sugarsyncappid' );
+ delete_site_option( 'backwpup_cfg_hash' );
+
+ foreach ( $this->settings_updaters as $setting ) {
+ $setting->reset();
+ }
+
+ BackWPup_Option::default_site_options();
+ BackWPup_Admin::message( __( 'Settings reset to default', 'backwpup' ) );
+
+ return;
+ }
+
+ foreach ( $this->settings_updaters as $setting ) {
+ $setting->update();
+ }
+
+ update_site_option( 'backwpup_cfg_showadminbar', ! empty( $_POST['showadminbarmenu'] ) );
+ update_site_option( 'backwpup_cfg_showfoldersize', ! empty( $_POST['showfoldersize'] ) );
+
+ if ( empty( $_POST['jobstepretry'] ) || 100 < $_POST['jobstepretry'] || 1 > $_POST['jobstepretry'] ) {
+ $_POST['jobstepretry'] = 3;
+ }
+
+ update_site_option( 'backwpup_cfg_jobstepretry', absint( $_POST['jobstepretry'] ) );
+
+ if ( (int) $_POST['jobmaxexecutiontime'] > 300 ) {
+ $_POST['jobmaxexecutiontime'] = 300;
+ }
+
+ update_site_option( 'backwpup_cfg_jobmaxexecutiontime', absint( $_POST['jobmaxexecutiontime'] ) );
+ update_site_option(
+ 'backwpup_cfg_loglevel',
+ in_array(
+ $_POST['loglevel'],
+ array( 'normal_translated', 'normal', 'debug_translated', 'debug' ),
+ true
+ ) ? $_POST['loglevel'] : 'normal_translated'
+ );
+ update_site_option( 'backwpup_cfg_jobwaittimems', absint( $_POST['jobwaittimems'] ) );
+ update_site_option( 'backwpup_cfg_jobdooutput', ! empty( $_POST['jobdooutput'] ) );
+ update_site_option( 'backwpup_cfg_windows', ! empty( $_POST['windows'] ) );
+
+ update_site_option( 'backwpup_cfg_maxlogs', absint( $_POST['maxlogs'] ) );
+ update_site_option( 'backwpup_cfg_gzlogs', ! empty( $_POST['gzlogs'] ) );
+ update_site_option( 'backwpup_cfg_protectfolders', ! empty( $_POST['protectfolders'] ) );
+
+ $_POST['jobrunauthkey'] = preg_replace( '/[^a-zA-Z0-9]/', '', trim( $_POST['jobrunauthkey'] ) );
+
+ update_site_option( 'backwpup_cfg_jobrunauthkey', $_POST['jobrunauthkey'] );
+
+ $_POST['logfolder'] = trailingslashit(
+ str_replace( '\\', '/', trim( stripslashes( sanitize_text_field( $_POST['logfolder'] ) ) ) )
+ );
+
+ //set def. folders
+ if ( empty( $_POST['logfolder'] ) || $_POST['logfolder'] === '/' ) {
+ delete_site_option( 'backwpup_cfg_logfolder' );
+ BackWPup_Option::default_site_options();
+ } else {
+ update_site_option( 'backwpup_cfg_logfolder', $_POST['logfolder'] );
+ }
+
+ $authentication = get_site_option(
+ 'backwpup_cfg_authentication',
+ array(
+ 'method' => '',
+ 'basic_user' => '',
+ 'basic_password' => '',
+ 'user_id' => 0,
+ 'query_arg' => '',
+ )
+ );
+ $authentication['method'] = ( in_array(
+ $_POST['authentication_method'],
+ array( 'user', 'basic', 'query_arg' ),
+ true
+ ) ) ? $_POST['authentication_method'] : '';
+ $authentication['basic_user'] = sanitize_text_field( $_POST['authentication_basic_user'] );
+ $authentication['basic_password'] = BackWPup_Encryption::encrypt(
+ (string) $_POST['authentication_basic_password']
+ );
+ $authentication['query_arg'] = sanitize_text_field( $_POST['authentication_query_arg'] );
+ $authentication['user_id'] = absint( $_POST['authentication_user_id'] );
+ update_site_option( 'backwpup_cfg_authentication', $authentication );
+ delete_site_transient( 'backwpup_cookies' );
+
+ do_action( 'backwpup_page_settings_save' );
+
+ BackWPup_Admin::message( __( 'Settings saved', 'backwpup' ) );
+ }
+
+ public function page() {
+
+ ?>
+
+
+
+
';
foreach ( $tabs as $id => $name ) {
echo '
' . esc_attr( $name ) . ' ';
@@ -232,9 +506,9 @@ public static function page() {