差分
このページの2つのバージョン間の差分を表示します。
次のリビジョン | 前のリビジョン | ||
nucleus:np_typepadantispam [2008/06/01 09:12] – 作成 osamu | nucleus:np_typepadantispam [2008/06/06 16:41] (現在) – osamu | ||
---|---|---|---|
行 1: | 行 1: | ||
====== NP_TypePadAntiSpam ====== | ====== NP_TypePadAntiSpam ====== | ||
+ | ===== What is this? ===== | ||
+ | |||
NP_TypePadAntiSpam is a plugin that integrates TypePad AntiSpam with Nucleus CMS. [[http:// | NP_TypePadAntiSpam is a plugin that integrates TypePad AntiSpam with Nucleus CMS. [[http:// | ||
NP_TypePadAntiSpam は、Nucleus CMS で TypePad AntiSpam を利用できるようにするプラグインです。[[http:// | NP_TypePadAntiSpam は、Nucleus CMS で TypePad AntiSpam を利用できるようにするプラグインです。[[http:// | ||
+ | ===== The Code ===== | ||
+ | This program is actually a quick hack based on [[http:// | ||
+ | Install the plugin files in your Nucleus plugin directory, and set your [[http:// | ||
+ | This plugin provides the core anti-spam engine only. It is recommended to use with an anti-spam UI plugin such as [[http:// | ||
+ | Japanese language files for NP_Moderate is also available. Put these language files in " | ||
+ | |||
+ | このプログラムは[[http:// | ||
+ | プラグインのファイルをNucleusのプラグインディレクトリにインストールして、プラグインの管理画面でType[[http:// | ||
+ | このプラグインにはコアとなるスパム防止のエンジンだけが入っています。スパムコメントの管理などのユーザーインターフェースを追加する[[http:// | ||
+ | NP_Moderateの日本語ランゲージファイルも用意しました。このランゲージファイルを " | ||
+ | |||
+ | {{nucleus: | ||
+ | |||
+ | {{nucleus: | ||
+ | |||
+ | ===== Source Code ===== | ||
+ | |||
+ | <code php> | ||
+ | <?php | ||
+ | /* ======================================================================== | ||
+ | * NP_TypePadAntiSpam -- TypePad AntiSpam Plugin for Nucleus CMS | ||
+ | * Copyright (C) 2008 Niels Leenheer, Matt Mullenweg, and Osamu Higuchi | ||
+ | * ------------------------------------------------------------------------ | ||
+ | * This program is free software; you can redistribute it and/or | ||
+ | * modify it under the terms of the GNU General Public License | ||
+ | * as published by the Free Software Foundation; either version 2 | ||
+ | * of the License, or (at your option) any later version. | ||
+ | * | ||
+ | * This program is distributed in the hope that it will be useful, | ||
+ | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
+ | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
+ | * GNU General Public License for more details. | ||
+ | * | ||
+ | * You should have received a copy of the GNU General Public License along | ||
+ | * with this program; if not, write to the Free Software Foundation, Inc., | ||
+ | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 | ||
+ | * http:// | ||
+ | * ======================================================================== | ||
+ | * By Osamu Higuchi http:// | ||
+ | * Based on NP_Akismet by Niels Leenheer and Matt Mullenweg | ||
+ | * ------------------------------------------------------------------------ | ||
+ | * Version History | ||
+ | * 0.1 May 30, 2008 : Prototype | ||
+ | * 0.2 May 30, 2008 : Prototype | ||
+ | * ======================================================================== | ||
+ | */ | ||
+ | |||
+ | class NP_TypePadAntiSpam extends NucleusPlugin { | ||
+ | function getName() { return ' | ||
+ | function getAuthor() | ||
+ | function getURL() | ||
+ | function getVersion() { return ' | ||
+ | function getDescription() { return 'Spam Check with TypePad AntiSpam'; | ||
+ | |||
+ | function supportsFeature($what) { | ||
+ | switch($what) { | ||
+ | case ' | ||
+ | return 1; | ||
+ | default: | ||
+ | return 0; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | function getEventList() { | ||
+ | return array(' | ||
+ | } | ||
+ | |||
+ | function install() { | ||
+ | $this-> | ||
+ | $this-> | ||
+ | } | ||
+ | |||
+ | function event_SpamPlugin(& | ||
+ | $data[' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | function event_SpamCheck(& | ||
+ | global $CONF, $manager; | ||
+ | |||
+ | if (isset($data[' | ||
+ | return; | ||
+ | |||
+ | if ($data[' | ||
+ | { | ||
+ | if ($data[' | ||
+ | $comment = array ( | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | |||
+ | if ($data[' | ||
+ | $comment = array ( | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | |||
+ | if (isset($data[' | ||
+ | { | ||
+ | $comment[' | ||
+ | $comment[' | ||
+ | $comment[' | ||
+ | |||
+ | if ($this-> | ||
+ | { | ||
+ | $ignore = array ( | ||
+ | ' | ||
+ | ); | ||
+ | |||
+ | foreach ($_SERVER as $key => $value) | ||
+ | if (!in_array($key, | ||
+ | $comment[$key] = $value; | ||
+ | } | ||
+ | |||
+ | if ($this-> | ||
+ | { | ||
+ | $approved = array ( | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | |||
+ | foreach ($_SERVER as $key => $value) | ||
+ | if (in_array($key, | ||
+ | $comment[$key] = $value; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | $query_string = ''; | ||
+ | |||
+ | foreach ($comment as $key => $part) | ||
+ | $query_string .= $key . ' | ||
+ | |||
+ | $response = $this-> | ||
+ | $query_string, | ||
+ | $this-> | ||
+ | '/ | ||
+ | 80 | ||
+ | ); | ||
+ | |||
+ | if (is_array($response)) { | ||
+ | $data[' | ||
+ | |||
+ | if ($response[1] == ' | ||
+ | $data[' | ||
+ | $data[' | ||
+ | } | ||
+ | } | ||
+ | |||
+ | $manager-> | ||
+ | } | ||
+ | } | ||
+ | |||
+ | function event_SpamMark(& | ||
+ | global $CONF; | ||
+ | |||
+ | if ($data[' | ||
+ | { | ||
+ | if ($data[' | ||
+ | $comment = array ( | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | |||
+ | if ($data[' | ||
+ | $comment = array ( | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | |||
+ | $query_string = ''; | ||
+ | |||
+ | foreach ($comment as $key => $part) | ||
+ | $query_string .= $key . ' | ||
+ | |||
+ | if ($data[' | ||
+ | { | ||
+ | $response = $this-> | ||
+ | $query_string, | ||
+ | $this-> | ||
+ | '/ | ||
+ | 80 | ||
+ | ); | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | $response = $this-> | ||
+ | $query_string, | ||
+ | $this-> | ||
+ | '/ | ||
+ | 80 | ||
+ | ); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | function _PostHTTP($request, | ||
+ | global $nucleus; | ||
+ | |||
+ | $http_request | ||
+ | $http_request .= "Host: $host\r\n"; | ||
+ | $http_request .= " | ||
+ | $http_request .= " | ||
+ | $http_request .= " | ||
+ | $http_request .= " | ||
+ | $http_request .= $request; | ||
+ | |||
+ | $response = ''; | ||
+ | if( false !== ( $fs = @fsockopen($host, | ||
+ | fwrite($fs, | ||
+ | while ( !feof($fs) ) | ||
+ | $response .= fgets($fs, 1160); // One TCP-IP packet | ||
+ | fclose($fs); | ||
+ | |||
+ | $response = explode(" | ||
+ | } | ||
+ | |||
+ | return $response; | ||
+ | } | ||
+ | } | ||
+ | ?> | ||
+ | </ | ||