<?xml version="1.0" encoding="utf-8" ?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">

    <title type="text">CodeIgniter Forums</title>
    <link rel="alternate" type="text/html" href="http://codeigniter.com/forums/" />
    <link rel="self" type="application/atom+xml" href="http://codeigniter.com/forums/atom/" />
    <updated>0</updated>
    <rights>Copyright (c) 2012</rights>
    <generator uri="http://www.pmachine.com/" version="2.2.2">ExpressionEngine</generator>
    <id>tag:codeigniter.com,2012:02:10</id>


    <entry>
      <title>Convert this PHP Class to CI Library</title>
      <link rel="alternate" type="text/html" href="http://codeigniter.com/forums/viewthread/210831/" />      
      <id>tag:codeigniter.com,2012:forums/viewthread/.210831</id>
      <published>2012-02-10T23:53:21Z</published>
      <updated>0</updated>
      <author><name>pulsorock</name></author>
      <content type="html">
      <![CDATA[
        <p>Hi!</p>

<p>I need to use this Class in a CI 2.1 project, and I would like to know how to convert it to work on CI.</p>

<p>Code: <a href="http://pastebin.com/HKTvWsGK">http://pastebin.com/HKTvWsGK</a></p>

<p>I tried this:</p>

<p>I copied the class php file to the application/libraries/ folder, and then wrote this in a controller:</p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">load</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">helper</span><span style="color: #007700">(</span><span style="color: #DD0000">'file'</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$json&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">read_file&#40;</span><span style="color: #DD0000">'assets/js/config.json'</span><span style="color: #0000BB">&#41;</span><span style="color: #007700">;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$config&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'var&nbsp;configFile&nbsp;=&nbsp;'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$json</span><span style="color: #007700">;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">load</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">library</span><span style="color: #007700">(</span><span style="color: #DD0000">'JavaScriptPacker'</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$myPacker&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">JavaScriptPacker</span><span style="color: #007700">(</span><span style="color: #0000BB">$config</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$packed&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$myPacker</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">pack</span><span style="color: #007700">();<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$packed</span><span style="color: #007700">;&nbsp;</span>
</span>
</code></div>

<p>But I get this Warning message when I run it:</p><blockquote>
<p>A PHP Error was encountered</p>

<p>Severity: Warning</p>

<p>Message: Missing argument 1 for JavaScriptPacker::__construct(), called in /var/www/myapp/system/core/Loader.php on line 1099 and defined</p>

<p>Filename: libraries/JavaScriptPacker.php</p>

<p>Line Number: 86</p>

<p>A PHP Error was encountered</p>

<p>Severity: Notice</p>

<p>Message: Undefined variable: _script</p>

<p>Filename: libraries/JavaScriptPacker.php</p>

<p>Line Number: 87</p>
</blockquote>

<p>Then after that error message, the correct output is shown. But don&#8217;t know how to avoid the error message.</p>

<p>Any ideas?</p>

<p>Thanks!</p>
      ]]>
      </content>
    </entry>

    <entry>
      <title>Asynchronously loaded data</title>
      <link rel="alternate" type="text/html" href="http://codeigniter.com/forums/viewthread/210826/" />      
      <id>tag:codeigniter.com,2012:forums/viewthread/.210826</id>
      <published>2012-02-10T22:13:14Z</published>
      <updated>2012-02-10T22:15:14Z</updated>
      <author><name>zie1ony</name></author>
      <content type="html">
      <![CDATA[
        <p>Hi<br />
I need some tip. I would like to make that kind of mechanism: <br />
1) user logs in to the server (this I know)<br />
2) user gets data (this I know :- )<br />
3) as long as user is logged in, when new data show up, they will be send to him asynchronously (that is the magic I don&#8217;t know)</p>

<p>Where should I search to find something about it? I would like to do this in CI and jQuery (client side)</p>

<p>Keep warm<br />
zie1ony</p>
      ]]>
      </content>
    </entry>

    <entry>
      <title>MSSQL, Blank Pages, and Smalldatetime</title>
      <link rel="alternate" type="text/html" href="http://codeigniter.com/forums/viewthread/210825/" />      
      <id>tag:codeigniter.com,2012:forums/viewthread/.210825</id>
      <published>2012-02-10T22:09:30Z</published>
      <updated>0</updated>
      <author><name>Kyle Johnson</name></author>
      <content type="html">
      <![CDATA[
        <p>Hi everyone,</p>

<p>I&#8217;m hoping someone else can verify this, I&#8217;m not sure if there are confounding factors or not because the query I was running it with was pretty complicated (like 30 joins&#8230; ewww)</p>

<p>However, In trying to figure out what was causing the issue, I finally stumbled upon one of the SELECT columns was causing it.&nbsp; I did a binary search, and just kept cutting it in half until I found the troubled area.</p>

<p>Turns out the cause was a &#8216;smalldatetime&#8217; column.&nbsp; I deleted it, and the query worked and the page displayed.&nbsp; Magic, right?</p>

<p>Well to go a step further, since I&#8217;m just on a test database, I changed the column type to datetime on SQL Server, and put it back in the query.&nbsp; It worked again, so I changed it back. Broken.</p>

<p>I&#8217;m running Ubuntu 10.04 with Apache 2.2.14 PHP 5.3.2-1ubuntu4.13, mssql. I tried with and without eaccelerator (on a second identical ubuntu box [did a fresh install to make sure I wasn&#8217;t crazy]).&nbsp; The database is MS SQL Server 2008 R2.</p>

<p>I&#8217;m not sure if this is a driver bug, mssql(sybase?) driver bug, or just something else.&nbsp; I&#8217;m not sure where to begin with blank pages, because the actual log says the page is being output correctly, the database analyzer says the query completes successfully&#8230;&nbsp; It&#8217;s just bizarre.</p>
      ]]>
      </content>
    </entry>

    <entry>
      <title>function help [solved]</title>
      <link rel="alternate" type="text/html" href="http://codeigniter.com/forums/viewthread/210824/" />      
      <id>tag:codeigniter.com,2012:forums/viewthread/.210824</id>
      <published>2012-02-10T22:07:25Z</published>
      <updated>2012-02-10T22:25:14Z</updated>
      <author><name>superfake123</name></author>
      <content type="html">
      <![CDATA[
        <p>Hello,</p>

<p>How/where can I put this function so that I can access it from within any controller/model or view etc?</p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">get_setting</span><span style="color: #007700">(</span><span style="color: #0000BB">$setting</span><span style="color: #007700">)<br /></span><span style="color: #0000BB">&#123;<br />&nbsp;$query&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">where</span><span style="color: #007700">(</span><span style="color: #DD0000">'setting_name'</span><span style="color: #007700">,</span><span style="color: #0000BB">$setting</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">get</span><span style="color: #007700">(</span><span style="color: #DD0000">'settings'</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">row</span><span style="color: #007700">();<br />&nbsp;return&nbsp;</span><span style="color: #0000BB">$query</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">value</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">&#125;&nbsp;</span>
</span>
</code></div>

<p>I tried putting it in a helper but the db class doesn&#8217;t work from helpers I guess?</p>

<p><br />
Thanks!</p>
      ]]>
      </content>
    </entry>

    <entry>
      <title>public var in extended core class not visible in controller</title>
      <link rel="alternate" type="text/html" href="http://codeigniter.com/forums/viewthread/210820/" />      
      <id>tag:codeigniter.com,2012:forums/viewthread/.210820</id>
      <published>2012-02-10T21:00:38Z</published>
      <updated>2012-02-10T21:09:48Z</updated>
      <author><name>potion</name></author>
      <content type="html">
      <![CDATA[
        <p>Why can&#8217;t my controller see the public var?</p>

<p>application/core/MY_Controller.php</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">MY_Controller&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #0000BB">CI_Controller<br />&#123;<br />&nbsp;</span><span style="color: #007700">public&nbsp;</span><span style="color: #0000BB">$template_data&nbsp;</span><span style="color: #007700">=&nbsp;array();<br /><br />&nbsp;function&nbsp;</span><span style="color: #0000BB">construct</span><span style="color: #007700">()<br />&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;parent</span><span style="color: #007700">::</span><span style="color: #0000BB">__construct</span><span style="color: #007700">();<br />&nbsp;&nbsp;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">template_data&#91;</span><span style="color: #DD0000">'page_title'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'My&nbsp;Site'</span><span style="color: #007700">;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">template_data&#91;</span><span style="color: #DD0000">'stylesheets'</span><span style="color: #0000BB">&#93;&#91;&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'css/styles.css'</span><span style="color: #007700">;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">template_data&#91;</span><span style="color: #DD0000">'javascripts'</span><span style="color: #0000BB">&#93;&#91;&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'js/functions.js'</span><span style="color: #007700">;&nbsp;<br />&nbsp;</span><span style="color: #0000BB">&#125;<br /><br />&#125;&nbsp;</span>
</span>
</code></div>

<p>application/controllers/home.php</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">Home&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #0000BB">MY_Controller<br />&#123;<br />&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">index</span><span style="color: #007700">()<br />&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">template_data&#91;</span><span style="color: #DD0000">'page_title'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">.=&nbsp;</span><span style="color: #DD0000">"&nbsp;-&nbsp;Home"</span><span style="color: #007700">;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">template_data&#91;</span><span style="color: #DD0000">'body_id'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"body_home"</span><span style="color: #007700">;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$content_data&#91;</span><span style="color: #DD0000">'some_var'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'some&nbsp;data&nbsp;for&nbsp;the&nbsp;content&nbsp;view'</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Render&nbsp;View<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">template_data&#91;</span><span style="color: #DD0000">'header_view'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">load</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">view</span><span style="color: #007700">(&nbsp;</span><span style="color: #DD0000">'header_view'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">''</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">true&nbsp;</span><span style="color: #007700">);<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">template_data&#91;</span><span style="color: #DD0000">'content_view'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">load</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">view</span><span style="color: #007700">(&nbsp;</span><span style="color: #DD0000">'home/content'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$content_data</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">true&nbsp;</span><span style="color: #007700">);<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">template_data&#91;</span><span style="color: #DD0000">'footer_view'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">load</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">view</span><span style="color: #007700">(&nbsp;</span><span style="color: #DD0000">'footer_view'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">''</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">true&nbsp;</span><span style="color: #007700">);<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">load</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">view</span><span style="color: #007700">(&nbsp;</span><span style="color: #DD0000">'page_template_home'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">template_data&nbsp;</span><span style="color: #007700">);<br />&nbsp;</span><span style="color: #0000BB">&#125;<br />&nbsp;<br />&#125;&nbsp;</span>
</span>
</code></div>

<p>When I run it I get a PHP error:</p><blockquote><p>A PHP Error was encountered<br />
Severity: Notice<br />
Message: Undefined index: page_title<br />
Filename: controllers/home.php<br />
Line Number: 6</p>
</blockquote>

<p>info: I&#8217;m updating from CI 1.6.3 to 2.1.0  -&nbsp; In 1.6.3 MY_Controller was an extension to Controller and resided in application/libraries - In 2.1.0 MY_Controller is an extension to CI_Controller and resides in application/core - I can&#8217;t spot my faux pas&#8230;&nbsp; please verify.</p>

<p>Denis</p>

<p>&nbsp;</p>
      ]]>
      </content>
    </entry>

    <entry>
      <title>Routing Question(s)</title>
      <link rel="alternate" type="text/html" href="http://codeigniter.com/forums/viewthread/210819/" />      
      <id>tag:codeigniter.com,2012:forums/viewthread/.210819</id>
      <published>2012-02-10T21:00:03Z</published>
      <updated>0</updated>
      <author><name>drakeonfire</name></author>
      <content type="html">
      <![CDATA[
        <p>Hello,</p>

<p>I&#8217;ve been pondering how to do some routing for a rather large system, and wanted to try and keep it as minimal as possible.</p>

<p>So, I was hoping that you may be able to answer some of my questions.</p>

<p>1) I noticed someone using code like this on the forum in a route, is this right and can anyone explain more? From what I understand it means you don&#8217;t have to do each one seperately.</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">$route&#91;</span><span style="color: #DD0000">'(home/contact/about)'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'main/$1'</span><span style="color: #007700">;&nbsp;</span>
</span>
</code></div>

<p>2) If the system I&#8217;m building is built off of a CMS, and the user adds pages etc, most of the page urls are not going to be known, but need to be at the root &#8216;url&#8217;, e.g. example.com/my_new_page</p>

<p>How can I effectively direct that to the correct page, when there&#8217;s also going to be things like categories, sub categories, products etc (categories would be at the root, e.g. example.com/fruit)</p>

<p>As from what I can tell, I can&#8217;t use a simple :any or reg xp to do it, as I&#8217;m not going to know if it&#8217;s a page or a category!?</p>

<p><br />
That&#8217;s all for now ... Thank you.</p>
      ]]>
      </content>
    </entry>

    <entry>
      <title>CodeIgniter Developer</title>
      <link rel="alternate" type="text/html" href="http://codeigniter.com/forums/viewthread/210817/" />      
      <id>tag:codeigniter.com,2012:forums/viewthread/.210817</id>
      <published>2012-02-10T20:40:01Z</published>
      <updated>0</updated>
      <author><name>kwaight</name></author>
      <content type="html">
      <![CDATA[
        <p>We are looking for a CodeIgniter Developer.&nbsp; This position is full time, and will exist indefinitely.&nbsp; The position for &#8220;Developer I&#8221; at $40,000 - $60,000 a year requires a high level understanding of CodeIgniter.&nbsp; Remote work is preferred.&nbsp; English skills are extremely important.&nbsp; </p>

<p>Thanks,<br />
Appealing Studio</p>
      ]]>
      </content>
    </entry>

    <entry>
      <title>When to Build your own Library &#63;</title>
      <link rel="alternate" type="text/html" href="http://codeigniter.com/forums/viewthread/210814/" />      
      <id>tag:codeigniter.com,2012:forums/viewthread/.210814</id>
      <published>2012-02-10T20:12:54Z</published>
      <updated>0</updated>
      <author><name>vincej</name></author>
      <content type="html">
      <![CDATA[
        <p>I&#8217;m building an order processing system - it needs to send automated emails from 5 different locations in the app. The part of me that wants to do things &#8216;correctly&#8217; says I should be extending the email class to accept parameters from the 5 locations and to store an extended email class into a library. </p>

<p>I have read the user guide thoroughly on Libraries. Given I have never done this before there is a clear learning overhead.&nbsp;  I don&#8217;t really understand how best to pass parameters from multiple sources into 1 instance of &#8216;sendmail()&#8217;</p>

<p>The other part of me says to heck with it. I will just place &#8216;sendmail()&#8217; into my controllers 5 times and update the parameters in each ... easy. </p>

<p>What is the best practice ?? Where si the dividing line when good programmers go &#8216;easy&#8217; or &#8216;hard&#8217; ? </p>

<p>I guess if there was a great tuorial with examples that would make things easier too - as the user guide is limited. </p>

<p>If there are any resources I shoud look at or ideas - as ever I am Very Gratefull ! </p>



<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>
      ]]>
      </content>
    </entry>

    <entry>
      <title>pagination help</title>
      <link rel="alternate" type="text/html" href="http://codeigniter.com/forums/viewthread/210810/" />      
      <id>tag:codeigniter.com,2012:forums/viewthread/.210810</id>
      <published>2012-02-10T19:32:58Z</published>
      <updated>2012-02-10T19:33:43Z</updated>
      <author><name>dadamssg</name></author>
      <content type="html">
      <![CDATA[
        <p>i&#8217;m not understanding how the pagination library works at all. </p>

<p>Here&#8217;s the simple controller and model functions i&#8217;m trying to use. The links seems to produce the offset i need to use in my query rather than the actual page number. I&#8217;m confused&#8230;.</p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">public&nbsp;function&nbsp;</span><span style="color: #0000BB">booking_list</span><span style="color: #007700">()<br /></span><span style="color: #0000BB">&#123;&nbsp;&nbsp;<br />&nbsp;&nbsp;$page&nbsp;</span><span style="color: #007700">=&nbsp;(int)&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">uri</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">segment</span><span style="color: #007700">(</span><span style="color: #0000BB">3</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$count&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">book_model</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">count_upcoming</span><span style="color: #007700">(</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">session</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">userdata</span><span style="color: #007700">(</span><span style="color: #DD0000">'username'</span><span style="color: #007700">));<br />&nbsp;&nbsp;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$config&#91;</span><span style="color: #DD0000">'base_url'</span><span style="color: #0000BB">&#93;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">base_url</span><span style="color: #007700">().</span><span style="color: #DD0000">'listing/booking_list/'</span><span style="color: #007700">;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$config&#91;</span><span style="color: #DD0000">'total_rows'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$count</span><span style="color: #007700">;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$config&#91;</span><span style="color: #DD0000">'per_page'</span><span style="color: #0000BB">&#93;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$bookings&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">book_model</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">upcoming</span><span style="color: #007700">(</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">session</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">userdata</span><span style="color: #007700">(</span><span style="color: #DD0000">'username'</span><span style="color: #007700">),</span><span style="color: #0000BB">$page</span><span style="color: #007700">,</span><span style="color: #0000BB">$config&#91;</span><span style="color: #DD0000">'per_page'</span><span style="color: #0000BB">&#93;</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"&lt;pre&gt;"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$bookings</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"&lt;/pre&gt;"</span><span style="color: #007700">;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">pagination</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">create_links</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">&#125;<br />?&gt;&nbsp;</span>
</span>
</code></div>

<p>book_model functions</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">count_upcoming</span><span style="color: #007700">(</span><span style="color: #0000BB">$username</span><span style="color: #007700">)<br />&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;$today&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">"Y-m-d"</span><span style="color: #007700">);<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$query&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">"SELECT&nbsp;id&nbsp;FROM&nbsp;Bookings&nbsp;WHERE&nbsp;DATE(last_night)&nbsp;&gt;=&nbsp;'</span><span style="color: #0000BB">$today</span><span style="color: #DD0000">'&nbsp;AND&nbsp;username&nbsp;=&nbsp;'</span><span style="color: #0000BB">$username</span><span style="color: #DD0000">'&nbsp;AND&nbsp;deleted&nbsp;=&nbsp;'0000-00-00&nbsp;00:00:00'&nbsp;AND&nbsp;unavailable&nbsp;=&nbsp;'0'"</span><span style="color: #007700">);<br />&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">$query</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">num_rows</span><span style="color: #007700">();<br />&nbsp;</span><span style="color: #0000BB">&#125;<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">upcoming</span><span style="color: #007700">(</span><span style="color: #0000BB">$username</span><span style="color: #007700">,</span><span style="color: #0000BB">$page&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,</span><span style="color: #0000BB">$per_page&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">)<br />&nbsp;</span><span style="color: #0000BB">&#123;&nbsp;&nbsp;<br />&nbsp;&nbsp;$offset&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$page&nbsp;</span><span style="color: #007700">*&nbsp;</span><span style="color: #0000BB">$per_page</span><span style="color: #007700">;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$today&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">"Y-m-d"</span><span style="color: #007700">);<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$query&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">"SELECT&nbsp;*&nbsp;FROM&nbsp;Bookings&nbsp;WHERE&nbsp;DATE(last_night)&nbsp;&gt;=&nbsp;'</span><span style="color: #0000BB">$today</span><span style="color: #DD0000">'&nbsp;AND&nbsp;username&nbsp;=&nbsp;'</span><span style="color: #0000BB">$username</span><span style="color: #DD0000">'&nbsp;AND&nbsp;deleted&nbsp;=&nbsp;'0000-00-00&nbsp;00:00:00'&nbsp;AND&nbsp;unavailable&nbsp;=&nbsp;'0'&nbsp;ORDER&nbsp;BY&nbsp;last_night&nbsp;ASC&nbsp;LIMIT&nbsp;</span><span style="color: #0000BB">$offset</span><span style="color: #DD0000">,&nbsp;</span><span style="color: #0000BB">$per_page</span><span style="color: #DD0000">"</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;if(</span><span style="color: #0000BB">$query</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">num_rows</span><span style="color: #007700">()&nbsp;&gt;&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">)<br />&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">foreach&nbsp;(</span><span style="color: #0000BB">$query</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">result</span><span style="color: #007700">()&nbsp;as&nbsp;</span><span style="color: #0000BB">$row</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;$bookings&#91;$row</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">id&#93;&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'id'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$row</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">id</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'check_in'&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$row</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">check_in</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'last_night'&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$row</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">last_night</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'unit'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$row</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">unit</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'guest'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$row</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">guest</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'unavailable'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$row</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">unavailable</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'pending'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$row</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">pending</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'hash'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$row</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">hash</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'created'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$row</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">created</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#125;<br />&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">return&nbsp;</span><span style="color: #0000BB">$bookings</span><span style="color: #007700">;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">&#125;<br />&nbsp;&#125;&nbsp;<br />?&gt;&nbsp;</span>
</span>
</code></div>
      ]]>
      </content>
    </entry>

    <entry>
      <title>Uploader.php function _file_mime_type fails in CI 2.1</title>
      <link rel="alternate" type="text/html" href="http://codeigniter.com/forums/viewthread/210809/" />      
      <id>tag:codeigniter.com,2012:forums/viewthread/.210809</id>
      <published>2012-02-10T19:16:01Z</published>
      <updated>0</updated>
      <author><name>ksorbo</name></author>
      <content type="html">
      <![CDATA[
        <p>There has been quite a bit of discussion in the code forum about problems uploading files (invalid file type). I have read all of them and nothing they did solved my problems.</p>

<p>I think I have found a problem (on my system, at least). I believe the problem lies with the use of the deprecated mime_content_type php function.</p>

<p>From upload.php CI version 2.1 lines 1019 - 1068</p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">protected&nbsp;function&nbsp;</span><span style="color: #0000BB">_file_mime_type</span><span style="color: #007700">(</span><span style="color: #0000BB">$file</span><span style="color: #007700">)<br />&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Use&nbsp;if&nbsp;the&nbsp;Fileinfo&nbsp;extension,&nbsp;if&nbsp;available&nbsp;(only&nbsp;versions&nbsp;above&nbsp;5.3&nbsp;support&nbsp;the&nbsp;FILEINFO_MIME_TYPE&nbsp;flag)<br />&nbsp;&nbsp;</span><span style="color: #007700">if&nbsp;(&nbsp;(float)&nbsp;</span><span style="color: #0000BB">substr</span><span style="color: #007700">(</span><span style="color: #0000BB">phpversion</span><span style="color: #007700">(),&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">3</span><span style="color: #007700">)&nbsp;&gt;=&nbsp;</span><span style="color: #0000BB">5.3&nbsp;</span><span style="color: #007700">&amp;&amp;&nbsp;</span><span style="color: #0000BB">function_exists</span><span style="color: #007700">(</span><span style="color: #DD0000">'finfo_file'</span><span style="color: #007700">))<br />&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;&nbsp;$finfo&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">finfo</span><span style="color: #007700">(</span><span style="color: #0000BB">FILEINFO_MIME_TYPE</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">$finfo&nbsp;</span><span style="color: #007700">!==&nbsp;</span><span style="color: #0000BB">FALSE</span><span style="color: #007700">)&nbsp;</span><span style="color: #FF8000">//&nbsp;This&nbsp;is&nbsp;possible,&nbsp;if&nbsp;there&nbsp;is&nbsp;no&nbsp;magic&nbsp;MIME&nbsp;database&nbsp;file&nbsp;found&nbsp;on&nbsp;the&nbsp;system<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;$file_type&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$finfo</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">file&#40;$file&#91;</span><span style="color: #DD0000">'tmp_name'</span><span style="color: #0000BB">&#93;&#41;</span><span style="color: #007700">;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">/*&nbsp;According&nbsp;to&nbsp;the&nbsp;comments&nbsp;section&nbsp;of&nbsp;the&nbsp;PHP&nbsp;manual&nbsp;page,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;it&nbsp;is&nbsp;possible&nbsp;that&nbsp;this&nbsp;function&nbsp;returns&nbsp;an&nbsp;empty&nbsp;string<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;for&nbsp;some&nbsp;files&nbsp;(e.g.&nbsp;if&nbsp;they&nbsp;don't&nbsp;exist&nbsp;in&nbsp;the&nbsp;magic&nbsp;MIME&nbsp;database)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">if&nbsp;(</span><span style="color: #0000BB">strlen</span><span style="color: #007700">(</span><span style="color: #0000BB">$file_type</span><span style="color: #007700">)&nbsp;&gt;&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">file_type&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$file_type</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#125;<br />&nbsp;&nbsp;&nbsp;&#125;<br />&nbsp;&nbsp;&#125;<br /><br />&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Fall&nbsp;back&nbsp;to&nbsp;the&nbsp;deprecated&nbsp;mime_content_type(),&nbsp;if&nbsp;available<br />&nbsp;&nbsp;</span><span style="color: #007700">if&nbsp;(</span><span style="color: #0000BB">function_exists</span><span style="color: #007700">(</span><span style="color: #DD0000">'mime_content_type'</span><span style="color: #007700">))<br />&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;&nbsp;$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">file_type&nbsp;</span><span style="color: #007700">=&nbsp;@</span><span style="color: #0000BB">mime_content_type</span><span style="color: #007700">(</span><span style="color: #0000BB">$file&#91;</span><span style="color: #DD0000">'tmp_name'</span><span style="color: #0000BB">&#93;</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;return;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">&#125;<br /><br />&nbsp;&nbsp;</span><span style="color: #FF8000">/*&nbsp;This&nbsp;is&nbsp;an&nbsp;ugly&nbsp;hack,&nbsp;but&nbsp;UNIX-type&nbsp;systems&nbsp;provide&nbsp;a&nbsp;native&nbsp;way&nbsp;to&nbsp;detect&nbsp;the&nbsp;file&nbsp;type,<br />&nbsp;&nbsp;&nbsp;*&nbsp;which&nbsp;is&nbsp;still&nbsp;more&nbsp;secure&nbsp;than&nbsp;depending&nbsp;on&nbsp;the&nbsp;value&nbsp;of&nbsp;$_FILES&#91;$field&#93;&#91;'type'&#93;.<br />&nbsp;&nbsp;&nbsp;*<br />&nbsp;&nbsp;&nbsp;*&nbsp;Notes:<br />&nbsp;&nbsp;&nbsp;*&nbsp;-&nbsp;a&nbsp;'W'&nbsp;in&nbsp;the&nbsp;substr()&nbsp;expression&nbsp;bellow,&nbsp;would&nbsp;mean&nbsp;that&nbsp;we're&nbsp;using&nbsp;Windows<br />&nbsp;&nbsp;&nbsp;*&nbsp;-&nbsp;many&nbsp;system&nbsp;admins&nbsp;would&nbsp;disable&nbsp;the&nbsp;exec&#40;&#41;&nbsp;function&nbsp;due&nbsp;to&nbsp;security&nbsp;concerns,&nbsp;hence&nbsp;the&nbsp;function_exists()&nbsp;check<br />&nbsp;&nbsp;&nbsp;*/<br />&nbsp;&nbsp;</span><span style="color: #007700">if&nbsp;(</span><span style="color: #0000BB">DIRECTORY_SEPARATOR&nbsp;</span><span style="color: #007700">!==&nbsp;</span><span style="color: #DD0000">'\\'&nbsp;</span><span style="color: #007700">&amp;&amp;&nbsp;</span><span style="color: #0000BB">function_exists</span><span style="color: #007700">(</span><span style="color: #DD0000">'exec'</span><span style="color: #007700">))<br />&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;&nbsp;$output&nbsp;</span><span style="color: #007700">=&nbsp;array();<br />&nbsp;&nbsp;&nbsp;@</span><span style="color: #0000BB">exec&#40;</span><span style="color: #DD0000">'file&nbsp;--brief&nbsp;--mime-type&nbsp;'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">escapeshellarg</span><span style="color: #007700">(</span><span style="color: #0000BB">$file&#91;</span><span style="color: #DD0000">'tmp_path'</span><span style="color: #0000BB">&#93;&#41;</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$output</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$return_code</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">$return_code&nbsp;</span><span style="color: #007700">===&nbsp;</span><span style="color: #0000BB">0&nbsp;</span><span style="color: #007700">&amp;&amp;&nbsp;</span><span style="color: #0000BB">strlen</span><span style="color: #007700">(</span><span style="color: #0000BB">$output&#91;0&#93;</span><span style="color: #007700">)&nbsp;&gt;&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">)&nbsp;</span><span style="color: #FF8000">//&nbsp;A&nbsp;return&nbsp;status&nbsp;code&nbsp;!=&nbsp;0&nbsp;would&nbsp;mean&nbsp;failed&nbsp;execution<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">file_type&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">rtrim</span><span style="color: #007700">(</span><span style="color: #0000BB">$output&#91;0&#93;</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;return;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#125;<br />&nbsp;&nbsp;&#125;<br /><br />&nbsp;&nbsp;$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">file_type&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$file&#91;</span><span style="color: #DD0000">'type'</span><span style="color: #0000BB">&#93;</span><span style="color: #007700">;<br />&nbsp;</span><span style="color: #0000BB">&#125;&nbsp;</span>
</span>
</code></div>

<p>I am running php 5.2.17 so the first IF (line 1022) fails. mime_content_type exists in 5.2.17 so the second if (line 1042) executes. $this-&gt;file_type is set using the mime_content_type function.</p>

<p>My server passes a random file name for the &#8216;tmp_name&#8217; with no file extension. I am uploading docx files and my browser passes the correct mime type. However, the mime_content_type function returns plain text mime type. This causes the entire upload function to fail.</p>

<p><b>My solution: revert to upload.php from 2.0.1.</b></p>

<p>I don&#8217;t know what the best way would be to detect mime type. The danger of using the browser&#8217;s data is that it could be hacked allowing the user to upload potentially dangerous files.</p>

<p>Obviously this problem goes away if you are using 5.3+. Unfortunately, I had a hard enough time getting my host to move from 4.+ to 5.+ so I am not holding my breath.</p>

<p>&nbsp;</p>
      ]]>
      </content>
    </entry>


</feed>
