zw870307
中级会员
 
UID 92902
精华
0
积分 286
帖子 387
金钱 286 喜悦币
威望 0
人脉 0
阅读权限 30
注册 2007-5-12
状态 离线
|
[推荐阅读] 谁有支持表格的编辑器
<?php function get_contents($url) { if(!strpos($url, '://')) return 'Invalid URI'; $content = ''; if(ini_get('allow_url_fopen')) { $content = file_get_contents($url); } elseif(function_exists('curl_init')) { $handle = curl_init(); curl_setopt($handle, CURLOPT_URL, $url); curl_setopt($handle, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($handle, CURLOPT_RETURNTRANSFER, 1); curl_setopt($handle, CURLOPT_FOLLOWLOCATION, 0); $content = curl_exec($handle); curl_close($handle); } elseif(function_exists('fsockopen')) { $urlinfo = parse_url($url); $host = $urlinfo['host']; $str = explode($host, $url); $uri = $str[1]; unset($urlinfo, $str); $content = ''; $fp = fsockopen($host, 80, $errno, $errstr, 30); if(!$fp) { $content = 'Can Not Open Socket...'; } else { $out = "GET $uri HTTP/1.1rn"; $out.= "Host: $host rn"; $out.= "Accept: */*rn"; $out.= "User-Agent: $_SERVER[HTTP_USER_AGENT]rn"; $out.= "Connection: Closernrn"; fputs($fp, $out); while (!feof($fp)) { $content .= fgets($fp, 4069); } fclose($fp); } } if(empty($content)) $content = 'Can Not Open Url, Please Check You Server ... <br/>For More Information, Please Visit [url]www.master8.net[/url]'; return $content; } ?> 网上看到的...
|
|