@package MicroAkismet
@author Gaby Vanhegan
@version 1.2
@date 2007-01-29
A straightforward set of functions for talking to the Akismet blog-spam
protection system. This is intended as a simple and compact method for
adding Akismet protection to any user-submitted content. Built using the
information and examples on the Akismet API page:
http://akismet.com/development/api/
There are two versions, a bunch of static functions or a stand-alone
class. Usage is practically identical for either, you can use whichever
one you want.
INSTALLATION:
1. To begin using the functions, download and unzip the script from the
website:
http://vanhegan.net/software/akismet/
2. Place the php file you want somewhere in your web root, and load
the functions or class using:
include_once("func.microakismet.inc.php")
Or:
include_once("class.microakismet.inc.php")
3. Obtain a valid WordPress API key, if you do not already have one, from:
http://wordpress.com/
If you don't have an account you will need to create one. Once you have an
account, your API key can be found at the bottom of this page:
http://wordpress.com/profile/
4a. If you're using the static functions (func.microakismet.inc.php) then
you will need to set the global variables at the top of the file; your
WordPress API key and the home page of the blog being protected. The
User Agent can be changed to suit your application. If it is not a blog
that is being protected, change the home page to the comments page or forum
page that is being protected.
4b. If you are using the class file (func.microakismet.inc.php), the API
key, homepage and user agent are specified in the class constructor.
USAGE:
There are three functions for talking to Akismet. In the static functions:
aksimet_check( $vars ) // Check if a comment is spam or not
aksimet_spam( $vars ) // Re-classify a comment as spam
aksimet_ham( $vars ) // Re-classify a comment as ham
And the corresponding member functions in the class version:
$akismet = new MicroAkismet( $api_key, $blog, $user_agent );
$akismet->check( $vars );
$akismet->spam( $vars );
$akismet->ham( $vars );
Each function takes one argument, $vars, which is a list of information
about the comment that is being checked. $vars *must* contain at least
this information:
$vars["user_ip"] // The IP of the comment poster
$vars["user_agent"] // The user-agent of the comment poster
The "blog" value (the homepage of the blog that this post came from) is
added automatically by the code. The following extra information can also
be added, to help Akismet classify the message more accurately:
$vars["referrer"] // The content of the HTTP_REFERER header
$vars["permalink"] // Permalink to the comment
$vars["comment_type"] // May be blank, comment, trackback, etc
$vars["comment_author"] // Submitted name with the comment
$vars["comment_author_email"] // Submitted email address
$vars["comment_author_url"] // Commenter URL
$vars["comment_content"] // The content that was submitted
In PHP, you can also add the contents of the $_SERVER array to this list,
which gives extra information to Akismet, and further increases the
accuracy of their system:
EXAMPLE:
To check if a message is spam or not:
<?php
// The array of data we need
$vars = array();
// Add the contents of the $_SERVER array, to help Akismet out
foreach ( $_SERVER as $key => $val ) { $vars[ $key ] = $val; }
// Mandatory fields of information
$vars["user_ip"] = $_SERVER["REMOTE_ADDR"];
$vars["user_agent"] = $_SERVER["HTTP_USER_AGENT"];
// The body of the message to check, the name of the person who
// posted it, and their email address
$vars["comment_content"] = $_POST["comment"];
$vars["comment_author"] = $_POST["sender_name"];
$vars["comment_author_email"] = $_POST["sender_email"];
// ... Add more fields if you want
// Check if it's spam
if ( akismet_check( $vars ) ) {
die( "The message was spam!" );
}
else {
// ...
// Do whatever we do if the message was OK
}
?>
Or to do this using the class version:
<?php
// The array of data we need
$vars = array();
// ... Add vars as before ...
$akismet = new MicroAkismet( "your.wordpress.api.key",
"http://homepaeg.com/blog/comments",
"mysite.com/1.0" );
// Check if it's spam
if ( $akismet->check( $vars ) ) {
die( "The message was spam!" );
}
else {
// Do whatever we do if the message was OK
}
?>
没有合适的资源?快使用搜索试试~ 我知道了~
一个php做的留言板
共245个文件
txt:101个
php:58个
gif:49个
需积分: 10 32 下载量 8 浏览量
2009-02-10
16:11:46
上传
评论
收藏 289KB RAR 举报
温馨提示
这是一个用PHP做的留言本,真的很好用的。
资源推荐
资源详情
资源评论
收起资源包目录
一个php做的留言板 (245个子文件)
index.php.bak 3KB
style.css.bak 3KB
jbastyle.css.bak 3KB
header.php.bak 2KB
config.php.bak 2KB
index.php.bak 774B
footer.php.bak 657B
style.css 3KB
jbastyle.css 3KB
style_js.css 394B
jbastyle_js.css 368B
ConfigForm.css 275B
Thumbs.db 22KB
Thumbs.db 10KB
logo.gif 2KB
logo.gif 2KB
middle_bg.gif 2KB
bottom_bg.gif 1KB
happy.gif 944B
squiggle.gif 942B
love.gif 942B
gasp.gif 941B
yell.gif 940B
sad.gif 940B
blush.gif 940B
yesh.gif 940B
biggrin.gif 938B
numnum.gif 937B
kawaii.gif 937B
razz.gif 937B
smile.gif 937B
angry.gif 936B
dead.gif 936B
squee.gif 935B
frustrated.gif 935B
blank.gif 934B
shifty.gif 934B
hmph.gif 934B
blah.gif 933B
huh.gif 933B
wink.gif 933B
befuddled.gif 929B
sigh.gif 927B
header_bg.gif 691B
button.gif 515B
header_bg.gif 218B
wave.gif 213B
jawdrop.gif 195B
excited.gif 195B
sweatdropsmile.gif 193B
sweatdropworried.gif 189B
headache.gif 187B
sob.gif 187B
lol.gif 185B
cry.gif 182B
fuss.gif 182B
argggh.gif 180B
template.gif 168B
content_bg.gif 146B
footer_bg.gif 146B
h3_bg.gif 111B
content_bg.gif 93B
body_bg.gif 70B
说明.htm 3KB
info.ini 23B
mootools.v1.11.js 38KB
jbscript.js 8KB
jbascript.js 3KB
ConfigForm.js 118B
HTMLPurifier.standalone.php 455KB
PH5P.php 165KB
ConfigForm.php 12KB
HTMLDefinition.php 10KB
Validator.php 8KB
comments.php 7KB
comments.php 7KB
comments.php 7KB
InterchangeBuilder.php 6KB
class.microakismet.inc.php 5KB
ExtractStyleBlocks.php 5KB
Printer.php 5KB
func.microakismet.inc.php 4KB
Xml.php 4KB
ru.php 4KB
PEARSax3.php 3KB
index.php 3KB
en.php 3KB
de.php 3KB
validateform.php 3KB
nl.php 3KB
add.php 3KB
zh.php 3KB
header.php 2KB
config.php 2KB
dom.php 2KB
load.php 2KB
ValidatorAtom.php 2KB
en.php 2KB
transformxml.php 2KB
Directive.php 2KB
共 245 条
- 1
- 2
- 3
资源评论
wangwt_02
- 粉丝: 1
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功