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

📄 nusoap.php

📁 学校网站源码http://您的网址/admin/admin_login.asp 默认登录用户:admin 默认登录密码:admin
💻 PHP
📖 第 1 页 / 共 5 页
字号:
				}
				$hashedDigest = md5( $unhashedDigest );
				$this->outgoing_headers['Authorization'] = "Digest username=\"".$username."\", realm=\"".$digestRequest['realm']."\", nonce=\"".$nonce."\", uri=\"".$this->uri."\", cnonce=\"".$cnonce."\", nc=".sprintf( "%08x", $digestRequest['nc'] ).", qop=\"".$digestRequest['qop']."\", response=\"".$hashedDigest."\"";
			}
		}
		$this->username = $username;
		$this->password = $password;
		$this->authtype = $authtype;
		$this->digestRequest = $digestRequest;
		if ( isset( $this->outgoing_headers['Authorization'] ) )
		{
			$this->debug( "Authorization header set: ".substr( $this->outgoing_headers['Authorization'], 0, 12 )."..." );
		}
		else
		{
			$this->debug( "Authorization header not set" );
		}
	}

	function setsoapaction( $soapaction )
	{
		$this->outgoing_headers['SOAPAction'] = "\"".$soapaction."\"";
	}

	function setencoding( $enc = "gzip, deflate" )
	{
		$this->protocol_version = "1.1";
		$this->outgoing_headers['Accept-Encoding'] = $enc;
		$this->outgoing_headers['Connection'] = "close";
		$this->persistentConnection = false;
		set_magic_quotes_runtime( 0 );
		$this->encoding = $enc;
	}

	function setproxy( $proxyhost, $proxyport, $proxyusername = "", $proxypassword = "" )
	{
		$this->uri = $this->url;
		$this->host = $proxyhost;
		$this->port = $proxyport;
		if ( $proxyusername != "" && $proxypassword != "" )
		{
			$this->outgoing_headers['Proxy-Authorization'] = " Basic ".base64_encode( $proxyusername.":".$proxypassword );
		}
	}

	function decodechunked( $buffer, $lb )
	{
		$length = 0;
		$new = "";
		$chunkend = strpos( $buffer, $lb );
		if ( $chunkend == FALSE )
		{
			$this->debug( "no linebreak found in decodeChunked" );
			return $new;
		}
		$temp = substr( $buffer, 0, $chunkend );
		$chunk_size = hexdec( trim( $temp ) );
		$chunkstart = $chunkend + strlen( $lb );
		while ( 0 < $chunk_size )
		{
			$this->debug( "chunkstart: {$chunkstart} chunk_size: {$chunk_size}" );
			$chunkend = strpos( $buffer, $lb, $chunkstart + $chunk_size );
			if ( $chunkend == FALSE )
			{
				$chunk = substr( $buffer, $chunkstart );
				$new .= $chunk;
				$length += strlen( $chunk );
				break;
			}
			$chunk = substr( $buffer, $chunkstart, $chunkend - $chunkstart );
			$new .= $chunk;
			$length += strlen( $chunk );
			$chunkstart = $chunkend + strlen( $lb );
			$chunkend = strpos( $buffer, $lb, $chunkstart ) + strlen( $lb );
			if ( $chunkend == FALSE )
			{
				break;
			}
			$temp = substr( $buffer, $chunkstart, $chunkend - $chunkstart );
			$chunk_size = hexdec( trim( $temp ) );
			$chunkstart = $chunkend;
		}
		return $new;
	}

	function buildpayload( $data )
	{
		$this->outgoing_headers['Content-Length'] = strlen( $data );
		$this->outgoing_payload = "{$this->request_method} {$this->uri} HTTP/{$this->protocol_version}\r\n";
		foreach ( $this->outgoing_headers as $k => $v )
		{
			$this->outgoing_payload .= $k.": ".$v."\r\n";
		}
		$this->outgoing_payload .= "\r\n";
		$this->outgoing_payload .= $data;
	}

	function sendrequest( $data )
	{
		$this->buildpayload( $data );
		if ( $this->scheme == "http" || $this->scheme == "ssl" )
		{
			if ( !fputs( $this->fp, $this->outgoing_payload, strlen( $this->outgoing_payload ) ) )
			{
				$this->seterror( "couldn't write message data to socket" );
				$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;
	}

}

class soap_server extends nusoap_base
{

	var $title = "NuSOAP";
	var $version = "0.6.7";
	var $revision = "\$Revision: 1.75 \$";
	var $error_str = false;
	var $debug_str = "";
	var $charencoding = true;
	var $XMLSchemaVersion = "http://www.w3.org/2001/XMLSchema";
	var $soap_defencoding = "ISO-8859-1";
	var $namespaces = array
	(
		"SOAP-ENV" => "http://schemas.xmlsoap.org/soap/envelope/",
		"xsd" => "http://www.w3.org/2001/XMLSchema",
		"xsi" => "http://www.w3.org/2001/XMLSchema-instance",
		"SOAP-ENC" => "http://schemas.xmlsoap.org/soap/encoding/",
		"si" => "http://soapinterop.org/xsd"
	);
	var $usedNamespaces = array( );
	var $typemap = array
	(
		"http://www.w3.org/2001/XMLSchema" => array
		(
			"string" => "string",
			"boolean" => "boolean",
			"float" => "double",
			"double" => "double",
			"decimal" => "double",
			"duration" => "",
			"dateTime" => "string",
			"time" => "string",
			"date" => "string",
			"gYearMonth" => "",
			"gYear" => "",
			"gMonthDay" => "",
			"gDay" => "",
			"gMonth" => "",
			"hexBinary" => "string",
			"base64Binary" => "string",
			"normalizedString" => "string",
			"token" => "string",
			"language" => 

⌨️ 快捷键说明

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