<?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; Programming</title>
	<atom:link href="http://blog.danigunawan.com/category/programming/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>IF Construct in One Line Using PHP</title>
		<link>http://blog.danigunawan.com/programming/if-construct-in-one-line-using-php/</link>
		<comments>http://blog.danigunawan.com/programming/if-construct-in-one-line-using-php/#comments</comments>
		<pubDate>Mon, 14 Sep 2009 03:49:49 +0000</pubDate>
		<dc:creator>Dagu</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Condition]]></category>
		<category><![CDATA[Construct]]></category>
		<category><![CDATA[If]]></category>
		<category><![CDATA[Script]]></category>

		<guid isPermaLink="false">http://blog.danigunawan.com/?p=582</guid>
		<description><![CDATA[The if construct is one of the most important features of many languages, PHP included. It allows for conditional execution of code fragments. PHP features an if structure that is similar to that of C: if (expr) statement The general format of if construct is like shown below: if (expr1) { //  statement if expr [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p>The <em>if</em> construct is one of the most important   features of many languages, PHP included.  It allows for   conditional execution of code fragments.  PHP features an   <em>if</em> structure that is similar to that of C:</p>
<pre>if (expr)
   statement</pre>
<p>The general format of if construct is like shown below:</p>
<pre>if (expr1) {
   //  statement if expr 1 true
} else if (expr2) {
   // statement if expr 2 true
} else {
   // statement if expr 1 and 2 false
}</pre>
<p>You may find useful documentation about<em> </em><a title="if construct" href="http://us3.php.net/manual/en/control-structures.if.php" target="_blank"><em>if</em> construct</a>, <em><a title="else condition" href="http://us3.php.net/manual/en/control-structures.else.php" target="_blank">else</a> </em>and<em> <a title="else if" href="http://us3.php.net/manual/en/control-structures.elseif.php" target="_blank">else if</a> </em>in <a title="control structures" href="http://us3.php.net/manual/en/language.control-structures.php" target="_blank">php.net</a>.</p>
<p>But how if you only need two condition to produce a word or digit, and then save it into a variable or just echo it? You may write it like shown below:</p>
<pre>if ($status = '0')
   echo 'Draft';
else
   echo 'Published';</pre>
<p>In code example above, you need to write four lines. Compare with code shown below:</p>
<pre>echo $status == '0' ? 'Draft' : 'Published';</pre>
<p>The syntax is show below</p>
<pre>echo expr ? 'value if true' : 'value if false';</pre>
<p>You may change echo with variable assignment such as:</p>
<pre>$var = expr ? 'value if true' : 'value if false';</pre>
<p>Easy right? It cuts down four lines into one line only.</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.danigunawan.com/programming/if-construct-in-one-line-using-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Free Adobe Flex Builder 3 Professional for Education</title>
		<link>http://blog.danigunawan.com/programming/free-adobe-flex-builder-3-professional-for-education/</link>
		<comments>http://blog.danigunawan.com/programming/free-adobe-flex-builder-3-professional-for-education/#comments</comments>
		<pubDate>Wed, 09 Sep 2009 22:56:49 +0000</pubDate>
		<dc:creator>Dagu</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Education]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Flex Builder]]></category>

		<guid isPermaLink="false">http://blog.danigunawan.com/?p=576</guid>
		<description><![CDATA[Flex is a highly productive, free open source framework for building and maintaining expressive web applications that deploy consistently on all major browsers, desktops, and operating systems. While Flex applications can be built using only the free open source framework, developers can use Adobe® Flex® Builder™ software to dramatically accelerate development. If you want to [...]
Related posts:<ol>
<li><a href='http://blog.danigunawan.com/web/facebook-addict-a-free-wordpress-theme/' rel='bookmark' title='Facebook Addict, a Free WordPress Theme'>Facebook Addict, a Free WordPress Theme</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div id="attachment_578" class="wp-caption aligncenter" style="width: 270px"><a href="http://blog.danigunawan.com/wp-content/uploads/2009/09/flex3.jpg"><img class="size-full wp-image-578" title="Adobe Flex Builder 3 Professional" src="http://blog.danigunawan.com/wp-content/uploads/2009/09/flex3.jpg" alt="Adobe Flex Builder 3 Professional" width="260" height="58" /></a><p class="wp-caption-text">Adobe Flex Builder 3 Professional</p></div>
<p><strong>Flex </strong>is a highly productive, free open source framework for building and maintaining expressive web applications that deploy consistently on all major browsers, desktops, and operating systems. While Flex applications can be built using only the free open source framework, developers can use <a title="adobe flex" href="http://www.adobe.com/products/flex/" target="_blank">Adobe® Flex® Builder™ software</a> to dramatically accelerate development.</p>
<p>If you want to know more about Flex, you may visit its website <a title="flex" href="http://www.flex.org" target="_blank">flex.org</a>. I won&#8217;t tell you about flex. I just wanna share my experience. As you read before, you may develop Flex application using only the free open source framework. In frankly speaking, you should work hard to develop it from the scratch. If you want the easier way, you need to use Adobe Flex Builder. The problem is, you should pay to use it. Of course, for a great software, we need to pay. It doesn&#8217;t matter if you are a software house or professional that make money from developing application using that software. But if you are a student that need to learn Flex? A student doesn&#8217;t make money but only need to learn.</p>
<p>For student, don&#8217;t worry. Adobe is very kind to student and faculty. They give <strong>Adobe Flex Builder for free</strong>. It sounds great doesn&#8217;t it? Yes. It&#8217;s very great! And I&#8217;m one of the lucky guy who get the Adobe Flex Builder for free.</p>
<p>How to get it? Easy. Remember, you need to be honest. You should be a student or a faculty. Adobe Flex Builder 3 Pro is available for free to all education customers. This includes all students, faculty and staff of eligible education institutions.</p>
<p><strong>Proof of Eligibility</strong><br />
To receive the product, you must upload a valid proof of eligibility to get the serial numbers to activate the product. Valid proofs of eligibility are:</p>
<ol>
<li> a student ID showing current enrollment,</li>
<li> a Faculty ID showing current employment</li>
<li> an employee ID showing current employment, or</li>
<li> a letter on an educational institution letterhead stating that you are either a current student, a current faculty member or a current employee of the institution.</li>
</ol>
<p><strong>Terms and conditions</strong><br />
The education version is only available to education customers and is not meant for distribution to institutions, organizations or people outside the authorized educational institution. For additional information on eligibility, please refer to their <a title="flex faq" href="http://www.adobe.com/products/flex/faq/#section-4" target="_blank">FAQ</a>.</p>
<p>After submitting your proof of eligibility, you need to download the Adobe Flex Builder 3 Professional trial version (60 days). They will check it within two weeks. I suggest you to use your university email address. If you are approved, they will send you a serial number to activate your Flex Builder 3 Professional. Then, you can smile.. :)</p>
<p>OK, what are you waiting for? come on <a title="free ria tools" href="https://freeriatools.adobe.com/flex/" target="_blank">get Adobe Flex Builder 3 Professional for free..</a> :)</p>
<p>Related posts:<ol>
<li><a href='http://blog.danigunawan.com/web/facebook-addict-a-free-wordpress-theme/' rel='bookmark' title='Facebook Addict, a Free WordPress Theme'>Facebook Addict, a Free WordPress Theme</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.danigunawan.com/programming/free-adobe-flex-builder-3-professional-for-education/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How To Install Java in Linux Ubuntu</title>
		<link>http://blog.danigunawan.com/operating-systems/how-to-install-java-in-linux-ubuntu/</link>
		<comments>http://blog.danigunawan.com/operating-systems/how-to-install-java-in-linux-ubuntu/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 04:53:30 +0000</pubDate>
		<dc:creator>Dagu</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Operating Systems]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://blog.danigunawan.com/?p=504</guid>
		<description><![CDATA[Java is one of the most popular programming languages. I learned Java a few years ago. I learned it in Windows OS. Now I need to install it in Ubuntu. Here are the steps: 1) You need to update Ubuntu Repository. Type this command: sudo apt-get update Just wait till your Ubuntu Repository updated. 2) [...]
Related posts:<ol>
<li><a href='http://blog.danigunawan.com/programming/java-mysql-connection/' rel='bookmark' title='Java &amp; MySQL Connection'>Java &amp; MySQL Connection</a></li>
<li><a href='http://blog.danigunawan.com/operating-systems/how-to-create-environment-variables-in-linux/' rel='bookmark' title='How to Create Environment Variables in Linux'>How to Create Environment Variables in Linux</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.danigunawan.com/tag/java/">Java</a> is one of the most popular programming languages. I learned Java a few years ago. I learned it in Windows OS. Now I need to install it in Ubuntu. Here are the steps:</p>
<p><strong>1) You need to update Ubuntu Repository</strong>. Type this command:</p>
<pre>sudo apt-get update</pre>
<p>Just wait till your Ubuntu Repository updated.</p>
<p><strong>2) Now it&#8217;s time to install Java</strong>. If you are developer, you need JDK (Java Development Kit), but if not, you only need JRE (Java Runtime Environment). I will install JDK 6 in my Ubuntu.</p>
<p>for JDK, here is the command:</p>
<pre>sudo apt-get install sun-java6-jdk sun-java6-plugin</pre>
<p>for JRE, here is the command:</p>
<pre>sudo apt-get install sun-java6-jre sun-java6-plugin</pre>
<p><strong>3) After that, run command</strong>:</p>
<pre>sudo update-java-alternatives -s java-6-sun</pre>
<p>Then add the line “<strong>/usr/lib/jvm/java-6-sun</strong>” to the top of <strong>/etc/jvm file</strong>.</p>
<p><strong>4) Check your Java installation using these commands</strong>:</p>
<pre>java -version</pre>
<p>the output:</p>
<pre>java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)</pre>
<p>if you install JDK, check Java compiler using:</p>
<pre>javac -version</pre>
<p>the output:</p>
<pre>javac 1.6.0_03</pre>
<p><strong>5) You&#8217;re done!</strong></p>
<p>Related posts:<ol>
<li><a href='http://blog.danigunawan.com/programming/java-mysql-connection/' rel='bookmark' title='Java &amp; MySQL Connection'>Java &amp; MySQL Connection</a></li>
<li><a href='http://blog.danigunawan.com/operating-systems/how-to-create-environment-variables-in-linux/' rel='bookmark' title='How to Create Environment Variables in Linux'>How to Create Environment Variables in Linux</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.danigunawan.com/operating-systems/how-to-install-java-in-linux-ubuntu/feed/</wfw:commentRss>
		<slash:comments>1</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>
		<item>
		<title>Java &amp; MySQL Connection</title>
		<link>http://blog.danigunawan.com/programming/java-mysql-connection/</link>
		<comments>http://blog.danigunawan.com/programming/java-mysql-connection/#comments</comments>
		<pubDate>Sat, 24 Nov 2007 04:18:00 +0000</pubDate>
		<dc:creator>Dagu</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://blog.danigunawan.com/2007/11/24/koneksi-java-mysql/</guid>
		<description><![CDATA[To connect a Java application with MySQL, we need a driver as interface between Java and MySQL. Driver can be downloaded from the official MySQL website. [ Download MySQL Connector ] Extract downloaded file (file type: *.jar). Copy that file to directory [jre installation]/lib/ext/. Ok, your Java application is ready to connect with MySQL. Testing [...]
Related posts:<ol>
<li><a href='http://blog.danigunawan.com/operating-systems/how-to-install-java-in-linux-ubuntu/' rel='bookmark' title='How To Install Java in Linux Ubuntu'>How To Install Java in Linux Ubuntu</a></li>
<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>
<li><a href='http://blog.danigunawan.com/java/after-oracle-bought-sun/' rel='bookmark' title='After Oracle Bought Sun'>After Oracle Bought Sun</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>To connect a Java application with MySQL, we need a driver as interface between Java and MySQL. Driver can be downloaded from the official MySQL website.</p>
<p><a href="http://dev.mysql.com/downloads/connector/j/3.0.html">[ Download MySQL Connector ]</a></p>
<p>Extract downloaded file (file type: *.jar). Copy that file to directory <span style="font-weight: bold;">[jre installation]/lib/ext/</span>. Ok, your Java application is ready to connect with MySQL.</p>
<p><span id="more-91"></span></p>
<p><strong>Testing</strong><br />
Code below is used to connect between Java and MySQL.<br />
<span style="font-family: courier new;">/*</span><br />
<span style="font-family: courier new;"> * DBConnection.java</span><br />
<span style="font-family: courier new;"> *</span><br />
<span style="font-family: courier new;"> * Created on 29 September 2007, 11:41</span><br />
<span style="font-family: courier new;"> *</span><br />
<span style="font-family: courier new;"> */</span></p>
<p><span style="font-family: courier new;">import java.sql.*;</span></p>
<p><span style="font-family: courier new;">/**</span><br />
<span style="font-family: courier new;"> *</span><br />
<span style="font-family: courier new;"> * @author Dani Gunawan</span><br />
<span style="font-family: courier new;"> */</span><br />
<span style="font-family: courier new;">public class DBConnection {</span><br />
<span style="font-family: courier new;"> </span><br />
<span style="font-family: courier new;"> /** Creates a new instance of DBConnection */</span><br />
<span style="font-family: courier new;"> public DBConnection() {</span><br />
<span style="font-family: courier new;"> }</span><br />
<span style="font-family: courier new;"> </span><br />
<span style="font-family: courier new;"> public Connection connect() {</span><br />
<span style="font-family: courier new;"> Connection conn = null;</span></p>
<p><span style="font-family: courier new;"> try</span><br />
<span style="font-family: courier new;"> {</span><br />
<span style="font-family: courier new;"> String userName = &#8220;root&#8221;;</span><br />
<span style="font-family: courier new;"> String password = &#8220;&#8221;;</span><br />
<span style="font-family: courier new;"> String url = &#8220;jdbc:mysql://blog.danigunawan.com/test&#8221;;</span><br />
<span style="font-family: courier new;"> Class.forName (&#8220;com.mysql.jdbc.Driver&#8221;).newInstance ();</span><br />
<span style="font-family: courier new;"> conn = DriverManager.getConnection (url, userName, password);</span><br />
<span style="font-family: courier new;"> } catch (Exception e) {</span><br />
<span style="font-family: courier new;"> e.printStackTrace();</span><br />
<span style="font-family: courier new;"> conn = null;</span><br />
<span style="font-family: courier new;"> } finally {</span><br />
<span style="font-family: courier new;"> if (conn != null)</span><br />
<span style="font-family: courier new;"> {</span><br />
<span style="font-family: courier new;"> try</span><br />
<span style="font-family: courier new;"> {</span><br />
<span style="font-family: courier new;"> conn.close ();</span><br />
<span style="font-family: courier new;"> }</span><br />
<span style="font-family: courier new;"> catch (Exception ex) { </span><br />
<span style="font-family: courier new;"> ex.printStackTrace();</span><br />
<span style="font-family: courier new;"> }</span><br />
<span style="font-family: courier new;"> }</span><br />
<span style="font-family: courier new;"> }</span><br />
<span style="font-family: courier new;"> </span><br />
<span style="font-family: courier new;"> return conn;</span><br />
<span style="font-family: courier new;"> }</span><br />
<span style="font-family: courier new;">}</span></p>
<p>Code below is used to test the database connection.</p>
<p><span style="font-family: courier new;">/**</span><br />
<span style="font-family: courier new;"> * TesConnection.java</span><br />
<span style="font-family: courier new;"> */</span><br />
<span style="font-family: courier new;">import java.sql.*;</span></p>
<p><span style="font-family: courier new;">public class TesConnection {</span></p>
<p><span style="font-family: courier new;"> public static void main(String args[]) {</span></p>
<p><span style="font-family: courier new;"> Connection dbcon = new DBConnection().connect();</span><br />
<span style="font-family: courier new;"> </span><br />
<span style="font-family: courier new;"> if (dbcon != null) {</span><br />
<span style="font-family: courier new;"> System.out.println(&#8220;Database connection is successfully created&#8221;);</span><br />
<span style="font-family: courier new;"> } else {</span><br />
<span style="font-family: courier new;"> System.out.println(&#8220;Database connection isn&#8217;t successfully created&#8221;);</span><br />
<span style="font-family: courier new;"> }</span><br />
<span style="font-family: courier new;"> }</span></p>
<p><span style="font-family: courier new;">}</span></p>
<p><strong>How to Use Them?</strong><br />
Put those two source in the same directory. Compile DBConnection.java and TesConnection.java respectively.<br />
<span style="font-family: courier new;"><br />
javac DBConnection.java</span><br />
<span style="font-family: courier new;">javac TesConnection.java</span></p>
<p>If you want to compile all of them, use wildcard asterisk (*).</p>
<p><span style="font-family: courier new;">javac *.java</span></p>
<p>Run TesConnection:</p>
<p><span style="font-family: courier new;">java TesConnection</span></p>
<p>If the result:</p>
<p><span style="font-weight: bold;">Database connection is successfully created</span></p>
<p>Then your database is has been connected. But if:</p>
<p><span style="font-weight: bold;">Database connection isn&#8217;t successfully created</span></p>
<p>means your Java application isn&#8217;t connected yet with the database.<br />
Possibility:<br />
- MySQL isn&#8217;t installed yet<br />
- Database hasn&#8217;t been created yet (or maybe wrong database name)<br />
- Wrong database user or password</p>
<p>Both source can be downloaded from link below:</p>
<p><a href="http://danigunawan.com/wp-content/uploads/2008/12/tesdb.zip" target="_blank">[ Download example file ]</a></p>
<p><span style="font-weight: bold;">P.S.: </span><br />
Code had been tested in Windows XP SP 2 Operating System, never been done in other operating systems.</p>
<p>Related posts:<ol>
<li><a href='http://blog.danigunawan.com/operating-systems/how-to-install-java-in-linux-ubuntu/' rel='bookmark' title='How To Install Java in Linux Ubuntu'>How To Install Java in Linux Ubuntu</a></li>
<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>
<li><a href='http://blog.danigunawan.com/java/after-oracle-bought-sun/' rel='bookmark' title='After Oracle Bought Sun'>After Oracle Bought Sun</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.danigunawan.com/programming/java-mysql-connection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Method Overloading</title>
		<link>http://blog.danigunawan.com/programming/method-overloading/</link>
		<comments>http://blog.danigunawan.com/programming/method-overloading/#comments</comments>
		<pubDate>Thu, 15 Nov 2007 01:58:00 +0000</pubDate>
		<dc:creator>Dagu</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Method]]></category>

		<guid isPermaLink="false">http://blog.danigunawan.com/2007/11/15/method-overloading/</guid>
		<description><![CDATA[Method overloading is used to make a few methods (functions) with the SAME NAME and do the SIMILAR TASK. It helps programmer to remember methods which have similar task. For example is multiplication method. The first method needs two arguments and another needs three arguments (similar task, that is multiply two arguments, the different is [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<div style="text-align: justify;font-family:georgia;">Method overloading is used to make a few methods (functions) with the SAME NAME and do the SIMILAR TASK. It helps programmer to remember methods which have similar task. For example is multiplication method. The first method needs two arguments and another needs three arguments (similar task, that is multiply two arguments, the different is amount of the arguments only). If we make that two methods using two different names, it will make redundant method names. For examples, the method name for two arguments multiplication, the name is <strong>multiply1(number1, number2)</strong>. For three arguments multiplication, the name is <strong>multiply2(number1, number2, number3)</strong>. That&#8217;s a trouble! How if there are ten types of multiplication? But, compare if we make the method name <strong>multiply(number1, number2) </strong>and <strong>multiply(number1, number2, number3)</strong>. We only need to remember the amount of arguments from method multiply.</p>
<p>So, how does C++ compiler differentiate those two methods? C++ compiler observes the amount, data type and argument sequence. It&#8217;s clear that the compiler use parameters to differentiate methods which have the same name. Not differentiate them with their return type.</p></div>
<div style="text-align: justify;font-family:georgia;">
<p><span id="more-90"></span></p>
<p>To make method overloading, we need at least one of these three conditions below;</p>
<ul>
<li>have different argument amount</li>
<li>have different argument data type</li>
<li>have different argument sequence</li>
</ul>
<div style="text-align: justify;font-family:georgia;"><strong>Example #1 (different argument amount):</strong></div>
<p>[sourcecode language='cpp']// method multiply with two arguments (number1 dan number2)<br />
int multiply(int number1, int number2) {<br />
   return number1*number2<br />
}[/sourcecode]</p>
<pre>// method multiply with three arguments (number1, number2 dan number3)
int multiply(int number1, int number2, int number3) {
   return number1*number2*number3;
}</pre>
<p>Method multiply above are <strong>VALID </strong>because they have <strong>different argument amount</strong>.</p>
<p><span style="font-weight: bold;">Example #2 (different argument data type):</span></p>
<pre>// method showGrade has a char data type argument
void showGrade(char grade) {
   cout &lt;&lt; "Grade (in letter): " &lt;&lt; grade;
}</pre>
<pre>// method showGrade has a int data type argument
void showGrade(int grade) {
   cout &lt;&lt; "Grade (in number): " &lt;&lt; grade;
}</pre>
<p>Method showGrade above are <strong>VALID </strong>because they have <strong>different data type argument </strong>although they have the same argument amount.</p>
<p><span style="font-weight: bold;">Example #3 (different argument sequence):</span></p>
<pre>// method multiply with data type number1 is int
// and number2 is double
double multiply(int number1, double number2) {
   return number1*number2;
}</pre>
<pre>// method multiply with data type number1 is double
// and number2 is int
double multiply(double number1, int number2) {
   return number1*number2;
}</pre>
<p>Those method above are <strong>VALID </strong>because they have <strong>different argument sequence</strong>. In the first multiply method, number1 has int data type then number2 has double data type. In the second method, number1 has double data type and number2 has int data type.</p>
<p><span style="font-weight: bold;">REMEMBER!!!</span><br />
Frequently mistake done by the programmer is assigning the same amount or sequence argument with the different return type.  It will return <span style="font-weight: bold;">SYNTAX ERROR</span> while compiling it.</p>
<p>Wrong example:</p>
<pre>// return type: int
int countAge(int age) {
   return age + 2;
}</pre>
<pre>// return type: void
void countAge(int age) {
   cout&lt;&lt;"Student age after two years = "&lt;&lt;age+2;
}</pre>
<p><span style="font-weight: bold;">SYNTAX ERROR</span>. Method can&#8217;t be <span style="font-style: italic;">overloaded</span> because they have same argument amount with the same data type.</div>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.danigunawan.com/programming/method-overloading/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASCII</title>
		<link>http://blog.danigunawan.com/programming/ascii/</link>
		<comments>http://blog.danigunawan.com/programming/ascii/#comments</comments>
		<pubDate>Tue, 06 Nov 2007 03:12:00 +0000</pubDate>
		<dc:creator>Dagu</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[ASCII]]></category>

		<guid isPermaLink="false">http://blog.danigunawan.com/2007/11/06/ascii/</guid>
		<description><![CDATA[We heard a lot of times a word about ASCII, but we have no idea about ASCII itself. ASCII stands for American Standard Code for Information Interchange. Based on its name, ASCII is used to exchange information and data communication. ASCII is code number which represent a character. ASCII is used because computers only understand [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p>We heard a lot of times a word about ASCII, but we have no idea about ASCII itself. ASCII stands for <strong>American Standard Code for Information Interchange</strong>. Based on its name, ASCII is used to exchange information and data communication. ASCII is code number which represent a character. ASCII is used because computers only understand numbers.</p>
<div style="text-align: justify;">Following table is ASCII codes (image format). For ASCII table in text can be found in <a href="http://ascii-table.com/ascii.php">http://ascii-table.com/ascii.php</a>.</p>
<p><a href="http://bp3.blogger.com/_K6HMnqCKvoA/Ry_kV8pPQ4I/AAAAAAAAAIY/Z680VhIJ35w/s1600-h/ascii-table-low.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img id="BLOGGER_PHOTO_ID_5129569566305764226" style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp3.blogger.com/_K6HMnqCKvoA/Ry_kV8pPQ4I/AAAAAAAAAIY/Z680VhIJ35w/s400/ascii-table-low.jpg" border="0" alt="" /></a><br />
Source: <a href="http://ascii-table.com">http://ascii-table.com</a>.</div>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.danigunawan.com/programming/ascii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What Do You Need to be a Programmer?</title>
		<link>http://blog.danigunawan.com/programming/what-do-you-need-to-be-a-programmer/</link>
		<comments>http://blog.danigunawan.com/programming/what-do-you-need-to-be-a-programmer/#comments</comments>
		<pubDate>Wed, 24 Oct 2007 03:08:00 +0000</pubDate>
		<dc:creator>Dagu</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Programmer]]></category>

		<guid isPermaLink="false">http://blog.danigunawan.com/2007/10/24/yang-dibutuhkan-untuk-menjadi-programmer/</guid>
		<description><![CDATA[What do you need to be a programmer? Expert in mathematics? Hmm&#8230; not really. Not all mathematics lesson should be known. No need to master Integral or imaginary. But there are a few lesson you should master them. They are logics, binary, hexadecimal. Know all programming languages? Not all programming languages. The important thing is [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p>What do you need to be a programmer?</p>
<p><strong>Expert in mathematics?</strong><br />
Hmm&#8230; not really. Not all mathematics lesson should be known. No need to master Integral or imaginary. But there are a few lesson you should master them. They are logics, binary, hexadecimal.</p>
<p><span style="font-weight: bold;">Know all programming languages?</span><br />
Not all programming languages. The important thing is know the basic programming technique.</p>
<p><span style="font-weight: bold;">Choose a favourite or populer programming language, then memorize all syntax?</span><br />
Are you crazy..? No need to do that!</p>
<p><span style="font-weight: bold;">Know all features of a programming language?Menguasai seluruh fitur sebuah bahasa pemrograman?</span><br />
Ooops&#8230; can you do it?t</p>
<p><span style="font-weight: bold; font-style: italic;">So, what do we need???</span></p>
<ul>
<li>Know algorithm (step-by-step in finishing a problem)</li>
<li style="text-align: justify;">Know logics, such as &#8220;AND&#8221;, &#8220;OR&#8221;, &#8220;NOT&#8221;</li>
<li style="text-align: justify;">Know binary and hexadecimal</li>
<li style="text-align: justify;">Desire to learn programming</li>
<li style="text-align: justify;">Trial and Error</li>
<li style="text-align: justify;">Carefulness</li>
<li style="text-align: justify;">Talent. Some people say that to be a programmer, you need talent. But I say, our talent will  be sharp along with our practice in programming, although we make a simple application only.</li>
</ul>
<div style="text-align: justify;"><strong>PS:</strong></div>
<div style="text-align: justify;">I write them based on my experience to be a programmer. Some points might be in contradiction to your experience.</div>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.danigunawan.com/programming/what-do-you-need-to-be-a-programmer/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

