xoops/regdom

Florian Sager的regdom库的OO(面向对象)版本,用于查询Mozilla公共后缀列表

v2.0.0 2024-07-27 03:57 UTC

This package is auto-updated.

Last update: 2024-08-28 01:13:00 UTC


README

面向对象的Florian Sager的regdom库的Mozilla公共后缀列表查询版本,包括单元测试。

有关公共后缀的更多信息,以及为什么你可能想要查询该列表,请参阅 publicsuffix.org

安装

composer require xoops/regdom

使用

类 Xoops\RegDom\PublicSuffixList

此类处理与公共后缀列表(PSL)的所有直接交互。这包括,从源URL获取列表,本地缓存该列表,将该列表转换为树形以方便快速查找,并将该树以序列化形式缓存。

$psl = new PublicSuffixList($url)

创建一个新的PublicSuffixList对象,该对象将使用指定的URL作为PSL的源。如果没有指定$url,则默认为 https://publicsuffix.org/list/public_suffix_list.dat

$psl->setURL($url)

重置当前PSL,并使用指定的URL作为源。

$psl->getTree()

返回当前PSL的树。Xoops\RegDom\RegisteredDomain使用此树形结构进行所有查找。

$psl->clearDataDirectory($cacheOnly)

默认情况下,这将清除所有缓存的PSL数据,包括远程访问的PSL数据的本地副本。传递true$cacheOnly仅清除序列化的树数据。

类 Xoops\RegDom\RegisteredDomain

此类可用于确定URL的可注册域名部分,遵循公共后缀列表约定。

$regdom = new RegisteredDomain(PublicSuffixList $psl)

创建一个新的RegisteredDomain对象,该对象将使用$psl访问PSL。如果没有指定$psl,将使用默认行为创建一个新的PublicSuffixList对象。

$regdom->getRegisteredDomain($host)

返回所提供$host的最短可注册域名部分,或如果主机无法有效注册,则返回null

示例:echo $regdom->getRegisteredDomain('https://www.google.com/'); 输出

google.com

echo $regdom->getRegisteredDomain('theregister.co.uk'); 输出

theregister.co.uk

echo null === $regdom->getRegisteredDomain('co.uk'); 输出

1

script bin\reloadpsl

此脚本可以用于加载PSL的新副本。它可能在cron作业或其他脚本更新中很有用。

致谢

Reg-dom由Florian Sager编写,2009-02-05,sager@agitos.de

原始代码发布在 http://www.dkim-reputation.org/regdom-lib-downloads/

Marcus Bointon的修改代码在此 http://github.com/Synchro

原始许可证

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to you under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at:
#
#     https://apache.ac.cn/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.