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

📄 nusoapmime.php

📁 学校网站源码http://您的网址/admin/admin_login.asp 默认登录用户:admin 默认登录密码:admin
💻 PHP
字号:
<?php


require_once( "Mail/mimeDecode.php" );
require_once( "Mail/mimePart.php" );
class soapclientmime extends soapclient
{

	var $requestAttachments = array( );
	var $responseAttachments;
	var $mimeContentType;

	function addattachment( $data, $filename = "", $contenttype = "application/octet-stream", $cid = false )
	{
		if ( !$cid )
		{
			$cid = md5( uniqid( time( ) ) );
		}
		$info['data'] = $data;
		$info['filename'] = $filename;
		$info['contenttype'] = $contenttype;
		$info['cid'] = $cid;
		$this->requestAttachments[] = $info;
		return $cid;
	}

	function clearattachments( )
	{
		$this->requestAttachments = array( );
	}

	function getattachments( )
	{
		return $this->responseAttachments;
	}

	function gethttpbody( $soapmsg )
	{
		if ( 0 < count( $this->requestAttachments ) )
		{
			$params['content_type'] = "multipart/related";
			$mimeMessage =& new mail_mimepart( "", $params );
			unset( $params );
			$params['content_type'] = "text/xml";
			$params['encoding'] = "8bit";
			$params['charset'] = $this->soap_defencoding;
			$mimeMessage->addsubpart( $soapmsg, $params );
			foreach ( $this->requestAttachments as $att )
			{
				unset( $params );
				$params['content_type'] = $att['contenttype'];
				$params['encoding'] = "base64";
				$params['disposition'] = "attachment";
				$params['dfilename'] = $att['filename'];
				$params['cid'] = $att['cid'];
				if ( $att['data'] == "" && $att['filename'] != "" )
				{
					if ( $fd = fopen( $att['filename'], "rb" ) )
					{
						$data = fread( $fd, filesize( $att['filename'] ) );
						fclose( $fd );
					}
					else
					{
						$data = "";
					}
					$mimeMessage->addsubpart( $data, $params );
				}
				else
				{
					$mimeMessage->addsubpart( $att['data'], $params );
				}
			}
			$output = $mimeMessage->encode( );
			$mimeHeaders = $output['headers'];
			foreach ( $mimeHeaders as $k => $v )
			{
				$this->debug( "MIME header {$k}: {$v}" );
				if ( strtolower( $k ) == "content-type" )
				{
					$this->mimeContentType = str_replace( "\r\n", " ", $v );
				}
			}
			return $output['body'];
		}
		return soapclient::gethttpbody( $soapmsg );
	}

	function gethttpcontenttype( )
	{
		if ( 0 < count( $this->requestAttachments ) )
		{
			return $this->mimeContentType;
		}
		return soapclient::gethttpcontenttype( );
	}

	function gethttpcontenttypecharset( )
	{
		if ( 0 < count( $this->requestAttachments ) )
		{
			return false;
		}
		return soapclient::gethttpcontenttypecharset( );
	}

	function parseresponse( $headers, $data )
	{
		$this->debug( "Entering parseResponse() for payload of length ".strlen( $data )." and type of ".$headers['content-type'] );
		$this->responseAttachments = array( );
		if ( strstr( $headers['content-type'], "multipart/related" ) )
		{
			$this->debug( "Decode multipart/related" );
			$input = "";
			foreach ( $headers as $k => $v )
			{
				$input .= "{$k}: {$v}\r\n";
			}
			$params['input'] = $input."\r\n".$data;
			$params['include_bodies'] = true;
			$params['decode_bodies'] = true;
			$params['decode_headers'] = true;
			$structure = mail_mimedecode::decode( $params );
			foreach ( $structure->parts as $part )
			{
				if ( !isset( $part->disposition ) )
				{
					$this->debug( "Have root part of type ".$part->headers['content-type'] );
					$return = soapclient::parseresponse( $part->headers, $part->body );
				}
				else
				{
					$this->debug( "Have an attachment of type ".$part->headers['content-type'] );
					$info['data'] = $part->body;
					$info['filename'] = isset( $part->d_parameters['filename'] ) ? $part->d_parameters['filename'] : "";
					$info['contenttype'] = $part->headers['content-type'];
					$info['cid'] = $part->headers['content-id'];
					$this->responseAttachments[] = $info;
				}
			}
			if ( isset( $return ) )
			{
				return $return;
			}
			$this->seterror( "No root part found in multipart/related content" );
			return;
		}
		$this->debug( "Not multipart/related" );
		return soapclient::parseresponse( $headers, $data );
	}

}

?>

⌨️ 快捷键说明

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