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

<channel>
	<title>Keithics Blog and Thoughts &#187; PHP</title>
	<atom:link href="http://keithics.com/blog/category/php-programming/feed" rel="self" type="application/rss+xml" />
	<link>http://keithics.com/blog</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Wed, 28 Jul 2010 17:10:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Apache/PHP HTTP Authentication</title>
		<link>http://keithics.com/blog/php-programming/apachephp-http-authentication</link>
		<comments>http://keithics.com/blog/php-programming/apachephp-http-authentication#comments</comments>
		<pubDate>Tue, 18 May 2010 10:41:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Snippets]]></category>

		<guid isPermaLink="false">http://keithics.com/blog/?p=328</guid>
		<description><![CDATA[Aside from having a complex login page where you can prevent access to users without privileges ,  PHP offers a simple way to do it.
But you must have an Apache Server (most of the servers are Apache).
Here is the code:



if &#40;$_SERVER&#91;&#8216;PHP_AUTH_USER&#8217;&#93; != &#8216;admin&#8217; and $_SERVER&#91;&#8216;PHP_AUTH_PW&#8217;&#93; != &#8216;admin&#8217;&#41; &#123;


&#160;header&#40;&#8216;WWW-Authenticate: Basic realm=&#34;TCG Admin Panel&#34;&#8217;&#41;;


&#160;header&#40;&#8216;HTTP/1.0 401 Unauthorized&#8217;&#41;;


&#160;echo &#8216;You [...]]]></description>
			<content:encoded><![CDATA[<p>Aside from having a complex login page where you can prevent access to users without privileges ,  PHP offers a simple way to do it.</p>
<p>But you must have an Apache Server (most of the servers are Apache).</p>
<p>Here is the code:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$_SERVER</span><span class="br0">&#91;</span><span class="st0">&#8216;PHP_AUTH_USER&#8217;</span><span class="br0">&#93;</span> != <span class="st0">&#8216;admin&#8217;</span> and <span class="re0">$_SERVER</span><span class="br0">&#91;</span><span class="st0">&#8216;PHP_AUTH_PW&#8217;</span><span class="br0">&#93;</span> != <span class="st0">&#8216;admin&#8217;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<a href="http://www.php.net/header"><span class="kw3">header</span></a><span class="br0">&#40;</span><span class="st0">&#8216;WWW-Authenticate: Basic realm=&quot;TCG Admin Panel&quot;&#8217;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<a href="http://www.php.net/header"><span class="kw3">header</span></a><span class="br0">&#40;</span><span class="st0">&#8216;HTTP/1.0 401 Unauthorized&#8217;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&#8216;You need to login&#8217;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp;<a href="http://www.php.net/exit"><span class="kw3">exit</span></a>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1"><a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&quot;OK!&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<p>Learn more about it <a href="http://php.net/manual/en/features.http-auth.php" target="_blank">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://keithics.com/blog/php-programming/apachephp-http-authentication/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DOMPDF Tips &#8211; HTML to PDF using PHP5</title>
		<link>http://keithics.com/blog/personal-thoughts/freelance/dompdf-html-to-pdf-using-php5</link>
		<comments>http://keithics.com/blog/personal-thoughts/freelance/dompdf-html-to-pdf-using-php5#comments</comments>
		<pubDate>Sun, 25 Apr 2010 15:54:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Freelancing]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://keithics.com/blog/?p=282</guid>
		<description><![CDATA[ 1. Always ask to save the file , don&#8217;t load  the PDF directly. I have printing problems when printing it directly without saving.
2. Add memory limit to php.ini
ini_set("memory_limit","128M");
3. Debug the output html first before converting to pdf.
4. Load  images on the same server and with relative paths. You can&#8217;t load images using [...]]]></description>
			<content:encoded><![CDATA[<p><strong> </strong>1. Always ask to save the file , don&#8217;t load  the PDF directly. I have printing problems when printing it directly without saving.</p>
<p>2. Add memory limit to php.ini</p>
<pre>ini_set("memory_limit","128M");</pre>
<p>3. Debug the output html first before converting to pdf.</p>
<p>4. Load  images on the same server and with relative paths. You can&#8217;t load images using &#8220;http://domain.com&#8221;.</p>
<p>5. Use wordwrap with caution.</p>
<p>6. Always add width to your table and  first row cells</p>
<p>7. Make sure images are in correct format with correct extension. A BMP file with .jpg extension will trigger an error.</p>
<p>8. Avoid special characters if possible.</p>
<p>If you some trouble with DOMPDF, just comment and  maybe I can help you out.</p>
<p><strong> </strong></p>
<p><strong>All are based on experience!</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://keithics.com/blog/personal-thoughts/freelance/dompdf-html-to-pdf-using-php5/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Wordpress get_page() function</title>
		<link>http://keithics.com/blog/php-programming/wordpress-get_page-function</link>
		<comments>http://keithics.com/blog/php-programming/wordpress-get_page-function#comments</comments>
		<pubDate>Wed, 14 Jan 2009 23:15:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[PHP bug]]></category>

		<guid isPermaLink="false">http://keithics.com/blog/?p=211</guid>
		<description><![CDATA[Well this is the first time that I am having a hard time debugging this simple Wordpress get_page() function:
$p = get_page(2); // error : Only variables can be passed by reference
it has to be like this:
$n = 2;
$p = get_page($n);
Getting the title and content is easy..
_e($p-&#62;post_title)
_e($p-&#62;post_content)
I know it sucks but I hope it helps!
]]></description>
			<content:encoded><![CDATA[<p>Well this is the first time that I am having a hard time debugging this simple Wordpress get_page() function:</p>
<p>$p = get_page(2); // error : Only variables can be passed by reference</p>
<p>it has to be like this:</p>
<p>$n = 2;<br />
$p = get_page($n);</p>
<p>Getting the title and content is easy..</p>
<p>_e($p-&gt;post_title)</p>
<p>_e($p-&gt;post_content)</p>
<p>I know it sucks but I hope it helps!</p>
]]></content:encoded>
			<wfw:commentRss>http://keithics.com/blog/php-programming/wordpress-get_page-function/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Opening Cake THTML file with Dreaweaver CS4</title>
		<link>http://keithics.com/blog/php-programming/opening-cake-thtml-file-with-dreaweaver-cs4</link>
		<comments>http://keithics.com/blog/php-programming/opening-cake-thtml-file-with-dreaweaver-cs4#comments</comments>
		<pubDate>Tue, 18 Nov 2008 07:31:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Adobe Dreaweaver]]></category>
		<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Dreaweaver]]></category>

		<guid isPermaLink="false">http://keithics.com/blog/?p=118</guid>
		<description><![CDATA[Just go to:
C:\Program Files\Adobe\Adobe Dreamweaver CS4\configuration
Open file: Extensions.txt
edit line 16 and add THTML





Save and Close the File
Next, Open MMDocumentTypes.xml at C:\Program Files\Adobe\Adobe Dreamweaver CS4\configuration\DocumentTypes
Add THTML online 75 :  winfileextension=&#8221;thtml,php,php3,php4,php5&#8243; macfileextension=&#8221;thtml,php,php3,php4,php5&#8243;
Save, close and Restart Dreamweaver!





]]></description>
			<content:encoded><![CDATA[<p>Just go to:</p>
<p>C:\Program Files\Adobe\Adobe Dreamweaver CS4\configuration</p>
<p>Open file: Extensions.txt</p>
<p>edit line 16 and add THTML</p>
<div class="mceTemp">
<dl id="attachment_119" class="wp-caption alignnone" style="width: 765px;">
<dt class="wp-caption-dt"><a href="http://keithics.com/blog/wp-content/uploads/2008/11/dreamweaver_with_cake1.jpg"><img class="size-full wp-image-119" title="dreamweaver_with_cake1" src="http://keithics.com/blog/wp-content/uploads/2008/11/dreamweaver_with_cake1.jpg" alt="dreamweaver with Cakephp" width="755" height="349" /></a></dt>
</dl>
</div>
<p>Save and Close the File</p>
<p>Next, Open MMDocumentTypes.xml at C:\Program Files\Adobe\Adobe Dreamweaver CS4\configuration\DocumentTypes</p>
<p>Add THTML online 75 : <strong> winfileextension=&#8221;<span style="color: #ffff00;">thtml,</span>php,php3,php4,php5&#8243; macfileextension=&#8221;<span style="color: #ffff00;">thtml</span>,php,php3,php4,php5&#8243;</strong><a href="http://keithics.com/blog/wp-content/uploads/2008/11/dreamweaver_with_cake2.jpg"><img class="size-full wp-image-120" title="dreamweaver_with_cake2" src="http://keithics.com/blog/wp-content/uploads/2008/11/dreamweaver_with_cake2.jpg" alt="dreamweaver_with_cake2" width="755" height="349" /></a></p>
<p>Save, close and Restart Dreamweaver!</p>
<div class="mceTemp">
<dl id="attachment_121" class="wp-caption alignnone" style="width: 765px;">
<dt class="wp-caption-dt"><a href="http://keithics.com/blog/wp-content/uploads/2008/11/dreamweaver_with_cake.jpg"><img class="size-full wp-image-121" title="dreamweaver_with_cake" src="http://keithics.com/blog/wp-content/uploads/2008/11/dreamweaver_with_cake.jpg" alt="dreamweaver_with_cake" width="755" height="349" /></a></dt>
</dl>
</div>
]]></content:encoded>
			<wfw:commentRss>http://keithics.com/blog/php-programming/opening-cake-thtml-file-with-dreaweaver-cs4/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get Articles from a specific cagetory in Wordpress</title>
		<link>http://keithics.com/blog/php-programming/get-articles-from-a-specific-cagetory-in-wordpress</link>
		<comments>http://keithics.com/blog/php-programming/get-articles-from-a-specific-cagetory-in-wordpress#comments</comments>
		<pubDate>Tue, 28 Oct 2008 15:03:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Freelancing]]></category>

		<guid isPermaLink="false">http://keithics.com/blog/?p=84</guid>
		<description><![CDATA[After googling and not found any code, I made my own script to get articles from wordpress with a specific category.

Category = term_taxonomy_id // you can see it in the database table called wp_term_taxonomy]]></description>
			<content:encoded><![CDATA[<p>After googling and not found any code, I made my own script to get articles from wordpress with a specific category.</p>
<p>Category = term_taxonomy_id // you can see it in the database table called wp_term_taxonomy</p>
<p><a href="http://keithics.com/blog/wp-content/uploads/2008/10/wordpress.gif"><img class="alignnone size-full wp-image-85" title="wordpress" src="http://keithics.com/blog/wp-content/uploads/2008/10/wordpress.gif" alt="" width="499" height="208" /></a></p>
<p>Here is the code:</p>
<p>[sourcecode language='php']</p>
<p>//////////////////////////////////////////////////////////////////////</p>
<p>$conn = mysql_connect(&#8216;localhost&#8217;,'root&#8217;,&#8221;);<br />
mysql_select_db(&#8220;keithics&#8221;,$conn) or die(mysql_error());</p>
<p>if (!$conn) {<br />
die(&#8216;Error!!&#8211;> &#8216; . mysql_error()); // if there&#8217;s an error, e.g. wrong password or username.<br />
}</p>
<p>$sql = &#8220;Select wp_posts.* ,wp_term_relationships.* from `wp_posts`,`wp_term_relationships` where wp_posts.post_status = &#8216;publish&#8217; and wp_term_relationships.term_taxonomy_id   = 7 and wp_posts.ID = wp_term_relationships.object_id order by rand() limit 5 &#8220;;</p>
<p>$result = mysql_query($sql) or die(mysql_error());<br />
while($row =  mysql_fetch_array($result))<br />
{<br />
echo &#8216;<a href="'.$site.'blog/article/'.$row['post_name'].'/'.$row['ID'].'/">&#8216;.$row['post_title'].&#8217;</a>&#8216;;<br />
}</p>
<p>[/sourcecode]</p>
]]></content:encoded>
			<wfw:commentRss>http://keithics.com/blog/php-programming/get-articles-from-a-specific-cagetory-in-wordpress/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get Posts from Wordpress to an External Page</title>
		<link>http://keithics.com/blog/php-programming/get-posts-from-wordpress-to-an-external-page</link>
		<comments>http://keithics.com/blog/php-programming/get-posts-from-wordpress-to-an-external-page#comments</comments>
		<pubDate>Tue, 28 Oct 2008 13:38:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Freelancing]]></category>

		<guid isPermaLink="false">http://keithics.com/blog/?p=66</guid>
		<description><![CDATA[Below will get the All articles from Wordpress Database to an external file and display in random order.Also, it depends on how you customized your "Permalink Structure". Sample below has "/article/%postname%/%post_id%/". I am using the same code on my footer!]]></description>
			<content:encoded><![CDATA[<p>Below will get the All articles from Wordpress Database to an external file and display in random order.Also, it depends on how you customized your &#8220;Permalink Structure&#8221;. Sample below has &#8220;/article/%postname%/%post_id%/&#8221;. I am using the same code on my footer!</p>
<p>[sourcecode language='php']</p>
<p>//////////////////////////////////////////////////////////////////////</p>
<p>$conn = mysql_connect(&#8216;localhost&#8217;,'root&#8217;,&#8221;);<br />
mysql_select_db(&#8220;keithics&#8221;,$conn) or die(mysql_error());</p>
<p>if (!$conn) {<br />
die(&#8216;Error!!&#8211;> &#8216; . mysql_error()); // if there&#8217;s an error, e.g. wrong password or username.<br />
}</p>
<p>$sql = &#8220;Select * from `wp_posts` where post_status = &#8216;publish&#8217; order by rand() limit 5 &#8220;;</p>
<p>$result = mysql_query($sql) or die(mysql_error());</p>
<p>while($row =  mysql_fetch_array($result))<br />
{<br />
echo &#8216;<a href="'.$site.'blog/article/'.$row['post_name'].'/'.$row['ID'].'/">&#8216;.$row['post_title'].&#8217;</a>&#8216;;<br />
}</p>
<p>[/sourcecode]</p>
]]></content:encoded>
			<wfw:commentRss>http://keithics.com/blog/php-programming/get-posts-from-wordpress-to-an-external-page/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
