<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Util; class CurlUtil { private static function JSONResult($vu_fe, $XKiRP = '', $EdQjV = null) { goto sLfL0; sLfL0: $ScTxp = array('code' => $vu_fe, 'msg' => $XKiRP); goto k2NOT; sdKaF: return $ScTxp; goto o4iwD; k2NOT: if (null !== $EdQjV) { $ScTxp['data'] = $EdQjV; } goto sdKaF; o4iwD: } private static function removeStringBOF($kWMSY) { if (strlen($kWMSY) >= 3) { if ('EFBBBF' == sprintf('%X%X%X', ord($kWMSY[0]), ord($kWMSY[1]), ord($kWMSY[2]))) { return substr($kWMSY, 3); } } return $kWMSY; } public static function getJSONData($xIfit, $Kp99R = array(), $WwRq4 = array()) { goto mDazA; ejugQ: if ($JOw_A['code'] === 0) { return $JOw_A['data']; } goto yowbL; mDazA: $JOw_A = self::getJSON($xIfit, $Kp99R, $WwRq4); goto ejugQ; yowbL: return null; goto hBt7Z; hBt7Z: } public static function getJSON($xIfit, $Kp99R = array(), $WwRq4 = array()) { goto EFqmH; QvHY1: if (empty($c8Hgd)) { return self::JSONResult(-1, 'CurlUtil.getJSON json parse error', $ScTxp['body']); } goto b0Ib8; b0Ib8: return self::JSONResult(0, '', $c8Hgd); goto gWqW8; EFqmH: $ScTxp = self::get($xIfit, $Kp99R, $WwRq4); goto dfLgg; Y8ty5: $c8Hgd = @json_decode($ScTxp['body'], true); goto QvHY1; i838R: $ScTxp['body'] = self::removeStringBOF($ScTxp['body']); goto Y8ty5; dfLgg: if (empty($ScTxp['body'])) { return self::JSONResult(-1, 'CurlUtil.getJSON result empty'); } goto i838R; gWqW8: } public static function postContent($xIfit, $Kp99R = array(), $WwRq4 = array()) { goto QVrsE; eBb5r: return $ScTxp['body']; goto pt3d3; QVrsE: $ScTxp = self::post($xIfit, $Kp99R, $WwRq4); goto JzOJN; JzOJN: if (empty($ScTxp['body'])) { return null; } goto eBb5r; pt3d3: } public static function postJSONBody($xIfit, $Kp99R = array(), $WwRq4 = array()) { goto OPmym; OPmym: $JOw_A = self::postJSON($xIfit, $Kp99R, $WwRq4); goto sMVfc; EG2ht: return $JOw_A['data']; goto LN8jP; sMVfc: if ($JOw_A['code']) { return $JOw_A; } goto EG2ht; LN8jP: } public static function postJSON($xIfit, $Kp99R = array(), $WwRq4 = array()) { goto wYLIe; XEmkT: if (empty($c8Hgd)) { return self::JSONResult(-1, 'CurlUtil.postJSON json parse error', $ScTxp['body']); } goto CPJvs; CPJvs: return self::JSONResult(0, '', $c8Hgd); goto cDfXz; FBDc1: $c8Hgd = @json_decode($ScTxp['body'], true); goto XEmkT; ZhEE5: if (empty($ScTxp['body'])) { return self::JSONResult(-1, 'CurlUtil.postJSON result empty'); } goto QxH21; wYLIe: $ScTxp = self::post($xIfit, $Kp99R, $WwRq4); goto ZhEE5; QxH21: $ScTxp['body'] = self::removeStringBOF($ScTxp['body']); goto FBDc1; cDfXz: } public static function putJSON($xIfit, $Kp99R = array(), $WwRq4 = array()) { goto pL5dK; KWrCQ: if (empty($c8Hgd)) { return self::JSONResult(-1, 'CurlUtil.putJSON json parse error', $ScTxp['body']); } goto Rsse4; Rsse4: return self::JSONResult(0, '', $c8Hgd); goto e5MCP; yQwLL: if (empty($ScTxp['body'])) { return self::JSONResult(-1, 'CurlUtil.putJSON result empty'); } goto n2S6i; gjK2z: $c8Hgd = @json_decode($ScTxp['body'], true); goto KWrCQ; pL5dK: $ScTxp = self::put($xIfit, $Kp99R, $WwRq4); goto yQwLL; n2S6i: $ScTxp['body'] = self::removeStringBOF($ScTxp['body']); goto gjK2z; e5MCP: } public static function deleteJSON($xIfit, $Kp99R = array(), $WwRq4 = array()) { goto S_ScM; XIGOB: $ScTxp['body'] = self::removeStringBOF($ScTxp['body']); goto ocsNY; KGAWg: return self::JSONResult(0, '', $c8Hgd); goto z0cxV; fFLGp: if (empty($c8Hgd)) { return self::JSONResult(-1, 'CurlUtil.deleteJSON json parse error', $ScTxp['body']); } goto KGAWg; q1NHi: if (empty($ScTxp['body'])) { return self::JSONResult(-1, 'CurlUtil.deleteJSON result empty'); } goto XIGOB; S_ScM: $ScTxp = self::delete($xIfit, $Kp99R, $WwRq4); goto q1NHi; ocsNY: $c8Hgd = @json_decode($ScTxp['body'], true); goto fFLGp; z0cxV: } public static function get($xIfit, $Kp99R = array(), $WwRq4 = array()) { $WwRq4['method'] = 'get'; return self::request($xIfit, $Kp99R, $WwRq4); } public static function post($xIfit, $Kp99R = array(), $WwRq4 = array()) { $WwRq4['method'] = 'post'; return self::request($xIfit, $Kp99R, $WwRq4); } public static function put($xIfit, $Kp99R = array(), $WwRq4 = array()) { $WwRq4['method'] = 'put'; return self::request($xIfit, $Kp99R, $WwRq4); } public static function delete($xIfit, $Kp99R = array(), $WwRq4 = array()) { $WwRq4['method'] = 'delete'; return self::request($xIfit, $Kp99R, $WwRq4); } public static function request($xIfit, $Kp99R, $WwRq4 = array()) { goto JB_jN; aazv3: curl_close($GDR6d); goto NsM89; hRZ6y: if ($tnoXd) { goto mQ0DW; FdCI9: $xCG9t = substr($ZK7zB, 0, $Lpe8W); goto RE6dW; mQ0DW: $Lpe8W = curl_getinfo($GDR6d, CURLINFO_HEADER_SIZE); goto FdCI9; Byrhv: foreach (explode('
', $xCG9t) as $oYaTJ) { $oYaTJ = trim($oYaTJ); if (preg_match('/^(.*?):(.*?)$/', $oYaTJ, $i5sAZ)) { $ScTxp['header'][] = array(trim($i5sAZ[1]) => trim($i5sAZ[2])); } } goto ixK7Z; RE6dW: $ScTxp['body'] = substr($ZK7zB, $Lpe8W); goto Byrhv; ixK7Z: } else { $ScTxp['body'] = $ZK7zB; } goto qAaTM; SVWjM: if (!empty($WwRq4['debugFile'])) { goto CQAvY; CQAvY: curl_setopt($GDR6d, CURLOPT_VERBOSE, true); goto lKdph; lKdph: $RyuNz = fopen($WwRq4['debugFile'], 'w'); goto Tz9OY; Tz9OY: curl_setopt($GDR6d, CURLOPT_STDERR, $RyuNz); goto n3KGm; n3KGm: } goto rvsSw; PZJQ2: $ScTxp = array(); goto oKM9I; ifva1: if (!empty($EPnQT)) { curl_setopt($GDR6d, CURLOPT_HTTPHEADER, $EPnQT); } goto rVoym; I8Nmu: $ScTxp['code'] = curl_getinfo($GDR6d, CURLINFO_HTTP_CODE); goto hRZ6y; jpvYW: curl_setopt($GDR6d, CURLOPT_TIMEOUT, $WwRq4['timeout']); goto BLjDY; NsM89: return $ScTxp; goto BajTP; M9me0: if ($WwRq4['method'] == 'get') { if (!empty($Kp99R)) { $xIfit = $xIfit . '?' . http_build_query($Kp99R); } } goto crNW_; Ry41H: if (!empty($WwRq4['returnHeader'])) { $tnoXd = true; } goto mdtK2; iGiqt: if ($tnoXd) { $ScTxp['header'] = array(); } goto M9me0; rVoym: curl_setopt($GDR6d, CURLOPT_RETURNTRANSFER, true); goto jpvYW; oypoG: if (!empty($WwRq4['header'])) { foreach ($WwRq4['header'] as $kh68j => $tHq0l) { $EPnQT[] = "{$kh68j}:{$tHq0l}"; } } goto kEVyz; EPeZK: if (!isset($WwRq4['timeout'])) { $WwRq4['timeout'] = 30; } goto PZJQ2; Rxaen: if (strpos($xIfit, 'https://') === 0) { curl_setopt($GDR6d, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($GDR6d, CURLOPT_SSL_VERIFYHOST, false); } goto l1tXt; mdtK2: if (!isset($WwRq4['method'])) { $WwRq4['method'] = 'get'; } goto EPeZK; EwlrT: switch (strtolower($WwRq4['method'])) { case 'post': goto FC2Vf; xSd0k: curl_setopt($GDR6d, CURLOPT_POSTFIELDS, $Kp99R); goto YqRGZ; YqRGZ: break; goto ByNte; FC2Vf: curl_setopt($GDR6d, CURLOPT_POST, true); goto xSd0k; ByNte: case 'put': goto cSDw_; cSDw_: curl_setopt($GDR6d, CURLOPT_CUSTOMREQUEST, 'PUT'); goto miJg3; miJg3: curl_setopt($GDR6d, CURLOPT_POSTFIELDS, $Kp99R); goto vAc4C; vAc4C: break; goto uQYFn; uQYFn: case 'delete': goto mWnEW; waY7l: curl_setopt($GDR6d, CURLOPT_POSTFIELDS, $Kp99R); goto GY9gi; mWnEW: curl_setopt($GDR6d, CURLOPT_CUSTOMREQUEST, 'DELETE'); goto waY7l; GY9gi: break; goto ujdre; ujdre: } goto Rxaen; BLjDY: if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) { curl_setopt($GDR6d, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); } goto EwlrT; rvsSw: curl_setopt($GDR6d, CURLOPT_HEADER, $tnoXd); goto ifva1; JB_jN: $EPnQT = array(); goto oypoG; l1tXt: if (!empty($WwRq4['socks5'])) { curl_setopt($GDR6d, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); curl_setopt($GDR6d, CURLOPT_PROXY, $WwRq4['socks5']); } goto nFM2T; qAaTM: if (0 === $ScTxp['code']) { $ScTxp['error'] = curl_error($GDR6d); } goto aazv3; nFM2T: $ZK7zB = curl_exec($GDR6d); goto t0SmT; gEIiG: $ScTxp['body'] = null; goto iGiqt; oKM9I: $ScTxp['code'] = 0; goto gEIiG; t0SmT: if (!empty($WwRq4['debugFile'])) { file_put_contents($WwRq4['debugFile'], '

' . $ZK7zB, FILE_APPEND); } goto I8Nmu; kEVyz: $tnoXd = false; goto Ry41H; crNW_: $GDR6d = curl_init($xIfit); goto SVWjM; BajTP: } public static function proxyRequest($lviAm, $xIfit, $Kp99R = array(), $WwRq4 = array()) { goto svdGQ; NfoRp: $I4p57['param'] = $Kp99R; goto WE3re; zQKUf: $rFmqf = self::getRaw($xIfit); goto Bm4Yu; svdGQ: $I4p57 = $WwRq4; goto qZcms; KYbEa: return $rFmqf; goto wzl7k; jsaG5: $rFmqf = @unserialize($rFmqf); goto KYbEa; WE3re: $xIfit = "{$lviAm}?package=" . urlencode(base64_encode(json_encode($I4p57))); goto zQKUf; Bm4Yu: $rFmqf = @base64_decode($rFmqf); goto jsaG5; qZcms: $I4p57['url'] = $xIfit; goto NfoRp; wzl7k: } public static function proxyCommon($lviAm, $I4p57) { goto tWY_e; BjhSY: $rFmqf = self::getRaw($xIfit); goto APuSI; APuSI: $rFmqf = @base64_decode($rFmqf); goto QN0gd; tWY_e: $xIfit = "{$lviAm}?package=" . urlencode(base64_encode(json_encode($I4p57))); goto BjhSY; a5ey8: return $rFmqf; goto yyWnQ; QN0gd: $rFmqf = @unserialize($rFmqf); goto a5ey8; yyWnQ: } public static function postRaw($xIfit, $Kp99R = array(), $WwRq4 = array()) { goto YD0WT; ghccR: curl_setopt($GDR6d, CURLOPT_REFERER, $xIfit); goto tynGb; cyr0k: $GDR6d = curl_init(); goto UHFui; tynGb: if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) { curl_setopt($GDR6d, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); } goto ceyqE; ceyqE: if (StrUtil::startWith($xIfit, 'https://')) { curl_setopt($GDR6d, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($GDR6d, CURLOPT_SSL_VERIFYHOST, false); } goto R1Gey; aacPw: $rnzc2 = curl_exec($GDR6d); goto bW1wf; R1Gey: curl_setopt($GDR6d, CURLOPT_POST, true); goto f5sUv; UHFui: curl_setopt($GDR6d, CURLOPT_URL, $xIfit); goto auvpv; uzzLq: if (!empty($EPnQT)) { curl_setopt($GDR6d, CURLOPT_HTTPHEADER, $EPnQT); } goto Ll1Kt; YD0WT: if (empty($WwRq4['timeout'])) { $WwRq4['timeout'] = 30; } goto eaR8p; XFmFk: if (!empty($WwRq4['header'])) { foreach ($WwRq4['header'] as $kh68j => $tHq0l) { $EPnQT[] = "{$kh68j}:{$tHq0l}"; } } goto cyr0k; bW1wf: curl_close($GDR6d); goto YmkYz; Ll1Kt: curl_setopt($GDR6d, CURLOPT_RETURNTRANSFER, 1); goto BF2uA; eaR8p: $EPnQT = array(); goto XFmFk; f5sUv: curl_setopt($GDR6d, CURLOPT_POSTFIELDS, $Kp99R); goto aacPw; BF2uA: curl_setopt($GDR6d, CURLOPT_TIMEOUT, $WwRq4['timeout']); goto ghccR; YmkYz: return $rnzc2; goto RQ3Nu; auvpv: curl_setopt($GDR6d, CURLOPT_HEADER, false); goto uzzLq; RQ3Nu: } public static function getRaw($xIfit, $Kp99R = array(), $WwRq4 = array()) { goto kkvT4; z2HW0: if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) { curl_setopt($GDR6d, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); } goto iCLeq; BJphQ: curl_setopt($GDR6d, CURLOPT_HEADER, false); goto pMKNq; iCLeq: if (StrUtil::startWith($xIfit, 'https://')) { curl_setopt($GDR6d, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($GDR6d, CURLOPT_SSL_VERIFYHOST, false); } goto UkAk9; pMKNq: if (!empty($EPnQT)) { curl_setopt($GDR6d, CURLOPT_HTTPHEADER, $EPnQT); } goto h0inN; n0Xy_: curl_close($GDR6d); goto QPHNd; IFWr3: $EPnQT = array(); goto NYyzP; kkvT4: if (empty($WwRq4['timeout'])) { $WwRq4['timeout'] = 30; } goto ZkymR; q6sId: curl_setopt($GDR6d, CURLOPT_TIMEOUT, $WwRq4['timeout']); goto dqCGu; ZkymR: if (!empty($Kp99R)) { $xIfit = $xIfit . '?' . http_build_query($Kp99R); } goto IFWr3; dqCGu: curl_setopt($GDR6d, CURLOPT_REFERER, $xIfit); goto z2HW0; zSLs_: $GDR6d = curl_init(); goto I23Nh; I23Nh: curl_setopt($GDR6d, CURLOPT_URL, $xIfit); goto BJphQ; QPHNd: return $rnzc2; goto XDQ_a; UkAk9: $rnzc2 = curl_exec($GDR6d); goto n0Xy_; h0inN: curl_setopt($GDR6d, CURLOPT_RETURNTRANSFER, 1); goto q6sId; NYyzP: if (!empty($WwRq4['header'])) { foreach ($WwRq4['header'] as $kh68j => $tHq0l) { $EPnQT[] = "{$kh68j}:{$tHq0l}"; } } goto zSLs_; XDQ_a: } }