Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
4 lines (4 sloc) 5.17 KB
<code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">require_once&nbsp;</span><span style="color: #0000BB">dirname</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">'/../helper.php'</span><span style="color: #007700">;<br />require_once&nbsp;</span><span style="color: #0000BB">dirname</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">'/../spyc/spyc.php5'</span><span style="color: #007700">;<br />require_once&nbsp;</span><span style="color: #DD0000">'Zend/Service/Akismet.php'</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//&nbsp;load&nbsp;comment&nbsp;fixtures&nbsp;from&nbsp;yaml&nbsp;file<br /></span><span style="color: #0000BB">$file&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">dirname</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">'/isspam.yml'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$comments&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">Spyc</span><span style="color: #007700">::</span><span style="color: #0000BB">YAMLLoad</span><span style="color: #007700">(</span><span style="color: #0000BB">$file</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;create&nbsp;a&nbsp;Akismet&nbsp;client&nbsp;instance<br /></span><span style="color: #0000BB">$akismet&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">Zend_Service_Akismet</span><span style="color: #007700">(</span><span style="color: #0000BB">AKISMET_API_KEY</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'http://www.simonecarletti.com/blog'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;batch&nbsp;check&nbsp;comments<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">"Starting&nbsp;batch:&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">count</span><span style="color: #007700">(</span><span style="color: #0000BB">$comments</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"&nbsp;comment(s)&nbsp;to&nbsp;check&nbsp;from&nbsp;$file"</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//&nbsp;loop&nbsp;over&nbsp;all&nbsp;$comments&nbsp;and&nbsp;do&nbsp;some&nbsp;stuff<br /></span><span style="color: #007700">foreach&nbsp;(</span><span style="color: #0000BB">$comments&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$comment</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"\nChecking&nbsp;comment&nbsp;from&nbsp;{$comment['comment_author']}&nbsp;({$comment['comment_author_email']})...&nbsp;"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$spam&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$akismet</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">isSpam</span><span style="color: #007700">(</span><span style="color: #0000BB">$comment</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"\n&nbsp;&nbsp;Permalink:&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$comment</span><span style="color: #007700">[</span><span style="color: #DD0000">'permalink'</span><span style="color: #007700">];<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"\n&nbsp;&nbsp;Referrer:&nbsp;&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$comment</span><span style="color: #007700">[</span><span style="color: #DD0000">'referrer'</span><span style="color: #007700">];<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"\n&nbsp;&nbsp;Akismet:&nbsp;&nbsp;&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;(</span><span style="color: #0000BB">$spam&nbsp;</span><span style="color: #007700">?&nbsp;</span><span style="color: #DD0000">'spam'&nbsp;</span><span style="color: #007700">:&nbsp;</span><span style="color: #DD0000">'ham'</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #FF8000">//&nbsp;The&nbsp;end...<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">"\nCompleted!"</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;</span>
</span>
</code>