background image

 

        

//判别用 Get 方法发送的头的应答结果是否正确

        

function

 IsGetOK()

        

{

                

if

ereg

(“^2″,

$this

->GetHead(“http-state”)) )

                

{

                        

return

 true;

                

}

else

 {

                        

$this

->m_error .= 

$this

->GetHead(“http-state”).” – “.

$this

->GetHead(“http-

describe”).”<br>”;

                        

return

 false;

                

}

        

}

        

//看看返回的网页是否是 text 类型

        

function

 IsText()

        

{

                

if

(

ereg

(“^2″,

$this

->GetHead(“http-state”)) && 

eregi

(“^text”,

$this

-

>GetHead(“content-type”)))

                

{

                        

return

 true;

                

}

else

 {

                        

$this

->m_error .= “内容为非文本类型<br>”;

                        

return

 false;

                

}

        

}

        

//判断返回的网页是否是特定的类型

        

function

 IsContentType(

$ctype

)

        

{

                

if

(

ereg

(“^2″,

$this

->GetHead(“http-state”)) && 

$this

->GetHead(“content-

type”)==

strtolower

(

$ctype

))

                

{

                        

return

 true;

                

}

else

{

                        

$this

->m_error .= “

 “

类型不对 .

$this

->GetHead(“content-type”).”<br>”;

                        

return

 false;

                

}

        

}

         

//用 Http 协议下载文件

        

function

 SaveToBin(

$savefilename

)

        

{

                

if

(!

$this

->IsGetOK()) 

return

 false;

                

if

(@

feof

(

$this

->m_fp))

                

{

                        

$this

->m_error = “

连接已经关闭! ; 

return

 false;