<?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>PHP Starter &#187; Scripts</title>
	<atom:link href="http://phpstarter.net/tag/scripts/feed/" rel="self" type="application/rss+xml" />
	<link>http://phpstarter.net</link>
	<description>PHP Tips &#38; Tools From Starters to Experts</description>
	<lastBuildDate>Fri, 25 Jun 2010 14:14:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Akismet Class/Library for Codeigniter</title>
		<link>http://phpstarter.net/2009/02/akismet-classlibrary-for-codeigniter/</link>
		<comments>http://phpstarter.net/2009/02/akismet-classlibrary-for-codeigniter/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 12:00:15 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://phpstarter.net/?p=301</guid>
		<description><![CDATA[Using Akismet to block spam on your WordPress blog is a no-brainer, but what about your custom blog or article site? It is possible to extend the Akismet anti-spam service to your own custom website. In this article, you will find a fully functional Akismet library for CodeIgniter as well as instructions and usage examples. [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p>Using Akismet to block spam on your WordPress blog is a no-brainer, but what about your custom blog or article site?  It is possible to extend the Akismet anti-spam service to your own custom website.  In this article, you will find a fully functional Akismet library for CodeIgniter as well as instructions and usage examples.</p>
<p><span id="more-301"></span></p>
<p><strong>Download Script:</strong> <a href="http://phpstarter.net/wp-content/uploads/2009/01/akismet_ci.tgz">tar</a> | <a href="http://phpstarter.net/wp-content/uploads/2009/01/akismet_ci.zip">zip</a></p>
<h3>Setup &#038; Configuration</h3>
<p>Extract the archive into your CI application.  There are two files &#8211; the library (class file) goes into the system/application/libraries directory, and the config file goes into the system/application/config directory.  Then, be sure to set the values in the config file.</p>
<h3>Usage Example</h3>
<pre class="brush: php">
$this-&gt;akismet-&gt;user_ip = $_SERVER[&#039;REMOTE_ADDR&#039;];
$this-&gt;akismet-&gt;user_agent = $_SERVER[&#039;HTTP_USER_AGENT&#039;];
$this-&gt;akismet-&gt;referrer = $_SERVER[&#039;HTTP_REFERRER&#039;];
$this-&gt;akismet-&gt;permalink = &#039;http://example.com/articles/some-article&#039;;
$this-&gt;akismet-&gt;comment_type = &#039;comment&#039;;
$this-&gt;akismet-&gt;comment_author = &#039;viagra-test-123&#039;;
$this-&gt;akismet-&gt;comment_author_url = &#039;&#039;;
$this-&gt;akismet-&gt;comment_author_email = &#039;user@example.com&#039;;
$this-&gt;akismet-&gt;comment_content = &#039;This is a test comment.&#039;;

$result = $this-&gt;akismet-&gt;is_spam($debug);
</pre>
<p>The example is pretty self-explanatory.  Just fill in those necessary values and get a result from the is_spam() function.  This function will return &#8216;true&#8217; if the comment is found to be spam, or &#8216;false&#8217; if it is ham.  Be advised, that it may also return error information if the request is not valid, so in a production environment, test for spam with something like this:</p>
<pre class="brush: php">
$spam = ($this-&gt;akismet-&gt;is_spam($debug) == &#039;true&#039;) ? 1 : 0;
</pre>
<p>The above statement forces the $spam variable to be &#8217;1&#8242; if spam, or &#8217;0&#8242; is ham, <strong>or if there was an error making the call to Akismet</strong>.  This sets it up to inserting into a MySQL boolean field.</p>
<p>That $debug variable is being passed by reference and is optional.  It will be set to the response headers received by the Akismet servers, and you can see the contents in case something goes wrong.</p>
<h3>Help Correct Akismet if they Mess Up</h3>
<p>Their spam detection isn&#8217;t always correct, but the cool thing about this service is that you can help them correct their mistakes.  (How cool is that?)  If they made a mistake, use the following methods to submit the correct information:</p>
<pre class="brush: php">
/* set the class variables - same as the usage example above */

/* submit spam to Akismet that was flagged as ham */
$result = $this-&gt;akismet-&gt;is_spam($debug);

/* submit ham to Akismet that was flagged as spam */
$result = $this-&gt;akismet-&gt;is_ham($debug);
</pre>
<h3>Getting an API Key</h3>
<p>Akismet only gives free API keys to WordPress blogs, so if you have one, just use that API key for your CI application.  See <a href="http://akismet.com/commercial/">this page</a> for more information on API keys and Akismet for commercial use.</p>
<p>So there you have it &#8211; easy spam protection on any CodeIgniter website.  This library can easily be extended to a non-CodeIgniter website.  The only CI resource this library uses is the config feature.</p>
<p>If you find a bug or have another feature idea to add, please post a comment. <img src='http://phpstarter.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Download Script:</strong> <a href="http://phpstarter.net/wp-content/uploads/2009/01/akismet_ci.tgz">tar</a> | <a href="http://phpstarter.net/wp-content/uploads/2009/01/akismet_ci.zip">zip</a></p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://phpstarter.net/2009/02/akismet-classlibrary-for-codeigniter/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

