T String Error. Can You See It?

Discussion in 'PHP' started by megler, Dec 30, 2008.

  1. #1
    There's a T string error buried in here somewhere, but darned if I can see it. I thought it was a missing } but so far I can't find it. Do your trained eyes see an error?

    For reference, the error is being thrown here:

    if(strtoupper($Method)=='LINK'){
    			$this->send_link($Source,$Destination,$VaildTime);
    PHP:
    Any help is greatly appreciated.

    Thx,

    Marceia


    	
    	function send($Source,$Destination,$Method='file',$Check=true,$VaildTime=24,$AllowPartial=true){
    		if(!is_readable($Source)){
    			header("HTTP/1.1 404 Not Found");
    			echo "<html><head><meta http-equiv='refresh' content='0; url=/'></head></html>";
    			return false;
    		}
    		if($Check){
    			$Deny=false;
    			$CheckKey=isset($_GET['LINKFIREWALL'])?$_GET['LINKFIREWALL']:$_COOKIE['LINKFIREWALL'];
    			preg_match('/[^\.]+\.([^\.]+).*/i',$_SERVER['HTTP_HOST'],$Tmp);
    			$Domain=$Tmp[1];
    			preg_match('/:[^\.]+\.([^\.]+).*/i',$_SERVER['HTTP_REFERER'],$Tmp);
    			$Referer=$Tmp[1];
    			$Key=md5('Password'.$Domain);
    			if(empty($CheckKey)||($CheckKey!=$Key)||($Domain!=$Referer)){
    				header("HTTP/1.1 404 Not Found");
    				exit("<html><head><meta http-equiv='refresh' content='3; url=/'></head><body>请不要盗链本站资源</body></html>");
    			}
    		}
    		if(strtoupper($Method)=='LINK'){
    			$this->send_link($Source,$Destination,$VaildTime);
    		}else{
    			$this->send_file($Source,$Destination,$AllowPartial);
    		}
    	}
    
    	function mime_type($Filename,$Unknow='octet-stream'){
    		$MIMETYPE=array("323"=>"text/h323","acx"=>"application/internet-property-stream","ai"=>"application/postscript","aif"=>"audio/x-aiff","aifc"=>"audio/x-aiff","aiff"=>"audio/x-aiff","asf"=>"video/x-ms-asf","asr"=>"video/x-ms-asf","asx"=>"video/x-ms-asf","au"=>"audio/basic",		"avi"=>"video/x-msvideo","axs"=>"application/olescript","bas"=>"text/plain","bcpio"=>"application/x-bcpio","bin"=>"application/octet-stream","bmp"=>"image/bmp","c"=>"text/plain","cat"=>"application/vnd.ms-pkiseccat","cdf"=>"application/x-cdf","cer"=>"application/x-x509-ca-cert","class"=>"application/octet-stream","clp"=>"application/x-msclip","cmx"=>"image/x-cmx","cod"=>"image/cis-cod","cpio"=>"application/x-cpio","crd"=>"application/x-mscardfile","crl"=>"application/pkix-crl","crt"=>"application/x-x509-ca-cert","csh"=>"application/x-csh","css"=>"text/css","dcr"=>"application/x-director","der"=>"application/x-x509-ca-cert","dir"=>"application/x-director","dll"=>"application/x-msdownload","dms"=>"application/octet-stream","doc"=>"application/msword","dot"=>"application/msword","dvi"=>"application/x-dvi","dxr"=>"application/x-director","eps"=>"application/postscript","etx"=>"text/x-setext","evy"=>"application/envoy","exe"=>"application/octet-stream","fif"=>"application/fractals","flr"=>"x-world/x-vrml","gif"=>"image/gif","gtar"=>"application/x-gtar","gz"=>"application/x-gzip","h"=>"text/plain","hdf"=>"application/x-hdf","hlp"=>"application/winhlp","hqx"=>"application/mac-binhex40","hta"=>"application/hta","htc"=>"text/x-component","htm"=>"text/html","html"=>"text/html","htt"=>"text/webviewhtml","ico"=>"image/x-icon","ief"=>"image/ief","iii"=>"application/x-iphone","ins"=>"application/x-internet-signup","isp"=>"application/x-internet-signup","jfif"=>"image/pipeg","jpe"=>"image/jpeg","jpeg"=>"image/jpeg","jpg"=>"image/jpeg","js"=>"application/x-javascript","latex"=>"application/x-latex","lha"=>"application/octet-stream","lsf"=>"video/x-la-asf","lsx"=>"video/x-la-asf","lzh"=>"application/octet-stream","m13"=>"application/x-msmediaview","m14"=>"application/x-msmediaview","m3u"=>"audio/x-mpegurl","man"=>"application/x-troff-man","mdb"=>"application/x-msaccess","me"=>"application/x-troff-me","mht"=>"message/rfc822","mhtml"=>"message/rfc822","mid"=>"audio/mid","mny"=>"application/x-msmoney","mov"=>"video/quicktime","movie"=>"video/x-sgi-movie","mp2"=>"video/mpeg","mp3"=>"audio/mpeg","mpa"=>"video/mpeg","mpe"=>"video/mpeg","mpeg"=>"video/mpeg","mpg"=>"video/mpeg","mpp"=>"application/vnd.ms-project","mpv2"=>"video/mpeg","ms"=>"application/x-troff-ms","mvb"=>"application/x-msmediaview","nws"=>"message/rfc822","oda"=>"application/oda","p10"=>"application/pkcs10","p12"=>"application/x-pkcs12","p7b"=>"application/x-pkcs7-certificates","p7c"=>"application/x-pkcs7-mime","p7m"=>"application/x-pkcs7-mime","p7r"=>"application/x-pkcs7-certreqresp","p7s"=>"application/x-pkcs7-signature","pbm"=>"image/x-portable-bitmap","pdf"=>"application/pdf","pfx"=>"application/x-pkcs12","pgm"=>"image/x-portable-graymap","pko"=>"application/ynd.ms-pkipko","pma"=>"application/x-perfmon","pmc"=>"application/x-perfmon","pml"=>"application/x-perfmon","pmr"=>"application/x-perfmon","pmw"=>"application/x-perfmon","pnm"=>"image/x-portable-anymap","pot,"=>"application/vnd.ms-powerpoint","ppm"=>"image/x-portable-pixmap","pps"=>"application/vnd.ms-powerpoint","ppt"=>"application/vnd.ms-powerpoint","prf"=>"application/pics-rules","ps"=>"application/postscript","pub"=>"application/x-mspublisher","qt"=>"video/quicktime","ra"=>"audio/x-pn-realaudio","ram"=>"audio/x-pn-realaudio","ras"=>"image/x-cmu-raster","rgb"=>"image/x-rgb","rmi"=>"audio/mid","roff"=>"application/x-troff","rtf"=>"application/rtf","rtx"=>"text/richtext","scd"=>"application/x-msschedule","sct"=>"text/scriptlet","setpay"=>"application/set-payment-initiation","setreg"=>"application/set-registration-initiation","sh"=>"application/x-sh","shar"=>"application/x-shar","sit"=>"application/x-stuffit","snd"=>"audio/basic","spc"=>"application/x-pkcs7-certificates","spl"=>"application/futuresplash","src"=>"application/x-wais-source","sst"=>"application/vnd.ms-pkicertstore","stl"=>"application/vnd.ms-pkistl","stm"=>"text/html","svg"=>"image/svg+xml","sv4cpio"=>"application/x-sv4cpio","sv4crc"=>"application/x-sv4crc","swf"=>"application/x-shockwave-flash","t"=>"application/x-troff","tar"=>"application/x-tar","tcl"=>"application/x-tcl","tex"=>"application/x-tex","texi"=>"application/x-texinfo","texinfo"=>"application/x-texinfo","tgz"=>"application/x-compressed","tif"=>"image/tiff","tiff"=>"image/tiff","tr"=>"application/x-troff","trm"=>"application/x-msterminal","tsv"=>"text/tab-separated-values","txt"=>"text/plain","uls"=>"text/iuls","ustar"=>"application/x-ustar","vcf"=>"text/x-vcard","vrml"=>"x-world/x-vrml","wav"=>"audio/x-wav","wcm"=>"application/vnd.ms-works","wdb"=>"application/vnd.ms-works","wks"=>"application/vnd.ms-works","wmf"=>"application/x-msmetafile","wps"=>"application/vnd.ms-works","wri"=>"application/x-mswrite","wrl"=>"x-world/x-vrml","wrz"=>"x-world/x-vrml","xaf"=>"x-world/x-vrml","xbm"=>"image/x-xbitmap","xla"=>"application/vnd.ms-excel","xlc"=>"application/vnd.ms-excel","xlm"=>"application/vnd.ms-excel","xls"=>"application/vnd.ms-excel","xlt"=>"application/vnd.ms-excel","xlw"=>"application/vnd.ms-excel","xof"=>"x-world/x-vrml","xpm"=>"image/x-xpixmap","xwd"=>"image/x-xwindowdump","z"=>"application/x-compress","zip"=>"application/zip","7z"=>"application/zip");
    		$Suffix=array_pop(explode('.',$Filename));
    		return array_key_exists($Suffix,$MIMETYPE)?$MIMETYPE[$Suffix]:$Unknow=='octet-stream'?'application/octet-stream':'application/unknow';
    	}
    }
    ?>
    PHP:
     
    megler, Dec 30, 2008 IP
  2. dtkirby

    dtkirby Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I don't get a T STRING error, only a complaint about an extra closed bracket - the last one. When removed, it executes without error.
     
    dtkirby, Dec 30, 2008 IP
  3. megler

    megler Peon

    Messages:
    68
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    crud, I was hoping it was near the error line. It must be further up. I can't post the entire code because there are too many characters. Here's the code above the code I already posted.

    class http {
    
    	var $CURL = false;
    	var $Socket;
    	var $Request;
    	var $AutoLocation=true;
    	var $CRLF="\r\n";
    	var $Header=array(
    	'Accept'=>"*/*",
    	'Accept-Language'=>"zh-cn,zh",
    	//'Accept-Encoding'=>"gzip, deflate",
    	'User-Agent'=>"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2)",
    	'Pragma'=>"no-cache",
    	'Cache-Control'=>"no-cache",
    	'Host'=>"",
    	'Referer'=>"",
    	'Cookie'=>""
    	);
    
    	var $Hostname;
    	var $Server;
    	var $Port=80;
    	var $SSL;
    	var $Timeout=10;
    	var $Document='/';
    	var $CookieFile;
    
    	var $ProxyHost;
    	var $ProxyPort=8080;
    	//var $ProxyUser;&#39564;&#35777;&#20195;&#29702;&#19981;&#25903;&#25345;
    	//var $ProxyPass;&#39564;&#35777;&#20195;&#29702;&#19981;&#25903;&#25345;
    
    	var $Debug=false;
    	var $ErrNo;
    	var $ErrStr;
    	var $Status;
    	var $TransferEncoding;
    	var $ContentEncoding;
    
    	var $CheckReferer;
    	var $CheckCookie;
    	var $SpeedLimit;
    	var $Time;
    
    	/**
    	 * &#26500;&#36896;&#20989;&#25968;
    	 * &#21464;&#37327;&#21021;&#22987;&#21270;
    	 */
    	function http($URL,$Debug=false){
    		$this->Debug=&$Debug;
    		$Parser=parse_url($URL);
    		$this->SSL=strtoupper($Parser['scheme'])=="HTTPS"?true:false;
    		$this->Hostname=$Parser['host'];
    		$this->Header['Host']=$this->Hostname;
    		$this->Server=gethostbyname($this->Hostname);
    		$this->Port=empty($Parser['port'])?$this->SSL?443:80:$Parser['port'];
    		empty($Parser['path'])?null:$this->Document=empty($Parser['query'])?$Parser['path']:"{$Parser['path']}?{$Parser['query']}";
    		/*if(function_exists('curl_init')&&function_exists('curl_setopt')&&function_exists('curl_exec')){
    			$this->CURL=true;
    		}*/
    	}
    
    	/**
    	 * &#36830;&#25509;&#20989;&#25968;
    	 * &#36830;&#25509;&#26381;&#21153;&#22120;/&#20195;&#29702;
    	 * &#22914;&#26524;&#21487;&#20197;&#20351;&#29992;CURL&#23601;&#20248;&#20808;&#20351;&#29992;CURL&#21542;&#21017;&#23601;&#29992;fsocket&#21457;&#36865;HTTP&#35831;&#27714;
    	 * &#22914;&#26524;fsocket&#37117;&#32473;&#31105;&#20102;...
    	 * !@#$$#%$%^%$&%^
    	 */
    	function connect(){
    		if($this->CURL===true){
    			$this->Socket=curl_init();
    		}else{
    			if(!empty($this->ProxyHost) && !empty($this->ProxyPort)){
    				$this->Socket=$this->Socket=fsockopen($this->ProxyHost,$this->ProxyPort,$this->ErrNo,$this->ErrStr,$this->Timeout);
    			}else{
    				@$this->Socket=$this->SSL?fsockopen('ssl://'.$this->Server,$this->Port,$this->ErrNo,$this->ErrStr,$this->Timeout):fsockopen($this->Server,$this->Port,$this->ErrNo,$this->ErrStr,$this->Timeout);
    			}
    		}
    		if(!$this->Socket){
    			if($this->CURL===true){
    				$this->ErrNo=curl_errno($this->Socket);
    				$this->ErrStr=curl_error($this->Socket);
    			}
    			exit("Connecting error: {$this->ErrNo}=>{$this->ErrStr}");
    		}
    	}
    
    	/**
    	 * HTTP&#22836;&#35831;&#27714;
    	 * &#40664;&#35748;HTTP&#22836;&#29983;&#25104;
    	 * &#22914;&#26524;&#27809;&#26377;&#23450;&#20041;&#31867;&#22411;&#23601;&#25353;$Header&#37324;&#30340;&#29983;&#25104;,&#25968;&#32452;&#37324;&#20026;&#31354;&#30340;&#36339;&#36807;
    	 * &#22914;&#26524;&#32473;&#20986;$Name&#23601;&#28155;&#21152;&#21040;Request
    	 */
    	function make_head($Name=null,$Value=null){
    		if(empty($Name)&&empty($Value)){
    			$Connection="Close";
    			strtoupper($Name)=='CONNECTION'?$Connection=$Value:null;
    			foreach($this->Header as $Key=>$Var){
    				empty($Var)?null:$this->Request.="$Key: $Var{$this->CRLF}";
    			}
    			$this->Request.="Connection: $Connection";
    		}else{
    			$this->Request.="$Name: $Value{$this->CRLF}";
    		}
    		return $this->Request;
    	}
    
    	/**
    	 * HTTP&#22836;&#35299;&#30721;
    	 * &#20174;http&#22836;&#37324;&#35299;&#26512;&#20986;&#26381;&#21153;&#22120;&#30340;&#29366;&#24577;,Cookies,&#32534;&#30721;&#31561;
    	 */
    	function decode_head($URL,$Header){
    		if($this->Debug){
    			var_dump($Header);
    		}
    		$this->Status=$this->parse_status($Header);
    		$this->AutoLocation?$this->parse_redirect($Header):null;
    		$this->parse_cookie($Header);
    		$this->parse_encoding($Header);
    	}
    
    	/**
    	 * &#35299;&#26512;&#26381;&#21153;&#22120;&#36820;&#22238;&#30340;&#29366;&#24577;
    	 */
    	function parse_status(&$Header){
    		$Regexp="/HTTP\/1\.[01] ([0-9]+) [a-z]+/i";
    		preg_match($Regexp,$Header,$Tmp);
    		return $Tmp[1];
    	}
    	/**
    	 * &#35299;&#26512;&#37325;&#23450;&#21521;
    	 * &#27880;&#24847;&#38750;HTML&#30340;<meta>&#36319;JS&#30340;
    	 */
    	function parse_redirect(&$Header){
    		$Regexp="/location:([^\n]+)\n/i";
    		preg_match($Regexp,$Header,$Tmp);
    		return trim($Tmp[1]);
    	}
    	/**
    	 * &#35299;&#26512;Cookie&#24182;&#20445;&#23384;&#22791;&#29992;
    	 */
    	function parse_cookie($Header){
    		$Regexp="/Set-Cookie:((?:[^=]+)=(?:[^\n;]+)).*/i";
    		preg_match_all($Regexp,$Header,$Tmp);
    		foreach($Tmp[1] as $Var){
    			$Var=trim($Var);
    			$this->Header['Cookie'].="$Var;";
    		}
    		return $this->Header['Cookie'];
    	}
    	/**
    	 * &#35299;&#26512;HTTP&#22836;&#30340;&#20256;&#36755;&#32534;&#30721;&#36319;&#21387;&#32553;&#26041;&#27861;
    	 */
    	function parse_encoding($Header){
    		$Regexp="/Transfer-Encoding:([^\n]+)\n/i";
    		preg_match($Regexp,$Header,$Tmp);
    		$this->TransferEncoding=strtoupper(trim($Tmp[1]));
    		$Regexp="/Content-Encoding:([^\n]+)\n/i";
    		preg_match($Regexp,$Header,$Tmp);
    		$this->ContentEncoding=strtoupper(trim($Tmp[1]));
    		return true;
    	}
    	/**
    	 * &#35299;&#26512;&#32463;&#36807;&#32534;&#30721;&#25110;&#32773;&#21387;&#32553;&#36807;&#30340;&#20869;&#23481;
    	 * &#25903;&#25345;:chunked,gzip,deflate
    	 * &#22791;&#27880;:
    	 * &#21482;&#26681;&#25454;&#26381;&#21153;&#22120;&#36820;&#22238;&#30340;Transfer-Encoding,Content-Encoding&#36827;&#34892;&#22788;&#29702;&#32780;&#38750;&#26681;&#25454;&#21028;&#26029;&#25991;&#20214;&#22836;&#36827;&#34892;&#22788;&#29702;&#30340;.
    	 * &#25152;&#20197;&#22312;&#26576;&#20123;&#32593;&#31449;&#21487;&#33021;&#20250;&#20986;&#29616;"&#20081;&#30721;"
    	 */
    	function decode_body($String,$EOL="\r\n"){
    		if(strtoupper($this->TransferEncoding)=='CHUNKED'){
    			$Return=null;
    			$EndLength=strlen($EOL);
    			do{
    				$String=ltrim($String);
    				$StartPos=strpos($String,$EOL);
    				$Length=hexdec(substr($String,0,$StartPos));
    				if($this->ContentEncoding=='DEFLATE'){
    					$Return.=gzinflate(substr($String,($StartPos+$EndLength+10),$Length));
    				}elseif($this->ContentEncoding=='GZIP'){
    					$Return.=gzuncompress(substr($String,($StartPos+$EndLength),$Length));
    				}else{
    					$Return.=substr($String,($StartPos+$EndLength),$Length);
    				}
    				$String=substr($String,($Length+$StartPos+$EndLength));
    				$End=trim($String);
    			}while(!empty($End));
    			return $Return;
    		}elseif($this->ContentEncoding=='GZIP' && !$this->CURL){
    			return gzuncompress($String);
    		}elseif($this->ContentEncoding=='DEFLATE' && !$this->CURL){
    			return gzinflate(substr($String,10));
    		}else{
    			return $String;
    		}
    	}
    
    	/**
    	 * &#21457;&#36865;&#24182;&#35835;&#21462;&#26381;&#21153;&#22120;&#36820;&#22238;&#20540;&#24182;&#20998;&#31163;&#20986;HTTP&#22836;&#36319;&#20869;&#23481;
    	 * &#29992;&#20110;Socket&#24314;&#31435;&#36830;&#25509;
    	 */
    	function request(){
    		fwrite($this->Socket,$this->Request,strlen($this->Request));
    		while(!feof($this->Socket)){
    			$Response.=fgets($this->Socket,256);
    		} //echo $Response;
    		$Response=explode($this->CRLF.$this->CRLF,$Response);
    		$Header=array_shift($Response);
    		$this->decode_head(null,$Header);
    		$Response=trim(implode($this->CRLF.$this->CRLF,$Response));
    		return $Response;
    	}
    
    	/**
    	 * &#21457;&#36865;HTTP&#22836;&#24182;&#35835;&#21462;&#25968;&#25454;
    	 */
    	function exec(){
    		if($this->CURL===true){
    			$Return=curl_exec($this->Socket);
    			if($this->Debug){
    				var_dump(curl_error($this->Socket));
    				var_dump(curl_errno($this->Socket));
    			}
    		}else{
    			$Return=$this->request();
    		}
    		if($this->Debug){
    			var_dump($this->Request);
    			var_dump($Return);
    		}
    		return $this->decode_body($Return);
    	}
    
    	/**
    	 * &#35774;&#32622;HTTP &#30340;&#26041;&#27861;
    	 * &#21482;&#25903;&#25345;HEAD,GET,POST
    	 */
    	function set_header($Method='get',$Document,$Data=null){
    		$AllowMethod=array('HEAD','GET','POST');
    		if(!in_array(strtoupper($Method),$AllowMethod)){
    			return false;
    		}
    		empty($Document)?null:$this->Document=$Document;
    		if($this->CURL){
    			$this->set_curl_head($Method,$Data);
    		}else{
    			$this->set_socket_head($Method,$Data);
    		}
    	}
    
    	/**
    	 * &#22312;&#21487;&#29992;CURL&#30340;&#24773;&#20917;&#19979;&#35774;&#32622;,HTTP&#22836;
    	 */
    	function set_curl_head($Method,$Data){
    		empty($this->CookieFile)?$this->CookieFile=tempnam('./',md5($this->Hostname)):null;
    		curl_setopt($this->Socket,CURLOPT_RETURNTRANSFER,true);
    		if(!empty($this->ProxyHost)&&!empty($this->ProxyPort)){
    			curl_setopt($this->Socket,CURLOPT_PROXY,"{$this->ProxyHost}:{$this->ProxyPort}");
    		}
    		if($Method=='HEAD'){
    			curl_setopt($this->Socket,CURLOPT_FOLLOWLOCATION,true);
    			curl_setopt($this->Socket,CURLOPT_HEADER,true);
    			curl_setopt($this->Socket,CURLOPT_HEADERFUNCTION,array(&$this,'decode_head'));
    			curl_setopt($this->Socket,CURLOPT_CUSTOMREQUEST,"HEAD");
    		}elseif($Method=='POST'){
    			curl_setopt($this->Socket,CURLOPT_POST,true);
    			curl_setopt($this->Socket,CURLOPT_POSTFIELDS,$Data);
    		}elseif($Method=='GET'){
    			//curl_setopt($this->Socket,CURLOPT_COOKIEJAR,$this->CookieFile);
    			//curl_setopt($this->Socket,CURLOPT_COOKIEFILE,$this->CookieFile);
    		}
    		if($this->SSL){
    			curl_setopt($this->Socket,CURLOPT_SSL_VERIFYPEER,false);
    			curl_setopt($this->Socket,CURLOPT_SSL_VERIFYHOST,false);
    			curl_setopt($this->Socket,CURLOPT_URL,'https://'.$this->Hostname.$this->Document);
    		}else{
    			curl_setopt($this->Socket,CURLOPT_URL,'http://'.$this->Hostname.$this->Document);
    		}
    		curl_setopt($this->Socket,CURLOPT_COOKIEJAR,$this->CookieFile);
    		curl_setopt($this->Socket,CURLOPT_COOKIEFILE,$this->CookieFile);
    		curl_setopt($this->Socket,CURLOPT_REFERER,$this->Header['Referer']);
    		curl_setopt($this->Socket,CURLOPT_USERAGENT,$this->Header['User-Agent']);
    	}
    
    	/**
    	 * &#22312;Socket&#30340;&#24773;&#20917;&#19979;&#35774;&#32622;,HTTP&#22836;
    	 */
    	function set_socket_head($Method){
    		if(!empty($this->ProxyHost)&&!empty($this->ProxyPort)){
    			$this->Request="{$Method} http://{$this->Hostname}{$this->Document} HTTP/1.1{$this->CRLF}";
    		}else{
    			$this->Request="{$Method} {$this->Document} HTTP/1.1{$this->CRLF}";
    		}
    		$this->make_head();
    	}
    	/**
    	 * &#21457;&#36865;HEAD&#35831;&#27714;
    	 * &#26242;&#19981;&#25903;&#25345;&#22522;&#20110;&#20195;&#29702;&#30340;HTTPS HEAD
    	 * &#21407;&#22240;&#26159;&#33258;&#24049;&#19981;&#30693;&#36947;&#35201;&#24590;&#20040;&#22788;&#29702;
    	 */
    	function head($Document=null){
    		$this->connect();
    		$this->set_header('HEAD',$Document);
    		if(!$this->CURL){
    			$this->Request.=$this->CRLF.$this->CRLF;
    		}
    		$this->exec();
    		if($this->Status==200){
    			return true;
    		}else{
    			return false;
    		}
    	}
    
    	/**
    	 * &#21457;&#36865;GET&#35831;&#27714;,&#33258;&#21160;&#20445;&#23384;cookie,&#35774;&#32622;referer,&#26242;&#19981;&#25903;&#25345;&#33258;&#21160;&#37325;&#23450;&#21521;,&#22788;&#29702;&#26381;&#21153;&#22120;&#32534;&#30721;&#36319;&#35299;&#21387;==
    	 */
    	function get($Document=null){
    		$this->connect();
    		$this->Header['Referer']="http://{$this->Hostname}{$this->Document}";
    		$this->set_header('GET',$Document);
    		if(!$this->CURL){
    			$this->Request.=$this->CRLF.$this->CRLF;
    		}
    		return $this->exec();
    	}
    
    	/**
    	 * &#21457;&#36865;POST&#35831;&#27714;,&#33258;&#21160;&#20445;&#23384;cookie,&#35774;&#32622;referer,&#26242;&#19981;&#25903;&#25345;&#21457;&#36865;&#25991;&#20214;,&#33258;&#21160;&#37325;&#23450;&#21521;,&#22788;&#29702;&#26381;&#21153;&#22120;&#32534;&#30721;&#36319;&#35299;&#21387;==
    	 */
    	function post($Document,$Data=null){
    		if(!is_array($Data)){
    			return false;
    		}
    		foreach($Data as $Key=>$Var){
    			$Tmp[]="$Key=".urlencode($Var);
    		}
    		$Data=implode('&',$Tmp);
    		$this->connect();
    		$this->Header['Referer']="http://{$this->Hostname}{$this->Document}";
    		$this->Header['Content-Type']='application/x-www-form-urlencoded';
    		$this->Header['Content-Length']=strlen($Data);
    		$this->set_header('POST',$Document,$Data);
    		if(!$this->CURL){
    			$this->Request.=$this->CRLF.$this->CRLF;
    			$this->Request.=$Data;
    		}
    		return $this->exec();
    	}
    
    	/**
    	 * &#20851;&#38381;&#36830;&#25509;
    	 */
    	function close($Handle=null){
    		if($this->CURL){
    			curl_close($this->Socket);
    			unlink($this->CookieFile);//&#19981;&#35201;&#24536;&#35760;&#21024;&#38500;&#25991;&#20214;
    		}else{
    			fclose($this->Socket);
    		}
    		return true;
    	}
    
    	function send_file($Source,$Destination,$AllowPartial=true){
    		//#&#33719;&#21462;&#25991;&#20214;&#29366;&#24577;
    		$FileStatus=stat($Source);
    		$LastModTime=$FileStatus['mtime'];
    		$FileHash=md5($FileStatus['mtime'].'='.$FileStatus['ino'].'='.$FileStatus['size']);
    		$Etag='"'.$FileHash.'-'.crc32($FileHash).'"';
    
    		#//&#33719;&#21462;&#25991;&#20214;&#29366;&#24577;
    		header('Last-Modified: '.gmdate("D, d M Y H:i:s",$LastModTime).' GMT');
    		header("ETag: $Etag");
    		//#&#27983;&#35272;&#22120;&#32531;&#23384;&#26816;&#27979;&#22788;&#29702;
    		if(isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $LastModTime){
    			return header("HTTP/1.1 304 Not Modified");
    		}
    		if(isset($_SERVER['HTTP_IF_UNMODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_UNMODIFIED_SINCE']) < $lastModified){
    			return header("HTTP/1.1 304 Not Modified");
    		}
    		if(isset($_SERVER['HTTP_IF_NONE_MATCH']) &&  $_SERVER['HTTP_IF_NONE_MATCH'] == $etag){
    			return header("HTTP/1.1 304 Not Modified");
    		}
    		#//&#27983;&#35272;&#22120;&#32531;&#23384;&#26816;&#27979;&#22788;&#29702;*/
    
    		empty($Destination)?$Destination=basename($Source):null;
    		$ContentType=$this->mime_type($Source);
    		$FileSize=$FileStatus['size'];
    		$ContentLength=$FileSize;
    		if($AllowPartial==false){
    			header('Pragma: cache');
    			header('Cache-Control: public, must-revalidate, max-age=0');
    			header('Content-Transfer-Encoding: binary');
    			header('Content-Encoding: none');
    			header('Content-type: ' . $ContentType);
    			header('Content-Disposition: attachment; filename="' .rawurlencode(basename($Destination)).'"');
    			header("Content-length: $ContentLength");
    			echo readfile($Source);
    			exit();
    		}
    		$IsPartial=false;
    		if(isset($_SERVER['HTTP_RANGE'])){
    			if(preg_match('/^bytes=(\d*)-(\d*)$/',$_SERVER['HTTP_RANGE'],$Matches)){
    				$StartPos=$Matches[1];
    				$EndPos=$Matches[2];
    				if($StartPos=='' && $EndPos=''){
    					return header('HTTP/1.1 400 Bad Request');
    				}
    				if($StartPos == ''){
    					$StartPos = $FileSize - $EndPos;
    					$EndPos = $FileSize - 1;
    				}elseif($EndPos == ''){
    					$EndPos = $FileSize - 1;
    				}
    				$StartPos = $StartPos < 0 ? 0 : $StartPos;
    				$EndPos = $EndPos > $FileSize - 1 ? $FileSize - 1 : $EndPos;
    				$Length = $EndPos-$StartPos + 1;
    				if ($Length < 0){
    					return header('HTTP/1.1 400 Bad Request');
    				}
    				$ContentLength = $Length;
    				$IsPartial = true;
    			}
    		}
    		if($IsPartial){
    			header('HTTP/1.1 206 Partial Content');
    			header("Content-Range: bytes $StartPos-$EndPos/$FileSize");
    		}else{
    			header("HTTP/1.1 200 OK");
    			$StartPos = 0;
    			$EndPos = $ContentLength - 1;
    		}
    		header('Pragma: cache');
    		header('Cache-Control: public, must-revalidate, max-age=0');
    		header('Accept-Ranges: bytes');
    		header('Content-type: '.$ContentType);
    		header('Content-Length: '.$ContentLength);
    		header('Content-Disposition: attachment; filename="'.rawurlencode($Destination).'"');
    		header("Content-Transfer-Encoding: binary");
    		header('Content-Encoding: none');
    		$BufferSize=2048;
    		$BytesSent=0;
    		$Handle=fopen($Source,'rb');
    		fseek($Handle,$StartPos);
    		while($BytesSent < $ContentLength && !feof($Handle) && connection_status() == 0){
    			$ReadBuffer=$ContentLength-$BytesSent<$BufferSize?$ContentLength-$BytesSent:$BufferSize;
    			$Buffer=fread($Handle,$ReadBuffer);
    			echo $Buffer;
    			ob_flush();//&#27809;&#29992;ob_start&#30340;&#21487;&#20197;&#21435;&#25481;
    			flush();
    			$BytesSent+=$ReadBuffer;
    		}
    		return true;
    	}
    
    	/**
    	 *
    	 */
    	function send_link($Source,$Destinaion,$VaildTime){
    		$TmpDownloadPath='./tmp/';
    		if($VaildTime>0){
    			foreach(glob($TmpDownloadPath.'*.*') as $File){
    				if(filemtime($File) < (time()-($VaildTime*60*60))){
    					$this->_unlink($File);
    				}
    			}
    		}
    		if(file_exists($Destinaion)){
    			header("HTTP/1.1 301 Moved Permanently");
    			header("Location: {$TmpDownloadPath}{$Destinaion}");
    		}else{
    			$this->_symlink($Source,$TmpDownloadPath.$Destinaion);
    			header("HTTP/1.1 301 Moved Permanently");
    			header("Location: {$TmpDownloadPath}{$Destinaion}");
    		}
    	}
    
    	/**
    	 * &#22312;Win&#19979;&#38656;&#35201;linkd&#36319;Web&#29992;&#25143;&#23545;linkd,cmd&#26377;&#25191;&#34892;&#30340;&#26435;&#38480;&#24182;&#21487;&#25191;&#34892;exec&#20989;&#25968;,&#24182;&#19988;&#26159;NTFS&#26684;&#24335;
    	 * linkd&#19979;&#36733;&#22320;&#22336;:
    	 * http://www.dynawell.com/reskit/microsoft/win2000/linkd.zip
    	 * &#27880;&#24847;&#22312;php&#23433;&#20840;&#27169;&#24335;&#19979;&#38656;&#35201;&#25226;linkd,cmd&#25918;&#21040;safe_mode_exec_dir&#25351;&#23450;&#30340;&#30446;&#24405;&#19979;
    	 */
    	function _symlink($Source,$Destination){
    		if(strtoupper(PHP_OS) == 'WINNT'){
    			$LinkExec="linkd";
    			return (function_exists('exec') && file_exists($Source))?exec("$LinkExec \"$Destination\" \"$Source\""):false;
    		}else{
    			return symlink($Source,$Destination);
    		}
    	}
    
    	//&#21024;&#38500;&#26377;_symlink&#21019;&#24314;&#30340;&#25991;&#20214;
    	//&#27880;&#24847;:&#35265;_symlink&#20989;&#25968;&#27880;&#37322;
    	function _unlink($Source){
    		if(strtoupper(PHP_OS) == 'WINNT'){
    			$LinkExec="linkd";
    			return (function_exists('exec') && file_exists($Source))?
    			exec("$LinkExec -d \"$Source\""):false;
    		}else{
    			unlink($Source);
    		}
    	}
    PHP:
     
    megler, Dec 30, 2008 IP
  4. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #4
    That's perfectly valid, (although it's missing it's final }) - (end class declaration.)
     
    Danltn, Dec 31, 2008 IP
  5. megler

    megler Peon

    Messages:
    68
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    wow, then why would I be getting that error? that's weird.
     
    megler, Dec 31, 2008 IP
  6. qualityfirst

    qualityfirst Peon

    Messages:
    147
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    0
    #6
    Can you post the error?

    That would help us a lot.
     
    qualityfirst, Dec 31, 2008 IP
  7. megler

    megler Peon

    Messages:
    68
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Here's the error:

    Parse error: syntax error, unexpected T_STRING in /home/username/public_html/domain/wpmanager/include/http.lib.php on line 542

    I thought maybe it was something in the php.ini, but the only thing weird was my host turned off magic quotes. I turned them back on and still have the same error.
     
    megler, Dec 31, 2008 IP