|
发表于 2016-8-31 20:44:54
|
显示全部楼层
广西壮族自治区南宁市
- /* 发包函数 */
- function fopen_send($url, $limit = 0, $post = '', $cookie = '', $bysocket = FALSE, $ip = '', $timeout = 10000, $block = TRUE) {
- $return = '';
- $matches = parse_url($url);
- !isset($matches['host']) && $matches['host'] = '';
- !isset($matches['path']) && $matches['path'] = '';
- !isset($matches['query']) && $matches['query'] = '';
- !isset($matches['port']) && $matches['port'] = '';
- $host = $matches['host'];
- $path = $matches['path'] ? $matches['path'].($matches['query'] ? '?'.$matches['query'] : '') : '/';
- $port = !empty($matches['port']) ? $matches['port'] : 80;
- if($post) {
- $out = "POST $path HTTP/1.0\r\n";
- $out .= "Accept: */*\r\n";
- //$out .= "Referer: $boardurl\r\n";
- $out .= "Accept-Language: zh-cn\r\n";
- $out .= "Content-Type: application/x-www-form-urlencoded\r\n";
- $out .= "User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1\r\n";
- $out .= "Host: $host\r\n";
- $out .= 'Content-Length: '.strlen($post)."\r\n";
- $out .= "Connection: Close\r\n";
- $out .= "Cache-Control: no-cache\r\n";
- $out .= "Cookie: $cookie\r\n\r\n";
- $out .= $post;
- } else {
- $out = "GET $path HTTP/1.0\r\n";
- $out .= "Accept: */*\r\n";
- //$out .= "Referer: $boardurl\r\n";
- $out .= "Accept-Language: zh-cn\r\n";
- $out .= "User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1\r\n";
- $out .= "Host: $host\r\n";
- $out .= "Connection: Close\r\n";
- $out .= "Cookie: $cookie\r\n\r\n";
- }
- if(function_exists('fsockopen')) {
- $fp = @fsockopen(($ip ? $ip : $host), $port, $errno, $errstr, $timeout);
- } elseif (function_exists('pfsockopen')) {
- $fp = @pfsockopen(($ip ? $ip : $host), $port, $errno, $errstr, $timeout);
- } else {
- $fp = false;
- }
- if(!$fp) {
- return '';
- } else {
- stream_set_blocking($fp, $block);
- stream_set_timeout($fp, $timeout);
- @fwrite($fp, $out);
- $status = stream_get_meta_data($fp);
- if(!$status['timed_out']) {
- while (!feof($fp)) {
- if(($header = @fgets($fp)) && ($header == "\r\n" || $header == "\n")) {
- break;
- }
- }
- $stop = false;
- while(!feof($fp) && !$stop) {
- $data = fread($fp, ($limit == 0 || $limit > 8192 ? 8192 : $limit));
- $return .= $data;
- if($limit) {
- $limit -= strlen($data);
- $stop = $limit <= 0;
- }
- }
- }
- @fclose($fp);
- return $return;
- }
- }
- function httpGet($url, $data=array(), $header=array(), $timeout=30) {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); // 从证书中检查SSL加密算法是否存在
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
- $response = curl_exec($ch);
- if($error=curl_error($ch)){
- die($error);
- }
- curl_close($ch);
- return $response;
- }
- function httpPost($uri,$param=array(),$header=array()){
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $uri);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- $response = curl_exec($ch);
- curl_close($ch);
- return $response;
- }
复制代码
币太少,我就敷衍下!!给多点币咯! |
评分
-
查看全部评分
|