Location: PHPKode > scripts > Email Parser > Documentation/__filesource/fsource_Parser__parser.class.php.html
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
		<head>
			<!-- template designed by Marco Von Ballmoos -->
			<title>File Source for parser.class.php</title>
			<link rel="stylesheet" href="../media/stylesheet.css" />
			<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'/>
		</head>
		<body>
						<h1>Source for file parser.class.php</h1>
<p>Documentation is available at <a href="../Parser/_parser_class_php.html">parser.class.php</a></p>
<div class="src-code">
<pre><ol><li><a name="a1"></a><span class="src-php">&lt;?php</span></li>
<li><a name="a2"></a>&nbsp;</li>
<li><a name="a3"></a><span class="src-doc">/**</span></li>
<li><a name="a4"></a><span class="src-doc">* Class for parsing raw emails</span></li>
<li><a name="a5"></a><span class="src-doc">*</span></li>
<li><a name="a6"></a><span class="src-doc">* This class is used to parse raw emails into</span></li>
<li><a name="a7"></a><span class="src-doc">* logical easy to use parts.</span></li>
<li><a name="a8"></a><span class="src-doc">*</span></li>
<li><a name="a9"></a><span class="src-doc">* </span><span class="src-doc-coretag">@author</span><span class="src-doc"> Joshua Gilman</span></li>
<li><a name="a10"></a><span class="src-doc">* </span><span class="src-doc-coretag">@package</span><span class="src-doc"> Parser</span></li>
<li><a name="a11"></a><span class="src-doc">*/</span></li>
<li><a name="a12"></a><span class="src-key">class </span><a href="../Parser/Parser.html">Parser</a></li>
<li><a name="a13"></a><span class="src-sym">{</span></li>
<li><a name="a14"></a>    <span class="src-doc">/**</span></li>
<li><a name="a15"></a><span class="src-doc">    * Determines how a newline is parsed</span></li>
<li><a name="a16"></a><span class="src-doc">    *</span></li>
<li><a name="a17"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@var </span><span class="src-doc-type">String </span></li>
<li><a name="a18"></a><span class="src-doc">    */</span></li>
<li><a name="a19"></a>    <span class="src-key">var </span><a href="../Parser/Parser.html#var$P_NEWLINE">$P_NEWLINE</a> = <span class="src-str">&quot;\r\n&quot;</span><span class="src-sym">;</span></li>
<li><a name="a20"></a>&nbsp;</li>
<li><a name="a21"></a>&nbsp;</li>
<li><a name="a22"></a>    <span class="src-doc">/**</span></li>
<li><a name="a23"></a><span class="src-doc">    * Contains the raw header of the email</span></li>
<li><a name="a24"></a><span class="src-doc">    *</span></li>
<li><a name="a25"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@var </span><span class="src-doc-type">String </span></li>
<li><a name="a26"></a><span class="src-doc">    */</span></li>
<li><a name="a27"></a>    <span class="src-key">var </span><a href="../Parser/Parser.html#var$header">$header</a> = <span class="src-id">NULL</span><span class="src-sym">;</span></li>
<li><a name="a28"></a>&nbsp;</li>
<li><a name="a29"></a>    <span class="src-doc">/**</span></li>
<li><a name="a30"></a><span class="src-doc">    * Contains the boundary used to parse the raw email</span></li>
<li><a name="a31"></a><span class="src-doc">    *</span></li>
<li><a name="a32"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@var </span><span class="src-doc-type">String </span></li>
<li><a name="a33"></a><span class="src-doc">    */</span></li>
<li><a name="a34"></a>    <span class="src-key">var </span><a href="../Parser/Parser.html#var$boundary">$boundary</a> = <span class="src-id">NULL</span><span class="src-sym">;</span></li>
<li><a name="a35"></a>&nbsp;</li>
<li><a name="a36"></a>    <span class="src-doc">/**</span></li>
<li><a name="a37"></a><span class="src-doc">    * Contains everything below the header of the raw email</span></li>
<li><a name="a38"></a><span class="src-doc">    *</span></li>
<li><a name="a39"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@var </span><span class="src-doc-type">String </span></li>
<li><a name="a40"></a><span class="src-doc">    */</span></li>
<li><a name="a41"></a>    <span class="src-key">var </span><a href="../Parser/Parser.html#var$content">$content</a> = <span class="src-id">NULL</span><span class="src-sym">;</span></li>
<li><a name="a42"></a>&nbsp;</li>
<li><a name="a43"></a>&nbsp;</li>
<li><a name="a44"></a>    <span class="src-doc">/**</span></li>
<li><a name="a45"></a><span class="src-doc">    * Contains who the email is addressed to</span></li>
<li><a name="a46"></a><span class="src-doc">    *</span></li>
<li><a name="a47"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@var </span><span class="src-doc-type">String </span></li>
<li><a name="a48"></a><span class="src-doc">    */</span></li>
<li><a name="a49"></a>    <span class="src-key">var </span><a href="../Parser/Parser.html#var$to">$to</a> = <span class="src-id">NULL</span><span class="src-sym">;</span></li>
<li><a name="a50"></a>&nbsp;</li>
<li><a name="a51"></a>    <span class="src-doc">/**</span></li>
<li><a name="a52"></a><span class="src-doc">    * Contains who the email is from</span></li>
<li><a name="a53"></a><span class="src-doc">    *</span></li>
<li><a name="a54"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@var </span><span class="src-doc-type">String </span></li>
<li><a name="a55"></a><span class="src-doc">    */</span></li>
<li><a name="a56"></a>    <span class="src-key">var </span><a href="../Parser/Parser.html#var$from">$from</a> = <span class="src-id">NULL</span><span class="src-sym">;</span></li>
<li><a name="a57"></a>&nbsp;</li>
<li><a name="a58"></a>    <span class="src-doc">/**</span></li>
<li><a name="a59"></a><span class="src-doc">    * Contains the subject of the email</span></li>
<li><a name="a60"></a><span class="src-doc">    *</span></li>
<li><a name="a61"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@var </span><span class="src-doc-type">String </span></li>
<li><a name="a62"></a><span class="src-doc">    */</span></li>
<li><a name="a63"></a>    <span class="src-key">var </span><a href="../Parser/Parser.html#var$subject">$subject</a> = <span class="src-id">NULL</span><span class="src-sym">;</span></li>
<li><a name="a64"></a>&nbsp;</li>
<li><a name="a65"></a>    <span class="src-doc">/**</span></li>
<li><a name="a66"></a><span class="src-doc">    * Contains all the types of messages sent</span></li>
<li><a name="a67"></a><span class="src-doc">    *</span></li>
<li><a name="a68"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@example</span></li>
<li><a name="a69"></a><span class="src-doc">    *  &lt;code&gt;</span></li>
<li><a name="a70"></a><span class="src-doc">    *  $parser-&gt;message['plain'] // Returns the plain text message</span></li>
<li><a name="a71"></a><span class="src-doc">    *  $parser-&gt;message['htmk'] // Returns the html formatted message</span></li>
<li><a name="a72"></a><span class="src-doc">    *  &lt;/code&gt;</span></li>
<li><a name="a73"></a><span class="src-doc">    *</span></li>
<li><a name="a74"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@var </span><span class="src-doc-type">Mixed </span></li>
<li><a name="a75"></a><span class="src-doc">    */</span></li>
<li><a name="a76"></a>    <span class="src-key">var </span><a href="../Parser/Parser.html#var$message">$message</a> = <span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a77"></a>&nbsp;</li>
<li><a name="a78"></a>&nbsp;</li>
<li><a name="a79"></a>    <span class="src-doc">/**</span></li>
<li><a name="a80"></a><span class="src-doc">    * Contains all the parsed attachments in the raw email</span></li>
<li><a name="a81"></a><span class="src-doc">    *</span></li>
<li><a name="a82"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@var </span><span class="src-doc-type">Mixed </span></li>
<li><a name="a83"></a><span class="src-doc">    */</span></li>
<li><a name="a84"></a>    <span class="src-key">var </span><a href="../Parser/Parser.html#var$files">$files</a> = <span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a85"></a>&nbsp;</li>
<li><a name="a86"></a>&nbsp;</li>
<li><a name="a87"></a>    <span class="src-doc">/**</span></li>
<li><a name="a88"></a><span class="src-doc">    * The constructor of the class</span></li>
<li><a name="a89"></a><span class="src-doc">    *</span></li>
<li><a name="a90"></a><span class="src-doc">    * This function loads and parses the raw email given ($mail)</span></li>
<li><a name="a91"></a><span class="src-doc">    * and prepares it for usage</span></li>
<li><a name="a92"></a><span class="src-doc">    *</span></li>
<li><a name="a93"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">String </span><span class="src-doc-var">$mail </span></li>
<li><a name="a94"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">void </span></li>
<li><a name="a95"></a><span class="src-doc">    */</span></li>
<li><a name="a96"></a>    <span class="src-key">function </span><a href="../Parser/Parser.html#method__construct">__construct</a><span class="src-sym">(</span><span class="src-var">$mail</span><span class="src-sym">)</span></li>
<li><a name="a97"></a>    <span class="src-sym">{</span></li>
<li><a name="a98"></a>        <span class="src-key">if </span><span class="src-sym">(</span><span class="src-key">empty</span><span class="src-sym">(</span><span class="src-var">$mail</span><span class="src-sym">))</span></li>
<li><a name="a99"></a>        <span class="src-sym">{</span></li>
<li><a name="a100"></a>            throw <span class="src-key">new </span><span class="src-id">Exception</span><span class="src-sym">(</span><span class="src-str">&quot;Invalid email argument; Email cannot be empty&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a101"></a>        <span class="src-sym">}</span></li>
<li><a name="a102"></a>&nbsp;</li>
<li><a name="a103"></a>        <span class="src-comm">// Load everything up //</span></li>
<li><a name="a104"></a>        <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#methodload_parts">load_parts</a><span class="src-sym">(</span><span class="src-var">$mail</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a105"></a>        <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#methodload_contents">load_contents</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a106"></a>        <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#methodload_message">load_message</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a107"></a>        <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#methodload_files">load_files</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a108"></a>    <span class="src-sym">}</span></li>
<li><a name="a109"></a>&nbsp;</li>
<li><a name="a110"></a>    <span class="src-doc">/**</span></li>
<li><a name="a111"></a><span class="src-doc">    * Sets up the class for other functions</span></li>
<li><a name="a112"></a><span class="src-doc">    *</span></li>
<li><a name="a113"></a><span class="src-doc">    * This function parses the boundary of the raw email</span></li>
<li><a name="a114"></a><span class="src-doc">    * then preceeds to parse the header and content of</span></li>
<li><a name="a115"></a><span class="src-doc">    * the raw email for other functions to use</span></li>
<li><a name="a116"></a><span class="src-doc">    *</span></li>
<li><a name="a117"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">String </span><span class="src-doc-var">$content </span></li>
<li><a name="a118"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">void </span></li>
<li><a name="a119"></a><span class="src-doc">    */</span></li>
<li><a name="a120"></a>    <span class="src-key">function </span><a href="../Parser/Parser.html#methodload_parts">load_parts</a><span class="src-sym">(</span><span class="src-var">$content</span><span class="src-sym">)</span></li>
<li><a name="a121"></a>    <span class="src-sym">{</span></li>
<li><a name="a122"></a>        <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$istart </span>= <a href="http://www.php.net/strpos">strpos</a><span class="src-sym">(</span><span class="src-var">$content</span><span class="src-sym">, </span><span class="src-str">&quot;Content-Type:&quot;</span><span class="src-sym">))</span></li>
<li><a name="a123"></a>        <span class="src-sym">{</span></li>
<li><a name="a124"></a>            <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$istart </span>= <a href="http://www.php.net/strpos">strpos</a><span class="src-sym">(</span><span class="src-var">$content</span><span class="src-sym">, </span><span class="src-str">&quot;boundary=\&quot;&quot;</span><span class="src-sym">, </span><span class="src-var">$istart</span><span class="src-sym">))</span></li>
<li><a name="a125"></a>            <span class="src-sym">{</span></li>
<li><a name="a126"></a>                <span class="src-var">$istart </span>+= <a href="http://www.php.net/strlen">strlen</a><span class="src-sym">(</span><span class="src-str">&quot;boundary=\&quot;&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a127"></a>                <span class="src-var">$iend </span>= <a href="http://www.php.net/strpos">strpos</a><span class="src-sym">(</span><span class="src-var">$content</span><span class="src-sym">, </span><span class="src-str">&quot;\&quot;&quot;</span><span class="src-sym">, </span><span class="src-var">$istart</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a128"></a>                <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$boundary">boundary</a> = <a href="http://www.php.net/substr">substr</a><span class="src-sym">(</span><span class="src-var">$content</span><span class="src-sym">, </span><span class="src-var">$istart</span><span class="src-sym">, </span><span class="src-var">$iend </span>- <span class="src-var">$istart</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a129"></a>            <span class="src-sym">}</span></li>
<li><a name="a130"></a>        <span class="src-sym">}</span></li>
<li><a name="a131"></a>&nbsp;</li>
<li><a name="a132"></a>        <span class="src-key">if </span><span class="src-sym">(</span><span class="src-sym">!</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$boundary">boundary</a><span class="src-sym">)</span></li>
<li><a name="a133"></a>        <span class="src-sym">{</span></li>
<li><a name="a134"></a>            <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$boundary">boundary</a> = <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$P_NEWLINE">P_NEWLINE</a><span class="src-sym">;</span></li>
<li><a name="a135"></a>        <span class="src-sym">}</span></li>
<li><a name="a136"></a>&nbsp;</li>
<li><a name="a137"></a>        <span class="src-var">$parts </span>= <a href="http://www.php.net/split">split</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$boundary">boundary</a><span class="src-sym">, </span><span class="src-var">$content</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a138"></a>&nbsp;</li>
<li><a name="a139"></a>        <span class="src-var">$header1 </span>= <a href="http://www.php.net/array_shift">array_shift</a><span class="src-sym">(</span><span class="src-var">$parts</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a140"></a>        <span class="src-var">$header2 </span>= <a href="http://www.php.net/array_shift">array_shift</a><span class="src-sym">(</span><span class="src-var">$parts</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a141"></a>&nbsp;</li>
<li><a name="a142"></a>        <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$header">header</a> = <span class="src-var">$header1 </span>. <span class="src-var">$header2</span><span class="src-sym">;</span></li>
<li><a name="a143"></a>        <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$content">content</a> = <a href="http://www.php.net/implode">implode</a><span class="src-sym">(</span><span class="src-var">$parts</span><span class="src-sym">, </span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$boundary">boundary</a><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a144"></a>    <span class="src-sym">}</span></li>
<li><a name="a145"></a>&nbsp;</li>
<li><a name="a146"></a>    <span class="src-doc">/**</span></li>
<li><a name="a147"></a><span class="src-doc">    * Parses the basic content of the email</span></li>
<li><a name="a148"></a><span class="src-doc">    *</span></li>
<li><a name="a149"></a><span class="src-doc">    * This function parses the to, from, and subject</span></li>
<li><a name="a150"></a><span class="src-doc">    * from the raw email's header</span></li>
<li><a name="a151"></a><span class="src-doc">    *</span></li>
<li><a name="a152"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">void </span></li>
<li><a name="a153"></a><span class="src-doc">    */</span></li>
<li><a name="a154"></a>    <span class="src-key">function </span><a href="../Parser/Parser.html#methodload_contents">load_contents</a><span class="src-sym">(</span><span class="src-sym">)</span></li>
<li><a name="a155"></a>    <span class="src-sym">{</span></li>
<li><a name="a156"></a>        <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/preg_match">preg_match</a><span class="src-sym">(</span><span class="src-str">&quot;/To: (.*)/&quot;</span><span class="src-sym">, </span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$header">header</a><span class="src-sym">, </span><span class="src-var">$match</span><span class="src-sym">))</span></li>
<li><a name="a157"></a>        <span class="src-sym">{</span></li>
<li><a name="a158"></a>            <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$to">to</a> = <span class="src-var">$match</span><span class="src-sym">[</span><span class="src-num">1</span><span class="src-sym">]</span><span class="src-sym">;</span></li>
<li><a name="a159"></a>            <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/preg_match">preg_match</a><span class="src-sym">(</span><span class="src-str">&quot;/.*&lt;(.*)&gt;/&quot;</span><span class="src-sym">, </span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$to">to</a><span class="src-sym">, </span><span class="src-var">$match</span><span class="src-sym">))</span></li>
<li><a name="a160"></a>            <span class="src-sym">{</span></li>
<li><a name="a161"></a>                <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$to">to</a> = <span class="src-var">$match</span><span class="src-sym">[</span><span class="src-num">1</span><span class="src-sym">]</span><span class="src-sym">;</span></li>
<li><a name="a162"></a>            <span class="src-sym">}</span></li>
<li><a name="a163"></a>        <span class="src-sym">}</span></li>
<li><a name="a164"></a>&nbsp;</li>
<li><a name="a165"></a>        <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/preg_match">preg_match</a><span class="src-sym">(</span><span class="src-str">&quot;/From: (.*)/&quot;</span><span class="src-sym">, </span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$header">header</a><span class="src-sym">, </span><span class="src-var">$match</span><span class="src-sym">))</span></li>
<li><a name="a166"></a>        <span class="src-sym">{</span></li>
<li><a name="a167"></a>            <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$from">from</a> = <span class="src-var">$match</span><span class="src-sym">[</span><span class="src-num">1</span><span class="src-sym">]</span><span class="src-sym">;</span></li>
<li><a name="a168"></a>        <span class="src-sym">}</span></li>
<li><a name="a169"></a>&nbsp;</li>
<li><a name="a170"></a>        <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/preg_match">preg_match</a><span class="src-sym">(</span><span class="src-str">&quot;/Subject: (.*)/&quot;</span><span class="src-sym">, </span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$header">header</a><span class="src-sym">, </span><span class="src-var">$match</span><span class="src-sym">))</span></li>
<li><a name="a171"></a>        <span class="src-sym">{</span></li>
<li><a name="a172"></a>            <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$subject">subject</a> = <span class="src-var">$match</span><span class="src-sym">[</span><span class="src-num">1</span><span class="src-sym">]</span><span class="src-sym">;</span></li>
<li><a name="a173"></a>        <span class="src-sym">}</span></li>
<li><a name="a174"></a>    <span class="src-sym">}</span></li>
<li><a name="a175"></a>&nbsp;</li>
<li><a name="a176"></a>    <span class="src-doc">/**</span></li>
<li><a name="a177"></a><span class="src-doc">    * Parses the message from the email</span></li>
<li><a name="a178"></a><span class="src-doc">    *</span></li>
<li><a name="a179"></a><span class="src-doc">    * This function parses the two common formats of</span></li>
<li><a name="a180"></a><span class="src-doc">    * a raw message, plain text, and html formatted.</span></li>
<li><a name="a181"></a><span class="src-doc">    * It loads both (if either one exists) into an</span></li>
<li><a name="a182"></a><span class="src-doc">    * associative array based on their names</span></li>
<li><a name="a183"></a><span class="src-doc">    *</span></li>
<li><a name="a184"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">void </span></li>
<li><a name="a185"></a><span class="src-doc">    */</span></li>
<li><a name="a186"></a>    <span class="src-key">function </span><a href="../Parser/Parser.html#methodload_message">load_message</a><span class="src-sym">(</span><span class="src-sym">)</span></li>
<li><a name="a187"></a>    <span class="src-sym">{</span></li>
<li><a name="a188"></a>        <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$istart </span>= <a href="http://www.php.net/strpos">strpos</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$content">content</a><span class="src-sym">, </span><span class="src-str">&quot;Content-Type: text/plain;&quot;</span><span class="src-sym">))</span></li>
<li><a name="a189"></a>        <span class="src-sym">{</span></li>
<li><a name="a190"></a>            <span class="src-var">$istart </span>= <a href="http://www.php.net/strpos">strpos</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$content">content</a><span class="src-sym">, </span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$P_NEWLINE">P_NEWLINE</a> . <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$P_NEWLINE">P_NEWLINE</a><span class="src-sym">, </span><span class="src-var">$istart</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a191"></a>            <span class="src-var">$istart </span>+= <a href="http://www.php.net/strlen">strlen</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$P_NEWLINE">P_NEWLINE</a> . <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$P_NEWLINE">P_NEWLINE</a><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a192"></a>            <span class="src-var">$iend </span>= <a href="http://www.php.net/strpos">strpos</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$content">content</a><span class="src-sym">, </span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$boundary">boundary</a><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a193"></a>            <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$message">message</a><span class="src-sym">[</span><span class="src-str">'plain'</span><span class="src-sym">] </span>= <a href="http://www.php.net/substr">substr</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$content">content</a><span class="src-sym">, </span><span class="src-var">$istart</span><span class="src-sym">, </span><span class="src-var">$iend </span>- <span class="src-var">$istart</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a194"></a>        <span class="src-sym">}</span></li>
<li><a name="a195"></a>&nbsp;</li>
<li><a name="a196"></a>        <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$istart </span>= <a href="http://www.php.net/strpos">strpos</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$content">content</a><span class="src-sym">, </span><span class="src-str">&quot;Content-Type: text/html;&quot;</span><span class="src-sym">))</span></li>
<li><a name="a197"></a>        <span class="src-sym">{</span></li>
<li><a name="a198"></a>            <span class="src-var">$istart </span>= <a href="http://www.php.net/strpos">strpos</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$content">content</a><span class="src-sym">, </span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$P_NEWLINE">P_NEWLINE</a> . <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$P_NEWLINE">P_NEWLINE</a><span class="src-sym">, </span><span class="src-var">$istart</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a199"></a>            <span class="src-var">$istart </span>+= <a href="http://www.php.net/strlen">strlen</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$P_NEWLINE">P_NEWLINE</a> . <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$P_NEWLINE">P_NEWLINE</a><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a200"></a>            <span class="src-var">$iend </span>= <a href="http://www.php.net/strpos">strpos</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$content">content</a><span class="src-sym">, </span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$boundary">boundary</a><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a201"></a>            <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$message">message</a><span class="src-sym">[</span><span class="src-str">'html'</span><span class="src-sym">] </span>= <a href="http://www.php.net/substr">substr</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$content">content</a><span class="src-sym">, </span><span class="src-var">$istart</span><span class="src-sym">, </span><span class="src-var">$iend </span>- <span class="src-var">$istart</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a202"></a>        <span class="src-sym">}</span></li>
<li><a name="a203"></a>    <span class="src-sym">}</span></li>
<li><a name="a204"></a>&nbsp;</li>
<li><a name="a205"></a>    <span class="src-doc">/**</span></li>
<li><a name="a206"></a><span class="src-doc">    * Parses any attachments in the raw email</span></li>
<li><a name="a207"></a><span class="src-doc">    *</span></li>
<li><a name="a208"></a><span class="src-doc">    * This function parses ALL attachments in</span></li>
<li><a name="a209"></a><span class="src-doc">    * the email into an array of associative arrays</span></li>
<li><a name="a210"></a><span class="src-doc">    * containing the common information of each</span></li>
<li><a name="a211"></a><span class="src-doc">    * file including the name, base name, extension,</span></li>
<li><a name="a212"></a><span class="src-doc">    * and content. The files contents are decoded</span></li>
<li><a name="a213"></a><span class="src-doc">    * when they are parsed.</span></li>
<li><a name="a214"></a><span class="src-doc">    *</span></li>
<li><a name="a215"></a><span class="src-doc">    * </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">void </span></li>
<li><a name="a216"></a><span class="src-doc">    */</span></li>
<li><a name="a217"></a>    <span class="src-key">function </span><a href="../Parser/Parser.html#methodload_files">load_files</a><span class="src-sym">(</span><span class="src-sym">)</span></li>
<li><a name="a218"></a>    <span class="src-sym">{</span></li>
<li><a name="a219"></a>        <span class="src-key">while </span><span class="src-sym">(</span><span class="src-var">$istart </span>= <a href="http://www.php.net/strpos">strpos</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$content">content</a><span class="src-sym">, </span><span class="src-str">&quot;Content-Disposition: attachment; filename=\&quot;&quot;</span><span class="src-sym">, </span><span class="src-var">$istart</span><span class="src-sym">))</span></li>
<li><a name="a220"></a>        <span class="src-sym">{</span></li>
<li><a name="a221"></a>            <span class="src-var">$cur_index </span>= <a href="http://www.php.net/sizeof">sizeof</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$files">files</a><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a222"></a>&nbsp;</li>
<li><a name="a223"></a>            <span class="src-var">$istart </span>+= <a href="http://www.php.net/strlen">strlen</a><span class="src-sym">(</span><span class="src-str">&quot;Content-Disposition: attachment; filename=\&quot;&quot;</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a224"></a>            <span class="src-var">$iend </span>= <a href="http://www.php.net/strpos">strpos</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$content">content</a><span class="src-sym">, </span><span class="src-str">&quot;\&quot;&quot;</span><span class="src-sym">, </span><span class="src-var">$istart</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a225"></a>            <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$files">files</a><span class="src-sym">[</span><span class="src-var">$cur_index</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-str">'name'</span><span class="src-sym">] </span>= <a href="http://www.php.net/substr">substr</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$content">content</a><span class="src-sym">, </span><span class="src-var">$istart</span><span class="src-sym">, </span><span class="src-var">$iend </span>- <span class="src-var">$istart</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a226"></a>&nbsp;</li>
<li><a name="a227"></a>            <span class="src-var">$parts </span>= <a href="http://www.php.net/explode">explode</a><span class="src-sym">(</span><span class="src-str">&quot;.&quot;</span><span class="src-sym">, </span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$files">files</a><span class="src-sym">[</span><span class="src-var">$cur_index</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-str">'name'</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a228"></a>            <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$files">files</a><span class="src-sym">[</span><span class="src-var">$cur_index</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-str">'base_name'</span><span class="src-sym">] </span>= <a href="http://www.php.net/array_shift">array_shift</a><span class="src-sym">(</span><span class="src-var">$parts</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a229"></a>            <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$files">files</a><span class="src-sym">[</span><span class="src-var">$cur_index</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-str">'ext'</span><span class="src-sym">] </span>= <a href="http://www.php.net/implode">implode</a><span class="src-sym">(</span><span class="src-str">&quot;.&quot;</span><span class="src-sym">, </span><span class="src-var">$parts</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a230"></a>&nbsp;</li>
<li><a name="a231"></a>            <span class="src-var">$istart </span>= <a href="http://www.php.net/strpos">strpos</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$content">content</a><span class="src-sym">, </span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$P_NEWLINE">P_NEWLINE</a> . <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$P_NEWLINE">P_NEWLINE</a><span class="src-sym">, </span><span class="src-var">$istart</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a232"></a>            <span class="src-var">$istart </span>+= <a href="http://www.php.net/strlen">strlen</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$P_NEWLINE">P_NEWLINE</a> . <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$P_NEWLINE">P_NEWLINE</a><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a233"></a>            <span class="src-var">$iend </span>= <a href="http://www.php.net/strpos">strpos</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$content">content</a><span class="src-sym">, </span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$boundary">boundary</a><span class="src-sym">, </span><span class="src-var">$istart</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a234"></a>            <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$files">files</a><span class="src-sym">[</span><span class="src-var">$cur_index</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-str">'content'</span><span class="src-sym">] </span>= <a href="http://www.php.net/base64_decode">base64_decode</a><span class="src-sym">(</span><a href="http://www.php.net/substr">substr</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../Parser/Parser.html#var$content">content</a><span class="src-sym">, </span><span class="src-var">$istart</span><span class="src-sym">, </span><span class="src-var">$iend </span>- <span class="src-var">$istart</span><span class="src-sym">))</span><span class="src-sym">;</span></li>
<li><a name="a235"></a>        <span class="src-sym">}</span></li>
<li><a name="a236"></a>    <span class="src-sym">}</span></li>
<li><a name="a237"></a><span class="src-sym">}</span></li>
<li><a name="a238"></a>&nbsp;</li>
<li><a name="a239"></a><span class="src-php">?&gt;</span></li>
</ol></pre>
</div>
	<p class="notes" id="credit">
		Documentation generated on Sun, 07 Jan 2007 21:19:37 -0800 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.3.0RC3</a>
	</p>
	</body>
</html>
Return current item: Email Parser