⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 class.soap_transport_http.php

📁 学校网站源码http://您的网址/admin/admin_login.asp 默认登录用户:admin 默认登录密码:admin
💻 PHP
📖 第 1 页 / 共 2 页
字号:
				$this->debug( "couldn't write message data to socket" );
				return false;
			}
			$this->debug( "wrote data to socket, length = ".strlen( $this->outgoing_payload ) );
			return true;
		}
		else if ( $this->scheme == "https" )
		{
			foreach ( $this->outgoing_headers as $k => $v )
			{
				$curl_headers[] = "{$k}: {$v}";
			}
			curl_setopt( $this->ch, CURLOPT_HTTPHEADER, $curl_headers );
			if ( $this->request_method == "POST" )
			{
				curl_setopt( $this->ch, CURLOPT_POST, 1 );
				curl_setopt( $this->ch, CURLOPT_POSTFIELDS, $data );
			}
			$this->debug( "set cURL payload" );
			return true;
		}
	}

	function getresponse( )
	{
		$this->incoming_payload = "";
		if ( $this->scheme == "http" || $this->scheme == "ssl" )
		{
			$data = "";
			while ( !isset( $lb ) )
			{
				if ( feof( $this->fp ) )
				{
					$this->incoming_payload = $data;
					$this->debug( "found no headers before EOF after length ".strlen( $data ) );
					$this->debug( "received before EOF:\n".$data );
					$this->seterror( "server failed to send headers" );
					return false;
				}
				$tmp = fgets( $this->fp, 256 );
				$tmplen = strlen( $tmp );
				$this->debug( "read line of {$tmplen} bytes: ".trim( $tmp ) );
				if ( $tmplen == 0 )
				{
					$this->incoming_payload = $data;
					$this->debug( "socket read of headers timed out after length ".strlen( $data ) );
					$this->debug( "read before timeout:\n".$data );
					$this->seterror( "socket read of headers timed out" );
					return false;
				}
				$data .= $tmp;
				$pos = strpos( $data, "\r\n\r\n" );
				if ( 1 < $pos )
				{
					$lb = "\r\n";
				}
				else
				{
					$pos = strpos( $data, "\n\n" );
					if ( 1 < $pos )
					{
						$lb = "\n";
					}
				}
				if ( isset( $lb ) && ereg( "^HTTP/1.1 100", $data ) )
				{
					unset( $lb );
					$data = "";
				}
			}
			$this->incoming_payload .= $data;
			$this->debug( "found end of headers after length ".strlen( $data ) );
			$header_data = trim( substr( $data, 0, $pos ) );
			$header_array = explode( $lb, $header_data );
			$this->incoming_headers = array( );
			foreach ( $header_array as $header_line )
			{
				$arr = explode( ":", $header_line, 2 );
				if ( 1 < count( $arr ) )
				{
					$header_name = strtolower( trim( $arr[0] ) );
					$this->incoming_headers[$header_name] = trim( $arr[1] );
				}
				else if ( isset( $header_name ) )
				{
					$this->incoming_headers[$header_name] .= $lb." ".$header_line;
				}
			}
			if ( isset( $this->incoming_headers['content-length'] ) )
			{
				$content_length = $this->incoming_headers['content-length'];
				$chunked = false;
				$this->debug( "want to read content of length {$content_length}" );
			}
			else
			{
				$content_length = 2147483647;
				if ( isset( $this->incoming_headers['transfer-encoding'] ) && strtolower( $this->incoming_headers['transfer-encoding'] ) == "chunked" )
				{
					$chunked = true;
					$this->debug( "want to read chunked content" );
				}
				else
				{
					$chunked = false;
					$this->debug( "want to read content to EOF" );
				}
			}
			$data = "";
			do
			{
				if ( $chunked )
				{
					$tmp = fgets( $this->fp, 256 );
					$tmplen = strlen( $tmp );
					$this->debug( "read chunk line of {$tmplen} bytes" );
					if ( $tmplen == 0 )
					{
						$this->incoming_payload = $data;
						$this->debug( "socket read of chunk length timed out after length ".strlen( $data ) );
						$this->debug( "read before timeout:\n".$data );
						$this->seterror( "socket read of chunk length timed out" );
						return false;
					}
					$content_length = hexdec( trim( $tmp ) );
					$this->debug( "chunk length {$content_length}" );
				}
				$strlen = 0;
				while ( $strlen < $content_length && !feof( $this->fp ) )
				{
					$readlen = min( 8192, $content_length - $strlen );
					$tmp = fread( $this->fp, $readlen );
					$tmplen = strlen( $tmp );
					$this->debug( "read buffer of {$tmplen} bytes" );
					if ( $tmplen == 0 && !feof( $this->fp ) )
					{
						$this->incoming_payload = $data;
						$this->debug( "socket read of body timed out after length ".strlen( $data ) );
						$this->debug( "read before timeout:\n".$data );
						$this->seterror( "socket read of body timed out" );
						return false;
					}
					$strlen += $tmplen;
					$data .= $tmp;
				}
				if ( $chunked && 0 < $content_length )
				{
					$tmp = fgets( $this->fp, 256 );
					$tmplen = strlen( $tmp );
					$this->debug( "read chunk terminator of {$tmplen} bytes" );
					if ( $tmplen == 0 )
					{
						$this->incoming_payload = $data;
						$this->debug( "socket read of chunk terminator timed out after length ".strlen( $data ) );
						$this->debug( "read before timeout:\n".$data );
						$this->seterror( "socket read of chunk terminator timed out" );
						return false;
					}
				}
			} while ( $chunked && 0 < $content_length && !feof( $this->fp ) );
			if ( feof( $this->fp ) )
			{
				$this->debug( "read to EOF" );
			}
			$this->debug( "read body of length ".strlen( $data ) );
			$this->incoming_payload .= $data;
			$this->debug( "received a total of ".strlen( $this->incoming_payload )." bytes of data from server" );
			if ( isset( $this->incoming_headers['connection'] ) && strtolower( $this->incoming_headers['connection'] ) == "close" || !$this->persistentConnection || feof( $this->fp ) )
			{
				fclose( $this->fp );
				$this->fp = false;
				$this->debug( "closed socket" );
			}
			if ( $this->incoming_payload == "" )
			{
				$this->seterror( "no response from server" );
				return false;
			}
		}
		else if ( $this->scheme == "https" )
		{
			$this->debug( "send and receive with cURL" );
			$this->incoming_payload = curl_exec( $this->ch );
			$data = $this->incoming_payload;
			$cErr = curl_error( $this->ch );
			if ( $cErr != "" )
			{
				$err = "cURL ERROR: ".curl_errno( $this->ch ).": ".$cErr."<br>";
				foreach ( curl_getinfo( $this->ch ) as $k => $v )
				{
					$err .= "{$k}: {$v}<br>";
				}
				$this->debug( $err );
				$this->seterror( $err );
				curl_close( $this->ch );
				return false;
			}
			$this->debug( "No cURL error, closing cURL" );
			curl_close( $this->ch );
			if ( ereg( "^HTTP/1.1 100", $data ) )
			{
				if ( $pos = strpos( $data, "\r\n\r\n" ) )
				{
					$data = ltrim( substr( $data, $pos ) );
				}
				else if ( $pos = strpos( $data, "\n\n" ) )
				{
					$data = ltrim( substr( $data, $pos ) );
				}
			}
			if ( $pos = strpos( $data, "\r\n\r\n" ) )
			{
				$lb = "\r\n";
			}
			else if ( $pos = strpos( $data, "\n\n" ) )
			{
				$lb = "\n";
			}
			else
			{
				$this->debug( "no proper separation of headers and document" );
				$this->seterror( "no proper separation of headers and document" );
				return false;
			}
			$header_data = trim( substr( $data, 0, $pos ) );
			$header_array = explode( $lb, $header_data );
			$data = ltrim( substr( $data, $pos ) );
			$this->debug( "found proper separation of headers and document" );
			$this->debug( "cleaned data, stringlen: ".strlen( $data ) );
			foreach ( $header_array as $header_line )
			{
				$arr = explode( ":", $header_line, 2 );
				if ( 1 < count( $arr ) )
				{
					$this->incoming_headers[strtolower( trim( $arr[0] ) )] = trim( $arr[1] );
				}
			}
		}
		if ( isset( $this->incoming_headers['www-authenticate'] ) && strstr( $header_array[0], "401 Unauthorized" ) )
		{
			$this->debug( "Got 401 Unauthorized with WWW-Authenticate: ".$this->incoming_headers['www-authenticate'] );
			if ( substr( "Digest ", $this->incoming_headers['www-authenticate'] ) )
			{
				$this->debug( "Server wants digest authentication" );
				$digestString = str_replace( "Digest ", "", $this->incoming_headers['www-authenticate'] );
				$digestElements = explode( ",", $digestString );
				foreach ( $digestElements as $val )
				{
					$tempElement = explode( "=", trim( $val ) );
					$digestRequest[$tempElement[0]] = str_replace( "\"", "", $tempElement[1] );
				}
				if ( isset( $digestRequest['nonce'] ) )
				{
					$this->setcredentials( $this->username, $this->password, "digest", $digestRequest );
					$this->tryagain = true;
					return false;
				}
			}
			$this->debug( "HTTP authentication failed" );
			$this->seterror( "HTTP authentication failed" );
			return false;
		}
		if ( isset( $this->incoming_headers['content-encoding'] ) && $this->incoming_headers['content-encoding'] != "" )
		{
			if ( strtolower( $this->incoming_headers['content-encoding'] ) == "deflate" || strtolower( $this->incoming_headers['content-encoding'] ) == "gzip" )
			{
				if ( function_exists( "gzuncompress" ) )
				{
					if ( $this->incoming_headers['content-encoding'] == "deflate" && ( $degzdata = @gzuncompress( $data ) ) )
					{
						$data = $degzdata;
					}
					else if ( $this->incoming_headers['content-encoding'] == "gzip" && ( $degzdata = gzinflate( substr( $data, 10 ) ) ) )
					{
						$data = $degzdata;
					}
					else
					{
						$this->seterror( "Errors occurred when trying to decode the data" );
					}
					$this->incoming_payload = $header_data.$lb.$lb.$data;
				}
				else
				{
					$this->seterror( "The server sent deflated data. Your php install must have the Zlib extension compiled in to support this." );
				}
			}
		}
		if ( strlen( $data ) == 0 )
		{
			$this->debug( "no data after headers!" );
			$this->seterror( "no data present after HTTP headers" );
			return false;
		}
		return $data;
	}

	function setcontenttype( $type, $charset = false )
	{
		$this->outgoing_headers['Content-Type'] = $type.( $charset ? "; charset=".$charset : "" );
	}

	function usepersistentconnection( )
	{
		if ( isset( $this->outgoing_headers['Accept-Encoding'] ) )
		{
			return false;
		}
		$this->protocol_version = "1.1";
		$this->persistentConnection = true;
		$this->outgoing_headers['Connection'] = "Keep-Alive";
		return true;
	}

}

?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -