<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Jeffri Hong</title>
	
	<link>http://jeffri.net</link>
	<description> </description>
	<lastBuildDate>Sun, 05 Sep 2010 12:00:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/jeffrinet" /><feedburner:info uri="jeffrinet" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>The Basics to Write a Secure PHP Web Application</title>
		<link>http://feedproxy.google.com/~r/jeffrinet/~3/-Ji5DwpwKpg/</link>
		<comments>http://jeffri.net/2010/09/the-basics-to-write-a-secure-php-web-application/#comments</comments>
		<pubDate>Fri, 03 Sep 2010 07:00:33 +0000</pubDate>
		<dc:creator>keaglez</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://jeffri.net/?p=654</guid>
		<description><![CDATA[Securing your application is the most important things when building an application. This is the basic that every programmer should follow, it&#8217;s a must. However, sometime programmer might forgot the basic, and the more complex your application is, the harder it is to maintain and looking for security holes. While securing your application doesn&#8217;t mean [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjeffri.net%2F2010%2F09%2Fthe-basics-to-write-a-secure-php-web-application%2F">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjeffri.net%2F2010%2F09%2Fthe-basics-to-write-a-secure-php-web-application%2F&amp;source=keaglez&amp;style=normal&amp;service=bit.ly&amp;service_api=R_8412a66499172453880523e0cb1bb28b" height="61" width="50" />
			</a>
		</div><p>Securing your application is the most important things when building an application. This is the basic that every programmer should follow, it&#8217;s a must. However, sometime programmer might forgot the basic, and the more complex your application is, the harder it is to maintain and looking for security holes. While securing your application doesn&#8217;t mean that you will be totally safe from a hack, since there is many factor of why a web can be hacked, but reduce the possibility is always a good practice.</p>
<p><img src="http://jeffri.net/wp-content/uploads/hack-target.jpg" alt="" title="hack-target" width="540" height="200" class="alignnone size-full wp-image-682" /></p>
<p>This article will give you walkthrough on the basics of creating a secured PHP application. I will give some step by step to filtering input, keep your code up to date and standard. I&#8217;ll also give you some good practice I always do.</p>
<p><span id="more-654"></span></p>
<h2>Filtering Input</h2>
<p>A web application is operated by retrieving inputs from user and then decide what to do based of the inputs. Filtering your input is a must to prevent any unwanted code to get executed.</p>
<h3>Making sure the input data type</h3>
<p>This is the most basic you should take care of for filtering. For example if you are retrieving integer type, you will need to make sure you always get an integer. Here is some example of how to make sure you get an integer.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #990000;">is_numeric</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'number'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;You must input a number&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'number'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'number'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;You must input a number&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Mostly, input retrieved will be always have a string data type, so sometime, you will need to convert it to make sure you get a correct data type.</p>
<h3>Validate the string</h3>
<p>If you have a list of string you will be accepting, you will need to make sure you only retrieve this value. Here is some example you can do.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'command'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;edit&quot;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'command'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;add&quot;</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Unknown command&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'command'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;add&quot;</span><span style="color: #339933;">:</span>
    <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;edit&quot;</span><span style="color: #339933;">:</span>
        <span style="color: #666666; font-style: italic;">// some code you will run</span>
        <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">default</span><span style="color: #339933;">:</span>
        <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Unknown command&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/^(edit|add)$/'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'command'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Unknown command&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>I personally like the Regular Expression (<em>regex</em>) solution, since it is simple and need less work when you decide to accept a bunch of other strings. Also when you are accepting a pattern of string, it&#8217;s always good to use <em>regex</em>. Here is some example of basic email and URL filtering.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/^[A-Za-z0-9_.-]@[A-Za-z0-9_.-]\.[A-Za-z0-9]{2,4}$/'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'email'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;You entered invalid email&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/^(http|https):\/\/[A-Za-z0-9_.-]\.[A-Za-z0-9]{2,4}$/'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;You entered invalid url&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Remember that while PHP have two function to execute <em>regex</em>, <a href="http://www.php.net/manual/en/book.regex.php">POSIX Extended</a> and <a href="http://php.net/manual/en/book.pcre.php">PCRE</a>, you must always use the PCRE solution as the other one has deprecated since PHP 5.3.0.</p>
<h3>Escape your string</h3>
<p>You should always escape your string before you insert it to your database. If your server have <em>magic quotes</em> turned on by default, you might be safe from this. But your code shouldn&#8217;t rely on server capabilities, your code should escape the string if the <em>magic quotes</em> is turned off. You also must check the <em>magic quotes</em> configuration to prevent you to escape your string twice.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #990000;">get_magic_quotes_gpc</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #000088;">$name</span> <span style="color: #339933;">=</span> <span style="color: #990000;">addslashes</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>If you are using MySQL database, use <strong>mysql_real_escape_string</strong> instead.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #990000;">get_magic_quotes_gpc</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #000088;">$name</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_real_escape_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Finally, if you don&#8217;t want to accept html string, you can strip it or convert it to html entities.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$no_html</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strip_tags</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'no_html'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// this will strip all html tags</span></pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$no_html</span> <span style="color: #339933;">=</span> <span style="color: #990000;">htmlentities</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'no_html'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// this will convert all html tags to entities</span></pre></td></tr></table></div>

<h3>Wrap it out in a function</h3>
<p>Making your code easier to maintain is one way to secure your application. Wrap it out in a function is a good solution. All you need to do is making sure the retrieved input has filtered in this function. So if you find any vulnerabilities, the first you will look is the function. This should save your time looking for the security holes.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> input_filter<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$input</span><span style="color: #339933;">,</span> <span style="color: #000088;">$type</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span> <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$filtered_input</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$input</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">get_magic_quotes_gpc</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
        <span style="color: #000088;">$filtered_input</span> <span style="color: #339933;">=</span> <span style="color: #990000;">stripslashes</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filtered_input</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$type</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'numeric'</span><span style="color: #339933;">:</span>
            <span style="color: #000088;">$filtered_input</span> <span style="color: #339933;">=</span> <span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filtered_input</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'email'</span><span style="color: #339933;">:</span>
            <span style="color: #000088;">$filtered_input</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/^[A-Za-z0-9_.-]@[A-Za-z0-9_.-]\.[A-Za-z0-9]{2,4}$/'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$filtered_input</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$filtered_input</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'url'</span><span style="color: #339933;">:</span>
            <span style="color: #000088;">$filtered_input</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/^(http|https):\/\/[A-Za-z0-9_.-]\.[A-Za-z0-9]{2,4}$/'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$filtered_input</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$filtered_input</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'html'</span><span style="color: #339933;">:</span>
            <span style="color: #000088;">$filtered_input</span> <span style="color: #339933;">=</span> <span style="color: #990000;">htmlentities</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filtered_input</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #990000;">mysql_real_escape_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filtered_input</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>And the example to use this function.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$number</span> <span style="color: #339933;">=</span> input_filter<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'number'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'numeric'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// it will return 0 if it is not numeric</span>
<span style="color: #000088;">$email</span> <span style="color: #339933;">=</span> input_filter<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'email'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'email'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// it will return empty string if invalid</span>
<span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> input_filter<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// it will return empty string if invalid</span>
<span style="color: #000088;">$no_html</span> <span style="color: #339933;">=</span> input_filter<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'no_html'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'html'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// it will return all html converted to entities</span>
<span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> input_filter<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'string'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// it will simply escape the string</span></pre></td></tr></table></div>

<p>Depends to your preference, you can wrap it to a numbers of separated functions or to a class. But I think wrap it in a function is not bad either if you are creating a simple application and only need a small numbers of filtering.</p>
<h2>Keeping Your Code Up To Date and Standards</h2>
<p>PHP keep growing. If you are writing your application in PHP 4, most likely, it will still working in PHP 5. However, some of them might not work anymore in PHP 6. Some example is the use of deprecated function. The function that deprecated in PHP 5 will still working for backward compability, but using this function is not safe anymore as they can be removed anytime in future.</p>
<p>Make sure you are up to date to the new PHP version. Always look the PHP manual for each function you use. Some time you can find a notice of how to correctly use the function. The user contributed notes is also helpful if you are looking for a solution related to that function.</p>
<h3>Do not rely on register globals</h3>
<p><em>Register globals</em> has been turned off by default and deprecated since PHP 5.3.0. Incorrect use of <em>register globals</em> will make your code vulnerable. Always use <a href="http://www.php.net/manual/en/language.variables.superglobals.php"><em>superglobal</em></a> variable instead.</p>
<p>However, it&#8217;s also a good practice to not use <strong>$_REQUEST</strong> variable if you don&#8217;t need to. This variable contains the content of <strong>$_GET</strong>, <strong>$_POST</strong> and <strong>$_COOKIE</strong>. Using this variable will prevent you to know where the variable came from, it&#8217;s always good to know where your variable came from. For example you would like some inputs came from post or cookie, but using <strong>$_REQUEST</strong>, the user can use get and it still get executed.</p>
<h3>Always define a variable before use it</h3>
<p>You must always define your variable before you use it. In some server, <em>register globals</em> might be turned on, and failing to do so might result in vulnerable codes.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> validate_user<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #000088;">$safe</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$safe</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #666666; font-style: italic;">// some sensitive code</span></pre></td></tr></table></div>

<p>The above code is vulnerable if <em>register globals</em> is turned on. If user run the script by calling <em>user.php?safe=1</em>, the user will always get validated. You can do this instead.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$safe</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> validate_user<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #000088;">$safe</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$safe</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #666666; font-style: italic;">// some sensitive code</span></pre></td></tr></table></div>

<h3>Use strict error reporting in development</h3>
<p>Checking each function you use to find a deprecated function is not fun. So in development environment you must show all PHP errors. You can do this by calling this function on top of your application.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">error_reporting</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">E_ALL</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>This way, you will know if you are using deprecated function. You will also know if there is any undefined variable. This also includes the array in <em>superglobals</em> variable. Making sure to check undefined variable with <strong>isset</strong> before you use it is also a good practice.</p>
<h3>Turn off all error reporting in production</h3>
<p>If your website is ready now, you will need to turn off all error reporting. Showing your error to everyone will not be a good thing, one thing is you will reveal something to your visitor, such as file structure. For example, your main code might not be vulnerable, but some of included codes might be vulnerable if requested directly. Keeping your file structure a secret might give you a better security.</p>
<p>One thing to note, you also shouldn&#8217;t show <strong>mysql_error</strong> value to your visitor. If somehow you don&#8217;t filter the inputs properly and you have a code like this.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT * FROM some_table WHERE some_field='<span style="color: #006699; font-weight: bold;">$field_value</span>'&quot;</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>The code above might look familiar as new programmer tends to use it to check for query error. However, if the <strong>$field_value</strong> variable is not filtered properly and vulnerable to injection, you will show the visitor the error and at the same time, you will reveal that your code is vulnerable. So instead of showing the error, you must log the error instead, this way only you can see the error.</p>
<h2>Conclusion</h2>
<p>So this is the basic you can use to secure your web application properly. Meeting this standard will make your application less vulnerable. Again, it will not guarantee that your application will be perfectly safe, as there is many other factors such as using an outdated web server or using some vulnerable library.</p>
<p>Hopefully, this will be useful for you. Do you also have a technique to write a secure web application? Please share in comment.</p>
<p>Final words, thank you to read this. <img src='http://jeffri.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<p><a href="http://feedads.g.doubleclick.net/~a/JXcqwjBN2-VpuMEhtbA_6tarUcw/0/da"><img src="http://feedads.g.doubleclick.net/~a/JXcqwjBN2-VpuMEhtbA_6tarUcw/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/JXcqwjBN2-VpuMEhtbA_6tarUcw/1/da"><img src="http://feedads.g.doubleclick.net/~a/JXcqwjBN2-VpuMEhtbA_6tarUcw/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/jeffrinet?a=-Ji5DwpwKpg:J154BgghpzE:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/jeffrinet?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/jeffrinet?a=-Ji5DwpwKpg:J154BgghpzE:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/jeffrinet?i=-Ji5DwpwKpg:J154BgghpzE:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/jeffrinet?a=-Ji5DwpwKpg:J154BgghpzE:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/jeffrinet?i=-Ji5DwpwKpg:J154BgghpzE:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/jeffrinet/~4/-Ji5DwpwKpg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://jeffri.net/2010/09/the-basics-to-write-a-secure-php-web-application/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://jeffri.net/2010/09/the-basics-to-write-a-secure-php-web-application/</feedburner:origLink></item>
		<item>
		<title>Best practice to clearing default text with jQuery</title>
		<link>http://feedproxy.google.com/~r/jeffrinet/~3/eIJc6AH0kac/</link>
		<comments>http://jeffri.net/2010/08/best-practice-to-clearing-default-text-with-jquery/#comments</comments>
		<pubDate>Mon, 30 Aug 2010 02:45:00 +0000</pubDate>
		<dc:creator>keaglez</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://jeffri.net/?p=620</guid>
		<description><![CDATA[Having default text that we later removed when retrieving user input is common in today&#8217;s website. Many web developer use this to enhance usability of the website, so user know what to type in what field. There is a lot of way to do this, using both focus and blur event. For example, this is [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjeffri.net%2F2010%2F08%2Fbest-practice-to-clearing-default-text-with-jquery%2F">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjeffri.net%2F2010%2F08%2Fbest-practice-to-clearing-default-text-with-jquery%2F&amp;source=keaglez&amp;style=normal&amp;service=bit.ly&amp;service_api=R_8412a66499172453880523e0cb1bb28b" height="61" width="50" />
			</a>
		</div><p>Having default text that we later removed when retrieving user input is common in today&#8217;s website. Many web developer use this to enhance usability of the website, so user know what to type in what field. There is a lot of way to do this, using both <em>focus</em> and <em>blur</em> event. For example, this is the shortest and easiest way that is commonly used:</p>
<input type="text" id="example-field" name="example-field" value="Your name" onfocus="if (this.value=='Your name') this.value=''" onblur="if (this.value=='') this.value='Your name'" />
&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;example-field&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;example-field&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Your name&quot;</span> <span style="color: #000066;">onfocus</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;if (this.value=='Your name') this.value=''&quot;</span> <span style="color: #000066;">onblur</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;if (this.value=='') this.value='Your name'&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span></pre></td></tr></table></div>

<p>However, this approach will be a pain when you are managing a lot of input fields. You will need to type the default text three times, which can lead to a trivial typo. Also, since we check againts the default value, we will not be able to accept this value. Here is the solution, by using the simplicity and power of jQuery, this is a clean and a better way to do this.</p>
<p><span id="more-620"></span></p>
<input type="text" id="example-field2" name="example-field2" value="Your name" />
<p><script type="text/javascript">
jQuery(document).ready(function($){
	$('#example-field2').focus(example_clean_field).blur(example_reset_field).each(example_populate_field);
	function example_populate_field()
	{
		if ( ! $.data(this, 'default') )
			$.data(this, 'default', $(this).val());	
	}
	function example_clean_field()
	{
		if ( ! $(this).hasClass('hasfocus') )
			$(this).addClass('hasfocus').val('');
	}
	function example_reset_field()
	{
		if ( $(this).val() == '' )
			$(this).removeClass('hasfocus').val($.data(this, 'default'));
	}
});
</script></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">&lt;input type=&quot;text&quot; id=&quot;example-field2&quot; name=&quot;example-field2&quot; value=&quot;Your name&quot; /&gt;
&nbsp;
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
jQuery<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#example-field2'</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">focus</span><span style="color: #009900;">&#40;</span>example_clean_field<span style="color: #009900;">&#41;</span>.<span style="color: #000066;">blur</span><span style="color: #009900;">&#40;</span>example_reset_field<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span>example_populate_field<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">function</span> example_populate_field<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> $.<span style="color: #660066;">data</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'default'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
			$.<span style="color: #660066;">data</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'default'</span><span style="color: #339933;">,</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
	<span style="color: #009900;">&#125;</span>
	<span style="color: #003366; font-weight: bold;">function</span> example_clean_field<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'hasfocus'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'hasfocus'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #003366; font-weight: bold;">function</span> example_reset_field<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">''</span> <span style="color: #009900;">&#41;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'hasfocus'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span>$.<span style="color: #660066;">data</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'default'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>You can see that we define three functions here, one for <em>focus</em> event, one for <em>blur</em> event and the other one to populate the default value. I&#8217;ll briefly explain how they work in short.</p>
<p>We add a callback to each fields with function <strong>example_populate_field</strong>, this function will make use of <a href="http://api.jquery.com/jQuery.data/">jQuery.data</a>, which allow us to attach any data to DOM element. We will iterate to each fields, and store the data in &#8220;default&#8221; key.</p>
<p>Next, we have a <em>focus</em> callback, <strong>example_clean_field</strong>, this function check whether the field has &#8220;hasfocus&#8221; class, if it doesn&#8217;t then we add the class and clear the field. Note that we use the &#8220;hasfocus&#8221; class to determine the state of the field, whether it has been cleared or not.</p>
<p>Lastly, we have <strong>example_reset_field</strong> that we use for <em>blur</em> event. This function will check the current value, when it&#8217;s empty, we remove the &#8220;hasfocus&#8221; class and set the value back to the default.</p>
<p>The usage as shown above is very simple, you just need to select any input or textarea element, and it will work. For example, using this selector below will make this work to all text input and textarea element.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input[type=text], textarea'</span><span style="color: #009900;">&#41;</span> .<span style="color: #000066;">focus</span><span style="color: #009900;">&#40;</span>example_clean_field<span style="color: #009900;">&#41;</span> .<span style="color: #000066;">blur</span><span style="color: #009900;">&#40;</span>example_reset_field<span style="color: #009900;">&#41;</span> .<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span>example_populate_field<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>That&#8217;s all. It&#8217;s simple, clean and it looks like the most elegant solution I can find. <img src='http://jeffri.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Hope that will be useful for you as well. Enjoy.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/KAT3kAfOpwH16GHm6ql1wvfxWfQ/0/da"><img src="http://feedads.g.doubleclick.net/~a/KAT3kAfOpwH16GHm6ql1wvfxWfQ/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/KAT3kAfOpwH16GHm6ql1wvfxWfQ/1/da"><img src="http://feedads.g.doubleclick.net/~a/KAT3kAfOpwH16GHm6ql1wvfxWfQ/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/jeffrinet?a=eIJc6AH0kac:44mCodqiYgg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/jeffrinet?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/jeffrinet?a=eIJc6AH0kac:44mCodqiYgg:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/jeffrinet?i=eIJc6AH0kac:44mCodqiYgg:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/jeffrinet?a=eIJc6AH0kac:44mCodqiYgg:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/jeffrinet?i=eIJc6AH0kac:44mCodqiYgg:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/jeffrinet/~4/eIJc6AH0kac" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://jeffri.net/2010/08/best-practice-to-clearing-default-text-with-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://jeffri.net/2010/08/best-practice-to-clearing-default-text-with-jquery/</feedburner:origLink></item>
		<item>
		<title>Filter get_terms to return only terms with published post</title>
		<link>http://feedproxy.google.com/~r/jeffrinet/~3/vUJ1jZGNu9M/</link>
		<comments>http://jeffri.net/2010/08/filter-get_terms-to-return-only-terms-with-published-post/#comments</comments>
		<pubDate>Sat, 21 Aug 2010 22:37:03 +0000</pubDate>
		<dc:creator>keaglez</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://jeffri.net/?p=609</guid>
		<description><![CDATA[So you are using custom taxonomy. You add terms to the taxonomy, and add the terms to your posts. Then, you use get_terms and list all your terms. Everything works fine, terms that doesn&#8217;t have any posts will not be returned if you set hide_empty argument to true. Now you move some of your posts [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjeffri.net%2F2010%2F08%2Ffilter-get_terms-to-return-only-terms-with-published-post%2F">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjeffri.net%2F2010%2F08%2Ffilter-get_terms-to-return-only-terms-with-published-post%2F&amp;source=keaglez&amp;style=normal&amp;service=bit.ly&amp;service_api=R_8412a66499172453880523e0cb1bb28b" height="61" width="50" />
			</a>
		</div><p>So you are using custom taxonomy. You add terms to the taxonomy, and add the terms to your posts. Then, you use <strong>get_terms</strong> and list all your terms. Everything works fine, terms that doesn&#8217;t have any posts will not be returned if you set <em>hide_empty</em> argument to true. Now you move some of your posts to draft and you get a problem. Terms that doesn&#8217;t have any published posts still returned. This lead to 404 error when you click on the link of this term. It doesn&#8217;t look good now, we need to remove term that doesn&#8217;t have any published post.</p>
<p>So how to do that? The answer is by using WordPress filter. This piece of code below will solve the problem.</p>
<p><span id="more-609"></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> get_terms_filter<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$terms</span><span style="color: #339933;">,</span> <span style="color: #000088;">$taxonomies</span><span style="color: #339933;">,</span> <span style="color: #000088;">$args</span> <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$taxonomy</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$taxonomies</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$terms</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$terms</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$terms</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$filtered_terms</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$terms</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$term</span> <span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_var</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT COUNT(*) FROM <span style="color: #006699; font-weight: bold;">$wpdb-&gt;posts</span> p JOIN <span style="color: #006699; font-weight: bold;">$wpdb-&gt;term_relationships</span> rl ON p.ID = rl.object_id WHERE rl.term_taxonomy_id = <span style="color: #006699; font-weight: bold;">$term-&gt;term_id</span> AND p.post_status = 'publish' LIMIT 1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span>
			<span style="color: #000088;">$filtered_terms</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$term</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$filtered_terms</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'get_terms'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'get_terms_filter'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>The code work like this. We add a filter to the <strong>get_terms</strong> hook. This hook is called before the terms is returned, so it is perfect to place the filter here. Next, we check each returned terms and see if they have any published post, by using our own query. Why didn&#8217;t I use the WordPress WP_Query instead? The answer is I can&#8217;t get it to work, beside, it builds a pretty complicated query that might increase your WordPress site load time if it is used too much. Using our own query, we make sure it only use the query that we need. If our query returned that the term has a published post, we add this term to our new array which we use to store the filtered terms. Finally, we return the filtered terms.</p>
<p>Now, when you are using <strong>get_terms</strong>, you will filter out all terms that doesn&#8217;t have any published post. <img src='http://jeffri.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Hope that helps. I have a hard time to explain the situation, so let me know if it doesn&#8217;t clear.</p>
<p>Thank you.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/uOYdeQTzut0osB38c87LFrvg-nY/0/da"><img src="http://feedads.g.doubleclick.net/~a/uOYdeQTzut0osB38c87LFrvg-nY/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/uOYdeQTzut0osB38c87LFrvg-nY/1/da"><img src="http://feedads.g.doubleclick.net/~a/uOYdeQTzut0osB38c87LFrvg-nY/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/jeffrinet?a=vUJ1jZGNu9M:oGysrzosKdk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/jeffrinet?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/jeffrinet?a=vUJ1jZGNu9M:oGysrzosKdk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/jeffrinet?i=vUJ1jZGNu9M:oGysrzosKdk:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/jeffrinet?a=vUJ1jZGNu9M:oGysrzosKdk:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/jeffrinet?i=vUJ1jZGNu9M:oGysrzosKdk:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/jeffrinet/~4/vUJ1jZGNu9M" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://jeffri.net/2010/08/filter-get_terms-to-return-only-terms-with-published-post/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://jeffri.net/2010/08/filter-get_terms-to-return-only-terms-with-published-post/</feedburner:origLink></item>
		<item>
		<title>Happy Independence Day for Indonesia</title>
		<link>http://feedproxy.google.com/~r/jeffrinet/~3/jfkVMRv9QP0/</link>
		<comments>http://jeffri.net/2010/08/happy-independence-day-for-indonesia/#comments</comments>
		<pubDate>Tue, 17 Aug 2010 03:03:55 +0000</pubDate>
		<dc:creator>keaglez</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jeffri.net/?p=605</guid>
		<description><![CDATA[Happy Independence Day for Indonesia! It has been 65 years since we have freed from colonialism, thanks to the patriots that fight back then. Well, this day remind me to my old school day where we have ceremony. And as usual, Google also celebrate it by changing their logo.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjeffri.net%2F2010%2F08%2Fhappy-independence-day-for-indonesia%2F">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjeffri.net%2F2010%2F08%2Fhappy-independence-day-for-indonesia%2F&amp;source=keaglez&amp;style=normal&amp;service=bit.ly&amp;service_api=R_8412a66499172453880523e0cb1bb28b" height="61" width="50" />
			</a>
		</div><p>Happy Independence Day for Indonesia! It has been 65 years since we have freed from colonialism, thanks to the patriots that fight back then. Well, this day remind me to my old school day where we have ceremony.</p>
<p>And as usual, Google also celebrate it by changing their logo. <img src='http://jeffri.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><img src="http://jeffri.net/wp-content/uploads/google_independence_day.jpg" alt="" title="google_independence_day" width="540" height="250" class="alignnone size-full wp-image-606" /></p>

<p><a href="http://feedads.g.doubleclick.net/~a/LYUe44ekcOd4gCWrN98Ik0y4A1U/0/da"><img src="http://feedads.g.doubleclick.net/~a/LYUe44ekcOd4gCWrN98Ik0y4A1U/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/LYUe44ekcOd4gCWrN98Ik0y4A1U/1/da"><img src="http://feedads.g.doubleclick.net/~a/LYUe44ekcOd4gCWrN98Ik0y4A1U/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/jeffrinet?a=jfkVMRv9QP0:7JeLYlNKWZQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/jeffrinet?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/jeffrinet?a=jfkVMRv9QP0:7JeLYlNKWZQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/jeffrinet?i=jfkVMRv9QP0:7JeLYlNKWZQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/jeffrinet?a=jfkVMRv9QP0:7JeLYlNKWZQ:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/jeffrinet?i=jfkVMRv9QP0:7JeLYlNKWZQ:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/jeffrinet/~4/jfkVMRv9QP0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://jeffri.net/2010/08/happy-independence-day-for-indonesia/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://jeffri.net/2010/08/happy-independence-day-for-indonesia/</feedburner:origLink></item>
		<item>
		<title>CSS Captcha 0.2 beta</title>
		<link>http://feedproxy.google.com/~r/jeffrinet/~3/EtqBXjHv5xg/</link>
		<comments>http://jeffri.net/2010/08/css-captcha-0-2-beta/#comments</comments>
		<pubDate>Sun, 08 Aug 2010 19:48:20 +0000</pubDate>
		<dc:creator>keaglez</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[captcha]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS Captcha]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://jeffri.net/?p=597</guid>
		<description><![CDATA[Here I update the CSS Captcha, it is now on 0.2 beta! Thank you for the response of the previous version. While this can work nicely on major new browser, the compatibility with older browser is still minimum. Some mobile browser also haven&#8217;t implement some of CSS3 functionality, such as Opera Mini and Opera Mobile. [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjeffri.net%2F2010%2F08%2Fcss-captcha-0-2-beta%2F">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjeffri.net%2F2010%2F08%2Fcss-captcha-0-2-beta%2F&amp;source=keaglez&amp;style=normal&amp;service=bit.ly&amp;service_api=R_8412a66499172453880523e0cb1bb28b" height="61" width="50" />
			</a>
		</div><p>Here I update the CSS Captcha, it is now on 0.2 beta! Thank you for the response of the previous version. While this can work nicely on major new browser, the compatibility with older browser is still minimum. Some mobile browser also haven&#8217;t implement some of CSS3 functionality, such as Opera Mini and Opera Mobile. So this is still experimental and shouldn&#8217;t be used yet on production website.</p>
<p><img src="http://jeffri.net/wp-content/uploads/csscaptcha0.2.jpg" alt="" title="csscaptcha0.2" width="540" height="189" class="alignnone size-full wp-image-598" /></p>
<p><a href="http://jeffri.net/2010/06/css-captcha-0-1-beta/">Please read the older version information here</a>.</p>
<p>This update is merely a security update. The inline style is randomized now, which make it more difficult for bot to read. The order of the character is also randomized. Sure, it still doesn&#8217;t prevent the bot to read or make it impossible to read at all, but it should give more difficulty on creating such bot. <img src='http://jeffri.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Still, no support for IE browser at all. <img src='http://jeffri.net/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>Change log 0.2b:<br />
- Automatically randomize inline style<br />
- Automatically randomize character order</p>
<p><a href="http://csscaptcha.keaglez.com">Demonstration</a><br />
<a href="http://csscaptcha.keaglez.com/csscaptcha0.2b.zip">Download</a></p>
<p>Enjoy! Any comment is appreciated.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/BrW2yZunQh4zzeY7ph-Id_M2jTM/0/da"><img src="http://feedads.g.doubleclick.net/~a/BrW2yZunQh4zzeY7ph-Id_M2jTM/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/BrW2yZunQh4zzeY7ph-Id_M2jTM/1/da"><img src="http://feedads.g.doubleclick.net/~a/BrW2yZunQh4zzeY7ph-Id_M2jTM/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/jeffrinet?a=EtqBXjHv5xg:hB5Z-RFSjKY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/jeffrinet?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/jeffrinet?a=EtqBXjHv5xg:hB5Z-RFSjKY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/jeffrinet?i=EtqBXjHv5xg:hB5Z-RFSjKY:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/jeffrinet?a=EtqBXjHv5xg:hB5Z-RFSjKY:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/jeffrinet?i=EtqBXjHv5xg:hB5Z-RFSjKY:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/jeffrinet/~4/EtqBXjHv5xg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://jeffri.net/2010/08/css-captcha-0-2-beta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://jeffri.net/2010/08/css-captcha-0-2-beta/</feedburner:origLink></item>
		<item>
		<title>August promotion, get 25% discount on PSD to XHTML service</title>
		<link>http://feedproxy.google.com/~r/jeffrinet/~3/SuStVjJmwq4/</link>
		<comments>http://jeffri.net/2010/08/august-promotion-get-25-discount-on-psd-to-xhtml-service/#comments</comments>
		<pubDate>Tue, 03 Aug 2010 07:41:29 +0000</pubDate>
		<dc:creator>keaglez</dc:creator>
				<category><![CDATA[Service]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://jeffri.net/?p=593</guid>
		<description><![CDATA[Only on August 2010, you will get 25% discount on my service, which includes: PSD to XHTML and CSS conversion (start at $45) PSD to WordPress conversion (start at $130) PSD to Magento conversion (start at $270) This promotion only apply to new customer and only for the first transaction. To get a free quote, [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjeffri.net%2F2010%2F08%2Faugust-promotion-get-25-discount-on-psd-to-xhtml-service%2F">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjeffri.net%2F2010%2F08%2Faugust-promotion-get-25-discount-on-psd-to-xhtml-service%2F&amp;source=keaglez&amp;style=normal&amp;service=bit.ly&amp;service_api=R_8412a66499172453880523e0cb1bb28b" height="61" width="50" />
			</a>
		</div><p>Only on August 2010, you will get 25% discount on my service, which includes:</p>
<ul>
<li>PSD to XHTML and CSS conversion (start at $45)</li>
<li>PSD to WordPress conversion (start at $130)</li>
<li>PSD to Magento conversion (start at $270)</li>
</ul>
<p>This promotion only apply to new customer and only for the first transaction. <img src='http://jeffri.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>To get a free quote, please <a href="/contact" title="Contact me">contact</a> me with your project detail.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/BQQAczr3AalQgjU6dL5hQn9WGws/0/da"><img src="http://feedads.g.doubleclick.net/~a/BQQAczr3AalQgjU6dL5hQn9WGws/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/BQQAczr3AalQgjU6dL5hQn9WGws/1/da"><img src="http://feedads.g.doubleclick.net/~a/BQQAczr3AalQgjU6dL5hQn9WGws/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/jeffrinet?a=SuStVjJmwq4:FnECSG_oum8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/jeffrinet?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/jeffrinet?a=SuStVjJmwq4:FnECSG_oum8:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/jeffrinet?i=SuStVjJmwq4:FnECSG_oum8:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/jeffrinet?a=SuStVjJmwq4:FnECSG_oum8:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/jeffrinet?i=SuStVjJmwq4:FnECSG_oum8:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/jeffrinet/~4/SuStVjJmwq4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://jeffri.net/2010/08/august-promotion-get-25-discount-on-psd-to-xhtml-service/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://jeffri.net/2010/08/august-promotion-get-25-discount-on-psd-to-xhtml-service/</feedburner:origLink></item>
		<item>
		<title>Farewell to online manga scanlation sites</title>
		<link>http://feedproxy.google.com/~r/jeffrinet/~3/3gkZsHQvn7o/</link>
		<comments>http://jeffri.net/2010/07/farewell-to-online-manga-scanlation-sites/#comments</comments>
		<pubDate>Sun, 25 Jul 2010 21:44:05 +0000</pubDate>
		<dc:creator>keaglez</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[manga]]></category>

		<guid isPermaLink="false">http://jeffri.net/?p=588</guid>
		<description><![CDATA[Few days ago, I was shocked when Manga Toshokan finally taken down the majority of series they host. That means, almost all of the scanlated manga is gone in their site, leaving to manhwa and manhua (Korean and Chinese comic respectively). While I read some manhwa and manhua, it still sad to see all of [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjeffri.net%2F2010%2F07%2Ffarewell-to-online-manga-scanlation-sites%2F">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjeffri.net%2F2010%2F07%2Ffarewell-to-online-manga-scanlation-sites%2F&amp;source=keaglez&amp;style=normal&amp;service=bit.ly&amp;service_api=R_8412a66499172453880523e0cb1bb28b" height="61" width="50" />
			</a>
		</div><p>Few days ago, I was shocked when Manga Toshokan finally taken down the majority of series they host. That means, almost all of the scanlated manga is gone in their site, leaving to manhwa and manhua (Korean and Chinese comic respectively). While I read some manhwa and manhua, it still sad to see all of the manga gone, since Manga Toshokan have a huge collection of manga that I can&#8217;t find anywhere.</p>
<p>That&#8217;s not ended here. One Manga will also close in a week time. One Manga is my favorite online reader site, though the quality is not as good as the one hosted in Manga Toshokan, it is much faster to load. Now they still have a good time updating any manga they had until the closing end. That&#8217;s the final week for them.</p>
<p>Two of the big sites have taken down for now or continue with lesser series, now there is also another big name that likely to follow them. Manga Fox for example. They still have majority of the series now, but the big three (as you might now, the big three is Bleach, One Piece and Naruto) is already taken down. So it seems that&#8217;s only time until the other series follow. <img src='http://jeffri.net/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>Ok, don&#8217;t get me wrong. I love manga, I always read them whenever I have time, I read scanlation manga, and whenever my favorite series published in my country, I buy them. I read both, scanlation and published manga. I love scanlation because they have updated series, so I don&#8217;t need to wait for months before it published in my country just to know the continuation of the story. There is also, many and many awesome manga that&#8217;s not published here, that leaves me with only scanlation manga to read them.</p>
<p>So why did the scanlation sites is taken down? The reason is, recently, US and Japanese publisher are forming a coalition to fight scanlation sites. You can read more on this news on ANN, <a href="http://www.animenewsnetwork.com/news/2010-06-08/u.s-japanese-publishers-unite-against-manga-scan-sites">U.S., Japanese Publishers Unite Against Manga Scan Sites</a>.</p>
<p>Now that it come to this, there should be a solution, for both sides. I know that scanlation is illegal due to copyright issue, but there is a lot of manga that is not available everywhere and not as update as in Japan. I won&#8217;t mind if I have to pay to get a licensed manga to read online, so I hope there is still a way, that we can still read manga online, no matter if it is paid or not.</p>
<p>At least, to the extent we can see now, there is two solution. First is the upcoming <a href="http://www.openmanga.org">Open Manga</a>. The second? Obviously, underground&#8230; IRC or P2P to get the latest scanlation&#8230; lol <img src='http://jeffri.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Hope everything will be well, but, farewell One Manga. It&#8217;s a good year I had with you. I still won&#8217;t said farewell to Manga Toshokan, as I will still open them regularly to check for updated manhwa and manhua. <img src='http://jeffri.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Update:</strong> One Manga has taken down all of their manga, farewell One Manga! Now let&#8217;s see how&#8217;s other sites going.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/jRu4zxJ2XF0Fg9XEGSjSZBTHbYg/0/da"><img src="http://feedads.g.doubleclick.net/~a/jRu4zxJ2XF0Fg9XEGSjSZBTHbYg/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/jRu4zxJ2XF0Fg9XEGSjSZBTHbYg/1/da"><img src="http://feedads.g.doubleclick.net/~a/jRu4zxJ2XF0Fg9XEGSjSZBTHbYg/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/jeffrinet?a=3gkZsHQvn7o:_bReJv7LW_w:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/jeffrinet?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/jeffrinet?a=3gkZsHQvn7o:_bReJv7LW_w:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/jeffrinet?i=3gkZsHQvn7o:_bReJv7LW_w:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/jeffrinet?a=3gkZsHQvn7o:_bReJv7LW_w:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/jeffrinet?i=3gkZsHQvn7o:_bReJv7LW_w:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/jeffrinet/~4/3gkZsHQvn7o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://jeffri.net/2010/07/farewell-to-online-manga-scanlation-sites/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://jeffri.net/2010/07/farewell-to-online-manga-scanlation-sites/</feedburner:origLink></item>
		<item>
		<title>Some useful tips for WordPress custom post type and taxonomy</title>
		<link>http://feedproxy.google.com/~r/jeffrinet/~3/wxOnGR0f2ks/</link>
		<comments>http://jeffri.net/2010/07/some-useful-tips-for-wordpress-custom-post-type-and-taxonomy/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 23:28:08 +0000</pubDate>
		<dc:creator>keaglez</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://jeffri.net/?p=569</guid>
		<description><![CDATA[Custom post type is one of the most powerful WordPress feature. It allows us to create just any content we need, combined with custom taxonomy, the possibility is just endless. WordPress have allowed to have custom post type and taxonomy for some while, but with WordPress 3, everything is far more easier. We have register_post_type [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjeffri.net%2F2010%2F07%2Fsome-useful-tips-for-wordpress-custom-post-type-and-taxonomy%2F">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjeffri.net%2F2010%2F07%2Fsome-useful-tips-for-wordpress-custom-post-type-and-taxonomy%2F&amp;source=keaglez&amp;style=normal&amp;service=bit.ly&amp;service_api=R_8412a66499172453880523e0cb1bb28b" height="61" width="50" />
			</a>
		</div><p>Custom post type is one of the most powerful WordPress feature. It allows us to create just any content we need, combined with custom taxonomy, the possibility is just endless. WordPress have allowed to have custom post type and taxonomy for some while, but with WordPress 3, everything is far more easier. We have <a href="http://codex.wordpress.org/Function_Reference/register_post_type">register_post_type</a> and <a href="http://codex.wordpress.org/Function_Reference/register_taxonomy">register_taxonomy</a> created specifically for this purpose.</p>
<p>While this two combined to be a wonderful addition for your WordPress blog, there is still a lot of things that is not yet documented. Here is a few useful tips I collected when working with custom post type and taxonomy.</p>
<p><span id="more-569"></span></p>
<h2>Add taxonomy to more than one post type</h2>
<p>There is few ways to doing this, depend to your code. If you register the post type first, then when register taxonomy, you&#8217;ll be able to include it to any post types you want.</p>
<p>Example (taken from codex).</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">  register_taxonomy<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'genre'</span><span style="color: #339933;">,</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'book'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'magazine'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'post'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'hierarchical'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'labels'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$labels</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'show_ui'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'query_var'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'rewrite'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'slug'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'genre'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>See the line 1 above, the second parameter for register_taxonomy function is the list of post types you can include. It accept both string and array, as you can expect, we use array when we want to include many post type, and use string when you only need one. The same thing is applied if you register the taxonomy first, you can assign any taxonomy you like when register the post type.</p>
<p>Example (taken from codex)</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">  <span style="color: #000088;">$args</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'labels'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$labels</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'public'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'publicly_queryable'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'show_ui'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span> 
    <span style="color: #0000ff;">'query_var'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'rewrite'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'capability_type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'hierarchical'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'menu_position'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'taxonomies'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'genre'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'grade'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'category'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'supports'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'title'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'editor'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'author'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'thumbnail'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'excerpt'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'comments'</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
  register_post_type<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'book'</span><span style="color: #339933;">,</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>As you can see, the <em>taxonomies</em> parameter can be used to assign any taxonomy you like to the post type you just registered. Again, it accept both array and string.</p>
<p>But what if you want to add taxonomy to certain post type later, after they are defined? WordPress have a function to do this, it is <a href="http://codex.wordpress.org/Function_Reference/register_taxonomy_for_object_type">register_taxonomy_for_object_type</a>. Take a look on the example below.</p>
<p>Example</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">register_taxonomy_for_object_type<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'genre'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'book'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Handy, huh?</p>
<h2>Querying more than one post type</h2>
<p>Let&#8217;s say, for example, you have defined post type for book, comic and magazine. Then, somewhere in your web page, you want to show the latest list of all of these post types together. As you might know already, custom post type is not included in normal WordPress loop, so you&#8217;ll need to add your own query and loop, whether by using query_posts, get_posts or by creating a new instance of WP_Query object.</p>
<p>Example</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$args</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'post_type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'book'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'comic'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'magazine'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'posts_per_page'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">5</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
query_posts<span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span> have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> the_post<span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// and so on</span>
<span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>See the line 2. You can add any post type you need in the <em>post_type</em> parameter. As always, it also accept both array and string.</p>
<h2>Querying the custom taxonomy</h2>
<p>You know how to querying multiple post type now, but how if you want to filter it by taxonomy? While post category and tags offer many ways to filter it, the custom taxonomy is still limited. The only way I can find right now is to filter the taxonomy by the slug.</p>
<p>Example</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$args</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'post_type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'book'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'comic'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'magazine'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'taxonomy'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'genre'</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'term'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'science'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'fiction'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'posts_per_page'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">5</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
query_posts<span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span> have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> the_post<span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// and so on</span>
<span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>From the example above, I filtered the result by including only science and fiction genre from all three post types we defined. Unfortunately, I haven&#8217;t find any way to filter it by multiple taxonomies at once.</p>
<h2>The custom post type feed</h2>
<p>Custom post type also have its own feed. Depend to your permalink structure, you can find it by either</p>
<blockquote><p>http://www.yourwordpresswebsite.com/?feed=rss2&#038;post_type=book</p></blockquote>
<p>or</p>
<blockquote><p>http://www.yourwordpresswebsite.com/feed/?post_type=book</p></blockquote>
<p>Unfortunately, again, I can&#8217;t find any way to get the feed for multiple post type.</p>
<p>So that&#8217;s it for now. If you find any good tips, you can share it in comment. <img src='http://jeffri.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<p><a href="http://feedads.g.doubleclick.net/~a/c01NTuGRuwAuy830G34ON5QhqdA/0/da"><img src="http://feedads.g.doubleclick.net/~a/c01NTuGRuwAuy830G34ON5QhqdA/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/c01NTuGRuwAuy830G34ON5QhqdA/1/da"><img src="http://feedads.g.doubleclick.net/~a/c01NTuGRuwAuy830G34ON5QhqdA/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/jeffrinet?a=wxOnGR0f2ks:3wXg8c7T0I0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/jeffrinet?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/jeffrinet?a=wxOnGR0f2ks:3wXg8c7T0I0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/jeffrinet?i=wxOnGR0f2ks:3wXg8c7T0I0:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/jeffrinet?a=wxOnGR0f2ks:3wXg8c7T0I0:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/jeffrinet?i=wxOnGR0f2ks:3wXg8c7T0I0:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/jeffrinet/~4/wxOnGR0f2ks" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://jeffri.net/2010/07/some-useful-tips-for-wordpress-custom-post-type-and-taxonomy/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://jeffri.net/2010/07/some-useful-tips-for-wordpress-custom-post-type-and-taxonomy/</feedburner:origLink></item>
		<item>
		<title>July Promotion on PSD to XHTML service</title>
		<link>http://feedproxy.google.com/~r/jeffrinet/~3/DCyPrKxJ5EQ/</link>
		<comments>http://jeffri.net/2010/07/july-promotion-on-psd-to-xhtml-service/#comments</comments>
		<pubDate>Sun, 18 Jul 2010 23:04:28 +0000</pubDate>
		<dc:creator>keaglez</dc:creator>
				<category><![CDATA[Service]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[Magento]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://jeffri.net/?p=562</guid>
		<description><![CDATA[Recently I try my luck on offering service for PSD to XHTML and CSS conversion on Kaskus, the biggest local forum in Indonesia. I have done many PSD to XHTML and CSS conversion before, often, I also do conversion to WordPress and Magento. While I want to list my previous work here, unfortunately, due to [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjeffri.net%2F2010%2F07%2Fjuly-promotion-on-psd-to-xhtml-service%2F">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjeffri.net%2F2010%2F07%2Fjuly-promotion-on-psd-to-xhtml-service%2F&amp;source=keaglez&amp;style=normal&amp;service=bit.ly&amp;service_api=R_8412a66499172453880523e0cb1bb28b" height="61" width="50" />
			</a>
		</div><p>Recently I try my luck on offering service for PSD to XHTML and CSS conversion on <a href="http://www.kaskus.us">Kaskus</a>, the biggest local forum in Indonesia. I have done many PSD to XHTML and CSS conversion before, often, I also do conversion to WordPress and Magento. While I want to list my previous work here, unfortunately, due to the contract, I&#8217;m not permitted to list them. So basically, you can see how well my blog markup is for an example of my work. <img src='http://jeffri.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Details for my service can be found <a href="http://www.kaskus.us/showthread.php?t=4635011">here</a>. For international user, you can just contact me for a quote.</p>
<p>For this service, I will offer a promotion every month. For July, you will get a limited offer for a <strong>free PSD to XHTML and CSS conversion</strong>, only for 1 person. The following condition is apply for this promotion:</p>
<ul>
<li>You must agree and give me permission to list the work on my portfolio page and Kaskus (with a clear position of me as the PSD to XHTML and CSS converter, the design is still yours of course, no worries <img src='http://jeffri.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> )</li>
<li>Turn around is in a week (I&#8217;ll work on it when I have time, but I&#8217;ll make sure it completed in a week)</li>
<li>Only for 1 page (additional page will be charged with normal price)</li>
<li>I will choose the design that sent to me</li>
<li>Only for client that haven&#8217;t working with me before (sorry for returning client <img src='http://jeffri.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> )</li>
</ul>
<p>Deadline is August 1. Your design will be converted to XHTML and CSS in a week after the deadline.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/rNxB1te7PvW7goihH_-xChnO3oE/0/da"><img src="http://feedads.g.doubleclick.net/~a/rNxB1te7PvW7goihH_-xChnO3oE/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/rNxB1te7PvW7goihH_-xChnO3oE/1/da"><img src="http://feedads.g.doubleclick.net/~a/rNxB1te7PvW7goihH_-xChnO3oE/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/jeffrinet?a=DCyPrKxJ5EQ:G8PSPSI6lUI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/jeffrinet?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/jeffrinet?a=DCyPrKxJ5EQ:G8PSPSI6lUI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/jeffrinet?i=DCyPrKxJ5EQ:G8PSPSI6lUI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/jeffrinet?a=DCyPrKxJ5EQ:G8PSPSI6lUI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/jeffrinet?i=DCyPrKxJ5EQ:G8PSPSI6lUI:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/jeffrinet/~4/DCyPrKxJ5EQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://jeffri.net/2010/07/july-promotion-on-psd-to-xhtml-service/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://jeffri.net/2010/07/july-promotion-on-psd-to-xhtml-service/</feedburner:origLink></item>
		<item>
		<title>Blog redesign</title>
		<link>http://feedproxy.google.com/~r/jeffrinet/~3/YP0CSSkfw7Q/</link>
		<comments>http://jeffri.net/2010/07/blog-redesign/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 01:46:22 +0000</pubDate>
		<dc:creator>keaglez</dc:creator>
				<category><![CDATA[Designing]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[templates]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://jeffri.net/?p=553</guid>
		<description><![CDATA[Welcome to my new redesigned blog! It&#8217;s been a year and a half since the last time I changed the design. I have always wanted to change it, but I just always don&#8217;t have enough time. I know I&#8217;m not that good enough in designing, but at least, this is the best design I ever [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjeffri.net%2F2010%2F07%2Fblog-redesign%2F">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjeffri.net%2F2010%2F07%2Fblog-redesign%2F&amp;source=keaglez&amp;style=normal&amp;service=bit.ly&amp;service_api=R_8412a66499172453880523e0cb1bb28b" height="61" width="50" />
			</a>
		</div><p>Welcome to my new redesigned blog! It&#8217;s been a year and a half since the last time I changed the design. I have always wanted to change it, but I just always don&#8217;t have enough time. <img src='http://jeffri.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  I know I&#8217;m not that good enough in designing, but at least, this is the best design I ever made until now!</p>
<p><img src="http://jeffri.net/wp-content/uploads/blog_design.jpg" alt="" title="blog_design" width="560" height="238" class="alignnone size-full wp-image-554" /></p>
<p>The idea behind this design is, to make a simple, usable layout and still looks beautiful. There is a lot of tutorial on the web that helped me when making this. I try to make the website small in size, so you&#8217;ll able to load it fast enough. There is also a cool trick on the background, which still make the markup small without much wrapping div over div to accomplish the effect. I also realize the importance on social networking nowadays, so I add links to some of my account. <img src='http://jeffri.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><span id="more-553"></span></p>
<p>With CSS 3 coming, I won&#8217;t forget to add some CSS 3 elements. I add a little transition, on the sidebar links and the social network icon above. You won&#8217;t see it if you don&#8217;t use webkit browser though, so if you use Google Chrome 5 and Safari 5, then you are in. This transition have no importance at all, the purpose is just to enrich the user experience, but won&#8217;t lose any functionality without it. Another CSS 3 property I used is the <em>border-radius</em>. I used this on some input fields you can find. There is also some jQuery here, although I&#8217;m only using it on input fields now, it might become handy in future.</p>
<p>While I haven&#8217;t check this on all browser yet, but I&#8217;m sure it will work fine on all major browser, includes Internet Explorer 8, Mozilla Firefox 3.6, Opera 10, Google Chrome 5 and Safari 5. While I&#8217;m not supporting older Internet Explorer version, it still, on some basic level, works fine. I even can confirm that the IE 7 load almost everything fine, but it just not perfect yet. I have some issues on the logo and button, same as IE 6. This might get fixed soon. <img src='http://jeffri.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I wish I could write the process on making this design. I might be able write it, but I won&#8217;t promise that. In short, there is 2 steps at least. First is design it in PSD, the second is convert it to WordPress. I&#8217;m skipping the step to convert it to XHTML/CSS first though, well, that&#8217;s just how I work. <img src='http://jeffri.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>I hope you will have one or two minute to type down a comment to share your opinion, so I can get better. <img src='http://jeffri.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Thanks!</p>

<p><a href="http://feedads.g.doubleclick.net/~a/E1EZlRGM7uwVETR57zut8uQoEdc/0/da"><img src="http://feedads.g.doubleclick.net/~a/E1EZlRGM7uwVETR57zut8uQoEdc/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/E1EZlRGM7uwVETR57zut8uQoEdc/1/da"><img src="http://feedads.g.doubleclick.net/~a/E1EZlRGM7uwVETR57zut8uQoEdc/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/jeffrinet?a=YP0CSSkfw7Q:87fflZJZZc4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/jeffrinet?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/jeffrinet?a=YP0CSSkfw7Q:87fflZJZZc4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/jeffrinet?i=YP0CSSkfw7Q:87fflZJZZc4:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/jeffrinet?a=YP0CSSkfw7Q:87fflZJZZc4:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/jeffrinet?i=YP0CSSkfw7Q:87fflZJZZc4:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/jeffrinet/~4/YP0CSSkfw7Q" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://jeffri.net/2010/07/blog-redesign/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://jeffri.net/2010/07/blog-redesign/</feedburner:origLink></item>
	</channel>
</rss>
