<?php

class 网络操作类{
	public $fk = "";

	function 发送POST数据($url,$data,$xyt,$scyxt=0){
		$ch = curl_init();
		curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
		curl_setopt($ch,CURLOPT_HEADER,$scyxt);
		curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
		curl_setopt($ch,CURLOPT_POST,1);
		curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
		curl_setopt($ch,CURLOPT_URL,$url);
	
	
		if(!empty($xyt)){
			curl_setopt($ch,CURLOPT_HTTPHEADER,$xyt);
		}
		if(!empty($this->fk)){
			curl_setopt($ch,CURLOPT_COOKIE,$this->fk);
		}
	
		$res = curl_exec($ch);
		curl_close($ch);
		preg_match_all("/Set-Cookie: (.+); expires=/i",$res ,$c);
		$this->fk  ="";
		foreach ($c[1] as $v){
			if(substr($v,-1) != ";"){
				$v = $v .";";
			}
			if(!empty($this->fk )){
				$this->fk = $this->fk. " " . $v;
			}else{
				$this->fk = $v;
			}
		}
		
		return $res ;
	}

	function 发送GET数据($url,$xyt,$scyxt=0){
		$ch = curl_init();
		curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
		curl_setopt($ch,CURLOPT_HEADER,$scyxt);
		curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
		curl_setopt($ch,CURLOPT_URL,$url);
		if(!empty($xyt)){
			curl_setopt($ch,CURLOPT_HTTPHEADER,$xyt);
		}
		
		if(!empty($this->fk)){
			curl_setopt($ch,CURLOPT_COOKIE,$this->fk);
		}
	
		$res = curl_exec($ch);
		curl_close($ch);
		preg_match_all("/Set-Cookie: (.+); expires=/i",$res ,$c);
		$this->fk = "";	
		foreach ($c[1] as $v){
			if(substr($v,-1) != ";"){
				$v = $v .";";
			}
			if(!empty($this->fk )){
				$this->fk = $this->fk . " " . $v;
			}else{
				$this->fk = $v;
			}
		}
		//var_dump($this->fk);
		return $res ;
	}
	
	function 取cookie(){
		return $this->fk;
	}
	function 置cookie($v){
		$this->fk = $v;
	}
}

?>