Location: PHPKode > scripts > IAM CSV Dump > iam-csv-dump/docs/__filesource/fsource_iam_csvdump__iam_csvdump.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 iam_csvdump.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 iam_csvdump.php</h1>
<p>Documentation is available at <a href="../iam_csvdump/_CSVDump_iam_csvdump_php.html">iam_csvdump.php</a></p>
<div class="src-code">
<pre><a name="a1"></a><br />1     <span class="src-php">&lt;?php</span><a name="a2"></a><br />2     <a name="a3"></a><br />3     <span class="src-doc">/**</span><a name="a4"></a><br />4     <span class="src-doc"> *  IAM_CSVDump A class form performing a query dump and sending it to the browser or setting it or download.</span><a name="a5"></a><br />5     <span class="src-doc"> *</span><span class="src-doc">  </span><span class="src-doc-coretag">@package</span><span class="src-doc">    iam_csvdump</span><a name="a6"></a><br />6     <span class="src-doc"> */</span><a name="a7"></a><br />7     <a name="a8"></a><br />8      <span class="src-doc">/**</span><a name="a9"></a><br />9     <span class="src-doc"> *  IAM_CSVDump A class form performing a query dump and sending it to the browser or setting it or download.</span><a name="a10"></a><br />10    <span class="src-doc"> *</span><span class="src-doc">  </span><span class="src-doc-coretag">@author</span><span class="src-doc">     Iván Ariel Melgrati &lt;hide@address.com&gt;</span><a name="a11"></a><br />11    <span class="src-doc"> *</span><span class="src-doc">  </span><span class="src-doc-coretag">@package</span><span class="src-doc">    iam_csvdump</span><a name="a12"></a><br />12    <span class="src-doc"> *</span><span class="src-doc">  </span><span class="src-doc-coretag">@version</span><span class="src-doc"> 1.0</span><a name="a13"></a><br />13    <span class="src-doc"> *</span><a name="a14"></a><br />14    <span class="src-doc"> *</span><span class="src-doc"> </span><span class="src-doc">  IAM_CSVDump A class form performing a query dump and sending it to the browser or setting it or download.</span><a name="a15"></a><br />15    <span class="src-doc"> *</span><a name="a16"></a><br />16    <span class="src-doc"> *</span><span class="src-doc"> </span><span class="src-doc">  Browser and OS detection for appropriate handling of download and EOL chars.</span><a name="a17"></a><br />17    <span class="src-doc"> *</span><a name="a18"></a><br />18    <span class="src-doc"> *</span><span class="src-doc"> </span><span class="src-doc">  Requires PHP v 4.0+ and MySQL 3.23+. Some portions taken from the CSV_UTIL_CLASS by Andrej Arn &lt;hide@address.com&gt;.</span><a name="a19"></a><br />19    <span class="src-doc"> *</span><a name="a20"></a><br />20    <span class="src-doc"> *</span><span class="src-doc"> </span><span class="src-doc">  This library is free software; you can redistribute it and/or</span><a name="a21"></a><br />21    <span class="src-doc"> *</span><span class="src-doc"> </span><span class="src-doc">  modify it under the terms of the GNU Lesser General Public</span><a name="a22"></a><br />22    <span class="src-doc"> *</span><span class="src-doc"> </span><span class="src-doc">  License as published by the Free Software Foundation; either</span><a name="a23"></a><br />23    <span class="src-doc"> *</span><span class="src-doc"> </span><span class="src-doc">  version 2 of the License, or (at your option) any later version.</span><a name="a24"></a><br />24    <span class="src-doc"> *</span><a name="a25"></a><br />25    <span class="src-doc"> *</span><span class="src-doc"> </span><span class="src-doc">  This library is distributed in the hope that it will be useful,</span><a name="a26"></a><br />26    <span class="src-doc"> *</span><span class="src-doc"> </span><span class="src-doc">  but WITHOUT ANY WARRANTY; without even the implied warranty of</span><a name="a27"></a><br />27    <span class="src-doc"> *</span><span class="src-doc"> </span><span class="src-doc">  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU</span><a name="a28"></a><br />28    <span class="src-doc"> *</span><span class="src-doc"> </span><span class="src-doc">  Lesser General Public License for more details.</span><a name="a29"></a><br />29    <span class="src-doc"> */</span><a name="a30"></a><br />30    <span class="src-key">class</span> <a href="../iam_csvdump/iam_csvdump.html">iam_csvdump</a><a name="a31"></a><br />31    <span class="src-sym">{</span><a name="a32"></a><br />32    <a name="a33"></a><br />33        <span class="src-doc">/**</span><a name="a34"></a><br />34    <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-tag">@desc</span><span class="src-doc"> Takes an array and creates a csv string from it.</span><a name="a35"></a><br />35    <span class="src-doc">    *</span><a name="a36"></a><br />36    <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@access</span><span class="src-doc"> public</span><a name="a37"></a><br />37    <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@param </span><span class="src-doc"> </span><span class="src-doc-type">Array </span><span class="src-doc"> </span><span class="src-doc-var">$array </span><span class="src-doc">(see below)</span><a name="a38"></a><br />38    <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@param </span><span class="src-doc"> </span><span class="src-doc-type">String </span><span class="src-doc"></span><span class="src-doc-var">$separator </span><span class="src-doc">Field separator ()default is ';')</span><a name="a39"></a><br />39    <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@param </span><span class="src-doc"> </span><span class="src-doc-type">String </span><span class="src-doc"></span><span class="src-doc-var">$trim </span><span class="src-doc"> If the cells should be trimmed , default is 'both'. It can also be 'left', 'right' or 'both'. 'none' makes it faster since omits many function calls.</span><a name="a40"></a><br />40    <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@param </span><span class="src-doc"> </span><span class="src-doc-type">Boolean </span><span class="src-doc">  </span><span class="src-doc-var">$removeEmptyLines </span><span class="src-doc">(default is TRUE. removes &quot;lines&quot; that have no value, would come out empty.)</span><a name="a41"></a><br />41    <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@return </span><span class="src-doc"></span><span class="src-doc-type">String </span><span class="src-doc"></span><span class="src-doc">A CSV String. It returns an empty string if there Array is empty (NULL)</span><a name="a42"></a><br />42    <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@todo</span><span class="src-doc"> Add param &quot;fill to fit max length&quot;?</span><a name="a43"></a><br />43    <span class="src-doc">    */</span><a name="a44"></a><br />44        <span class="src-key">function</span> <a href="../iam_csvdump/iam_csvdump.html#methodarrayToCsvString">arrayToCsvString</a><span class="src-sym">(</span><span class="src-var">$array</span><span class="src-sym">,</span> <span class="src-var">$separator</span>=<span class="src-str">';'</span><span class="src-sym">,</span> <span class="src-var">$trim</span>=<span class="src-str">'both'</span><span class="src-sym">,</span> <span class="src-var">$removeEmptyLines</span>=<span class="src-id">TRUE</span><span class="src-sym">)</span> <span class="src-sym">{</span><a name="a45"></a><br />45        <span class="src-key">if</span> <span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/is_array">is_array</a><span class="src-sym">(</span><span class="src-var">$array</span><span class="src-sym">)</span> || <span class="src-key">empty</span><span class="src-sym">(</span><span class="src-var">$array</span><span class="src-sym">)</span><span class="src-sym">)</span> <span class="src-key">return</span> <span class="src-str">''</span>;<a name="a46"></a><br />46    <a name="a47"></a><br />47        <span class="src-key">switch</span> <span class="src-sym">(</span><span class="src-var">$trim</span><span class="src-sym">)</span> <span class="src-sym">{</span><a name="a48"></a><br />48          <span class="src-key">case</span> <span class="src-str">'none'</span>:<a name="a49"></a><br />49            <span class="src-var">$trimFunction</span> = <span class="src-id">FALSE</span>;<a name="a50"></a><br />50            <span class="src-key">break</span>;<a name="a51"></a><br />51          <span class="src-key">case</span> <span class="src-str">'left'</span>:<a name="a52"></a><br />52            <span class="src-var">$trimFunction</span> = <span class="src-str">'ltrim'</span>;<a name="a53"></a><br />53            <span class="src-key">break</span>;<a name="a54"></a><br />54          <span class="src-key">case</span> <span class="src-str">'right'</span>:<a name="a55"></a><br />55            <span class="src-var">$trimFunction</span> = <span class="src-str">'rtrim'</span>;<a name="a56"></a><br />56            <span class="src-key">break</span>;<a name="a57"></a><br />57          <span class="src-key">default</span>: <span class="src-comm">//'both':</span><a name="a58"></a><br />58            <span class="src-var">$trimFunction</span> = <span class="src-str">'trim'</span>;<a name="a59"></a><br />59            <span class="src-key">break</span>;<a name="a60"></a><br />60        <span class="src-sym">}</span><a name="a61"></a><br />61        <span class="src-var">$ret</span> = <span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span>;<a name="a62"></a><br />62        <a href="http://www.php.net/reset">reset</a><span class="src-sym">(</span><span class="src-var">$array</span><span class="src-sym">)</span>;<a name="a63"></a><br />63        <span class="src-key">if</span> <span class="src-sym">(</span><a href="http://www.php.net/is_array">is_array</a><span class="src-sym">(</span><a href="http://www.php.net/current">current</a><span class="src-sym">(</span><span class="src-var">$array</span><span class="src-sym">)</span><span class="src-sym">)</span><span class="src-sym">)</span> <span class="src-sym">{</span><a name="a64"></a><br />64          <span class="src-key">while</span> <span class="src-sym">(</span>list<span class="src-sym">(</span><span class="src-sym">,</span><span class="src-var">$lineArr</span><span class="src-sym">)</span> = <a href="http://www.php.net/each">each</a><span class="src-sym">(</span><span class="src-var">$array</span><span class="src-sym">)</span><span class="src-sym">)</span> <span class="src-sym">{</span><a name="a65"></a><br />65            <span class="src-key">if</span> <span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/is_array">is_array</a><span class="src-sym">(</span><span class="src-var">$lineArr</span><span class="src-sym">)</span><span class="src-sym">)</span> <span class="src-sym">{</span><a name="a66"></a><br />66              <span class="src-comm">//Could issue a warning ...</span><a name="a67"></a><br />67              <span class="src-var">$ret</span><span class="src-sym">[</span><span class="src-sym">]</span> = <span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span>;<a name="a68"></a><br />68            <span class="src-sym">}</span> <span class="src-key">else</span> <span class="src-sym">{</span><a name="a69"></a><br />69              <span class="src-var">$subArr</span> = <span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span>;<a name="a70"></a><br />70              <span class="src-key">while</span> <span class="src-sym">(</span>list<span class="src-sym">(</span><span class="src-sym">,</span><span class="src-var">$val</span><span class="src-sym">)</span> = <a href="http://www.php.net/each">each</a><span class="src-sym">(</span><span class="src-var">$lineArr</span><span class="src-sym">)</span><span class="src-sym">)</span> <span class="src-sym">{</span><a name="a71"></a><br />71                <span class="src-var">$val</span>      = <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../iam_csvdump/iam_csvdump.html#method_valToCsvHelper">_valToCsvHelper</a><span class="src-sym">(</span><span class="src-var">$val</span><span class="src-sym">,</span> <span class="src-var">$separator</span><span class="src-sym">,</span> <span class="src-var">$trimFunction</span><span class="src-sym">)</span>;<a name="a72"></a><br />72                <span class="src-var">$subArr</span><span class="src-sym">[</span><span class="src-sym">]</span> = <span class="src-var">$val</span>;<a name="a73"></a><br />73              <span class="src-sym">}</span><a name="a74"></a><br />74            <span class="src-sym">}</span><a name="a75"></a><br />75            <span class="src-var">$ret</span><span class="src-sym">[</span><span class="src-sym">]</span> = <a href="http://www.php.net/join">join</a><span class="src-sym">(</span><span class="src-var">$separator</span><span class="src-sym">,</span> <span class="src-var">$subArr</span><span class="src-sym">)</span>;<a name="a76"></a><br />76          <span class="src-sym">}</span><a name="a77"></a><br />77          <span class="src-key">return</span> <a href="http://www.php.net/join">join</a><span class="src-sym">(</span><span class="src-str">&quot;\n&quot;</span><span class="src-sym">,</span> <span class="src-var">$ret</span><span class="src-sym">)</span>;<a name="a78"></a><br />78        <span class="src-sym">}</span> <span class="src-key">else</span> <span class="src-sym">{</span><a name="a79"></a><br />79          <span class="src-key">while</span> <span class="src-sym">(</span>list<span class="src-sym">(</span><span class="src-sym">,</span><span class="src-var">$val</span><span class="src-sym">)</span> = <a href="http://www.php.net/each">each</a><span class="src-sym">(</span><span class="src-var">$array</span><span class="src-sym">)</span><span class="src-sym">)</span> <span class="src-sym">{</span><a name="a80"></a><br />80            <span class="src-var">$val</span>   = <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../iam_csvdump/iam_csvdump.html#method_valToCsvHelper">_valToCsvHelper</a><span class="src-sym">(</span><span class="src-var">$val</span><span class="src-sym">,</span> <span class="src-var">$separator</span><span class="src-sym">,</span> <span class="src-var">$trimFunction</span><span class="src-sym">)</span>;<a name="a81"></a><br />81            <span class="src-var">$ret</span><span class="src-sym">[</span><span class="src-sym">]</span> = <span class="src-var">$val</span>;<a name="a82"></a><br />82          <span class="src-sym">}</span><a name="a83"></a><br />83          <span class="src-key">return</span> <a href="http://www.php.net/join">join</a><span class="src-sym">(</span><span class="src-var">$separator</span><span class="src-sym">,</span> <span class="src-var">$ret</span><span class="src-sym">)</span>;<a name="a84"></a><br />84        <span class="src-sym">}</span><a name="a85"></a><br />85        <span class="src-sym">}</span><a name="a86"></a><br />86    <a name="a87"></a><br />87        <span class="src-doc">/**</span><a name="a88"></a><br />88    <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-tag">@desc</span><span class="src-doc"> Works on a string to include in a csv string.</span><a name="a89"></a><br />89    <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@access</span><span class="src-doc"> private</span><a name="a90"></a><br />90    <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@param </span><span class="src-doc"> </span><span class="src-doc-type">String </span><span class="src-doc"></span><span class="src-doc-var">$val </span><a name="a91"></a><br />91    <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@param </span><span class="src-doc"> </span><span class="src-doc-type">String </span><span class="src-doc"></span><span class="src-doc-var">$separator </span><a name="a92"></a><br />92    <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@param </span><span class="src-doc"> </span><span class="src-doc-type">Mixed </span><span class="src-doc"> </span><span class="src-doc-var">$trimFunction </span><span class="src-doc">If the cells should be trimmed , default is 'both'. It can also be 'left', 'right' or 'both'. 'none' makes it faster since omits many function calls.</span><a name="a93"></a><br />93    <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@return </span><span class="src-doc"></span><span class="src-doc-type">String </span><a name="a94"></a><br />94    <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@see</span><span class="src-doc">    arrayToCsvString()</span><a name="a95"></a><br />95    <span class="src-doc">    */</span><a name="a96"></a><br />96        <span class="src-key">function</span> <a href="../iam_csvdump/iam_csvdump.html#method_valToCsvHelper">_valToCsvHelper</a><span class="src-sym">(</span><span class="src-var">$val</span><span class="src-sym">,</span> <span class="src-var">$separator</span><span class="src-sym">,</span> <span class="src-var">$trimFunction</span><span class="src-sym">)</span> <span class="src-sym">{</span><a name="a97"></a><br />97        <span class="src-key">if</span> <span class="src-sym">(</span><span class="src-var">$trimFunction</span><span class="src-sym">)</span> <span class="src-var">$val</span> = <span class="src-var">$trimFunction</span><span class="src-sym">(</span><span class="src-var">$val</span><span class="src-sym">)</span>;<a name="a98"></a><br />98        <span class="src-comm">//If there is a separator (;) or a quote (&quot;) or a linebreak in the string, we need to quote it.</span><a name="a99"></a><br />99        <span class="src-var">$needQuote</span> = <span class="src-id">FALSE</span>;<a name="a100"></a><br />100       do <span class="src-sym">{</span><a name="a101"></a><br />101         <span class="src-key">if</span> <span class="src-sym">(</span><a href="http://www.php.net/strpos">strpos</a><span class="src-sym">(</span><span class="src-var">$val</span><span class="src-sym">,</span> <span class="src-str">'&quot;'</span><span class="src-sym">)</span> !== <span class="src-id">FALSE</span><span class="src-sym">)</span> <span class="src-sym">{</span><a name="a102"></a><br />102           <span class="src-var">$val</span> = <a href="http://www.php.net/str_replace">str_replace</a><span class="src-sym">(</span><span class="src-str">'&quot;'</span><span class="src-sym">,</span> <span class="src-str">'&quot;&quot;'</span><span class="src-sym">,</span> <span class="src-var">$val</span><span class="src-sym">)</span>;<a name="a103"></a><br />103           <span class="src-var">$needQuote</span> = <span class="src-id">TRUE</span>;<a name="a104"></a><br />104           <span class="src-key">break</span>;<a name="a105"></a><br />105         <span class="src-sym">}</span><a name="a106"></a><br />106         <span class="src-key">if</span> <span class="src-sym">(</span><a href="http://www.php.net/strpos">strpos</a><span class="src-sym">(</span><span class="src-var">$val</span><span class="src-sym">,</span> <span class="src-var">$separator</span><span class="src-sym">)</span> !== <span class="src-id">FALSE</span><span class="src-sym">)</span> <span class="src-sym">{</span><a name="a107"></a><br />107           <span class="src-var">$needQuote</span> = <span class="src-id">TRUE</span>;<a name="a108"></a><br />108           <span class="src-key">break</span>;<a name="a109"></a><br />109         <span class="src-sym">}</span><a name="a110"></a><br />110         <span class="src-key">if</span> <span class="src-sym">(</span><span class="src-sym">(</span><a href="http://www.php.net/strpos">strpos</a><span class="src-sym">(</span><span class="src-var">$val</span><span class="src-sym">,</span> <span class="src-str">&quot;\n&quot;</span><span class="src-sym">)</span> !== <span class="src-id">FALSE</span><span class="src-sym">)</span> || <span class="src-sym">(</span><a href="http://www.php.net/strpos">strpos</a><span class="src-sym">(</span><span class="src-var">$val</span><span class="src-sym">,</span> <span class="src-str">&quot;\r&quot;</span><span class="src-sym">)</span> !== <span class="src-id">FALSE</span><span class="src-sym">)</span><span class="src-sym">)</span> <span class="src-sym">{</span> <span class="src-comm">// \r is for mac</span><a name="a111"></a><br />111           <span class="src-var">$needQuote</span> = <span class="src-id">TRUE</span>;<a name="a112"></a><br />112           <span class="src-key">break</span>;<a name="a113"></a><br />113         <span class="src-sym">}</span><a name="a114"></a><br />114       <span class="src-sym">}</span> <span class="src-key">while</span> <span class="src-sym">(</span><span class="src-id">FALSE</span><span class="src-sym">)</span>;<a name="a115"></a><br />115       <span class="src-key">if</span> <span class="src-sym">(</span><span class="src-var">$needQuote</span><span class="src-sym">)</span> <span class="src-sym">{</span><a name="a116"></a><br />116         <span class="src-var">$val</span> = <span class="src-str">'&quot;'</span> . <span class="src-var">$val</span> . <span class="src-str">'&quot;'</span>;<a name="a117"></a><br />117       <span class="src-sym">}</span><a name="a118"></a><br />118       <span class="src-key">return</span> <span class="src-var">$val</span>;<a name="a119"></a><br />119       <span class="src-sym">}</span><a name="a120"></a><br />120   <a name="a121"></a><br />121       <span class="src-doc">/**</span><a name="a122"></a><br />122   <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-tag">@desc</span><span class="src-doc"> Define EOL character according to target OS</span><a name="a123"></a><br />123   <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@access</span><span class="src-doc"> private</span><a name="a124"></a><br />124   <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@return </span><span class="src-doc"></span><span class="src-doc-type">String </span><span class="src-doc"></span><span class="src-doc">A String containing the End Of Line Sequence corresponding to the client's OS</span><a name="a125"></a><br />125   <span class="src-doc">    */</span><a name="a126"></a><br />126       <span class="src-key">function</span> <a href="../iam_csvdump/iam_csvdump.html#method_define_newline">_define_newline</a><span class="src-sym">(</span><span class="src-sym">)</span><a name="a127"></a><br />127       <span class="src-sym">{</span><a name="a128"></a><br />128            <span class="src-var">$unewline</span> = <span class="src-str">&quot;\r\n&quot;</span>;<a name="a129"></a><br />129   <a name="a130"></a><br />130            <span class="src-key">if</span> <span class="src-sym">(</span><a href="http://www.php.net/strstr">strstr</a><span class="src-sym">(</span><a href="http://www.php.net/strtolower">strtolower</a><span class="src-sym">(</span><span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">&quot;HTTP_USER_AGENT&quot;</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">,</span> <span class="src-str">'win'</span><span class="src-sym">)</span><span class="src-sym">)</span><a name="a131"></a><br />131            <span class="src-sym">{</span><a name="a132"></a><br />132               <span class="src-var">$unewline</span> = <span class="src-str">&quot;\r\n&quot;</span>;<a name="a133"></a><br />133            <span class="src-sym">}</span><a name="a134"></a><br />134            <span class="src-key">else</span> <span class="src-key">if</span> <span class="src-sym">(</span><a href="http://www.php.net/strstr">strstr</a><span class="src-sym">(</span><a href="http://www.php.net/strtolower">strtolower</a><span class="src-sym">(</span><span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">&quot;HTTP_USER_AGENT&quot;</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">,</span> <span class="src-str">'mac'</span><span class="src-sym">)</span><span class="src-sym">)</span><a name="a135"></a><br />135            <span class="src-sym">{</span><a name="a136"></a><br />136               <span class="src-var">$unewline</span> = <span class="src-str">&quot;\r&quot;</span>;<a name="a137"></a><br />137            <span class="src-sym">}</span><a name="a138"></a><br />138            <span class="src-key">else</span><a name="a139"></a><br />139            <span class="src-sym">{</span><a name="a140"></a><br />140               <span class="src-var">$unewline</span> = <span class="src-str">&quot;\n&quot;</span>;<a name="a141"></a><br />141            <span class="src-sym">}</span><a name="a142"></a><br />142   <a name="a143"></a><br />143            <span class="src-key">return</span> <span class="src-var">$unewline</span>;<a name="a144"></a><br />144       <span class="src-sym">}</span><a name="a145"></a><br />145   <a name="a146"></a><br />146       <span class="src-doc">/**</span><a name="a147"></a><br />147   <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-tag">@desc</span><span class="src-doc"> Define the client's browser type</span><a name="a148"></a><br />148   <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@access</span><span class="src-doc"> private</span><a name="a149"></a><br />149   <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@return </span><span class="src-doc"></span><span class="src-doc-type">String </span><span class="src-doc"></span><span class="src-doc">A String containing the Browser's type or brand</span><a name="a150"></a><br />150   <span class="src-doc">    */</span><a name="a151"></a><br />151       <span class="src-key">function</span> <a href="../iam_csvdump/iam_csvdump.html#method_get_browser_type">_get_browser_type</a><span class="src-sym">(</span><span class="src-sym">)</span><a name="a152"></a><br />152       <span class="src-sym">{</span><a name="a153"></a><br />153           <span class="src-var">$USER_BROWSER_AGENT</span>=<span class="src-str">&quot;&quot;</span>;<a name="a154"></a><br />154   <a name="a155"></a><br />155           <span class="src-key">if</span> <span class="src-sym">(</span><a href="http://www.php.net/ereg">ereg</a><span class="src-sym">(</span><span class="src-str">'OPERA(/| )([0-9].[0-9]{1,2})'</span><span class="src-sym">,</span> <a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">&quot;HTTP_USER_AGENT&quot;</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">,</span> <span class="src-var">$log_version</span><span class="src-sym">)</span><span class="src-sym">)</span><a name="a156"></a><br />156           <span class="src-sym">{</span><a name="a157"></a><br />157               <span class="src-var">$USER_BROWSER_AGENT</span>=<span class="src-str">'OPERA'</span>;<a name="a158"></a><br />158           <span class="src-sym">}</span><a name="a159"></a><br />159           <span class="src-key">else</span> <span class="src-key">if</span> <span class="src-sym">(</span><a href="http://www.php.net/ereg">ereg</a><span class="src-sym">(</span><span class="src-str">'MSIE ([0-9].[0-9]{1,2})'</span><span class="src-sym">,</span><a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">&quot;HTTP_USER_AGENT&quot;</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">,</span> <span class="src-var">$log_version</span><span class="src-sym">)</span><span class="src-sym">)</span><a name="a160"></a><br />160           <span class="src-sym">{</span><a name="a161"></a><br />161               <span class="src-var">$USER_BROWSER_AGENT</span>=<span class="src-str">'IE'</span>;<a name="a162"></a><br />162           <span class="src-sym">}</span><a name="a163"></a><br />163           <span class="src-key">else</span> <span class="src-key">if</span> <span class="src-sym">(</span><a href="http://www.php.net/ereg">ereg</a><span class="src-sym">(</span><span class="src-str">'OMNIWEB/([0-9].[0-9]{1,2})'</span><span class="src-sym">,</span> <a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">&quot;HTTP_USER_AGENT&quot;</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">,</span> <span class="src-var">$log_version</span><span class="src-sym">)</span><span class="src-sym">)</span><a name="a164"></a><br />164           <span class="src-sym">{</span><a name="a165"></a><br />165               <span class="src-var">$USER_BROWSER_AGENT</span>=<span class="src-str">'OMNIWEB'</span>;<a name="a166"></a><br />166           <span class="src-sym">}</span><a name="a167"></a><br />167           <span class="src-key">else</span> <span class="src-key">if</span> <span class="src-sym">(</span><a href="http://www.php.net/ereg">ereg</a><span class="src-sym">(</span><span class="src-str">'MOZILLA/([0-9].[0-9]{1,2})'</span><span class="src-sym">,</span> <a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">&quot;HTTP_USER_AGENT&quot;</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">,</span> <span class="src-var">$log_version</span><span class="src-sym">)</span><span class="src-sym">)</span><a name="a168"></a><br />168           <span class="src-sym">{</span><a name="a169"></a><br />169               <span class="src-var">$USER_BROWSER_AGENT</span>=<span class="src-str">'MOZILLA'</span>;<a name="a170"></a><br />170           <span class="src-sym">}</span><a name="a171"></a><br />171           <span class="src-key">else</span> <span class="src-key">if</span> <span class="src-sym">(</span><a href="http://www.php.net/ereg">ereg</a><span class="src-sym">(</span><span class="src-str">'KONQUEROR/([0-9].[0-9]{1,2})'</span><span class="src-sym">,</span> <a href="http://www.php.net/strtoupper">strtoupper</a><span class="src-sym">(</span><span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">&quot;HTTP_USER_AGENT&quot;</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">,</span> <span class="src-var">$log_version</span><span class="src-sym">)</span><span class="src-sym">)</span><a name="a172"></a><br />172           <span class="src-sym">{</span><a name="a173"></a><br />173               <span class="src-var">$USER_BROWSER_AGENT</span>=<span class="src-str">'KONQUEROR'</span>;<a name="a174"></a><br />174           <span class="src-sym">}</span><a name="a175"></a><br />175           <span class="src-key">else</span><a name="a176"></a><br />176           <span class="src-sym">{</span><a name="a177"></a><br />177               <span class="src-var">$USER_BROWSER_AGENT</span>=<span class="src-str">'OTHER'</span>;<a name="a178"></a><br />178           <span class="src-sym">}</span><a name="a179"></a><br />179   <a name="a180"></a><br />180           <span class="src-key">return</span> <span class="src-var">$USER_BROWSER_AGENT</span>;<a name="a181"></a><br />181       <span class="src-sym">}</span><a name="a182"></a><br />182   <a name="a183"></a><br />183       <span class="src-doc">/**</span><a name="a184"></a><br />184   <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-tag">@desc</span><span class="src-doc"> Define MIME-TYPE according to target Browser</span><a name="a185"></a><br />185   <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@access</span><span class="src-doc"> private</span><a name="a186"></a><br />186   <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@return </span><span class="src-doc"></span><span class="src-doc-type">String </span><span class="src-doc"></span><span class="src-doc">A string containing the MIME-TYPE String corresponding to the client's browser</span><a name="a187"></a><br />187   <span class="src-doc">    */</span><a name="a188"></a><br />188       <span class="src-key">function</span> <a href="../iam_csvdump/iam_csvdump.html#method_get_mime_type">_get_mime_type</a><span class="src-sym">(</span><span class="src-sym">)</span><a name="a189"></a><br />189       <span class="src-sym">{</span><a name="a190"></a><br />190           <span class="src-var">$USER_BROWSER_AGENT</span>= <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../iam_csvdump/iam_csvdump.html#method_get_browser_type">_get_browser_type</a><span class="src-sym">(</span><span class="src-sym">)</span>;<a name="a191"></a><br />191   <a name="a192"></a><br />192           <span class="src-var">$mime_type</span> = <span class="src-sym">(</span><span class="src-var">$USER_BROWSER_AGENT</span> == <span class="src-str">'IE'</span> || <span class="src-var">$USER_BROWSER_AGENT</span> == <span class="src-str">'OPERA'</span><span class="src-sym">)</span><a name="a193"></a><br />193                          ? <span class="src-str">'application/octetstream'</span><a name="a194"></a><br />194                          : <span class="src-str">'application/octet-stream'</span>;<a name="a195"></a><br />195           <span class="src-key">return</span> <span class="src-var">$mime_type</span>;<a name="a196"></a><br />196       <span class="src-sym">}</span><a name="a197"></a><br />197   <a name="a198"></a><br />198       <span class="src-doc">/**</span><a name="a199"></a><br />199   <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-tag">@desc</span><span class="src-doc"> Generates a CSV File from an SQL String (and outputs it to the browser)</span><a name="a200"></a><br />200   <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@access</span><span class="src-doc"> private</span><a name="a201"></a><br />201   <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@param </span><span class="src-doc"> </span><span class="src-doc-type">String </span><span class="src-doc"></span><span class="src-doc-var">$dbname </span><span class="src-doc">Name of the Database</span><a name="a202"></a><br />202   <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@param </span><span class="src-doc"> </span><span class="src-doc-type">String </span><span class="src-doc"></span><span class="src-doc-var">$user </span><span class="src-doc">User to Access the Database</span><a name="a203"></a><br />203   <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@param </span><span class="src-doc"> </span><span class="src-doc-type">String </span><span class="src-doc"></span><span class="src-doc-var">$password </span><span class="src-doc">Password to Access the Database</span><a name="a204"></a><br />204   <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@param </span><span class="src-doc"> </span><span class="src-doc-type">String </span><span class="src-doc"></span><span class="src-doc-var">$host </span><span class="src-doc">Name of the Host holding the DB</span><a name="a205"></a><br />205   <span class="src-doc">    */</span><a name="a206"></a><br />206       <span class="src-key">function</span> <a href="../iam_csvdump/iam_csvdump.html#method_db_connect">_db_connect</a><span class="src-sym">(</span><span class="src-var">$dbname</span>=<span class="src-str">&quot;mysql&quot;</span><span class="src-sym">,</span> <span class="src-var">$user</span>=<span class="src-str">&quot;root&quot;</span><span class="src-sym">,</span> <span class="src-var">$password</span>=<span class="src-str">&quot;&quot;</span><span class="src-sym">,</span> <span class="src-var">$host</span>=<span class="src-str">&quot;localhost&quot;</span><span class="src-sym">)</span><a name="a207"></a><br />207       <span class="src-sym">{</span><a name="a208"></a><br />208         <span class="src-var">$result</span> = <span class="src-sym">@</span><a href="http://www.php.net/mysql_pconnect">mysql_pconnect</a><span class="src-sym">(</span><span class="src-var">$host</span><span class="src-sym">,</span> <span class="src-var">$user</span><span class="src-sym">,</span> <span class="src-var">$password</span><span class="src-sym">)</span>;<a name="a209"></a><br />209         <span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><span class="src-var">$result</span><span class="src-sym">)</span>     <span class="src-comm">// If no connection, return 0</span><a name="a210"></a><br />210         <span class="src-sym">{</span><a name="a211"></a><br />211          <span class="src-key">return</span> <span class="src-id">false</span>;<a name="a212"></a><br />212         <span class="src-sym">}</span><a name="a213"></a><br />213   <a name="a214"></a><br />214         <span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><span class="src-sym">@</span><a href="http://www.php.net/mysql_select_db">mysql_select_db</a><span class="src-sym">(</span><span class="src-var">$dbname</span><span class="src-sym">)</span><span class="src-sym">)</span>  <span class="src-comm">// If db not set, return 0</span><a name="a215"></a><br />215         <span class="src-sym">{</span><a name="a216"></a><br />216          <span class="src-key">return</span> <span class="src-id">false</span>;<a name="a217"></a><br />217         <span class="src-sym">}</span><a name="a218"></a><br />218         <span class="src-key">return</span> <span class="src-var">$result</span>;<a name="a219"></a><br />219       <span class="src-sym">}</span><a name="a220"></a><br />220   <a name="a221"></a><br />221       <span class="src-doc">/**</span><a name="a222"></a><br />222   <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-tag">@desc</span><span class="src-doc"> Generates a CSV File from an SQL String (and outputs it to the browser)</span><a name="a223"></a><br />223   <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@access</span><span class="src-doc"> private</span><a name="a224"></a><br />224   <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@param </span><span class="src-doc"> </span><span class="src-doc-type">String </span><span class="src-doc"></span><span class="src-doc-var">$query_string </span><span class="src-doc">An SQL statement (usually a SELECT statement)</span><a name="a225"></a><br />225   <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@param </span><span class="src-doc"> </span><span class="src-doc-type">String </span><span class="src-doc"></span><span class="src-doc-var">$dbname </span><span class="src-doc">Name of the Database</span><a name="a226"></a><br />226   <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@param </span><span class="src-doc"> </span><span class="src-doc-type">String </span><span class="src-doc"></span><span class="src-doc-var">$user </span><span class="src-doc">User to Access the Database</span><a name="a227"></a><br />227   <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@param </span><span class="src-doc"> </span><span class="src-doc-type">String </span><span class="src-doc"></span><span class="src-doc-var">$password </span><span class="src-doc">Password to Access the Database</span><a name="a228"></a><br />228   <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@param </span><span class="src-doc"> </span><span class="src-doc-type">String </span><span class="src-doc"></span><span class="src-doc-var">$host </span><span class="src-doc">Name of the Host holding the DB</span><a name="a229"></a><br />229   <span class="src-doc">    */</span><a name="a230"></a><br />230       <span class="src-key">function</span> <a href="../iam_csvdump/iam_csvdump.html#method_generate_csv">_generate_csv</a><span class="src-sym">(</span><span class="src-var">$query_string</span><span class="src-sym">,</span> <span class="src-var">$dbname</span>=<span class="src-str">&quot;mysql&quot;</span><span class="src-sym">,</span> <span class="src-var">$user</span>=<span class="src-str">&quot;root&quot;</span><span class="src-sym">,</span> <span class="src-var">$password</span>=<span class="src-str">&quot;&quot;</span><span class="src-sym">,</span> <span class="src-var">$host</span>=<span class="src-str">&quot;localhost&quot;</span><span class="src-sym">)</span><a name="a231"></a><br />231       <span class="src-sym">{</span><a name="a232"></a><br />232         <span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><span class="src-var">$conn</span>= <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../iam_csvdump/iam_csvdump.html#method_db_connect">_db_connect</a><span class="src-sym">(</span><span class="src-var">$dbname</span><span class="src-sym">,</span> <span class="src-var">$user</span> <span class="src-sym">,</span> <span class="src-var">$password</span><span class="src-sym">,</span> <span class="src-var">$host</span><span class="src-sym">)</span><span class="src-sym">)</span><a name="a233"></a><br />233             <span class="src-key">die</span><span class="src-sym">(</span><span class="src-str">&quot;Error. Cannot connect to Database.&quot;</span><span class="src-sym">)</span>;<a name="a234"></a><br />234         <span class="src-key">else</span><a name="a235"></a><br />235         <span class="src-sym">{</span><a name="a236"></a><br />236           <span class="src-var">$result</span> = <span class="src-sym">@</span><a href="http://www.php.net/mysql_query">mysql_query</a><span class="src-sym">(</span><span class="src-var">$query_string</span><span class="src-sym">,</span> <span class="src-var">$conn</span><span class="src-sym">)</span>;<a name="a237"></a><br />237           <span class="src-key">if</span><span class="src-sym">(</span><span class="src-sym">!</span><span class="src-var">$result</span><span class="src-sym">)</span><a name="a238"></a><br />238               <span class="src-key">die</span><span class="src-sym">(</span><span class="src-str">&quot;Could not perform the Query: &quot;</span>.<a href="http://www.php.net/mysql_error">mysql_error</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">)</span>;<a name="a239"></a><br />239           <span class="src-key">else</span><a name="a240"></a><br />240           <span class="src-sym">{</span><a name="a241"></a><br />241               <span class="src-var">$file</span> = <span class="src-str">&quot;&quot;</span>;<a name="a242"></a><br />242               <span class="src-var">$crlf</span> = <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../iam_csvdump/iam_csvdump.html#method_define_newline">_define_newline</a><span class="src-sym">(</span><span class="src-sym">)</span>;<a name="a243"></a><br />243               <span class="src-key">while</span> <span class="src-sym">(</span><span class="src-var">$str</span>= <span class="src-sym">@</span><a href="http://www.php.net/mysql_fetch_array">mysql_fetch_array</a><span class="src-sym">(</span><span class="src-var">$result</span><span class="src-sym">,</span> <span class="src-id">MYSQL_NUM</span><span class="src-sym">)</span><span class="src-sym">)</span><a name="a244"></a><br />244               <span class="src-sym">{</span><a name="a245"></a><br />245                   <span class="src-var">$file</span> .= <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../iam_csvdump/iam_csvdump.html#methodarrayToCsvString">arrayToCsvString</a><span class="src-sym">(</span><span class="src-var">$str</span><span class="src-sym">,</span><span class="src-str">&quot;,&quot;</span><span class="src-sym">)</span>.<span class="src-var">$crlf</span>;<a name="a246"></a><br />246               <span class="src-sym">}</span><a name="a247"></a><br />247               echo <span class="src-var">$file</span>;<a name="a248"></a><br />248           <span class="src-sym">}</span><a name="a249"></a><br />249         <span class="src-sym">}</span><a name="a250"></a><br />250       <span class="src-sym">}</span><a name="a251"></a><br />251   <a name="a252"></a><br />252       <span class="src-doc">/**</span><a name="a253"></a><br />253   <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-tag">@desc</span><span class="src-doc"> Generate the CSV File and send it to browser or download it as a file</span><a name="a254"></a><br />254   <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@access</span><span class="src-doc"> public</span><a name="a255"></a><br />255   <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@param </span><span class="src-doc"></span><span class="src-doc-type">String </span><span class="src-doc"></span><span class="src-doc-var">$query_string </span><span class="src-doc"> An SQL statement (usually a SELECT statement)</span><a name="a256"></a><br />256   <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@param </span><span class="src-doc"></span><span class="src-doc-type">String </span><span class="src-doc"></span><span class="src-doc-var">$filename </span><span class="src-doc"> Filename to use when downloading the File. Default=&quot;dump&quot;. If set to &quot;&quot;, the dump is displayed on the browser.</span><a name="a257"></a><br />257   <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@param </span><span class="src-doc"></span><span class="src-doc-type">String </span><span class="src-doc"></span><span class="src-doc-var">$extension </span><span class="src-doc">Extension to use when downloading the File. Default=&quot;csv&quot;</span><a name="a258"></a><br />258   <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@param </span><span class="src-doc"> </span><span class="src-doc-type">String </span><span class="src-doc"></span><span class="src-doc-var">$dbname </span><span class="src-doc">Name of the Database to use</span><a name="a259"></a><br />259   <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@param </span><span class="src-doc"> </span><span class="src-doc-type">String </span><span class="src-doc"></span><span class="src-doc-var">$user </span><span class="src-doc">User to Access the Database</span><a name="a260"></a><br />260   <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@param </span><span class="src-doc"> </span><span class="src-doc-type">String </span><span class="src-doc"></span><span class="src-doc-var">$password </span><span class="src-doc">Password to Access the Database</span><a name="a261"></a><br />261   <span class="src-doc">    *</span><span class="src-doc"> </span><span class="src-doc-coretag">@param </span><span class="src-doc"> </span><span class="src-doc-type">String </span><span class="src-doc"></span><span class="src-doc-var">$host </span><span class="src-doc">Name of the Host holding the DB</span><a name="a262"></a><br />262   <span class="src-doc">    */</span><a name="a263"></a><br />263       <span class="src-key">function</span> <a href="../iam_csvdump/iam_csvdump.html#methoddump">dump</a><span class="src-sym">(</span><span class="src-var">$query_string</span><span class="src-sym">,</span> <span class="src-var">$filename</span>=<span class="src-str">&quot;dump&quot;</span><span class="src-sym">,</span> <span class="src-var">$ext</span>=<span class="src-str">&quot;csv&quot;</span><span class="src-sym">,</span> <span class="src-var">$dbname</span>=<span class="src-str">&quot;mysql&quot;</span><span class="src-sym">,</span> <span class="src-var">$user</span>=<span class="src-str">&quot;root&quot;</span><span class="src-sym">,</span> <span class="src-var">$password</span>=<span class="src-str">&quot;&quot;</span><span class="src-sym">,</span> <span class="src-var">$host</span>=<span class="src-str">&quot;localhost&quot;</span> <span class="src-sym">)</span><a name="a264"></a><br />264       <span class="src-sym">{</span><a name="a265"></a><br />265               <span class="src-var">$now</span> = <a href="http://www.php.net/gmdate">gmdate</a><span class="src-sym">(</span><span class="src-str">'D, d M Y H:i:s'</span><span class="src-sym">)</span> . <span class="src-str">' GMT'</span>;<a name="a266"></a><br />266               <span class="src-var">$USER_BROWSER_AGENT</span>= <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../iam_csvdump/iam_csvdump.html#method_get_browser_type">_get_browser_type</a><span class="src-sym">(</span><span class="src-sym">)</span>;<a name="a267"></a><br />267   <a name="a268"></a><br />268               <span class="src-key">if</span> <span class="src-sym">(</span><span class="src-var">$filename</span>!=<span class="src-str">&quot;&quot;</span><span class="src-sym">)</span><a name="a269"></a><br />269               <span class="src-sym">{</span><a name="a270"></a><br />270                    <a href="http://www.php.net/header">header</a><span class="src-sym">(</span><span class="src-str">'Content-Type: '</span> . <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../iam_csvdump/iam_csvdump.html#method_get_mime_type">_get_mime_type</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">)</span>;<a name="a271"></a><br />271                    <a href="http://www.php.net/header">header</a><span class="src-sym">(</span><span class="src-str">'Expires: '</span> . <span class="src-var">$now</span><span class="src-sym">)</span>;<a name="a272"></a><br />272                    <span class="src-key">if</span> <span class="src-sym">(</span><span class="src-var">$USER_BROWSER_AGENT</span> == <span class="src-str">'IE'</span><span class="src-sym">)</span><a name="a273"></a><br />273                    <span class="src-sym">{</span><a name="a274"></a><br />274                         <a href="http://www.php.net/header">header</a><span class="src-sym">(</span><span class="src-str">'Content-Disposition: inline; filename=&quot;'</span> . <span class="src-var">$filename</span> . <span class="src-str">'.'</span> . <span class="src-var">$ext</span> . <span class="src-str">'&quot;'</span><span class="src-sym">)</span>;<a name="a275"></a><br />275                         <a href="http://www.php.net/header">header</a><span class="src-sym">(</span><span class="src-str">'Cache-Control: must-revalidate, post-check=0, pre-check=0'</span><span class="src-sym">)</span>;<a name="a276"></a><br />276                         <a href="http://www.php.net/header">header</a><span class="src-sym">(</span><span class="src-str">'Pragma: public'</span><span class="src-sym">)</span>;<a name="a277"></a><br />277                    <span class="src-sym">}</span><a name="a278"></a><br />278                    <span class="src-key">else</span><a name="a279"></a><br />279                    <span class="src-sym">{</span><a name="a280"></a><br />280                         <a href="http://www.php.net/header">header</a><span class="src-sym">(</span><span class="src-str">'Content-Disposition: attachment; filename=&quot;'</span> . <span class="src-var">$filename</span> . <span class="src-str">'.'</span> . <span class="src-var">$ext</span> . <span class="src-str">'&quot;'</span><span class="src-sym">)</span>;<a name="a281"></a><br />281                         <a href="http://www.php.net/header">header</a><span class="src-sym">(</span><span class="src-str">'Pragma: no-cache'</span><span class="src-sym">)</span>;<a name="a282"></a><br />282                    <span class="src-sym">}</span><a name="a283"></a><br />283   <a name="a284"></a><br />284                    <span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../iam_csvdump/iam_csvdump.html#method_generate_csv">_generate_csv</a><span class="src-sym">(</span><span class="src-var">$query_string</span><span class="src-sym">,</span> <span class="src-var">$dbname</span><span class="src-sym">,</span> <span class="src-var">$user</span><span class="src-sym">,</span> <span class="src-var">$password</span><span class="src-sym">,</span> <span class="src-var">$host</span><span class="src-sym">)</span>;<a name="a285"></a><br />285               <span class="src-sym">}</span><a name="a286"></a><br />286               <span class="src-key">else</span><a name="a287"></a><br />287               <span class="src-sym">{</span><a name="a288"></a><br />288                    echo <span class="src-str">&quot;&lt;html&gt;&lt;body&gt;&lt;pre&gt;&quot;</span>;<a name="a289"></a><br />289                    echo <a href="http://www.php.net/htmlspecialchars">htmlspecialchars</a><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><a href="../iam_csvdump/iam_csvdump.html#method_generate_csv">_generate_csv</a><span class="src-sym">(</span><span class="src-var">$query_string</span><span class="src-sym">,</span> <span class="src-var">$dbname</span><span class="src-sym">,</span> <span class="src-var">$user</span><span class="src-sym">,</span> <span class="src-var">$password</span><span class="src-sym">,</span> <span class="src-var">$host</span><span class="src-sym">)</span><span class="src-sym">)</span>;<a name="a290"></a><br />290                    echo <span class="src-str">&quot;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;&quot;</span>;<a name="a291"></a><br />291               <span class="src-sym">}</span><a name="a292"></a><br />292       <span class="src-sym">}</span><a name="a293"></a><br />293   <span class="src-sym">}</span><a name="a294"></a><br />294   <span class="src-php">?&gt;</span></pre>
</div>
	<p class="notes" id="credit">
		Documentation generated on Fri, 12 Dec 2003 18:43:03 -0300 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.2.3</a>
	</p>
	</body>
</html>
Return current item: IAM CSV Dump