<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Knowledge Sharing &#187; PHP</title>
	<atom:link href="http://blog.danigunawan.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.danigunawan.com</link>
	<description>"Say it... although a word..."</description>
	<lastBuildDate>Wed, 25 Jan 2012 00:14:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Joomla in the Future</title>
		<link>http://blog.danigunawan.com/cms/joomla-in-the-future/</link>
		<comments>http://blog.danigunawan.com/cms/joomla-in-the-future/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 07:42:56 +0000</pubDate>
		<dc:creator>Dagu</dc:creator>
				<category><![CDATA[CMS]]></category>
		<category><![CDATA[Joomla]]></category>
		<category><![CDATA[Opinion]]></category>
		<category><![CDATA[Future]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.danigunawan.com/?p=606</guid>
		<description><![CDATA[As we know, Joomla is one of the best CMS in the world. It often uses to make websites. You can make a great website fast. You don&#8217;t need to know PHP or HTML to use it. You only need to understand Joomla. I started using Joomla from version 1.13. The Joomla is very great, [...]
Related posts:<ol>
<li><a href='http://blog.danigunawan.com/web/new-release-of-joomla-1-5-12/' rel='bookmark' title='New Release of Joomla 1.5.12'>New Release of Joomla 1.5.12</a></li>
<li><a href='http://blog.danigunawan.com/cms-joomla/joomla-1-5-13-security-release/' rel='bookmark' title='Joomla 1.5.13 Security Release'>Joomla 1.5.13 Security Release</a></li>
<li><a href='http://blog.danigunawan.com/review/joomla-won-best-cms-award-again/' rel='bookmark' title='Joomla! Won &quot;Best CMS Award&quot; (Again)'>Joomla! Won &quot;Best CMS Award&quot; (Again)</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft" title="Joomla logo" src="http://cdn.joomla.org/images/logo.png" alt="" width="235" height="46" />As we know, Joomla is one of the best CMS in the world. It often uses to make websites. You can make a great website fast. You don&#8217;t need to know PHP or HTML to use it. You only need to understand Joomla.</p>
<p>I started using Joomla from version 1.13. The Joomla is very great, although it still has many drawbacks. After that, Joomla changed the core. Joomla released version 1.5, a version that is not compatible with previous version. Yes, that&#8217;s right, it&#8217;s a brand new Joomla. Although it is not backward compatible, but some Joomla 1.13 extensions and templates can run in Joomla1 1.5 by condition you need to turn on system legacy plugin. For Joomla 1.13 lovers, don&#8217;t stay there, move to Joomla 1.5 because Joomla stops the development of version 1.3. They no longer support it.</p>
<p>For web programmer, understanding Joomla is not enough. We need to understand more to extend or build template for Joomla. Now, Joomla releases version 1.6alpha. In general, alpha version is not recommended for production. It&#8217;s only for developer or hobbyist. What&#8217;s new in Joomla 1.6alpha? Take a look at the list below:</p>
<ul>
<li> ACL: access management for global permissions as well as content item specific permissions, variable usergroups, users member of more than one usergroup, permissions are inherited, really fast (it&#8217;s the main feature I expect for a long time ago)</li>
<li> Extendable user profile, profile view in frontend, extendable user parameters</li>
<li> Tableless com_content layouts</li>
<li> Improved com_content modules (mod_articles_archive, mod_articles_latest, mod_articles_popular)</li>
<li> Article linker plugin for editors (Nice!)</li>
<li> New frontend template (atomic)</li>
<li>New backend template (bluestork)</li>
<li> New uploader for media manager</li>
</ul>
<p>Other Joomla 1.6 improvements that existed in alpha 1:</p>
<ul>
<li> Mootools 1.2</li>
<li>Refactored backend</li>
<li> JForm</li>
<li> Nested Categories and category parameters</li>
<li> New views in frontend: categories, category</li>
<li> Lots of small code improvements, almost cut the code size in half while adding to the functionality</li>
<li> PHP 5.2 required, huge performance improvements, partially eaten up by new features =&gt; 1.6 will be faster than 1.5</li>
</ul>
<p><strong>What&#8217;s next?</strong><br />
After alpha 2, the Joomla community can expect a beta release. There are no intentions for a 3rd alpha release. Hmm.. the stable version is coming up! Can&#8217;t wait to try it!</p>
<p>Future improvements will be developed by Joomla Team:</p>
<ul>
<li> Commenting solution is going to be added (At last.. :D)</li>
<li> Additional DB drivers</li>
<li> Lots of small performance/UI/code improvements</li>
</ul>
<p>Great! Hope they will win <a title="vote for joomla " href="http://www.joomla.org/announcements/general-news/5248-vote-for-joomla.html" target="_blank">Best Open Source PHP CMS</a>.</p>
<p>Related posts:<ol>
<li><a href='http://blog.danigunawan.com/web/new-release-of-joomla-1-5-12/' rel='bookmark' title='New Release of Joomla 1.5.12'>New Release of Joomla 1.5.12</a></li>
<li><a href='http://blog.danigunawan.com/cms-joomla/joomla-1-5-13-security-release/' rel='bookmark' title='Joomla 1.5.13 Security Release'>Joomla 1.5.13 Security Release</a></li>
<li><a href='http://blog.danigunawan.com/review/joomla-won-best-cms-award-again/' rel='bookmark' title='Joomla! Won &quot;Best CMS Award&quot; (Again)'>Joomla! Won &quot;Best CMS Award&quot; (Again)</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.danigunawan.com/cms/joomla-in-the-future/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Load PHP Extension</title>
		<link>http://blog.danigunawan.com/programming/load-php-extension/</link>
		<comments>http://blog.danigunawan.com/programming/load-php-extension/#comments</comments>
		<pubDate>Mon, 10 Nov 2008 16:19:10 +0000</pubDate>
		<dc:creator>Dagu</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://blog.danigunawan.com/?p=357</guid>
		<description><![CDATA[A few CMSs need PHP library which is not activated as default. For example, in installation an e-commerce named magento (www.magentocommerce.com), needs a few PHP extensions. Usually, a good CMS checks system requirements before installation begins. Image below is an example for system requirements checking on Magento Installation. We could use phpinfo() function to view [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p>A few CMSs need PHP library which is not activated as default. For example, in installation an e-commerce named magento (<a href="http://www.magentocommerce.com">www.magentocommerce.com</a>), needs a few PHP extensions. Usually, a good CMS checks system requirements before installation begins. Image below is an example for system requirements checking on Magento Installation.</p>
<div id="attachment_358" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.danigunawan.com/wp-content/uploads/2008/11/magento_config.jpg"><img class="size-medium wp-image-358" title="Pengecekan Kebutuhan Sistem di Magento" src="http://blog.danigunawan.com/wp-content/uploads/2008/11/magento_config-300x98.jpg" alt="Pengecekan Kebutuhan Sistem di Magento" width="300" height="98" /></a><p class="wp-caption-text">System Requirement Checking on Magento Commerce</p></div>
<p>We could use phpinfo() function to view which extensions have been loaded. The php.ini file is used to configure it. We could find it in PHP installation directory. If you use XAMPP, PHP configuration can be found in <strong>[XAMPP's Installation directory]/apache/bin</strong>.</p>
<p><span id="more-357"></span></p>
<p>To edit it, simply use a text editor (such as notepad). Find which extension will be activated. For example, in magento case, it needs <strong>curl </strong>and <strong>mcrypt </strong>extensions to be activated. All we need is finding lines that have words <strong>php_curl.dll</strong> and <strong>php_mcrypt.dll</strong> in php.ini. As default, the configuration for those extensions is:</p>
<pre>;extension=php_curl.dll
;extension=php_mcrypt.dll</pre>
<p>To activate them we need to delete semicolon in the first character of those two lines. If we have done, restart apache and check extensions status using phpinfo().</p>
<div id="attachment_359" class="wp-caption aligncenter" style="width: 490px"><a href="http://blog.danigunawan.com/wp-content/uploads/2008/11/phpinfo.jpg"><img class="size-full wp-image-359" title="PHP Info" src="http://blog.danigunawan.com/wp-content/uploads/2008/11/phpinfo.jpg" alt="PHP Info" width="480" height="282" /></a><p class="wp-caption-text">PHP Info</p></div>
<p><strong>Question: why does we delete that semicolon?</strong><br />
In PHP configuration file (you will find the same thing in apache configuration), a semicolon is used to mark that the line after that will not be executed. Because of that, the programmers use it to make comments.</p>
<p><strong>Becareful </strong>if you need to edit configuration file. If you make a mistake, possibly your PHP won&#8217;t work well. Always make a configuration file backup before make changes, in order to make sure it would be easy to restore the configuration file if something wrong happens.</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.danigunawan.com/programming/load-php-extension/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Avoid Direct Download</title>
		<link>http://blog.danigunawan.com/web/avoid-direct-download/</link>
		<comments>http://blog.danigunawan.com/web/avoid-direct-download/#comments</comments>
		<pubDate>Wed, 19 Dec 2007 02:29:00 +0000</pubDate>
		<dc:creator>Dagu</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Download]]></category>

		<guid isPermaLink="false">http://blog.danigunawan.com/2007/12/19/mencegah-direct-download/</guid>
		<description><![CDATA[Case study: We would like to provide pdf files to be downloaded by visitors, but the file location is hidden. Visitors can download file with URL given only. Programming language used is PHP. Analysis: We could make a link directly to the file location. Example: &#60;a href="myebook.pdf"&#62;Download MyEbook&#60;/a&#62; What happen if the link above clicked? [...]
Related posts:<ol>
<li><a href='http://blog.danigunawan.com/database/creating-database-in-mysql/' rel='bookmark' title='Creating Database in MySQL'>Creating Database in MySQL</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><span style="font-weight: bold;">Case study:</span><br />
We would like to provide pdf files to be downloaded by visitors, but the file location is hidden. Visitors can download file with URL given only. Programming language used is PHP.</p>
<p><span style="font-weight: bold;">Analysis:</span><br />
We could make a link directly to the file location. Example:</p>
<pre><span style="font-family: courier new;">&lt;a href="myebook.pdf"&gt;Download MyEbook&lt;/a&gt;</span></pre>
<p>What happen if the link above clicked? It depends to the visitors&#8217; browser. If the plugin to read pdf is installed, then browser will open that file inside browser. But, how if there&#8217;s no pdf reader plugin? Then a save file dialog box appear. We could save that file.</p>
<p>A problem is done if the visitors don&#8217;t have pdf reader plugin. But what about the visitors who have it? Of course the problem is not solved. Another problem is the visitors know the file location,  so it allows the visitors to download the file directly (download it directly by typing/copy paste the URL in the browser, without clicking from link given).</p>
<p><span id="more-92"></span></p>
<p><span style="font-weight: bold;">Solution:</span><br />
We need a bit code (PHP) to solve this problem.</p>
<p>The code to avoid direct download is shown below:</p>
<div class="geshi no php">
<div class="head">$task = $_REQUEST[&#39;task&#39;];</div>
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">switch</span><span class="br0">&#40;</span><span class="re1">$task</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1"> <span class="kw1">case</span> <span class="st0">&#39;download&#39;</span><span class="sy0">:</span></div>
</li>
<li class="li1">
<div class="de1"> <span class="co1">// file location</span></div>
</li>
<li class="li1">
<div class="de1"> <span class="re1">$file_path</span> <span class="sy0">=</span> <span class="st0">&#39;dl/myebook.pdf&#39;</span><span class="sy0">;</span> </div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"> <span class="co1">// function to get file name without path</span></div>
</li>
<li class="li1">
<div class="de1"> <span class="re1">$file_name</span> <span class="sy0">=</span> <span class="kw3">basename</span><span class="br0">&#40;</span><span class="re1">$file_path</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"> <span class="co1">// get file size</span></div>
</li>
<li class="li1">
<div class="de1"> <span class="re1">$fsize</span> <span class="sy0">=</span> <span class="kw3">filesize</span><span class="br0">&#40;</span><span class="re1">$file_path</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"> <span class="co1">// set headers</span></div>
</li>
<li class="li1">
<div class="de1"> <span class="kw3">header</span><span class="br0">&#40;</span><span class="st0">&quot;Pragma: public&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"> <span class="kw3">header</span><span class="br0">&#40;</span><span class="st0">&quot;Expires: 0&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"> <span class="kw3">header</span><span class="br0">&#40;</span><span class="st0">&quot;Cache-Control: must-revalidate, post-check=0, pre-check=0&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"> <span class="kw3">header</span><span class="br0">&#40;</span><span class="st0">&quot;Cache-Control: public&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"> <span class="kw3">header</span><span class="br0">&#40;</span><span class="st0">&quot;Content-Description: File Transfer&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"> <span class="kw3">header</span><span class="br0">&#40;</span><span class="st0">&quot;Content-Type: application/pdf&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"> <span class="kw3">header</span><span class="br0">&#40;</span><span class="st0">&#39;Content-Disposition: attachment; filename=&quot;&#39;</span> <span class="sy0">.</span> <span class="re1">$file_name</span> <span class="sy0">.</span> <span class="st0">&#39;&quot;&#39;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"> <span class="kw3">header</span><span class="br0">&#40;</span><span class="st0">&quot;Content-Transfer-Encoding: binary&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"> <span class="kw3">header</span><span class="br0">&#40;</span><span class="st0">&quot;Content-Length: &quot;</span> <span class="sy0">.</span> <span class="re1">$fsize</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"> <span class="co1">// start downloading from here</span></div>
</li>
<li class="li1">
<div class="de1"> <span class="re1">$file</span> <span class="sy0">=</span> <span class="sy0">@</span><span class="kw3">fopen</span><span class="br0">&#40;</span><span class="re1">$file_path</span><span class="sy0">,</span><span class="st0">&quot;rb&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"> <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re1">$file</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> </div>
</li>
<li class="li1">
<div class="de1">   <span class="kw1">while</span><span class="br0">&#40;</span><span class="sy0">!</span><span class="kw3">feof</span><span class="br0">&#40;</span><span class="re1">$file</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> </div>
</li>
<li class="li1">
<div class="de1">   <span class="kw3">print</span><span class="br0">&#40;</span><span class="kw3">fread</span><span class="br0">&#40;</span><span class="re1">$file</span><span class="sy0">,</span> <span class="nu0">1024</span><span class="sy0">*</span><span class="nu0">8</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span> </div>
</li>
<li class="li1">
<div class="de1">   <span class="kw3">flush</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">     <span class="kw1">if</span> <span class="br0">&#40;</span><span class="kw3">connection_status</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">!=</span><span class="nu0">0</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">         <span class="sy0">@</span><span class="kw3">fclose</span><span class="br0">&#40;</span><span class="re1">$file</span><span class="br0">&#41;</span><span class="sy0">;</span> </div>
</li>
<li class="li1">
<div class="de1">         <span class="kw3">die</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">     <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">   <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">   <span class="sy0">@</span><span class="kw3">fclose</span><span class="br0">&#40;</span><span class="re1">$file</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"> <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"> <span class="kw1">break</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"> <span class="kw2">default</span><span class="sy0">:</span></div>
</li>
<li class="li1">
<div class="de1">   <span class="kw3">echo</span> <span class="st0">&#39;&lt;a href=&quot;dlfile.php?task=download&quot;&gt;Download MyEbook&lt;/a&gt;&#39;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">   <span class="kw1">break</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<p>You need to concern to this line:</p>
<pre><span style="font-family: courier new;">header('Content-Disposition: attachment; filename="myebook.pdf"');</span></pre>
<p>This line forces browser to show save dialog box for &#8220;myebook.pdf&#8221; although there&#8217;s pdf reader plugin in the browser.</p>
<p>To change file type (exe or zip), we need to change Content-Type only. Here are the lists:</p>
<pre><span style="font-family: courier new;">// archives</span>
<span style="font-family: courier new;">application/zip</span></pre>
<pre><span style="font-family: courier new;">// documents</span>
<span style="font-family: courier new;">application/pdf</span>
<span style="font-family: courier new;">application/msword</span>
<span style="font-family: courier new;">application/vnd.ms-excel</span>
<span style="font-family: courier new;">application/vnd.ms-powerpoint</span>
<span style="font-family: courier new;">// executables</span>
<span style="font-family: courier new;">application/octet-stream</span></pre>
<pre><span style="font-family: courier new;">// images</span>
<span style="font-family: courier new;">image/gif</span>
<span style="font-family: courier new;">image/png</span>
<span style="font-family: courier new;">image/jpeg</span><span style="font-family: courier new;">
</span></pre>
<pre><span style="font-family: courier new;">// audio</span>
<span style="font-family: courier new;">audio/mpeg</span>
<span style="font-family: courier new;">audio/x-wav</span></pre>
<pre><span style="font-family: courier new;">// video</span>
<span style="font-family: courier new;">video/mpeg</span>
<span style="font-family: courier new;">video/quicktime</span>
<span style="font-family: courier new;">video/x-msvideo</span></pre>
<p>File starts downloading from the line after this line:</p>
<pre><span style="font-family: courier new;">// start downloading from here</span></pre>
<p>There&#8217;s a question. Why do we need to avoid direct download? The purpose is to check how many times a file has been downloaded. If the visitors are allowed to download files directly, I&#8217;m sure it will be difficult to know how many times a file is downloaded. If you don&#8217;t need to check how many times the visitors download your files, you could use both direct download or indirect download.</p>
<p>Related posts:<ol>
<li><a href='http://blog.danigunawan.com/database/creating-database-in-mysql/' rel='bookmark' title='Creating Database in MySQL'>Creating Database in MySQL</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.danigunawan.com/web/avoid-direct-download/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

