現在位置: Top/CPGのコメントスパム対策
*CPGのコメントスパム対策
Coppermine Photo Galleryは写真を管理するウェブアプリケーションです。
このコメントスパム対策をします。
元の記事は
http://coppermine-gallery.net/forum/index.php?topic=33827.0
**ダウンロード
+Akismet API keyを入手する
http://wordpress.com/api-keys/
+ライブラリを入手
PHP4用
http://miphp.net/blog/view/php4_akismet_class
PHP5用
http://www.achingbrain.net/stuff/akismet/
+解凍した中にあるAkismet.class.phpをCPGのルートへアップロードする。
**設定
db_input.phpを開く
最初の方に
 include 'Akismet.class.php';
を加える。
$insert = cpg_db_queryを含む行が2つありますが、その最初の方の行の前に
 $WordPressAPIKey =  'your Akismet API key goes here';
 $MyBlogURL = 'http://www.example.com/coppermine_root_dir/';
 $name = $msg_author;
 $comment = $msg_body;
 
 $akismet = new Akismet($MyBlogURL ,$WordPressAPIKey);
 $akismet->setCommentAuthor($name);
 $akismet->setCommentAuthorEmail($email);
 $akismet->setCommentAuthorURL($url);
 $akismet->setCommentContent($comment);
 $akismet->setPermalink('http://www.example.com/blog/alex/someurl/');
 
 if($akismet->isCommentSpam())
 // store the comment but mark it as spam (in case of a mis-diagnosis)
 cpg_die(ERROR, $lang_errors['perm_denied'], __FILE__, __LINE__);
 else
を挿入する。
このelseの後ろで、
$insert = cpg_db_query("INSERT INTO {$CONFIG…
という行が実行される。