ページへ戻る
印刷
POST SPAM 対策を考える
をテンプレートにして作成 ::
XOOPS マニア
UsersWiki
:nao-pon/blog/2006-08-28 をテンプレートにして作成
開始行:
** POST SPAM 対策を考える
#keyword()
RIGHT:&tag(プログラミング);
最近、POST SPAM が%%うざい%%鬱陶しいので、ちょっと対策を...
面倒なので、XOOPS全体でPOST時にチェックをかけてみます。
*** HypCommonFunc に関数を追加。
<a>タグの数、BBコードの[URL=]の数、URLの数をカウントしま...
汎用関数の get_postspam_avr() で POSTデータ中に含まれる合...
#code(){{{
// POST SPAM Check
function PostSpam_Check($post)
{
static $filters = NULL;
if (is_null($filters)) {$filters = HypCommonFunc::PostS...
$counts = array();
$counts[0] = $counts[1] = $counts[2] = $counts[3] = 0;
foreach($post as $dat)
{
$tmp = array();
$tmp['a'] = $tmp['bb'] = $tmp['url'] = $tmp['filter'] ...
if (is_array($dat))
{
list($tmp['a'],$tmp['bb'],$tmp['url'],$tmp['filter'])...
}
else
{
// <a> タグの個数
$tmp['a'] = count(preg_split("/<a.+?\/a>/i",$dat)) - 1;
// [url] タグの個数
$tmp['bb'] = count(preg_split("/\[url=.+?\/url\]/i",$...
// URL の個数
$tmp['url'] = count(preg_split("/(ht|f)tps?:\/\/...
// フィルター
if ($filters)
{
foreach($filters as $reg => $point)
{
$counts[3] += (count(preg_split($reg,$dat)) - 1) * ...
//echo $dat."<br>".$reg.": ".$counts[3]."<hr>";
}
}
}
$counts[0] += $tmp['a'];
$counts[1] += $tmp['bb'];
$counts[2] += $tmp['url'];
$counts[3] += $tmp['filter'];
}
return $counts;
}
// POST SPAM フィルター
function PostSpam_filter($reg="", $point=1)
{
static $regs = array();
if (empty($reg)) {return $regs;}
$regs[$reg] = $point;
}
// POST SPAM Check 汎用関数
function get_postspam_avr($alink=1,$bb=1,$url=1)
{
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
list($a_p,$bb_p,$url_p,$filter_p) = HypCommonFunc::Pos...
return $a_p * $alink + $bb_p * $bb + $url_p * $url + $...
}
else
{
return 0;
}
}
}}}
*** XOOPS_ROOT/include/common.php の最後に次の内容を書き...
この例では、ゲストは 15ポイント超、ログインユーザーは 30...
#code(){{{
// PostSpam をチェック by nao-pon
HypCommonFunc::PostSpam_filter("/((?:ht|f)tps?:\/\/...
if (!is_object($xoopsUser))
{
if (HypCommonFunc::get_postspam_avr() > 15)
{
header("Location: ".XOOPS_URL."/");
exit();
}
}
else if (!$xoopsUserIsAdmin)
{
if (HypCommonFunc::get_postspam_avr() > 30)
{
header("Location: ".XOOPS_URL."/");
exit();
}
}
}}}
----
しばらく、これで様子を見てみて調子がいいようなら CVS に投...
----
-&areaedit(uid:288,preview:5){おおおおおぉぉぉぉぉぉ!!...
-&areaedit(uid:1,preview:5){そうですね。テキストパターン...
#comment(,btn:つっこみ)
----
終了行:
** POST SPAM 対策を考える
#keyword()
RIGHT:&tag(プログラミング);
最近、POST SPAM が%%うざい%%鬱陶しいので、ちょっと対策を...
面倒なので、XOOPS全体でPOST時にチェックをかけてみます。
*** HypCommonFunc に関数を追加。
<a>タグの数、BBコードの[URL=]の数、URLの数をカウントしま...
汎用関数の get_postspam_avr() で POSTデータ中に含まれる合...
#code(){{{
// POST SPAM Check
function PostSpam_Check($post)
{
static $filters = NULL;
if (is_null($filters)) {$filters = HypCommonFunc::PostS...
$counts = array();
$counts[0] = $counts[1] = $counts[2] = $counts[3] = 0;
foreach($post as $dat)
{
$tmp = array();
$tmp['a'] = $tmp['bb'] = $tmp['url'] = $tmp['filter'] ...
if (is_array($dat))
{
list($tmp['a'],$tmp['bb'],$tmp['url'],$tmp['filter'])...
}
else
{
// <a> タグの個数
$tmp['a'] = count(preg_split("/<a.+?\/a>/i",$dat)) - 1;
// [url] タグの個数
$tmp['bb'] = count(preg_split("/\[url=.+?\/url\]/i",$...
// URL の個数
$tmp['url'] = count(preg_split("/(ht|f)tps?:\/\/...
// フィルター
if ($filters)
{
foreach($filters as $reg => $point)
{
$counts[3] += (count(preg_split($reg,$dat)) - 1) * ...
//echo $dat."<br>".$reg.": ".$counts[3]."<hr>";
}
}
}
$counts[0] += $tmp['a'];
$counts[1] += $tmp['bb'];
$counts[2] += $tmp['url'];
$counts[3] += $tmp['filter'];
}
return $counts;
}
// POST SPAM フィルター
function PostSpam_filter($reg="", $point=1)
{
static $regs = array();
if (empty($reg)) {return $regs;}
$regs[$reg] = $point;
}
// POST SPAM Check 汎用関数
function get_postspam_avr($alink=1,$bb=1,$url=1)
{
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
list($a_p,$bb_p,$url_p,$filter_p) = HypCommonFunc::Pos...
return $a_p * $alink + $bb_p * $bb + $url_p * $url + $...
}
else
{
return 0;
}
}
}}}
*** XOOPS_ROOT/include/common.php の最後に次の内容を書き...
この例では、ゲストは 15ポイント超、ログインユーザーは 30...
#code(){{{
// PostSpam をチェック by nao-pon
HypCommonFunc::PostSpam_filter("/((?:ht|f)tps?:\/\/...
if (!is_object($xoopsUser))
{
if (HypCommonFunc::get_postspam_avr() > 15)
{
header("Location: ".XOOPS_URL."/");
exit();
}
}
else if (!$xoopsUserIsAdmin)
{
if (HypCommonFunc::get_postspam_avr() > 30)
{
header("Location: ".XOOPS_URL."/");
exit();
}
}
}}}
----
しばらく、これで様子を見てみて調子がいいようなら CVS に投...
----
-&areaedit(uid:288,preview:5){おおおおおぉぉぉぉぉぉ!!...
-&areaedit(uid:1,preview:5){そうですね。テキストパターン...
#comment(,btn:つっこみ)
----
ページ名: