php读取flash文件高宽帧数背景颜色代码

 更新时间:2016年11月25日 16:25  点击:1496

php教程读取flash文件高宽帧数背景颜色代码

<?php
/*
示例:
  $file = '/data/ad_files/5/5.swf';
  $flash = new flash();
  $flash = $flash->getswfinfo($file);
  echo "
文件的宽高是:".$flash["width"].":".$info["height"];
  echo "
文件版本是".$flash["version"];
  echo "
文件帧数量是".$flash["framecount"];
  echo "
文件帧速率是".$flash["framerate"];
  echo "
文件背景颜色是".$flash["bgcolor"];
*/
class flash
{
  //是否返回背景色
  public $need_back_color = false ;
 
  //是否返回版本
  public $need_version = false ;
 
  //是否返回帧速率
  public $need_framerate = false ;
 
  //是否返回帧数量
  public $need_framecount = false ;

  public function __construct()
  {

  }

  public function getswfinfo( $filename )
  {
    if ( file_exists($filename) ) {
       //echo "文件的修改时间:".date("m d y h:i:s.", filemtime($filename))."
";
    } else {
       //echo "目标文件不存在!";
       return array( "error" => $filename ) ;
    }

    //打开文件
    $rs = fopen($filename,"r");
   
    //读取文件的数据
    $str = fread( $rs , filesize( $filename ) ) ;
    ///
    if($str[0] == "f")
    {
       //echo "
文件已是解压缩的文件:";
    } else {
       $first = substr($str,0,8);
       $last = substr($str,8);
       //
       $last = gzuncompress($last);
       //
       $str = $first . $last ;
       $str[0] = "f";
       //echo "
解压缩后的文件信息:";
    }

    $info = $this->getinfo( $str );
    fclose ( $rs ) ;
    return $info;
  }

  private function mydecbin($str,$index)
  {
    $fbin = decbin(ord($str[$index]));
    while(strlen($fbin)<8)$fbin="0".$fbin;
    return $fbin;
  }

  private function colorhex($data)
  {
    $tmp = dechex($data);
    if ( strlen($tmp)<2 ) {
      $tmp='0' . $tmp ;
    }
    return $tmp;
  }

  private function getinfo( $str )
  {
    //换算成二进制
    $fbin = $this->mydecbin( $str , 8 ) ;
   
    //计算rec的单位长度
    $slen = bindec( substr( $fbin , 0 , 5 ) );
   
    //计算rec所在的字节
    $recsize = $slen * 4 + 5 ;
    $recsize = ceil( $recsize / 8 ) ;

    //rec的二进制
    $recbin = $fbin ;
    for( $i = 9 ; $i < $recsize + 8 ; $i++ )
    {
       $recbin .= $this->mydecbin( $str ,$i );
    }

    //rec数据
    $rec = array();
    for( $i = 0 ; $i < 4 ; $i++ )
    {
       $rec[] = bindec( substr( $recbin , 5 + $i * $slen , $slen ) ) / 20 ;
    }
   
    if ( $this->need_back_color ) {
      //背景颜色
      for( $i = $recsize + 12 ; $i < strlen ( $str ) ; $i ++ )
      {
         if ( ord( $str[$i] ) == 67 && ord( $str[$i+1] ) == 2 )
         {
          $bgcolor = $this->colorhex(ord($str[$i+2])).$this->colorhex(ord($str[$i+3])).$this->colorhex(ord($str[$i+4]));
          break;
         }
      }
    }
   
    if ( $this->need_version ) {
      //版本
      $version = ord( $str[3] );
    }
    if ( $this->need_framerate ) {
      //帧速率
      $framerate = ord( $str[$recsize + 8] ) / 256 + ord( $str[$recsize + 9] ) ;
    }

    if ( $this->need_framecount ) {   
      //帧数量
      $framecount = ord( $str[$recsize + 11] ) * 256 + ord( $str[$recsize + 10] );
    }
   
    return  array ( "bgcolor" => $bgcolor ,
            "version" => $version ,
            "framerate" => $framerate ,
            "framecount" => $framecount ,
            'width'=>$rec[1],
            'height'=>$rec[3]
            );
  }
}

?>

如果你看到的话,那么你需要设置你的php教程并开启这个库。如果你是在windows平台下,那么非常简单,你需要改一改你的php.ini文件的设置,找到php_curl.dll,并取消前面的分号注释就行了。如下所示:
//取消下在的注释
extension=php_curl.dll

  如果你是在linux下面,那么,google排名你需要重新编译你的php了,编辑时,你需要打开编译参数——在configure命令上加上“–with-curl” 参数。
  一个小示例
  如果一切就绪,下面是一个小例程:
复制代码 代码如下:

<?php
// 初始化一个 curl 对象
$curl = curl_init();
// 设置你需要抓取的url
curl_setopt($curl, curlopt_url, 'http://111cn.net');
// 设置header
curl_setopt($curl, curlopt_header, 1);
// 设置curl 参数,要求结果保存到字符串中还是输出到屏幕上。
curl_setopt($curl, curlopt_returntransfer, 1);
// 运行curl,请求网页
$data = curl_exec($curl);
// 关闭url请求
curl_close($curl);
// 显示获得的数据
var_dump($data);

  如何post数据
  上面是抓取网页的代码,下面则是向某个网页post数据。假设我们有一个处理表单的网址http://www.example.com/sendsms.php,其可以接受两个表单域,一个是电话号码,一个是短信内容。
复制代码 代码如下:

<?php
$phonenumber = '13912345678';
$message = 'this message was generated by curl and php';
$curlpost = 'pnumber=' . urlencode($phonenumber) . '&message=' . urlencode($message) . '&submit=send';
$ch = curl_init();chain link fencing
curl_setopt($ch, curlopt_url, 'http://www.example.com/sendsms.php');
curl_setopt($ch, curlopt_header, 1);
curl_setopt($ch, curlopt_returntransfer, 1);
curl_setopt($ch, curlopt_post, 1);
curl_setopt($ch, curlopt_postfields, $curlpost);
$data = curl_exec();
curl_close($ch);
?>

  从上面的程序我们可以看到,使用curlopt_post设置http协议的post方法,而不是get方法,然后以curlopt_postfields设置post的数据。
  关于代理服务器
  下面是一个如何使用代理服务器的示例。请注意其中高亮的代码,代码很简单,我就不用多说了。
复制代码 代码如下:

<?php
$ch = curl_init();
curl_setopt($ch, curlopt_url, 'http://www.example.com');
curl_setopt($ch, curlopt_header, 1);
curl_setopt($ch, curlopt_returntransfer, 1);
curl_setopt($ch, curlopt_httpproxytunnel, 1);
curl_setopt($ch, curlopt_proxy, 'fakeproxy.com:1080');
curl_setopt($ch, curlopt_proxyuserpwd, 'user:password');
$data = curl_exec();
curl_close($ch);
?>


  
  关于ssl和cookie
  关于ssl也就是https教程协议,煤气发生炉你只需要把curlopt_url连接中的http://变成https://就可以了。当然,还有一个参数叫curlopt_ssl_verifyhost可以设置为验证站点。
  关于cookie,你需要了解下面三个参数:
  curlopt_cookie,在当面的会话中设置一个cookie
  curlopt_cookiejar,当会话结束的时候保存一个cookie
  curlopt_cookiefile,cookie的文件。
  http服务器认证
  最后,我们来看一看http服务器认证的情况。
复制代码 代码如下:

<?php
$ch = curl_init();
curl_setopt($ch, curlopt_url, 'http://www.example.com');
curl_setopt($ch, curlopt_returntransfer, 1);
curl_setopt($ch, curlopt_httpauth, curlauth_basic);
curl_setopt(curlopt_userpwd, '[username]:[password]')
$data = curl_exec();
curl_close($ch);
?>


看一个利用curl抓取163邮箱地址列表代码

curl技术说白了就是模拟浏览器的动作实现页面抓取或表单提交,通过此技术可以实现许多有去的功能。
复制代码 代码如下:

<?php
error_reporting(0);
//邮箱用户名(不带@163.com后缀的)
$user = 'papatata_test';
//邮箱密码
$pass = '000000';
//目标邮箱
//$mail_addr = uenucom@163.com';
//登陆
$url = 'http://reg.163.com/logins.jsp教程?type=1&url=http://entry.mail.163.com/coremail/fcg/ntesdoor2?lightweight%3d1%26verifycookie%3d1%26language%3d-1%26style%3d-1';
$ch = curl_init($url);
//创建一个用于存放cookie信息的临时文件
$cookie = tempnam('.','~');
$referer_login = 'http://mail.163.com';
//返回结果存放在变量中,而不是默认的直接输出
curl_setopt($ch, curlopt_returntransfer, true);
curl_setopt($ch, curlopt_header, true);
curl_setopt($ch, curlopt_connecttimeout, 120);
curl_setopt($ch, curlopt_post, true);
curl_setopt($ch, curlopt_referer, $referer_login);
$fields_post = array(
'username'=> $user,
'password'=> $pass,
'verifycookie'=>1,
'style'=>-1,
'product'=> 'mail163',
'seltype'=>-1,
'secure'=>'on'
);
$headers_login = array(
'user-agent' => 'mozilla/5.0 (windows; u; windows nt 5.1; zh-cn; rv:1.9) gecko/2008052906 firefox/3.0',
'referer' => 'http://www.163.com'
);
$fields_string = '';
foreach($fields_post as $key => $value)
{
$fields_string .= $key . '=' . $value . '&';
}
$fields_string = rtrim($fields_string , '&');
curl_setopt($ch, curlopt_cookiesession, true);
//关闭连接时,将服务器端返回的cookie保存在以下文件中
curl_setopt($ch, curlopt_cookiejar, $cookie);
curl_setopt($ch, curlopt_httpheader, $headers_login);
curl_setopt($ch, curlopt_post, count($fields));
curl_setopt($ch, curlopt_postfields, $fields_string);
$result= curl_exec($ch);
curl_close($ch);
//跳转
$url='http://entry.mail.163.com/coremail/fcg/ntesdoor2?lightweight=1&verifycookie=1&language=-1&style=-1&username=loki_wuxi';
$ch = curl_init($url);
$headers = array(
'user-agent' => 'mozilla/5.0 (windows; u; windows nt 5.1; zh-cn; rv:1.9) gecko/2008052906 firefox/3.0'
);
curl_setopt($ch, curlopt_returntransfer, true);
curl_setopt($ch, curlopt_header, true);
curl_setopt($ch, curlopt_connecttimeout, 120);
curl_setopt($ch, curlopt_post, true);
curl_setopt($ch, curlopt_httpheader, $headers);
//将之前保存的cookie信息,一起发送到服务器端
curl_setopt($ch, curlopt_cookiefile, $cookie);
curl_setopt($ch, curlopt_cookiejar, $cookie);
$result = curl_exec($ch);
curl_close($ch);
//取得sid
preg_match('/sid=[^"].*/', $result, $location);
$sid = substr($location[0], 4, -1);
//file_put_contents('./result.txt', $sid);
//通讯录地址
$url='http://g4a30.mail.163.com/jy3/address/addrlist.jsp?sid='.$sid.'&gid=all';
$ch = curl_init($url);
$headers = array(
'user-agent' => 'mozilla/5.0 (windows; u; windows nt 5.1; zh-cn; rv:1.9) gecko/2008052906 firefox/3.0'
);
curl_setopt($ch, curlopt_returntransfer, true);
curl_setopt($ch, curlopt_header, true);
curl_setopt($ch, curlopt_connecttimeout, 120);
curl_setopt($ch, curlopt_post, true);
curl_setopt($ch, curlopt_httpheader, $headers);
curl_setopt($ch, curlopt_cookiefile, $cookie);
curl_setopt($ch, curlopt_cookiejar, $cookie);
$result = curl_exec($ch);
curl_close($ch);
//file_put_contents('./result.txt', $result);
unlink($cookie);
//开始抓取内容
preg_match_all('/<td class="ibx_td_addrname"><a[^>]*>(.*?)</a></td><td class="ibx_td_addremail"><a[^>]*>(.*?)</a></td>/i', $result,$infos,preg_set_order);
//1:姓名2:邮箱
print_r($infos);
?>

php教程 获取目录下所有文件实现代码
class a{   
 private $img_dir;
        private $img_path;
        private $face_files = array();
        private $allow_extension = array();

private function get_face_files()
        {
            $files = array();
            if(is_dir($this->img_dir))
            {
                if ($dh = opendir($this->img_dir))
                {
                    while (($file = readdir($dh)) !== false)
                    {
                        if($file == '.') continue;
                        if($file == '..') continue;
                        $fileinfo = explode('.', (basename($file)));
                        if(in_array($fileinfo[1], $this->allow_extension))
                        {
                            $files[] = array(
                                'filename' => $fileinfo[0],
                                'extension' => $fileinfo[1],
                            );
                        }
                    }
                    closedir($dh);
                }
            }
            return $files;
        }
}

php教程自动获取关键字代码

$mincipin=5;//最小词频

$minlen=4;//关键字最小长度

tiqukeyword($tiqustr,$minlen,$mincipin);

function tiqukeyword($tiqustr,$minlen,$mincipin)

{$strlong=strlen($tiqustr);

$arr=array();

$k=-1;

for($i=0;$i<($strlong-$mincipin*$minlen);$i++){

$end=ceil(($strlong-$i)/$mincipin+$i);

for($j=$minlen;$j<$end;$j++){$num=0;

if(($guanjianzi=substr($tiqustr,$i,$j))!==false){

$wz=$i+$j;

$num++;}

else{break;}

while($wz<$strlong){if(($wz=strpos($tiqustr,$guanjianzi,$wz))!==false)

{$num++;

$wz=$wz+strlen($guanjianzi);}

else break;

}

if($j==$minlen){

if($num>=$mincipin){$maxnum=$num;$k++;$str=substr($tiqustr,$i,$j);

$arr[$k]=array($i,$j,$str,$num,0);

}

else{break;}
}

else{

if($num>=$maxnum){

$maxnum=$num;

$str=substr($tiqustr,$i,$j);

$arr[$k]=array($i,$j,$str,$num,0);

}

else break;

}
}

}

echo '初步得到的数组:';

print_r($arr);

//echo '<br/><br/><br/><br/>';

 

$arrlong=count($arr);

for($i=0;$i<$arrlong;$i++){

$bjarr=$arr[$i];

$nowid=$i;

if($bjarr[4]==1)continue;

for($j=$i+1;$j<$arrlong;$j++){

if($arr[$j][4]==1)continue;

$qujianks=$bjarr[0];

$qujianjs=$bjarr[1]+$bjarr[0]-1;

$a=$arr[$j][0];

$b=$arr[$j][1]+$arr[$j][0]-1;

if(($bjarr[2]==$arr[$j][2])&&($bjarr[3]>$arr[$j][3]))$arr[$j][4]=1;

 

if($a<=$qujianks&&$qujianks<=$b&&$a<=$qujianjs&&$qujianjs<=$b)

{if($bjarr[3]<=$arr[$j][3]){

$arr[$nowid][4]=1;$nowid=$j;$bjarr=$arr[$j];
}
}

elseif($qujianks<=$a&&$a<=$qujianjs&&$qujianks<=$b&&$b<=$qujianjs){

$arr[$j][4]=1;
}

}

}

 

echo '<br/><br/><br/><br/>重叠加标记后的数组:';

print_r($arr);

 

$jieguoarr=array();

for($i=0;$i<$arrlong;$i++)

{if($arr[$i][4]==0)$jieguoarr[]=$arr[$i];

 

}

echo '<br/><br/><br/><br/>';

echo '最后得到的数组:';

print_r($jieguoarr);

}

 

类名 :httprequest($url="",$method="get",$usesocket=0)
//$url为请求的地址;默认请求方法为get;$usesocket默认为0,使用fsockopen方法,如果设置为1则使用socket_create方法

方法:
open($ip="",$port=-1) //打开同服务器的连接,默认不用设置这两个参数(一个同事在linux用的时候,请求的不是hostname解析的ip,因此加了这两个参数,以连接真实的服务器ip)
settimeout($timeout=0) //设置获取数据的超时时间,必须在send方法调用之前设置才有效,单位秒,默认值0为不限制
setrequestheader($key,$value="") //设置请求头,必须在send方法调用之前设置才有效
removerequestheader($key,$value="") //移除指定键值的请求头,必须在send方法调用之前调用才有效
send($data="") //发送数据$data到服务器
getresponsebody() //获取服务器返回的文本
getallresponseheaders() //获取服务器响应的所有头信息
getresponseheader($key) //获取服务器响应的某个头信息,例如server,set_cookie等

属性:
$url //要请求的url
$method //请求方法(post/get)
$port //请求的端口
$hostname //请求的主机名
$uri //url的文件部分
$protocol //请求协议(http)(包括本属性的以上5个属性均由程序自动通过url分析)
$excption //异常信息
$_headers=array() //请求头array("key"=>"value")
$_senddata //发送到服务器的数据
$status //返回的状态码
$statustext //状态信息
$httpprotocolversion //服务器的http协议版本

注意:
host头由程序自动设置,当用post方法请求时,content-length和content-type已被自动设置。
支持gzip压缩的页面

inc.http.php教程文件

<?php

class httprequest{
 public $url,$method,$port,$hostname,$uri,$protocol,$excption,$_headers=array(),$_senddata,$status,$statustext,$httpprotocolversion;
 private $fp=0,$_buffer="",$responsebody,$responseheader,$timeout=0,$usesocket;
 //构造函数
 function __construct($url="",$method="get",$usesocket=0){
  $this->url = $url;
  $this->method = strtoupper($method);
  $this->usesocket = $usesocket;
  $this->setrequestheader("accept","*/*");
  $this->setrequestheader("accept-language","zh-cn");
  $this->setrequestheader("accept-encoding","gzip, deflate");
  $this->setrequestheader("user-agent","httprequest class 1.0");  //可调用setrequestheader来修改
 }
 
 //连接服务器
 public function open($ip="",$port=-1){
  if(!$this->_geturlinfo()) return false;
  $this->setrequestheader("host",$this->hostname);
  $this->setrequestheader("connection","close");
  $ip = ($ip=="" ? $this->hostname : $ip);
  $port = ($port==-1 ? $this->port : $port);
  if($this->usesocket==1){
   if(!$this->fp=$socket=socket_create(af_inet,sock_stream,0)) {
    $this->excption="can not create socket";return false;
   }else{
    if(!socket_connect($this->fp,$ip, $port) ){
     $this->excption="can not connect to server " . $this->hostname . " on port" . $this->port;return false;
    }
   }
  }else{
   if(!$this->fp=fsockopen($ip, $port,$errno,$errstr,10)) {
    $this->excption="can not connect to server " . $this->hostname . " on port" . $this->port;return false;
   }
  }
  return true;
 }
 
 public function send($data=""){
  if(!$this->fp){$this->excption="is not a resource id";return false;}
  if($this->method=="get" && $data!=""){
   $s_str="?";
   if(strpos($this->uri,"?")>0) $s_str = "&";
   $this->uri.= $s_str . $data;
   $data="";
  }
  $senddata=$this->method . " " . $this->uri . " http/1.1rn";
  if($this->method=="post"){
   $this->setrequestheader("content-length",strlen($data));
   $this->setrequestheader("content-type", "application/x-www-form-urlencoded");
  }
  foreach($this->_headers as $keys => $value){
   $senddata .= "$keys: $valuern";
  }
  $senddata .= "rn";
  if($this->method=="post") $senddata .= $data;
  $this->_senddata = $senddata;
  if($this->usesocket==1){
   socket_write($this->fp,$this->_senddata);
   $buffer="";
   $timestart = time();
   do{
    if($this->timeout>0){
     if(time()-$timestart>$this->timeout){break;}
    }
    $this->_buffer.=$buffer;
    $buffer = socket_read($this->fp,4096);
   }while($buffer!="");
   socket_close($this->fp); 
  }else{
   fputs($this->fp, $senddata);
   $this->_buffer="";
   $timestart = time();
   while(!feof($this->fp))
   {
    if($this->timeout>0){
     if(time()-$timestart>$this->timeout){break;}
    }
    $this->_buffer.=fgets($this->fp,4096);
   }
   fclose($this->fp);   
  }
  $this->_splitcontent();
  $this->_getheaderinfo();
 }
 
 public function getresponsebody(){
  if($this->getresponseheader("content-encoding")=="gzip" && $this->getresponseheader("transfer-encoding")=="chunked"){
   return gzdecode_1(transfer_encoding_chunked_decode($this->responsebody));
  }else if($this->getresponseheader("content-encoding")=="gzip"){
   return gzdecode_1($this->responsebody);
  }else{
   return $this->responsebody;
  }
 }
 
 public function getallresponseheaders(){
  return  $this->responseheader;
 }
 
 public function getresponseheader($key){
  $key = str_replace("-","-",$key);
  $headerstr = $this->responseheader . "rn";
  $count = preg_match_all("/n$key:(.+?)r/is",$headerstr,$result,preg_set_order);
  if($count>0){
   $returnstr="";
   foreach($result as $key1=>$value){
    if(strtoupper($key)=="set-cookie"){
     $value[1] = substr($value[1],0,strpos($value[1],";"));
    }
    $returnstr .= ltrim($value[1]) . "; ";
   }
   $returnstr = substr($returnstr,0,strlen($returnstr)-2);
   return $returnstr;
  }else{return "";}
 }
 
 public function settimeout($timeout=0){
  $this->timeout = $timeout; 
 }
 
 public function setrequestheader($key,$value=""){
  $this->_headers[$key]=$value;
 }
 
 public function removerequestheader($key){
  if(count($this->_headers)==0){return;}
  $_temp=array();
  foreach($this->_headers as $keys => $value){
   if($keys!=$key){
    $_temp[$keys]=$value;
   }
  }
  $this->_headers = $_temp;
 }
 
 //拆分url
 private function _geturlinfo(){
  $url = $this->url;
  $count = preg_match("/^http://([^:/]+?)(:(d+))?/(.+?)$/is",$url,$result);
  if($count>0){
   $this->uri="/" . $result[4];
  }else{
   $count = preg_match("/^http://([^:/]+?)(:(d+))?(/)?$/is",$url,$result);
   if($count>0){
    $this->uri="/";
   }
  }
  if($count>0){
   $this->protocol="http";
   $this->hostname=$result[1];
   if(isset($result[2]) && $result[2]!="") {$this->port=intval($result[3]);}else{$this->port=80;}
   return true;
  }else{$this->excption="url format error";return false;}
 }
 
 private function _splitcontent(){
  $this->responseheader="";
  $this->responsebody="";
  $p1 = strpos($this->_buffer,"rnrn");
  if($p1>0){
   $this->responseheader = substr($this->_buffer,0,$p1);
   if($p1+4<strlen($this->_buffer)){
    $this->responsebody = substr($this->_buffer,$p1+4);
   }
  }
 }
 
 private function _getheaderinfo(){
  $headerstr = $this->responseheader;
  $count = preg_match("/^http/(.+?)s(d+)s(.+?)rn/is",$headerstr,$result);
  if($count>0){
   $this->httpprotocolversion = $result[1];
   $this->status = intval($result[2]);
   $this->statustext = $result[3];
  }
 }
}


//以下两函数参考网络
function gzdecode_1 ($data) {
 $data = ($data);
 if (!function_exists ( 'gzdecode' )) {
  $flags = ord ( substr ( $data, 3, 1 ) );
  $headerlen = 10;
  $extralen = 0;
  $filenamelen = 0;
  if ($flags & 4) {
   $extralen = unpack ( 'v', substr ( $data, 10, 2 ) );
   $extralen = $extralen [1];
   $headerlen += 2 + $extralen;
  }
  if ($flags & 8) // filename
   $headerlen = strpos ( $data, chr ( 0 ), $headerlen ) + 1;
  if ($flags & 16) // comment
   $headerlen = strpos ( $data, chr ( 0 ), $headerlen ) + 1;
  if ($flags & 2) // crc at end of file
   $headerlen += 2;
  $unpacked = @gzinflate ( substr ( $data, $headerlen ) );
  if ($unpacked === false)
   $unpacked = $data;
  return $unpacked;
 }else{
  return gzdecode($data);
 }
}

function transfer_encoding_chunked_decode($in) {
 $out = "";
 while ( $in !="") {
  $lf_pos = strpos ( $in, "12" );
  if ($lf_pos === false) {
   $out .= $in;
   break;
  }
  $chunk_hex = trim ( substr ( $in, 0, $lf_pos ) );
  $sc_pos = strpos ( $chunk_hex, ';' );
  if ($sc_pos !== false)
   $chunk_hex = substr ( $chunk_hex, 0, $sc_pos );
  if ($chunk_hex =="") {
   $out .= substr ( $in, 0, $lf_pos );
   $in = substr ( $in, $lf_pos + 1 );
   continue;
  }
  $chunk_len = hexdec ( $chunk_hex );
  if ($chunk_len) {
   $out .= substr ( $in, $lf_pos + 1, $chunk_len );
   $in = substr ( $in, $lf_pos + 2 + $chunk_len );
  } else {
   $in = "";
  }
 }
 return $out;
}
function utf8togb($str){
 return iconv("utf-8","gbk",$str);
}

function gbtoutf8($str){
 return iconv("gbk","utf-8",$str);
}
?>

response.asp教程文件

<%
response.cookies("a") = "anlige"
response.cookies("a").expires = dateadd("yyyy",1,now())
response.cookies("b")("c") = "wsdasdadsa"
response.cookies("b")("d") = "ddd"
response.cookies("b").expires = dateadd("yyyy",1,now())
response.write "querystring : " & request.querystring & "<br />"
for each v in request.querystring
 response.write v & "=" & request.querystring(v) & "<br />"
next
response.write "<br />form : " &  request.form  & "<br />"
for each v in request.form
 response.write v & "=" & request.form(v) & "<br />"
next
response.write "<br />url : " &  request.servervariables("url")  & "<br />"
response.write "referer : " &  request.servervariables("http_referer")  & "<br />"
response.write "host : " &  request.servervariables("http_host")  & "<br />"
response.write "user-agent : " &  request.servervariables("http_user_agent")  & "<br />"
response.write "cookie" & request.servervariables("http_cookie")
%>

index.php文件

<a href="?action=get">get传数据</a>
<a href="?action=post">post传数据</a>
<a href="?action=header_referer">向服务器发送来路信息</a>
<a href="?action=header_useragent">向服务器发送user-agent</a>
<a href="?action=status">获取服务器返回的状态</a>
<a href="?action=get_headers">获取服务器响应头</a>
<a href="?action=get_image">保存图片</a><br /><br /><br />
<?php
include("inc_http.php");
$responseurl = "http://dev.mo.cn/aiencode/http/response.asp";

$act = isset($_get["action"]) ? $_get["action"] : "";
if($act == "get"){  //get传数据

 $myhttp = new httprequest("$responseurl?a=text");
 $myhttp->open();
 $myhttp->send("name=anlige&city=" . urlencode("杭州"));
 echo($myhttp->getresponsebody()); 
 
}else if($act == "post"){ //post传数据

 $myhttp = new httprequest("$responseurl?a=text","post");
 $myhttp->open();
 $myhttp->send("name=anlige&city=" . urlencode("杭州"));
 echo($myhttp->getresponsebody());
 
}else if($act == "header_referer"){  //向服务器发送来路信息

 $myhttp = new httprequest("$responseurl?a=text","post");
 $myhttp->open();
 $myhttp->setrequestheader("referer","http://www.baidu.com");
 $myhttp->send("name=anlige&city=" . urlencode("杭州"));
 echo($myhttp->getresponsebody()); 
 
}else if($act == "header_useragent"){  //向服务器发送user-agent

 $myhttp = new httprequest("$responseurl?a=text","post");
 $myhttp->open();
 $myhttp->setrequestheader("referer","http://www.baidu.com");
 $myhttp->setrequestheader("user-agent","mozilla/4.0 (compatible; msie 7.0; windows nt 6.0; trident/4.0)");
 $myhttp->send("name=anlige&city=" . urlencode("杭州"));
 echo($myhttp->getresponsebody()); 
 
}else if($act == "status"){   //获取服务器返回的状态

 $myhttp = new httprequest("$responseurl?a=text","post");
 $myhttp->open();
 $myhttp->send("name=anlige&city=" . urlencode("杭州"));
 echo($myhttp->status . " " . $myhttp->statustext ."<br /><br />"); 
 echo($myhttp->getresponsebody());
 
}else if($act == "get_headers"){  //获取服务器响应头

 $myhttp = new httprequest("$responseurl?a=text","get");
 $myhttp->open();
 $myhttp->send("name=anlige&city=" . urlencode("杭州"));
 echo($myhttp->getallresponseheaders()."<br /><br />");  
 echo($myhttp->getresponseheader("server")."<br /><br />"); 
 
}else if($act == "get_image"){
 
 $myhttp = new httprequest("http://www.baidu.com/img/baidu_logo.gif");
 $myhttp->open();
 $myhttp->send(); 
 $fp = @fopen("demo.gif","w");
 fwrite($fp,$myhttp->getresponsebody());
 fclose($fp);
 echo("<img src="demo.gif" />");
}

?>

[!--infotagslink--]

相关文章

  • php读取zip文件(删除文件,提取文件,增加文件)实例

    下面小编来给大家演示几个php操作zip文件的实例,我们可以读取zip包中指定文件与删除zip包中指定文件,下面来给大这介绍一下。 从zip压缩文件中提取文件 代...2016-11-25
  • Jupyter Notebook读取csv文件出现的问题及解决

    这篇文章主要介绍了JupyterNotebook读取csv文件出现的问题及解决,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教...2023-01-06
  • C#从数据库读取图片并保存的两种方法

    这篇文章主要介绍了C#从数据库读取图片并保存的方法,帮助大家更好的理解和使用c#,感兴趣的朋友可以了解下...2021-01-16
  • Photoshop打开PSD文件空白怎么解决

    有时我们接受或下载到的PSD文件打开是空白的,那么我们要如何来解决这个 问题了,下面一聚教程小伙伴就为各位介绍Photoshop打开PSD文件空白解决办法。 1、如我们打开...2016-09-14
  • C#操作本地文件及保存文件到数据库的基本方法总结

    C#使用System.IO中的文件操作方法在Windows系统中处理本地文件相当顺手,这里我们还总结了在Oracle中保存文件的方法,嗯,接下来就来看看整理的C#操作本地文件及保存文件到数据库的基本方法总结...2020-06-25
  • 解决python 使用openpyxl读写大文件的坑

    这篇文章主要介绍了解决python 使用openpyxl读写大文件的坑,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2021-03-13
  • C#实现HTTP下载文件的方法

    这篇文章主要介绍了C#实现HTTP下载文件的方法,包括了HTTP通信的创建、本地文件的写入等,非常具有实用价值,需要的朋友可以参考下...2020-06-25
  • SpringBoot实现excel文件生成和下载

    这篇文章主要为大家详细介绍了SpringBoot实现excel文件生成和下载,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2021-02-09
  • php把读取xml 文档并转换成json数据代码

    在php中解析xml文档用专门的函数domdocument来处理,把json在php中也有相关的处理函数,我们要把数据xml 数据存到一个数据再用json_encode直接换成json数据就OK了。...2016-11-25
  • php无刷新利用iframe实现页面无刷新上传文件(1/2)

    利用form表单的target属性和iframe 一、上传文件的一个php教程方法。 该方法接受一个$file参数,该参数为从客户端获取的$_files变量,返回重新命名后的文件名,如果上传失...2016-11-25
  • php批量替换内容或指定目录下所有文件内容

    要替换字符串中的内容我们只要利用php相关函数,如strstr,str_replace,正则表达式了,那么我们要替换目录所有文件的内容就需要先遍历目录再打开文件再利用上面讲的函数替...2016-11-25
  • PHP文件上传一些小收获

    又码了一个周末的代码,这次在做一些关于文件上传的东西。(PHP UPLOAD)小有收获项目是一个BT种子列表,用户有权限上传自己的种子,然后配合BT TRACK服务器把种子的信息写出来...2016-11-25
  • AI源文件转photoshop图像变模糊问题解决教程

    今天小编在这里就来给photoshop的这一款软件的使用者们来说下AI源文件转photoshop图像变模糊问题的解决教程,各位想知道具体解决方法的使用者们,那么下面就快来跟着小编...2016-09-14
  • C++万能库头文件在vs中的安装步骤(图文)

    这篇文章主要介绍了C++万能库头文件在vs中的安装步骤(图文),文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2021-02-23
  • Zend studio文件注释模板设置方法

    步骤:Window -> PHP -> Editor -> Templates,这里可以设置(增、删、改、导入等)管理你的模板。新建文件注释、函数注释、代码块等模板的实例新建模板,分别输入Name、Description、Patterna)文件注释Name: 3cfileDescriptio...2013-10-04
  • php文件上传你必须知道的几点

    本篇文章主要说明的是与php文件上传的相关配置的知识点。PHP文件上传功能配置主要涉及php.ini配置文件中的upload_tmp_dir、upload_max_filesize、post_max_size等选项,下面一一说明。打开php.ini配置文件找到File Upl...2015-10-21
  • ant design中upload组件上传大文件,显示进度条进度的实例

    这篇文章主要介绍了ant design中upload组件上传大文件,显示进度条进度的实例,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2020-10-29
  • C#使用StreamWriter写入文件的方法

    这篇文章主要介绍了C#使用StreamWriter写入文件的方法,涉及C#中StreamWriter类操作文件的相关技巧,需要的朋友可以参考下...2020-06-25
  • php实现文件下载实例分享

    举一个案例:复制代码 代码如下:<?phpclass Downfile { function downserver($file_name){$file_path = "./img/".$file_name;//转码,文件名转为gb2312解决中文乱码$file_name = iconv("utf-8","gb2312",$file_name...2014-06-07
  • C#路径,文件,目录及IO常见操作汇总

    这篇文章主要介绍了C#路径,文件,目录及IO常见操作,较为详细的分析并汇总了C#关于路径,文件,目录及IO常见操作,具有一定参考借鉴价值,需要的朋友可以参考下...2020-06-25