3v4l.org

run code in 300+ PHP versions simultaneously
<?php class PlancakeEmailParser { const PLAINTEXT = 1; const HTML = 2; /** * * @var boolean */ private $isImapExtensionAvailable = false; /** * * @var string */ private $emailRawContent; /** * * @var associative array */ protected $rawFields; /** * * @var array of string (each element is a line) */ protected $rawBodyLines; /** * * @param string $emailRawContent */ public function __construct($emailRawContent) { $this->emailRawContent = $emailRawContent; $this->extractHeadersAndRawBody(); if (function_exists('imap_open')) { $this->isImapExtensionAvailable = true; } } private function extractHeadersAndRawBody() { $lines = preg_split("/(\r?\n|\r)/", $this->emailRawContent); $currentHeader = ''; $i = 0; foreach ($lines as $line) { if(self::isNewLine($line)) { // end of headers $this->rawBodyLines = array_slice($lines, $i); break; } if ($this->isLineStartingWithPrintableChar($line)) // start of new header { preg_match('/([^:]+): ?(.*)$/', $line, $matches); $newHeader = strtolower($matches[1]); $value = $matches[2]; $this->rawFields[$newHeader] = $value; $currentHeader = $newHeader; } else // more lines related to the current header { if ($currentHeader) { // to prevent notice from empty lines $this->rawFields[$currentHeader] .= substr($line, 1); } } $i++; } } /** * * @return string (in UTF-8 format) * @throws Exception if a subject header is not found */ public function getSubject() { if (!isset($this->rawFields['subject'])) { throw new Exception("Couldn't find the subject of the email"); } $ret = ''; if ($this->isImapExtensionAvailable) { foreach (imap_mime_header_decode($this->rawFields['subject']) as $h) { // subject can span into several lines $charset = ($h->charset == 'default') ? 'US-ASCII' : $h->charset; $ret .= iconv($charset, "UTF-8//TRANSLIT", $h->text); } } else { $ret = utf8_encode(iconv_mime_decode($this->rawFields['subject'])); } return $ret; } /** * * @return array */ public function getCc() { if (!isset($this->rawFields['cc'])) { return array(); } return explode(',', $this->rawFields['cc']); } /** * * @return array * @throws Exception if a to header is not found or if there are no recipient */ public function getTo() { if ( (!isset($this->rawFields['to'])) || (!count($this->rawFields['to']))) { throw new Exception("Couldn't find the recipients of the email"); } return explode(',', $this->rawFields['to']); } /** * return string - UTF8 encoded * * Example of an email body * --0016e65b5ec22721580487cb20fd Content-Type: text/plain; charset=ISO-8859-1 Hi all. I am new to Android development. Please help me. -- My signature email: myemail@gmail.com web: http://www.example.com --0016e65b5ec22721580487cb20fd Content-Type: text/html; charset=ISO-8859-1 */ public function getBody($returnType=self::PLAINTEXT) { $body = ''; $detectedContentType = false; $contentTransferEncoding = null; $charset = 'ASCII'; $waitingForContentStart = true; if ($returnType == self::HTML) $contentTypeRegex = '/^Content-Type: ?text\/html/i'; else $contentTypeRegex = '/^Content-Type: ?text\/plain/i'; // there could be more than one boundary preg_match_all('/boundary=(.*)/', $this->emailRawContent, $matches); $boundaries = $matches[1]; //preg_match('!boundary=(.*)$!mi', $this->emailRawContent, $matches); //*Removed 17Feb2017 MC //preg_match('/boundary=(.*)/', $this->emailRawContent, $matches); //Previous line was not catching boundaries properly //$boundary = str_replace(array("'", '"'), '', $matches[1]); // sometimes boundaries are delimited by quotes - we want to remove them foreach($boundaries as $i => $v) { $boundaries[$i] = str_replace(array("'", '"'), '', $v); } foreach ($this->rawBodyLines as $line) { if (!$detectedContentType) { if (preg_match($contentTypeRegex, $line, $matches)) { $detectedContentType = true; } if(preg_match('/charset=(.*)/i', $line, $matches)) { $charset = strtoupper(trim($matches[1], '"')); } } else if ($detectedContentType && $waitingForContentStart) { if(preg_match('/charset=(.*)/i', $line, $matches)) { $charset = strtoupper(trim($matches[1], '"')); } if ($contentTransferEncoding == null && preg_match('/^Content-Transfer-Encoding: ?(.*)/i', $line, $matches)) { $contentTransferEncoding = strtoupper($matches[1]); //MC 04Nov16: Added strtoupper } if (self::isNewLine($line)) { $waitingForContentStart = false; } } else { // ($detectedContentType && !$waitingForContentStart) // collecting the actual content until we find the delimiter // if the delimited is AAAAA, the line will be --AAAAA - that's why we use substr if (is_array($boundaries)) { if (in_array(substr($line, 2), $boundaries)) { // found the delimiter break; } } elseif (strpos($line, $boundary)) { break; } $body .= $line . "\n"; } } if (!$detectedContentType) { // if here, we missed the text/plain content-type (probably it was // in the header), thus we assume the whole body is what we are after $body = implode("\n", $this->rawBodyLines); } // removing trailing new lines $body = preg_replace('/((\r?\n)*)$/', '', $body); if ($contentTransferEncoding == 'BASE64') //MC 04Nov16: changed base64 to BASE64 $body = base64_decode($body, true); else if ($contentTransferEncoding == 'QUOTED-PRINTABLE') //MC 04Nov16: changed quoted-printable to QUOTED-PRINTABLE $body = quoted_printable_decode($body); if($charset != 'UTF-8') { // FORMAT=FLOWED, despite being popular in emails, it is not // supported by iconv $charset = str_replace("FORMAT=FLOWED", "", $charset); $body = iconv($charset, 'UTF-8//TRANSLIT', $body); if ($body === FALSE) { // iconv returns FALSE on failure $body = utf8_encode($body); } } return $body; } /** * @return string - UTF8 encoded * */ public function getPlainBody() { return $this->getBody(self::PLAINTEXT); } /** * return string - UTF8 encoded */ public function getHTMLBody() { return $this->getBody(self::HTML); } /** * N.B.: if the header doesn't exist an empty string is returned * * @param string $headerName - the header we want to retrieve * @return string - the value of the header */ public function getHeader($headerName) { $headerName = strtolower($headerName); if (isset($this->rawFields[$headerName])) { return $this->rawFields[$headerName]; } return ''; } /** * * @param string $line * @return boolean */ public static function isNewLine($line) { $line = str_replace("\r", '', $line); $line = str_replace("\n", '', $line); return (strlen($line) === 0); } /** * * @param string $line * @return boolean */ private function isLineStartingWithPrintableChar($line) { return preg_match('/^[A-Za-z]/', $line); } } $rawEmail = "From 8083199272@mms.att.net Tue Jul 03 19:10:49 2018\nReceived: from stcotaapp-apps-sfm1a.mobile.att.net ([166.216.152.37]:50252 helo=stcceg-mtmta01.wnsnet.attws.com)\n by gator3049.hostgator.com with esmtps (TLSv1:DHE-RSA-AES128-SHA:128)\n (Exim 4.91)\n (envelope-from <8083199272@mms.att.net>)\n id 1faVNh-002Xxu-GQ\n for bosque@firepage.org; Tue, 03 Jul 2018 19:10:49 -0500\nReceived: from alnnms01 ([107.79.70.30])\n by stcceg-mtmta01.wnsnet.attws.com with bizsmtp\n id 69421y01Y0fBW5X01QAe4c; Tue, 03 Jul 2018 19:10:38 -0500\nMessage-ID: <69421y01Y0fBW5X01QAe4c@txt.att.net>\nIn-Reply-To: 1383951446.40200251530663038311.JavaMail.nems@alnnms01\nX-Mms-Message-Type: m-send-req\nX-Mms-Transaction-Id: T16462a1a936\nX-Mms-MMS-Version: 1.2\nTo: bosque@firepage.org\nX-Mms-Message-Class: Personal\nX-Mms-Priority: Normal\nX-Mms-Delivery-Report: No\nX-Mms-Read-Reply: No\nFrom: 8083199272@mms.att.net\nDate: Tue, 3 Jul 2018 19:10:38 -0500 (CDT)\nX-Mms-Sender-Visibility: Show\nContent-Type: multipart/mixed; \n boundary=\"----=_Part_1669496_1731281007.1530663038311\"\nMIME-Version: 1.0\nDKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mms.att.net;\n s=EMG20171113; t=1530663038;\n bh=+kwzoNYvPgMRHfPJi5CwsNVIk5NlSAOY1AHbjrbjBAI=;\n h=In-Reply-To:To:From:Date;\n b=nMIh249YCq/Er2msND65RSC4HgQpbI3KtVOJ0CvZO3rud6mxY44a17RdeRpwLa3YT\n QPWxVW8QVZtD8/Bc4Tpf2DqGjOsR92pQRP9w79zXSssG1pZ0vgDeLldhF92hkj3n/5\n dG2/1jOaMqO4MvIhyX4U5+dp8EI/2xPbrkAu1Wm9LmJuMCJ3eGckyi7Zfk3x4+P1kx\n W5KEBEOi0FPyHIJD/pTmZJe5n179CUFToz+CKgjtNeFH+kkak8NUUx+GCHgL49030A\n jbw53rDN+Z2g9Ts4bYx63Ywf1zX0ZRo0gwXAFTeTY6KbGgJcXNVfWxVVVY27GGtRO6\n xExmhRGYpR6Tg==\n\n------=_Part_1669496_1731281007.1530663038311\nContent-Type: text/plain; charset=UTF-8\nContent-ID: <text_1530663119159.txt>\nContent-Location: text_1530663119159.txt\nContent-Transfer-Encoding: BASE64\n\nVGVzdCBwYWdlIGltIGRyaXZpbmcgdGVzdCBwYWdl\n------=_Part_1669496_1731281007.1530663038311--\n\n\n"; $emailParser = new PlancakeEmailParser($rawEmail); echo print_r($emailParser->getPlainBody()); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dWvUP
function name:  (null)
number of ops:  12
compiled vars:  !0 = $rawEmail, !1 = $emailParser
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  306     0  E >   ASSIGN                                                   !0, 'From+8083199272%40mms.att.net+Tue+Jul+03+19%3A10%3A49+2018%0AReceived%3A+from+stcotaapp-apps-sfm1a.mobile.att.net+%28%5B166.216.152.37%5D%3A50252+helo%3Dstcceg-mtmta01.wnsnet.attws.com%29%0A++++by+gator3049.hostgator.com+with+esmtps+%28TLSv1%3ADHE-RSA-AES128-SHA%3A128%29%0A+%28Exim+4.91%29%0A+++%28envelope-from+%3C8083199272%40mms.att.net%3E%29%0A++id+1faVNh-002Xxu-GQ%0A+++for+bosque%40firepage.org%3B+Tue%2C+03+Jul+2018+19%3A10%3A49+-0500%0AReceived%3A+from+alnnms01+%28%5B107.79.70.30%5D%29%0A++++by+stcceg-mtmta01.wnsnet.attws.com+with+bizsmtp%0A+++id+69421y01Y0fBW5X01QAe4c%3B+Tue%2C+03+Jul+2018+19%3A10%3A38+-0500%0AMessage-ID%3A+%3C69421y01Y0fBW5X01QAe4c%40txt.att.net%3E%0AIn-Reply-To%3A+1383951446.40200251530663038311.JavaMail.nems%40alnnms01%0AX-Mms-Message-Type%3A+m-send-req%0AX-Mms-Transaction-Id%3A+T16462a1a936%0AX-Mms-MMS-Version%3A+1.2%0ATo%3A+bosque%40firepage.org%0AX-Mms-Message-Class%3A+Personal%0AX-Mms-Priority%3A+Normal%0AX-Mms-Delivery-Report%3A+No%0AX-Mms-Read-Reply%3A+No%0AFrom%3A+8083199272%40mms.att.net%0ADate%3A+Tue%2C+3+Jul+2018+19%3A10%3A38+-0500+%28CDT%29%0AX-Mms-Sender-Visibility%3A+Show%0AContent-Type%3A+multipart%2Fmixed%3B+%0A++boundary%3D%22----%3D_Part_1669496_1731281007.1530663038311%22%0AMIME-Version%3A+1.0%0ADKIM-Signature%3A+v%3D1%3B+a%3Drsa-sha256%3B+c%3Drelaxed%2Fsimple%3B+d%3Dmms.att.net%3B%0A++s%3DEMG20171113%3B+t%3D1530663038%3B%0A++bh%3D%2BkwzoNYvPgMRHfPJi5CwsNVIk5NlSAOY1AHbjrbjBAI%3D%3B%0A++h%3DIn-Reply-To%3ATo%3AFrom%3ADate%3B%0A+++b%3DnMIh249YCq%2FEr2msND65RSC4HgQpbI3KtVOJ0CvZO3rud6mxY44a17RdeRpwLa3YT%0A++++QPWxVW8QVZtD8%2FBc4Tpf2DqGjOsR92pQRP9w79zXSssG1pZ0vgDeLldhF92hkj3n%2F5%0A++++dG2%2F1jOaMqO4MvIhyX4U5%2Bdp8EI%2F2xPbrkAu1Wm9LmJuMCJ3eGckyi7Zfk3x4%2BP1kx%0A++++W5KEBEOi0FPyHIJD%2FpTmZJe5n179CUFToz%2BCKgjtNeFH%2Bkkak8NUUx%2BGCHgL49030A%0A++++jbw53rDN%2BZ2g9Ts4bYx63Ywf1zX0ZRo0gwXAFTeTY6KbGgJcXNVfWxVVVY27GGtRO6%0A++++xExmhRGYpR6Tg%3D%3D%0A%0A------%3D_Part_1669496_1731281007.1530663038311%0AContent-Type%3A+text%2Fplain%3B+charset%3DUTF-8%0AContent-ID%3A+%3Ctext_1530663119159.txt%3E%0AContent-Location%3A+text_1530663119159.txt%0AContent-Transfer-Encoding%3A+BASE64%0A%0AVGVzdCBwYWdlIGltIGRyaXZpbmcgdGVzdCBwYWdl%0A------%3D_Part_1669496_1731281007.1530663038311--%0A%0A%0A'
  308     1        NEW                                              $3      'PlancakeEmailParser'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $3
  310     5        INIT_FCALL                                               'print_r'
          6        INIT_METHOD_CALL                                         !1, 'getPlainBody'
          7        DO_FCALL                                      0  $6      
          8        SEND_VAR                                                 $6
          9        DO_ICALL                                         $7      
         10        ECHO                                                     $7
  315    11      > RETURN                                                   1

Class PlancakeEmailParser:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/dWvUP
function name:  __construct
number of ops:  12
compiled vars:  !0 = $emailRawContent
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   RECV                                             !0      
   37     1        ASSIGN_OBJ                                               'emailRawContent'
          2        OP_DATA                                                  !0
   39     3        INIT_METHOD_CALL                                         'extractHeadersAndRawBody'
          4        DO_FCALL                                      0          
   41     5        INIT_FCALL                                               'function_exists'
          6        SEND_VAL                                                 'imap_open'
          7        DO_ICALL                                         $3      
          8      > JMPZ                                                     $3, ->11
   42     9    >   ASSIGN_OBJ                                               'isImapExtensionAvailable'
         10        OP_DATA                                                  <true>
   44    11    > > RETURN                                                   null

End of function __construct

Function extractheadersandrawbody:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 52
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 52
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 21
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 52
Branch analysis from position: 52
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 42
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 50
Branch analysis from position: 50
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 42
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 50
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 50
Branch analysis from position: 52
Branch analysis from position: 52
filename:       /in/dWvUP
function name:  extractHeadersAndRawBody
number of ops:  54
compiled vars:  !0 = $lines, !1 = $currentHeader, !2 = $i, !3 = $line, !4 = $matches, !5 = $newHeader, !6 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   48     0  E >   INIT_FCALL                                               'preg_split'
          1        SEND_VAL                                                 '%2F%28%0D%3F%0A%7C%0D%29%2F'
          2        FETCH_OBJ_R                                      ~7      'emailRawContent'
          3        SEND_VAL                                                 ~7
          4        DO_ICALL                                         $8      
          5        ASSIGN                                                   !0, $8
   50     6        ASSIGN                                                   !1, ''
   52     7        ASSIGN                                                   !2, 0
   53     8      > FE_RESET_R                                       $12     !0, ->52
          9    > > FE_FETCH_R                                               $12, !3, ->52
   55    10    >   INIT_STATIC_METHOD_CALL                                  'isNewLine'
         11        SEND_VAR_EX                                              !3
         12        DO_FCALL                                      0  $13     
         13      > JMPZ                                                     $13, ->21
   58    14    >   INIT_FCALL                                               'array_slice'
         15        SEND_VAR                                                 !0
         16        SEND_VAR                                                 !2
         17        DO_ICALL                                         $15     
         18        ASSIGN_OBJ                                               'rawBodyLines'
         19        OP_DATA                                                  $15
   59    20      > JMP                                                      ->52
   62    21    >   INIT_METHOD_CALL                                         'isLineStartingWithPrintableChar'
         22        SEND_VAR_EX                                              !3
         23        DO_FCALL                                      0  $16     
         24      > JMPZ                                                     $16, ->42
   64    25    >   INIT_FCALL                                               'preg_match'
         26        SEND_VAL                                                 '%2F%28%5B%5E%3A%5D%2B%29%3A+%3F%28.%2A%29%24%2F'
         27        SEND_VAR                                                 !3
         28        SEND_REF                                                 !4
         29        DO_ICALL                                                 
   65    30        INIT_FCALL                                               'strtolower'
         31        FETCH_DIM_R                                      ~18     !4, 1
         32        SEND_VAL                                                 ~18
         33        DO_ICALL                                         $19     
         34        ASSIGN                                                   !5, $19
   66    35        FETCH_DIM_R                                      ~21     !4, 2
         36        ASSIGN                                                   !6, ~21
   67    37        FETCH_OBJ_W                                      $23     'rawFields'
         38        ASSIGN_DIM                                               $23, !5
         39        OP_DATA                                                  !6
   68    40        ASSIGN                                                   !1, !5
         41      > JMP                                                      ->50
   72    42    > > JMPZ                                                     !1, ->50
   73    43    >   INIT_FCALL                                               'substr'
         44        SEND_VAR                                                 !3
         45        SEND_VAL                                                 1
         46        DO_ICALL                                         $28     
         47        FETCH_OBJ_RW                                     $26     'rawFields'
         48        ASSIGN_DIM_OP                .=               8          $26, !1
         49        OP_DATA                                                  $28
   76    50    >   PRE_INC                                                  !2
   53    51      > JMP                                                      ->9
         52    >   FE_FREE                                                  $12
   78    53      > RETURN                                                   null

End of function extractheadersandrawbody

Function getsubject:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 38
Branch analysis from position: 11
2 jumps found. (Code = 77) Position 1 = 18, Position 2 = 36
Branch analysis from position: 18
2 jumps found. (Code = 78) Position 1 = 19, Position 2 = 36
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 24
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dWvUP
function name:  getSubject
number of ops:  50
compiled vars:  !0 = $ret, !1 = $h, !2 = $charset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   87     0  E >   FETCH_OBJ_IS                                     ~3      'rawFields'
          1        ISSET_ISEMPTY_DIM_OBJ                         0  ~4      ~3, 'subject'
          2        BOOL_NOT                                         ~5      ~4
          3      > JMPZ                                                     ~5, ->8
   89     4    >   NEW                                              $6      'Exception'
          5        SEND_VAL_EX                                              'Couldn%27t+find+the+subject+of+the+email'
          6        DO_FCALL                                      0          
          7      > THROW                                         0          $6
   92     8    >   ASSIGN                                                   !0, ''
   94     9        FETCH_OBJ_R                                      ~9      'isImapExtensionAvailable'
         10      > JMPZ                                                     ~9, ->38
   95    11    >   INIT_FCALL_BY_NAME                                       'imap_mime_header_decode'
         12        CHECK_FUNC_ARG                                           
         13        FETCH_OBJ_FUNC_ARG                               $10     'rawFields'
         14        FETCH_DIM_FUNC_ARG                               $11     $10, 'subject'
         15        SEND_FUNC_ARG                                            $11
         16        DO_FCALL                                      0  $12     
         17      > FE_RESET_R                                       $13     $12, ->36
         18    > > FE_FETCH_R                                               $13, !1, ->36
   96    19    >   FETCH_OBJ_R                                      ~14     !1, 'charset'
         20        IS_EQUAL                                                 ~14, 'default'
         21      > JMPZ                                                     ~15, ->24
         22    >   QM_ASSIGN                                        ~16     'US-ASCII'
         23      > JMP                                                      ->26
         24    >   FETCH_OBJ_R                                      ~17     !1, 'charset'
         25        QM_ASSIGN                                        ~16     ~17
         26    >   ASSIGN                                                   !2, ~16
   97    27        INIT_FCALL_BY_NAME                                       'iconv'
         28        SEND_VAR_EX                                              !2
         29        SEND_VAL_EX                                              'UTF-8%2F%2FTRANSLIT'
         30        CHECK_FUNC_ARG                                           
         31        FETCH_OBJ_FUNC_ARG                               $19     !1, 'text'
         32        SEND_FUNC_ARG                                            $19
         33        DO_FCALL                                      0  $20     
         34        ASSIGN_OP                                     8          !0, $20
   95    35      > JMP                                                      ->18
         36    >   FE_FREE                                                  $13
         37      > JMP                                                      ->48
  100    38    >   INIT_FCALL                                               'utf8_encode'
         39        INIT_FCALL_BY_NAME                                       'iconv_mime_decode'
         40        CHECK_FUNC_ARG                                           
         41        FETCH_OBJ_FUNC_ARG                               $22     'rawFields'
         42        FETCH_DIM_FUNC_ARG                               $23     $22, 'subject'
         43        SEND_FUNC_ARG                                            $23
         44        DO_FCALL                                      0  $24     
         45        SEND_VAR                                                 $24
         46        DO_ICALL                                         $25     
         47        ASSIGN                                                   !0, $25
  103    48    > > RETURN                                                   !0
  104    49*     > RETURN                                                   null

End of function getsubject

Function getcc:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dWvUP
function name:  getCc
number of ops:  13
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  112     0  E >   FETCH_OBJ_IS                                     ~0      'rawFields'
          1        ISSET_ISEMPTY_DIM_OBJ                         0  ~1      ~0, 'cc'
          2        BOOL_NOT                                         ~2      ~1
          3      > JMPZ                                                     ~2, ->5
  114     4    > > RETURN                                                   <array>
  117     5    >   INIT_FCALL                                               'explode'
          6        SEND_VAL                                                 '%2C'
          7        FETCH_OBJ_R                                      ~3      'rawFields'
          8        FETCH_DIM_R                                      ~4      ~3, 'cc'
          9        SEND_VAL                                                 ~4
         10        DO_ICALL                                         $5      
         11      > RETURN                                                   $5
  118    12*     > RETURN                                                   null

End of function getcc

Function getto:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 14
Branch analysis from position: 10
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/dWvUP
function name:  getTo
number of ops:  22
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  127     0  E >   FETCH_OBJ_IS                                     ~0      'rawFields'
          1        ISSET_ISEMPTY_DIM_OBJ                         0  ~1      ~0, 'to'
          2        BOOL_NOT                                         ~2      ~1
          3      > JMPNZ_EX                                         ~2      ~2, ->9
          4    >   FETCH_OBJ_R                                      ~3      'rawFields'
          5        FETCH_DIM_R                                      ~4      ~3, 'to'
          6        COUNT                                            ~5      ~4
          7        BOOL_NOT                                         ~6      ~5
          8        BOOL                                             ~2      ~6
          9    > > JMPZ                                                     ~2, ->14
  129    10    >   NEW                                              $7      'Exception'
         11        SEND_VAL_EX                                              'Couldn%27t+find+the+recipients+of+the+email'
         12        DO_FCALL                                      0          
         13      > THROW                                         0          $7
  131    14    >   INIT_FCALL                                               'explode'
         15        SEND_VAL                                                 '%2C'
         16        FETCH_OBJ_R                                      ~9      'rawFields'
         17        FETCH_DIM_R                                      ~10     ~9, 'to'
         18        SEND_VAL                                                 ~10
         19        DO_ICALL                                         $11     
         20      > RETURN                                                   $11
  132    21*     > RETURN                                                   null

End of function getto

Function getbody:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
2 jumps found. (Code = 77) Position 1 = 20, Position 2 = 30
Branch analysis from position: 20
2 jumps found. (Code = 78) Position 1 = 21, Position 2 = 30
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 30
2 jumps found. (Code = 77) Position 1 = 33, Position 2 = 119
Branch analysis from position: 33
2 jumps found. (Code = 78) Position 1 = 34, Position 2 = 119
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 59
Branch analysis from position: 36
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 43
Branch analysis from position: 42
2 jumps found. (Code = 43) Position 1 = 49, Position 2 = 58
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 118
Branch analysis from position: 118
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
Branch analysis from position: 58
Branch analysis from position: 43
Branch analysis from position: 59
2 jumps found. (Code = 46) Position 1 = 60, Position 2 = 61
Branch analysis from position: 60
2 jumps found. (Code = 43) Position 1 = 62, Position 2 = 97
Branch analysis from position: 62
2 jumps found. (Code = 43) Position 1 = 68, Position 2 = 77
Branch analysis from position: 68
2 jumps found. (Code = 46) Position 1 = 79, Position 2 = 85
Branch analysis from position: 79
2 jumps found. (Code = 43) Position 1 = 86, Position 2 = 91
Branch analysis from position: 86
2 jumps found. (Code = 43) Position 1 = 95, Position 2 = 96
Branch analysis from position: 95
1 jumps found. (Code = 42) Position 1 = 118
Branch analysis from position: 118
Branch analysis from position: 96
Branch analysis from position: 91
Branch analysis from position: 85
Branch analysis from position: 77
Branch analysis from position: 97
2 jumps found. (Code = 43) Position 1 = 99, Position 2 = 110
Branch analysis from position: 99
2 jumps found. (Code = 43) Position 1 = 108, Position 2 = 109
Branch analysis from position: 108
1 jumps found. (Code = 42) Position 1 = 119
Branch analysis from position: 119
2 jumps found. (Code = 43) Position 1 = 122, Position 2 = 128
Branch analysis from position: 122
2 jumps found. (Code = 43) Position 1 = 136, Position 2 = 142
Branch analysis from position: 136
1 jumps found. (Code = 42) Position 1 = 148
Branch analysis from position: 148
2 jumps found. (Code = 43) Position 1 = 150, Position 2 = 168
Branch analysis from position: 150
2 jumps found. (Code = 43) Position 1 = 164, Position 2 = 168
Branch analysis from position: 164
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 168
Branch analysis from position: 168
Branch analysis from position: 142
2 jumps found. (Code = 43) Position 1 = 144, Position 2 = 148
Branch analysis from position: 144
2 jumps found. (Code = 43) Position 1 = 150, Position 2 = 168
Branch analysis from position: 150
Branch analysis from position: 168
Branch analysis from position: 148
Branch analysis from position: 128
Branch analysis from position: 109
1 jumps found. (Code = 42) Position 1 = 116
Branch analysis from position: 116
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
Branch analysis from position: 110
2 jumps found. (Code = 43) Position 1 = 115, Position 2 = 116
Branch analysis from position: 115
1 jumps found. (Code = 42) Position 1 = 119
Branch analysis from position: 119
Branch analysis from position: 116
Branch analysis from position: 61
Branch analysis from position: 119
Branch analysis from position: 119
Branch analysis from position: 30
Branch analysis from position: 10
2 jumps found. (Code = 77) Position 1 = 20, Position 2 = 30
Branch analysis from position: 20
Branch analysis from position: 30
filename:       /in/dWvUP
function name:  getBody
number of ops:  170
compiled vars:  !0 = $returnType, !1 = $body, !2 = $detectedContentType, !3 = $contentTransferEncoding, !4 = $charset, !5 = $waitingForContentStart, !6 = $contentTypeRegex, !7 = $matches, !8 = $boundaries, !9 = $v, !10 = $i, !11 = $line, !12 = $boundary
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  154     0  E >   RECV_INIT                                        !0      <const ast>
  156     1        ASSIGN                                                   !1, ''
  157     2        ASSIGN                                                   !2, <false>
  158     3        ASSIGN                                                   !3, null
  159     4        ASSIGN                                                   !4, 'ASCII'
  160     5        ASSIGN                                                   !5, <true>
  162     6        IS_EQUAL                                                 !0, 2
          7      > JMPZ                                                     ~18, ->10
  163     8    >   ASSIGN                                                   !6, '%2F%5EContent-Type%3A+%3Ftext%5C%2Fhtml%2Fi'
          9      > JMP                                                      ->11
  165    10    >   ASSIGN                                                   !6, '%2F%5EContent-Type%3A+%3Ftext%5C%2Fplain%2Fi'
  168    11    >   INIT_FCALL                                               'preg_match_all'
         12        SEND_VAL                                                 '%2Fboundary%3D%28.%2A%29%2F'
         13        FETCH_OBJ_R                                      ~21     'emailRawContent'
         14        SEND_VAL                                                 ~21
         15        SEND_REF                                                 !7
         16        DO_ICALL                                                 
  169    17        FETCH_DIM_R                                      ~23     !7, 1
         18        ASSIGN                                                   !8, ~23
  174    19      > FE_RESET_R                                       $25     !8, ->30
         20    > > FE_FETCH_R                                       ~26     $25, !9, ->30
         21    >   ASSIGN                                                   !10, ~26
  175    22        INIT_FCALL                                               'str_replace'
         23        SEND_VAL                                                 <array>
         24        SEND_VAL                                                 ''
         25        SEND_VAR                                                 !9
         26        DO_ICALL                                         $29     
         27        ASSIGN_DIM                                               !8, !10
         28        OP_DATA                                                  $29
  174    29      > JMP                                                      ->20
         30    >   FE_FREE                                                  $25
  178    31        FETCH_OBJ_R                                      ~30     'rawBodyLines'
         32      > FE_RESET_R                                       $31     ~30, ->119
         33    > > FE_FETCH_R                                               $31, !11, ->119
  179    34    >   BOOL_NOT                                         ~32     !2
         35      > JMPZ                                                     ~32, ->59
  181    36    >   INIT_FCALL                                               'preg_match'
         37        SEND_VAR                                                 !6
         38        SEND_VAR                                                 !11
         39        SEND_REF                                                 !7
         40        DO_ICALL                                         $33     
         41      > JMPZ                                                     $33, ->43
  182    42    >   ASSIGN                                                   !2, <true>
  185    43    >   INIT_FCALL                                               'preg_match'
         44        SEND_VAL                                                 '%2Fcharset%3D%28.%2A%29%2Fi'
         45        SEND_VAR                                                 !11
         46        SEND_REF                                                 !7
         47        DO_ICALL                                         $35     
         48      > JMPZ                                                     $35, ->58
  186    49    >   INIT_FCALL                                               'strtoupper'
         50        INIT_FCALL                                               'trim'
         51        FETCH_DIM_R                                      ~36     !7, 1
         52        SEND_VAL                                                 ~36
         53        SEND_VAL                                                 '%22'
         54        DO_ICALL                                         $37     
         55        SEND_VAR                                                 $37
         56        DO_ICALL                                         $38     
         57        ASSIGN                                                   !4, $38
         58    > > JMP                                                      ->118
  189    59    > > JMPZ_EX                                          ~40     !2, ->61
         60    >   BOOL                                             ~40     !5
         61    > > JMPZ                                                     ~40, ->97
  191    62    >   INIT_FCALL                                               'preg_match'
         63        SEND_VAL                                                 '%2Fcharset%3D%28.%2A%29%2Fi'
         64        SEND_VAR                                                 !11
         65        SEND_REF                                                 !7
         66        DO_ICALL                                         $41     
         67      > JMPZ                                                     $41, ->77
  192    68    >   INIT_FCALL                                               'strtoupper'
         69        INIT_FCALL                                               'trim'
         70        FETCH_DIM_R                                      ~42     !7, 1
         71        SEND_VAL                                                 ~42
         72        SEND_VAL                                                 '%22'
         73        DO_ICALL                                         $43     
         74        SEND_VAR                                                 $43
         75        DO_ICALL                                         $44     
         76        ASSIGN                                                   !4, $44
  195    77    >   IS_EQUAL                                         ~46     !3, null
         78      > JMPZ_EX                                          ~46     ~46, ->85
         79    >   INIT_FCALL                                               'preg_match'
         80        SEND_VAL                                                 '%2F%5EContent-Transfer-Encoding%3A+%3F%28.%2A%29%2Fi'
         81        SEND_VAR                                                 !11
         82        SEND_REF                                     

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
224.59 ms | 1428 KiB | 45 Q