<?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>Free Android CakePHP GMaps Articles</title>
	<atom:link href="http://www.balistupa.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.balistupa.com/blog</link>
	<description>Bali Stupa Blog</description>
	<lastBuildDate>Mon, 30 Jan 2012 04:42:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>How to add first column on existing table mysql</title>
		<link>http://www.balistupa.com/blog/2012/01/how-to-add-first-column-on-existing-table-mysql/</link>
		<comments>http://www.balistupa.com/blog/2012/01/how-to-add-first-column-on-existing-table-mysql/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 04:42:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[query tips]]></category>

		<guid isPermaLink="false">http://www.balistupa.com/blog/?p=149</guid>
		<description><![CDATA[I am encountering problem to add increment column on existing table mysql database. The existing table has some columns except increment column. So now i need increment column, but i don&#8217;t want to put this column at the end of the table, this is not look good for me. So i check to mysql manual [...]]]></description>
			<content:encoded><![CDATA[<p>I am encountering problem to add increment column on existing table mysql database. The existing table has some columns except increment column. So now i need increment column, but i don&#8217;t want to put this column at the end of the table, this is not look good for me.</p>
<p>So i check to mysql manual and found interesting sintak, beside use AFTER column syntax, there is FIRST syntax. So the query is look like this</p>
<p><code>ALTER TABLE table_name ADD COLUMN `ID` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT First,<br />
ADD PRIMARY KEY (`ID`);</code></p>
<p>I hope this article can help you to add first column on existing table mysql database server.</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.balistupa.com%2Fblog%2F2012%2F01%2Fhow-to-add-first-column-on-existing-table-mysql%2F';
  addthis_title  = 'How+to+add+first+column+on+existing+table+mysql';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.balistupa.com/blog/2012/01/how-to-add-first-column-on-existing-table-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Saving Mysql Function Now on Cakephp</title>
		<link>http://www.balistupa.com/blog/2011/05/saving-mysql-function-now-on-cakephp/</link>
		<comments>http://www.balistupa.com/blog/2011/05/saving-mysql-function-now-on-cakephp/#comments</comments>
		<pubDate>Wed, 25 May 2011 08:45:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.balistupa.com/blog/?p=142</guid>
		<description><![CDATA[I think many cakephp programmer will get confuse when they want to save column/field on table with mysql function such as NOW(), CURDATE(), etc, We cannot use simple way of the saveField method or save method on model object. This code will not save the data field into current date time on mysql. $this-&#62;ModelName-&#62;saveField('date_field', 'NOW()'); [...]]]></description>
			<content:encoded><![CDATA[<p>I think many cakephp programmer will get confuse when they want to save column/field on table with mysql function such as NOW(), CURDATE(), etc, We cannot use simple way of the saveField method or save method on model object.</p>
<p>This code will not save the data field into current date time on mysql.</p>
<p><code>$this-&gt;ModelName-&gt;saveField('date_field', 'NOW()');</code></p>
<p>or</p>
<p><code>$data['ModelName']['id'] = 1;<br />
$data['ModelName']['date_field'] = 'NOW()';<br />
$this-&gt;ModelName-&gt;save($data);</code></p>
<p>It will not work as you want. Because cakephp will ada quote on the value.</p>
<p><span id="more-142"></span>So the solution is by using DboSource class. Here are the code look like to save table column with current data time on mysql.</p>
<p><code>$this-&gt;ModelName-&gt;saveField('date_field', DboSource::expression('NOW()'));</code></p>
<p>or</p>
<p><code>$data['ModelName']['id'] = 1;<br />
$data['ModelName']['date_field'] = DboSource::expression('NOW()');<br />
$this-&gt;ModelName-&gt;save($data);</code></p>
<p>I hope this article help you for saving mysql function now, curdate, etc on cakephp model object.</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.balistupa.com%2Fblog%2F2011%2F05%2Fsaving-mysql-function-now-on-cakephp%2F';
  addthis_title  = 'Saving+Mysql+Function+Now+on+Cakephp';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.balistupa.com/blog/2011/05/saving-mysql-function-now-on-cakephp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>debug certificate expired android problem</title>
		<link>http://www.balistupa.com/blog/2011/01/debug-certificate-expired-android-problem/</link>
		<comments>http://www.balistupa.com/blog/2011/01/debug-certificate-expired-android-problem/#comments</comments>
		<pubDate>Mon, 31 Jan 2011 07:18:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.balistupa.com/blog/?p=139</guid>
		<description><![CDATA[I got this error message on my android projects after upgrading eclipse and android sdk manager. But it probably not the thing that makes this problem. So i explored about this problem on google and found the solution, at least this is work for my eclipse. I am using windows Vista, here are my step [...]]]></description>
			<content:encoded><![CDATA[<p>I got this error message on my android projects after upgrading eclipse and android sdk manager. But it probably not the thing that makes this problem. So i explored about this problem on google and found the solution, at least this is work for my eclipse.</p>
<p>I am using windows Vista, here are my step to solve debug certificate expired android problem :</p>
<ol>
<li>Delete debug.keystore on C:\Users\{USER_PROFILE}\.android folder. For others operating system, you could check the path on eclipse. Please open menu <strong>Preferences &#8211; Android &#8211; Build &#8211; Default debug keystore</strong>.</li>
<li>On eclipse, Clean the projects ( Menu <strong>Projects</strong> &gt; <strong>Clean</strong> ). You probably need to restart your eclipse.</li>
</ol>
<p>I figure out this problem are because the certificate is expired. I wondering if this debug keystore is same as keystore that i create when i installing the Android SDK. I don&#8217;t know, but eclipse can generate it. It seem the certificate is expired in 365 days. I hope this article can help to solve this problem.</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.balistupa.com%2Fblog%2F2011%2F01%2Fdebug-certificate-expired-android-problem%2F';
  addthis_title  = 'debug+certificate+expired+android+problem';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.balistupa.com/blog/2011/01/debug-certificate-expired-android-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>strange id added on form create url cakephp</title>
		<link>http://www.balistupa.com/blog/2011/01/strange-id-added-on-form-create-url-cakephp/</link>
		<comments>http://www.balistupa.com/blog/2011/01/strange-id-added-on-form-create-url-cakephp/#comments</comments>
		<pubDate>Thu, 20 Jan 2011 02:18:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.balistupa.com/blog/?p=137</guid>
		<description><![CDATA[I found something strange on cakephp when i create form using FormHelper, a strange id appear on the action url. So i have this code on my view &#60;?php echo $form-&#62;create('Evoucher', array('url' =&#62; array('controller' =&#62; 'gift_vouchers', 'action' =&#62; 'buy', $giftVoucher['GiftVoucher']['amount'])));?&#62; It is generated a form tag with strange id added on action url. Something like [...]]]></description>
			<content:encoded><![CDATA[<p>I found something strange on cakephp when i create form using FormHelper, a strange id appear on the action url. So i have this code on my view</p>
<pre>&lt;?php echo $form-&gt;create('Evoucher', array('url' =&gt; array('controller' =&gt; 'gift_vouchers', 'action' =&gt; 'buy', $giftVoucher['GiftVoucher']['amount'])));?&gt;</pre>
<p>It is generated a form tag with strange id added on action url. Something like this</p>
<pre>&lt;form id="EvoucherBuyForm" method="post" action="/gift_vouchers/buy/2/20" accept-charset="utf-8"&gt;</pre>
<p>After exploration, i found the problem was on the controller action for buy. I have set id for the data variable</p>
<pre>$this-&gt;data['Evoucher']['id'] = 2;</pre>
<p>So after taking out this line, i change it into</p>
<pre>$this-&gt;Evoucher-&gt;id = 2;</pre>
<p>And cakephp can generate correct action url for the form tag</p>
<pre>&lt;form id="EvoucherBuyForm" method="post" action="/gift_vouchers/buy/20" accept-charset="utf-8"&gt;</pre>
<p>I hope this tutorial help you. Thanks for visiting our blog</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.balistupa.com%2Fblog%2F2011%2F01%2Fstrange-id-added-on-form-create-url-cakephp%2F';
  addthis_title  = 'strange+id+added+on+form+create+url+cakephp';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.balistupa.com/blog/2011/01/strange-id-added-on-form-create-url-cakephp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to install cakephp on hostgator shared hosting</title>
		<link>http://www.balistupa.com/blog/2010/11/how-to-install-cakephp-on-hostgator-shared-hosting/</link>
		<comments>http://www.balistupa.com/blog/2010/11/how-to-install-cakephp-on-hostgator-shared-hosting/#comments</comments>
		<pubDate>Tue, 09 Nov 2010 01:03:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.balistupa.com/blog/?p=134</guid>
		<description><![CDATA[I just buy new shared hosting account for my new domain on hostgator. I want to install cakephp web application into this hosting. However the local setting or common setting that i used on other hosting is not work on hostgator. After figure out the problem, i found that the hostgator hosting does not allow [...]]]></description>
			<content:encoded><![CDATA[<p>I just buy new shared hosting account for my new domain on hostgator. I want to install cakephp web application into this hosting. However the local setting or common setting that i used on other hosting is not work on hostgator. After figure out the problem, i found that the hostgator hosting does not allow for changing DOCUMENT ROOT setting.</p>
<p>So after research on cakephp tutorial, which come to setting cakephp on shared hosting and i think this solution also good for production phase. I will mention how i set my cakephp on hostgator<span id="more-134"></span></p>
<ol>
<li>move app, cake, plugins, vendors folder into your hosting root folder. It is user root folder on your hosting</li>
<li>delete .htaccess and index.php on cakephp root folder</li>
<li>move /app/webroot/*.* to /public_html folder</li>
<li>delete empty /app/webroot folder</li>
<li>edit /public_html/index.php to point to the &#8216;cake&#8217; and &#8216;app&#8217; directories. For example my public_html path for my domain is /home/myhost/public_html, so i point<br />
- ROOT to look at /home/myhost<br />
- APP_DIR to look at /home/myhost/app<br />
- CAKE_CORE_INCLUDE_PATH to look at /home/myhost/cake</li>
<li>edit this line on /public_html/index.php with your appropriate path<br />
<code>if (!defined('ROOT')) {<br />
define('ROOT', DS.'home'.DS.'myhost');<br />
}</code></p>
<p><code>if (!defined('APP_DIR')) {<br />
define('APP_DIR', 'app');<br />
}</code></p>
<p><code>if (!defined('CAKE_CORE_INCLUDE_PATH')) {<br />
define('CAKE_CORE_INCLUDE_PATH', DS.'home'.DS.'myhost');<br />
}</code></li>
<li>The only .htaccess i have on /home/myhost/public_html, the setting for .htaccess look like this<br />
<code>&lt;IfModule mod_rewrite.c&gt;<br />
RewriteEngine On<br />
RewriteCond %{REQUEST_FILENAME} !-d<br />
RewriteCond %{REQUEST_FILENAME} !-f<br />
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]<br />
&lt;/IfModule&gt;</code></li>
</ol>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.balistupa.com%2Fblog%2F2010%2F11%2Fhow-to-install-cakephp-on-hostgator-shared-hosting%2F';
  addthis_title  = 'How+to+install+cakephp+on+hostgator+shared+hosting';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.balistupa.com/blog/2010/11/how-to-install-cakephp-on-hostgator-shared-hosting/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to remove generator meta tag wordpress</title>
		<link>http://www.balistupa.com/blog/2010/10/how-to-remove-generator-meta-tag-wordpress/</link>
		<comments>http://www.balistupa.com/blog/2010/10/how-to-remove-generator-meta-tag-wordpress/#comments</comments>
		<pubDate>Fri, 29 Oct 2010 03:13:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.balistupa.com/blog/?p=130</guid>
		<description><![CDATA[Starting from wordpress 2.5 and above, you cannot remove generated meta tag wordpress version through your template. On prior version, it is simple by comment the line for showing wordpress version on your template. &#60;meta name="generator" content="WordPress &#60;?php bloginfo('version'); ?&#62;" /&#62; WordPress 2.5 and above, the version is moved into the core of the wordpress. [...]]]></description>
			<content:encoded><![CDATA[<p>Starting from wordpress 2.5 and above, you cannot remove generated meta tag wordpress version through your template. On prior version, it is simple by comment the line for showing wordpress version on your template.</p>
<p><code>&lt;meta name="generator" content="WordPress &lt;?php bloginfo('version'); ?&gt;" /&gt;</code></p>
<p>WordPress 2.5 and above, the version is moved into the core of the wordpress. So it will automatically generate metatag generate, such as</p>
<p><code>&lt;meta name="generator" content="WordPress 3.0" /&gt;</code></p>
<p>If you want to remove this generated line, there are some ways :</p>
<ol>
<li>Login to administration wordpress page, and then go to Appearance &gt; Themes, And then Editor. Open functions.php, Add this line before the closing <code>?&gt;</code> tag<br />
<code>remove_action('wp_head', 'wp_generator');</code></li>
<li>Or use <a href="http://just-thinkin.net/2008/04/wordpress-25-plugin-keeps-the-version-out-of-source/" target="_blank">this plugin</a>. Install on plugins area.</li>
</ol>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.balistupa.com%2Fblog%2F2010%2F10%2Fhow-to-remove-generator-meta-tag-wordpress%2F';
  addthis_title  = 'How+to+remove+generator+meta+tag+wordpress';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.balistupa.com/blog/2010/10/how-to-remove-generator-meta-tag-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Redirect with exit using cakephp</title>
		<link>http://www.balistupa.com/blog/2010/10/redirect-with-exit-using-cakephp/</link>
		<comments>http://www.balistupa.com/blog/2010/10/redirect-with-exit-using-cakephp/#comments</comments>
		<pubDate>Thu, 28 Oct 2010 13:38:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.balistupa.com/blog/?p=127</guid>
		<description><![CDATA[If you run redirect function on cakephp 1.1, don&#8217;t forget to add exit() function after redirect sintax. This thing can make security hole that confusing you. The purpose of adding exit() function after redirect sintax is to avoid php running others code after redirect function. $this-&#62;redirect('controller/action'); exit(); However cakephp 1.2 give you default exit after [...]]]></description>
			<content:encoded><![CDATA[<p>If you run redirect function on cakephp 1.1, don&#8217;t forget to add exit() function after redirect sintax. This thing can make security hole that confusing you. The purpose of adding exit() function after redirect sintax is to avoid php running others code after redirect function.</p>
<p><code>$this-&gt;redirect('controller/action');<br />
exit();</code></p>
<p>However cakephp 1.2 give you default exit after redirect. The complete sintax for redirect on cakephp 1.2 is</p>
<p><code>$this-&gt;redirect('controller/action', null, true);</code></p>
<p>which the third parameter define exit = true, means terminate the script. second parameter is for setting exit status, for example 404, etc. Defaultly you only need to write</p>
<p><code>$this-&gt;redirect('controller/action');</code></p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.balistupa.com%2Fblog%2F2010%2F10%2Fredirect-with-exit-using-cakephp%2F';
  addthis_title  = 'Redirect+with+exit+using+cakephp';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.balistupa.com/blog/2010/10/redirect-with-exit-using-cakephp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>get referer url using cakephp</title>
		<link>http://www.balistupa.com/blog/2010/10/get-referer-url-using-cakephp/</link>
		<comments>http://www.balistupa.com/blog/2010/10/get-referer-url-using-cakephp/#comments</comments>
		<pubDate>Thu, 28 Oct 2010 13:08:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.balistupa.com/blog/?p=125</guid>
		<description><![CDATA[Sometime we need to get the referer url that access a page or url on our website. It is easy to find referer url using cakephp framework. Inside your controller or cakephp class, you can get the referer url using this sintak Controller::referer() Referer url is the last page or url that accessed by the [...]]]></description>
			<content:encoded><![CDATA[<p>Sometime we need to get the referer url that access a page or url on our website. It is easy to find referer url using cakephp framework. Inside your controller or cakephp class, you can get the referer url using this sintak</p>
<p><code>Controller::referer()</code></p>
<p>Referer url is the last page or url that accessed by the user before open current page or url.</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.balistupa.com%2Fblog%2F2010%2F10%2Fget-referer-url-using-cakephp%2F';
  addthis_title  = 'get+referer+url+using+cakephp';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.balistupa.com/blog/2010/10/get-referer-url-using-cakephp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to log your website using cakephp</title>
		<link>http://www.balistupa.com/blog/2010/10/how-to-log-your-website-using-cakephp/</link>
		<comments>http://www.balistupa.com/blog/2010/10/how-to-log-your-website-using-cakephp/#comments</comments>
		<pubDate>Thu, 28 Oct 2010 12:50:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.balistupa.com/blog/?p=123</guid>
		<description><![CDATA[Cakephp is a good framework, it is a rapid web development framework for building any type of website. As a framework, cakephp has many built in feature. One of cakephp feature is build in logging system. Developer can easily log their application using cakephp. Log function that can be accessed through your controller easily. You [...]]]></description>
			<content:encoded><![CDATA[<p>Cakephp is a good framework, it is a rapid web development framework for building any type of website. As a framework, cakephp has many built in feature. One of cakephp feature is build in logging system. Developer can easily log their application using cakephp.</p>
<p>Log function that can be accessed through your controller easily. You can save or add new log into error log or debug log, or you can make new log file. All file will be placed inside CAKEPHP_FOLDER/app/tmp/logs folder</p>
<p>default sintax that added to CAKEPHP_FOLDER/app/tmp/logs/error.log</p>
<p><code>$this-&gt;log("error message log");</code></p>
<p><span id="more-123"></span>log for debugging that added to CAKEPHP_FOLDER/app/tmp/logs/debug.log</p>
<p><code>$this-&gt;log('debug message log', LOG_DEBUG);</code></p>
<p>log to specific filename</p>
<p><code>$this-&gt;log('daily log', 'daily');</code></p>
<p>One of log purpose is to track user access on our website. Here is a sample of user access log or tracking user access using cakephp :</p>
<p><code>$this-&gt;log($this-&gt;RequestHandler-&gt;getClientIP() ."\t". $this-&gt;params['url']['url'] ."\t". Controller::referer(), 'access_log'. date('dmY'));</code></p>
<p>One thing you need to remember is that the log function add the datetime automatically for new log.</p>
<p>So this is how we can track user access or create log for catch the error message or for debuging in cakephp. I hope this article help you.</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.balistupa.com%2Fblog%2F2010%2F10%2Fhow-to-log-your-website-using-cakephp%2F';
  addthis_title  = 'How+to+log+your+website+using+cakephp';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.balistupa.com/blog/2010/10/how-to-log-your-website-using-cakephp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Captcha component for cakephp using captcha.net</title>
		<link>http://www.balistupa.com/blog/2010/10/captcha-component-for-cakephp-using-captchanet/</link>
		<comments>http://www.balistupa.com/blog/2010/10/captcha-component-for-cakephp-using-captchanet/#comments</comments>
		<pubDate>Thu, 14 Oct 2010 01:32:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.balistupa.com/blog/?p=113</guid>
		<description><![CDATA[Captcha is a type of challenge-response to ensure that the user is really a person that the response is not generated by computer. We usually find captcha on any form input on a website such us contact us, feedback, registration and etc. The captcha is used to protect our site from spammer. The popular captcha [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Captcha</strong> is a type of challenge-response to ensure that the user is really a person that the response is not generated by computer. We usually find captcha on any form input on a website such us contact us, feedback, registration and etc. The captcha is used to protect our site from spammer.</p>
<p>The popular captcha is recaptcha from captcha.net website. It is free for use. Their interface or design also really nice to put on your website. You can check their sample in http://www.captcha.net/. They support both image captcha and audio chaptca.</p>
<p>Since i work with cakephp framework, i need to integrate this captcha into my application. I would like to share my captcha component for you. It is a simple code and easy to integrate. Here are the step<span id="more-113"></span></p>
<ol>
<li>Download the library <a title="Download recaptcha" href="http://code.google.com/p/recaptcha/downloads/list?q=label:phplib-Latest">here</a> and you can read their document for the manual in <a title="Recaptcha manual" href="http://code.google.com/apis/recaptcha/docs/php.html">this page</a>.</li>
<li>Extract <em>recaptcha-php-1.11.zip</em> ( or latest version ) into <em>yourcakephpfolder/app/vendors/recaptcha-php</em>. So the <em>recaptchalib.php</em> will have path on <em>yourcakephpfolder/app/vendors/recaptcha-php/recaptchalib.php</em></li>
<li>Get public key and private key for your domain <a title="Register for rechaptca" href="http://www.google.com/recaptcha/whyrecaptcha">here</a>. You will need an google account for login</li>
<li>And then create new component CaptchaComponent on your cakephp. This is the code for file yourcakephpfolder/app/controllers/components/captcha.php <br class="br" /><code>&lt;?php<br />
App::import('Vendor', 'recaptcha-php', array('file'=&gt;'recaptcha-php'.DS.'recaptchalib.php'));</code></p>
<p><code>class CaptchaComponent extends Object {<br />
var $controller;<br />
var $public_key = 'your_recaptcha_public_key';<br />
var $private_key = 'your_recaptcha_private_key';</code></p>
<p><code>function startup( &amp;$controller ) {<br />
$this-&gt;controller = &amp;$controller;<br />
}</code></p>
<p><code>function create_image_captcha() {<br />
return recaptcha_get_html($this-&gt;public_key);<br />
}</code></p>
<p><code>function check_captcha() {<br />
$resp = recaptcha_check_answer($this-&gt;private_key, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);<br />
return $resp-&gt;is_valid;<br />
}<br />
}<br />
?&gt;</code></li>
<li>Include CaptchaComponent in any controllers that you want to add a captcha<br />
<code>var $components = array('Captcha');</code></li>
<li>And then inside the action function, create new captcha<br />
<code>$this-&gt;set('captcha_code', $this-&gt;Captcha-&gt;create_image_captcha());</code></li>
<li>You can use <code>$captcha_code</code> inside your view, place and echo this variable on appropriate place inside the form.</li>
<li>To check user captcha input, you can check using this <code>$this-&gt;Captcha-&gt;check_captcha()</code>, it will return true if user input correct captcha, and false if incorrect captcha</li>
</ol>
<p>That is a simple Captcha component for cakephp using popular captcha.net. I hope this help you againts spammer on your website. If you get any difficulty of using this component, just write a comment below, i will try to answer your question and fix the problems.</p>
<p><a title="Demo for Chaptcha Component" href="http://www.baligmaps.com/feedback">My Demo for Captcha Component</a></p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.balistupa.com%2Fblog%2F2010%2F10%2Fcaptcha-component-for-cakephp-using-captchanet%2F';
  addthis_title  = 'Captcha+component+for+cakephp+using+captcha.net';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.balistupa.com/blog/2010/10/captcha-component-for-cakephp-using-captchanet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

