首頁 美術繪圖 | 美術設計 | 熱門標籤 | 首選 | 首頁宣傳 | 近期作品 論壇: 發表 | 美術工作 | 美術比賽 | 展覽活動 | 美術相關 | 一般討論 | 美術同好 CG 討論 :: Photoshop | Painter | 3D 行動 | AMP

【 立即註冊 】 : 更改個人資料 : : 登入

會員名稱: 登入密碼: 保持登入

Anti SPAM: PHP compare similar string/text (with sorting)

發表新主題 回覆主題 討論區 Windows, Linux, Perl, PHP, C/C++, Driver, Web 理論、應用、硬體、軟體

| 1頁, 共1
人氣點閱:2743 發表人
Anti SPAM: PHP compare similar string/text (with sorting) 2014-11-02 17:08
/ / /

Anti SPAM: PHP compare similar string/text (with sorting)



PHP::similar_text will be defeated by shuffling the text sequence,
this function try to sort before compare similar string.

Note: This only considers "\n"(LF) as token,
you could add more delimiter/separator. (e.g. "space", "period")

代碼:


function compare_similar_str($var_1, $var_2)
{
    $a1 = array();
    $a2 = array();
    $percent = 0;

    // You could add more delimiter/separators to fit your need
    $a1 = explode("\n", str_replace(' ', '', $var_1));
    $a2 = explode("\n", str_replace(' ', '', $var_2));

    sort($a1);
    sort($a2);

    $var_1 = implode('', $a1);
    $var_2 = implode('', $a2);

    similar_text($var_1, $var_2, $percent);

    return intval($percent);
}


________________

美術插畫設計案子報價系統 v0.1 Beta
爪哇禾雀
Type



繪圖畫廊設計藝廊
攝影相簿留言板
最愛收藏分類標籤
暱稱: Type
註冊: 2002-11-30
發表: 11072
來自: vovo2000.com
V幣: 900702
Re: Anti SPAM: PHP compare similar string/text (with sorting) 2014-11-07 14:26
/ / /

PHP: remove_symbols



This co-works with compare_similar_str() to achieve preliminary anti-spam
代碼:

/*
* Replace symbols --> compare to achieve preliminary spam-proof
*/
function remove_symbols($this_str)
{
    $symbols = array('‘','’',':',',',';','。',',','"',';','、','~','@','#','$','%','︿','&','*',
            '/','!','@','#','$','%',':','^','&','*','(',')','-','_','+','=','{','[','}',']','?',
            '<','>','~', "\n", '\\',
            '╳','○','☆','★','□','■','●','【','】','「','」','『','』','〈','〉',
            '【','】','「','」','『','』','〈','〉','《','》','〔','〕','{','}','↑','↓','←','→','↖','↗','↙','↘','╳','○','☆',
            '☻','☺','♠','♣','♥','♦','♪','♀','♂','㊣', "'", ' ',
            );

    $test = str_replace($symbols, '', $this_str);
    return $test;
}


________________

美術插畫設計案子報價系統 v0.1 Beta
爪哇禾雀
Type



繪圖畫廊設計藝廊
攝影相簿留言板
最愛收藏分類標籤
暱稱: Type
註冊: 2002-11-30
發表: 11072
來自: vovo2000.com
V幣: 900702





資訊相關理論、技術、管理、應用、產品等
發表新主題 回覆主題