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

📄 class.uebimiau.php

📁 极限网络智能办公系统—MYOA26—100%—源程序。
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php

class uebimiau_core
{

	var $mail_connection = 0;
	var $mail_server = "localhost";
	var $mail_port = 110;
	var $mail_error_msg = "";
	var $mail_user = "unknown";
	var $mail_pass = "";
	var $mail_email = "unknown@localhost";
	var $mail_protocol = "pop3";
	var $use_html = false;
	var $charset = "iso-8859-1";
	var $timezone = "+0000";
	var $debug = false;
	var $user_folder = "./";
	var $temp_folder = "./";
	var $timeout = 10;
	var $displayimages = false;
	var $save_temp_attachs = true;
	var $_msgbody = "";
	var $_content = array( );
	var $_sid = "";

	function _get_headers_from_cache( $strfile )
	{
		if ( !file_exists( $strfile ) )
		{
			return;
		}
		$f = fopen( $strfile, "rb" );
		while ( !feof( $f ) )
		{
			$result .= chop( fread( $f, 1024 ) )."\r\n";
			$pos = strpos( $result, "\r\n\r\n" );
			if ( !( $pos === false ) )
			{
				$result = substr( $result, 0, $pos );
				break;
			}
		}
		fclose( $f );
		unset( $f );
		unset( $pos );
		unset( $strfile );
		return $result;
	}

	function _read_file( $strfile )
	{
		if ( $strfile == "" || !file_exists( $strfile ) )
		{
			return;
		}
		$fd = fopen( $strfile, "rb" );
		while ( !feof( $fd ) )
		{
			$result .= chop( fgets( $fd, 65536 ) )."\r\n";
		}
		fclose( $fd );
		return $result;
	}

	function _save_file( $filename, $content )
	{
		$tmpfile = fopen( $filename, "wb" );
		fwrite( $tmpfile, $content );
		fclose( $tmpfile );
		unset( $content );
		unset( $tmpfile );
	}

	function _rmdirr( $location )
	{
		if ( substr( $location, -1 ) != "/" )
		{
			$location = $location."/";
		}
		$all = opendir( $location );
		while ( $file = readdir( $all ) )
		{
			if ( is_dir( $location.$file ) && $file != ".." && $file != "." )
			{
				$this->_rmdirr( $location.$file );
				unset( $file );
			}
			else if ( !is_dir( $location.$file ) )
			{
				unlink( $location.$file );
				unset( $file );
			}
		}
		closedir( $all );
		unset( $all );
		rmdir( $location );
	}

	function mime_encode_headers( $string )
	{
		if ( $string == "" )
		{
			return;
		}
		if ( !eregi( "^([[:print:]]*)\$", $string ) )
		{
			$string = "=?".$this->charset."?Q?".str_replace( "+", "_", str_replace( "%", "=", urlencode( $string ) ) )."?=";
		}
		return $string;
	}

	function add_body( $strbody )
	{
		if ( $this->_msgbody == "" )
		{
			$this->_msgbody = $strbody;
		}
		else
		{
			$this->_msgbody .= "\r\n<br>\r\n<br>\r\n<hr>\r\n<br>\r\n{$strbody}";
		}
	}

	function decode_mime_string( $subject )
	{
		$string = $subject;
		if ( ( $pos = strpos( $string, "=?" ) ) === false )
		{
			return $string;
		}
		while ( !( $pos === false ) )
		{
			$newresult .= substr( $string, 0, $pos );
			$string = substr( $string, $pos + 2, strlen( $string ) );
			$intpos = strpos( $string, "?" );
			$charset = substr( $string, 0, $intpos );
			$enctype = strtolower( substr( $string, $intpos + 1, 1 ) );
			$string = substr( $string, $intpos + 3, strlen( $string ) );
			$endpos = strpos( $string, "?=" );
			$mystring = substr( $string, 0, $endpos );
			$string = substr( $string, $endpos + 2, strlen( $string ) );
			if ( $enctype == "q" )
			{
				$mystring = quoted_printable_decode( ereg_replace( "_", " ", $mystring ) );
			}
			else if ( $enctype == "b" )
			{
				$mystring = base64_decode( $mystring );
			}
			$newresult .= $mystring;
			$pos = strpos( $string, "=?" );
		}
		$result = $newresult.$string;
		if ( ereg( "koi8", $subject ) )
		{
			$result = convert_cyr_string( $result, "k", "w" );
		}
		return $result;
	}

	function decode_header( $header )
	{
		$headers = explode( "\r\n", $header );
		$decodedheaders = array( );
		$i = 0;
		for ( ;	$i < count( $headers );	++$i	)
		{
			$thisheader = trim( $headers[$i] );
			if ( !empty( $thisheader ) )
			{
				if ( !ereg( "^[A-Z0-9a-z_-]+:", $thisheader ) )
				{
					$decodedheaders[$lasthead] .= " {$thisheader}";
				}
				else
				{
					$dbpoint = strpos( $thisheader, ":" );
					$headname = strtolower( substr( $thisheader, 0, $dbpoint ) );
					$headvalue = trim( substr( $thisheader, $dbpoint + 1 ) );
					if ( $decodedheaders[$headname] != "" )
					{
						$decodedheaders[$headname] .= "; {$headvalue}";
					}
					else
					{
						$decodedheaders[$headname] = $headvalue;
					}
					$lasthead = $headname;
				}
			}
		}
		return $decodedheaders;
	}

	function get_names( $strmail )
	{
		$ARfrom = array( );
		$strmail = stripslashes( ereg_replace( "\t", "", ereg_replace( "\n", "", ereg_replace( "\r", "", $strmail ) ) ) );
		if ( trim( $strmail ) == "" )
		{
			return $ARfrom;
		}
		$armail = array( );
		$counter = 0;
		$inthechar = 0;
		$chartosplit = ",;";
		$protectchar = "\"";
		$temp = "";
		$lt = "<";
		$gt = ">";
		$closed = 1;
		$i = 0;
		for ( ;	$i < strlen( $strmail );	++$i	)
		{
			$thischar = $strmail[$i];
			if ( $thischar == $lt && $closed )
			{
				$closed = 0;
			}
			if ( $thischar == $gt && !$closed )
			{
				$closed = 1;
			}
			if ( $thischar == $protectchar )
			{
				$inthechar = $inthechar ? 0 : 1;
			}
			if ( !( strpos( $chartosplit, $thischar ) === false ) && !$inthechar && $closed )
			{
				$armail[] = $temp;
				$temp = "";
			}
			else
			{
				$temp .= $thischar;
			}
		}
		if ( trim( $temp ) != "" )
		{
			$armail[] = trim( $temp );
		}
		$i = 0;
		for ( ;	$i < count( $armail );	++$i	)
		{
			$thisPart = trim( eregi_replace( "^\"(.*)\"\$", "\\1", trim( $armail[$i] ) ) );
			if ( $thisPart != "" )
			{
				if ( eregi( "(.*)<(.*)>", $thisPart, $regs ) )
				{
					$email = trim( $regs[2] );
					$name = trim( $regs[1] );
				}
				else if ( eregi( "([-a-z0-9_\$+.]+@[-a-z0-9_.]+[-a-z0-9_]+)((.*))", $thisPart, $regs ) )
				{
					$email = $regs[1];
					$name = $regs[2];
				}
				else
				{
					$email = $thisPart;
				}
				$email = preg_replace( "/<(.*)\\>/", "\\1", $email );
				$name = preg_replace( "/\"(.*)\"/", "\\1", trim( $name ) );
				$name = preg_replace( "/\\((.*)\\)/", "\\1", $name );
				if ( $name == "" )
				{
					$name = $email;
				}
				if ( $email == "" )
				{
					$email = $name;
				}
				$ARfrom[$i]['name'] = $this->decode_mime_string( $name );
				$ARfrom[$i]['mail'] = $email;
				unset( $name );
				unset( $email );
			}
		}
		return $ARfrom;
	}

	function build_alternative_body( $ctype, $body )
	{
		$boundary = $this->get_boundary( $ctype );
		$part = $this->split_parts( $boundary, $body );
		$thispart = $this->use_html ? $part[1] : $part[0];
		$email = $this->fetch_structure( $thispart );
		$header = $email['header'];
		$body = $email['body'];
		$headers = $this->decode_header( $header );
		$body = $this->compile_body( $body, $headers['content-transfer-encoding'], $headers['content-type'] );
		$this->add_body( $body );
	}

	function build_complex_body( $ctype, $body )
	{
		global $sid;
		global $lid;
		global $ix;
		global $folder;
		$Rtype = trim( substr( $ctype, strpos( $ctype, "type=" ) + 5, strlen( $ctype ) ) );
		if ( strpos( $Rtype, ";" ) != 0 )
		{
			$Rtype = substr( $Rtype, 0, strpos( $Rtype, ";" ) );
		}
		if ( substr( $Rtype, 0, 1 ) == "\"" && substr( $Rtype, -1 ) == "\"" )
		{
			$Rtype = substr( $Rtype, 1, strlen( $Rtype ) - 2 );
		}
		$boundary = $this->get_boundary( $ctype );
		$part = $this->split_parts( $boundary, $body );
		$i = 0;
		for ( ;	$i < count( $part );	++$i	)
		{
			$email = $this->fetch_structure( $part[$i] );
			$header = $email['header'];
			$body = $email['body'];
			$headers = $this->decode_header( $header );
			$ctype = $headers['content-type'];
			$cid = $headers['content-id'];
			$Actype = split( ";", $headers['content-type'] );
			$types = split( "/", $Actype[0] );
			$rctype = strtolower( $Actype[0] );
			$is_download = ereg( "name=", $headers['content-disposition'].$headers['content-type'] ) || $headers['content-id'] != "" || $rctype == "message/rfc822";
			if ( $rctype == "multipart/alternative" )
			{
				$this->build_alternative_body( $ctype, $body );
			}
			else if ( $rctype == "text/plain" && !$is_download )
			{
				$body = $this->compile_body( $body, $headers['content-transfer-encoding'], $headers['content-type'] );
				$this->add_body( $this->build_text_body( $body ) );
			}
			else if ( $rctype == "text/html" && !$is_download )
			{
				$body = $this->compile_body( $body, $headers['content-transfer-encoding'], $headers['content-type'] );
				if ( !$this->use_html )
				{
					$body = $this->build_text_body( strip_tags( $body ) );
				}
				$this->add_body( $body );
			}
			else if ( $is_download )
			{
				$thisattach = $this->build_attach( $header, $body, $boundary, $i );
				$thisfile = "download.php?sid={$sid}&tid={$tid}&lid={$lid}&folder=".urlencode( $folder )."&ix=".$ix."&bound=".base64_encode( $thisattach['boundary'] )."&part=".$thisattach['part']."&filename=".urlencode( $thisattach['name'] );
				$temp_attach = false;
				$filename = $this->user_folder."_attachments/".md5( $thisattach['boundary'] )."_".$thisattach['name'];
				if ( $cid != "" )
				{
					$temp_attach = true;
					if ( $this->save_temp_attachs )
					{
						$thisfile .= "&cache=true";
					}
					if ( substr( $cid, 0, 1 ) == "<" && substr( $cid, -1 ) == ">" )
					{
						$cid = substr( $cid, 1, strlen( $cid ) - 2 );
					}
					$cid = "cid:{$cid}";
					$this->_msgbody = str_replace( $cid, $thisfile, $this->_msgbody );
				}
				else if ( $this->displayimages )
				{
					$ext = substr( $thisattach['name'], -4 );
					$allowed_ext = array( ".gif", ".jpg" );
					if ( in_array( $ext, $allowed_ext ) )
					{
						$temp_attach = true;
						if ( $this->save_temp_attachs )
						{
							$thisfile .= "&cache=true";
						}
						$this->add_body( "<img src=\"{$thisfile}\">" );
					}
				}
				if ( $temp_attach && $this->save_temp_attachs )
				{
					$this->save_attach( $header, $body, $filename );
				}
			}
			else
			{
				$this->process_message( $header, $body );
			}
		}
	}

⌨️ 快捷键说明

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