HEX
Server: nginx/1.28.1
System: Linux 10-41-63-61 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64
User: www (1001)
PHP: 7.4.33
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: //www/wwwroot/bs.kntsleep.com/system/basic/class/mailto.class.php
<?php
/*
 * Copyright (c) Huyin Information Technology Co., Ltd. All Rights Reserved.
 * BOSSCMS Content Management System (https://www.bosscms.net/)
 */
defined('IS_OK') or exit('Access Forbidden');

class mailto
{
    public static $host;
    public static $port;
    public static $user;
    public static $password;
    public static $socket;

    public static function init()
    {
		global $G;
		$bosscms;
        self::$password = $G['config']['mail_password'];
        self::$user = $G['config']['mail_user'];
        self::$port = is_numeric($G['config']['mail_port'])?$G['config']['mail_port']:443;
        self::$host = (self::$port==25?'tcp://':'ssl://').$G['config']['mail_host'];
        self::$socket = fsockopen(self::$host, self::$port);
		if(self::$socket){
			preg_match('/\d+/is', fgets(self::$socket), $match);
			$G['email'] = (self::$socket && in_array(220, $match));
		}
    }
	
	public static function detail($recipient, $title, $content)
	{
		return
			'MIME-Version: 1.0'."\r\n".
			'Content-Type:text/html;charset=utf-8'."\r\n".
			'From: '.self::$user."\r\n".
			'To: '.$recipient."\r\n".
			'Subject: '.$title."\r\n".
			"\r\n".
			preg_replace("/(^|(\r\n))(\.)/","\1.\3",$content)."\r\n".
			'.'."\r\n";
	}
	
	public static function details($recipient, $title, $content, $files)
	{
		$files = is_array($files)?$files:array($files);
		$text = 
			'From: '.self::$user."\r\n".
			'To: '.$recipient."\r\n".
			'Subject: =?UTF-8?B?'.base64_encode($title).'?='."\r\n".
			'Mime-Version: 1.0'."\r\n".
			'Content-Type: multipart/mixed;'."\r\n".
			'    boundary="--==BOUNDARY++"'."\r\n".
			'Content-Transfer-Encoding: 8Bit'."\r\n".
			'----==BOUNDARY++'."\r\n".
			'Content-Type: multipart/alternative;'."\r\n".
			'    boundary="++==BOUNDARY--"'."\r\n".
			"\r\n".
			'--++==BOUNDARY--'."\r\n".
			'Content-Type: text/html;'."\r\n".
			'    charset="utf-8"'."\r\n".
			'Content-Transfer-Encoding: base64'."\r\n".
			"\r\n".
			base64_encode($content)."\r\n".
			"\r\n".
			'--++==BOUNDARY----'."\r\n";
		foreach($files as $path){
			$info = pathinfo($path);
			$text .= 
				"\r\n".
				'----==BOUNDARY++'."\r\n".
				'Content-Type: application/octet-stream;'."\r\n".
				'    charset="utf-8";'."\r\n".
				'    name="'.$info['basename'].'"'."\r\n".
				'Content-Disposition: attachment; filename="'.$info['basename'].'"'."\r\n".
				'Content-Transfer-Encoding: base64'."\r\n".
				"\r\n".
				base64_encode(file_get_contents($path))."\r\n";
		}
		$text .= 
			"\r\n".
			'----==BOUNDARY++--'."\r\n".
			'.'."\r\n";
		return $text;
	}
	
    public static function run($cmd, $code=null){
		if(self::$socket){
			fwrite(self::$socket, $cmd);
			$res = fgets(self::$socket);
			if(isset($code)){
				preg_match('/\d+/is', $res, $match);
				return in_array($code, $match);
			}
		}
    }

    public static function send($recipient, $title, $content, $files=null)
	{
		self::run("HELO ".self::$host."\r\n");
		self::run("AUTH LOGIN\r\n");
		self::run(base64_encode(self::$user)."\r\n");
		self::run(base64_encode(self::$password)."\r\n");
		self::run("MAIL FROM:<".self::$user.">\r\n");
		self::run("RCPT TO:<".$recipient.">\r\n");
		self::run("DATA\r\n"); /* BOSS_CMS */
		return self::run($files?self::details($recipient,$title,$content,$files):self::detail($recipient,$title,$content), 250);
    }
	
	public static function close()
	{
		if(self::$socket){
        	fclose(self::$socket);
		}
	}
}
?>