加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

PHP Spoofchecker类

发布时间:2020-12-13 17:24:44 所属栏目:PHP教程 来源:网络整理
导读:我正在阅读 PHP手册,并在 intl extension文档页面中遇到了 Spoofchecker class.类中的方法,它们的参数以及类本身都是公平的,所以我想知道它的目的是什么. 解决方法 该课程正在调用 ICU’ library,因此您可以找到更多详细信息.有 they say, Because Unicode c
我正在阅读 PHP手册,并在 intl extension文档页面中遇到了 Spoofchecker class.类中的方法,它们的参数以及类本身都是公平的,所以我想知道它的目的是什么.

解决方法

该课程正在调用 ICU’ library,因此您可以找到更多详细信息.有 they say,

Because Unicode contains such a large number of characters and
incorporates the varied writing systems of the world,incorrect usage
can expose programs or systems to possible security attacks. This
document specifies mechanisms that can be used to detect possible
security problems.

这是我使用Spoofchecker类的简短示例代码.我自己还没有将它用于真实网站,但我认为当你需要从用户输入生成和显示来自URL的外部链接时,它会很有用.如果恶意的人试图将其他访问者带到虚假网站而不是谷歌,Paypal,URL缩短等等,您可以取消链接,或拒绝其提交.

if(!extension_loaded('intl') || !class_exists("Spoofchecker")) {
    exit ('turn on php_intl extension first');
}

$checker = new Spoofchecker();

// false: all letters are in ASCII
var_dump($checker->isSuspicious("goog1e.com"));
// true: the first Cyrillic letter is from different set
var_dump($checker->isSuspicious("Рaypal.com"));

// true: digit one instead of small L
var_dump(
    $checker->areConfusable(
        'google.com','goog1e.com'
    )
);

// false: digit zero and small O are not confusable
var_dump(
    $checker->areConfusable(
        'google.com','g00g1e.com'
    )
);

// true: Cyrillic letter instead of P
var_dump(
    $checker->areConfusable(
        'Рaypal.com','Paypal.com'
    )
);

// true: Japanese Katakana and Hiragana 'he'
var_dump(
    $checker->areConfusable(
        'ヘいせい.com','ヘいせい.com'
    )
);

// true: identical detected as confusable so you might check === first
var_dump(
    $checker->areConfusable(
        'google.com','google.com'
    )
);

您可以在this table查看哪些字符被认为是可混淆的.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读