文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>乾坤小小小挪移

乾坤小小小挪移

时间:2007-02-17  来源:PHP爱好者

类文件:
chin a i t p oe er . co muQ0RVXCYMWkitGm2vio1wxTAR
<?
chin a i t p oe er . co muQ0RVXCYMWkitGm2vio1wxTAR
Class getFile{
chin a i t p oe er . co muQ0RVXCYMWkitGm2vio1wxTAR
var $info = array();
chin a i t p oe er . co muQ0RVXCYMWkitGm2vio1wxTAR
var $size = 0;
chin a i t p oe er . co muQ0RVXCYMWkitGm2vio1wxTAR
var $type = 'unknown';
chin a i t p oe er . co muQ0RVXCYMWkitGm2vio1wxTAR
var $lastModified = '';
var $sp;
chin a i t p oe er . co muQ0RVXCYMWkitGm2vio1wxTAR
var $content;
chin a i t p oe er . co muQ0RVXCYMWkitGm2vio1wxTAR
var $header;
chin a i t p oe er . co muQ0RVXCYMWkitGm2vio1wxTAR
var $max_run_time = 30;
chin a i t p oe er . co muQ0RVXCYMWkitGm2vio1wxTAR
var $max_get_size = 1024;
chin a i t p oe er . co muQ0RVXCYMWkitGm2vio1wxTAR
var $error_no;
chin a i t p oe er . co muQ0RVXCYMWkitGm2vio1wxTAR
var $error_str;
chin a i t p oe er . co muQ0RVXCYMWkitGm2vio1wxTAR

chin a i t p oe er . co muQ0RVXCYMWkitGm2vio1wxTAR
function getFile($url = '', $request_ver = 'HTTP/1.0') {
chin a i t p oe er . co muQ0RVXCYMWkitGm2vio1wxTAR
if($url <> '') {
chin a i t p oe er . co muQ0RVXCYMWkitGm2vio1wxTAR
$this->getContent($url, $request_ver);
chin a i t p oe er . co muQ0RVXCYMWkitGm2vio1wxTAR
}
chin a i t p oe er . co muQ0RVXCYMWkitGm2vio1wxTAR
}
chin a i t p oe er . co muQ0RVXCYMWkitGm2vio1wxTAR
function getContent($url, $request_ver = 'HTTP/1.0') {
chin a i t p oe er . co muQ0RVXCYMWkitGm2vio1wxTAR
$infomax_get_size)%20? $this->max_get_size : 4098;
$max_run_time = ($this->max_run_time) ? $this->max_run_time : 30;
$tmp = parse_url($url);
$info[port] = ($tmp[port]) ? $tmp[port] : 80;
if(!$tmp[path]) {
return 0;
}
if(!$tmp[host]) {
return 0;
}
$info[host] = $tmp[host];
$info[path] = $tmp[path];
$sp = fsockopen($info[host], $info[port], &$this->error_no, &$this->error_str,
$max_run_time);
if(!$sp) {
return 0;
}
$request = "GET $info[path] $request_ver";
$request.= "rnHost: $info[host]";
$request.= "rnrn";
fputs($sp, $request);
while(!feof($sp)) {
$buffer = fread($sp, $max_get_size);
$content .= $buffer;
}
preg_match("/Content-Type: (.+)/i", $content, $tmp);
$this->type = ($tmp[1]) ? $tmp[1] : 'unknown';
preg_match("/Content-Length: (d+)/i", $content, $tmp);
$this->size = ($tmp[1]) ? $tmp[1] : 'unknown';
preg_match("/^(.+?rnrn)/s", $content, $tmp);
$this->header = $tmp[1];
$this->content = str_replace($this->header, '', $content);
}
function size() {
return $this->size;
}
function type() {
return $this->type;
}
function lastModified() {
return $this->lastModified;
}
function sp() {
return $this->sp;
}
function content() {
return $this->content;
}
function host() {
return $this->info[host];
}
function path() {
return $this->info[path];
}
function header() {
return $this->header;
}
function export($file) {
$p = fopen($file, 'w');
fwrite($p, $this->content);
fclose($p);
}
}
?>
-------------------------------------------------------------
主程序:

文件URL:
保存名字:


整理日期:2001-08-27  首页 > ◆ PHP文章 -> 乾坤小小小挪移 www.chinaitp ower .comuQ0RVXCYMWkitGm2vio1wxTAR
php爱好者站 http://www.phpfans.net 为phper提供一切资讯.
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载