eliasis-framework/license-handler

此包已被放弃,不再维护。未建议替代包。

许可和应用管理器。

安装: 16

依赖: 0

建议者: 0

安全: 0

星标: 7

关注者: 3

分支: 1

类型:eliasis-plugin

1.0.0 2018-03-01 01:23 UTC

This package is auto-updated.

Last update: 2022-08-19 12:47:56 UTC


README

Packagist License

西班牙语版本

许可和应用管理器。

需求

此插件支持 PHP 版本 5.6 或更高版本,并与 HHVM 版本 3.0 或更高版本兼容。

安装

安装此扩展的首选方式是通过 Composer

要安装 License Handler,只需

composer require eliasis-framework/license-handler

前面的命令只会安装必要的文件,如果您想 下载整个源代码,可以使用

composer require eliasis-framework/license-handler --prefer-source

您也可以使用 Git 克隆完整的存储库

git clone https://github.com/eliasis-framework/license-handler.git

可用方法

此插件中的可用方法

应用

- 添加应用

$application->add($name, $type, $category, $active);
属性 描述 类型 必需
$name 应用名称。 string
$type 应用类型。 string
$category 应用类别。 string
$active 应用状态。 boolean

返回值 (int) → 插入的应用 ID。

- 更新应用

$application->update($id, $name, $type, $category, $active);
属性 描述 类型 必需
$id 应用 ID。 string
$name 应用名称。 string
$type 应用类型。 string
$category 应用类别。 string
$active 应用状态。 boolean

返回值 (int) → 受影响的行数。

站点

- 添加站点

$site->add($domain, $host, $ip, $authorized);
属性 描述 类型 必需
$domain 站点域名。 string
$host 站点主机。 string
$ip 站点 IP。 string
$authorized 授权?。 boolean

返回值 (int) → 插入的站点 ID。

- 更新站点

$site->update($id, $domain, $host, $ip, $authorized);
属性 描述 类型 必需
$id 站点 ID。 string
$domain 站点域名。 string
$host 站点主机。 string
$ip 站点 IP。 string
$authorized 授权?。 boolean

返回值 (int) → 受影响的行数。

许可

- 生成许可密钥

$license->generateKey($characters, $segments);
属性 描述 类型 必需 默认值
$characters 每段的字符数。 int 5
$segments 段数。 int 5

返回值 (string) → 许可密钥。

- 添加许可

$license->add($appID, $siteID, $key, $state, $expire);
属性 描述 类型 必需
$appID 应用表 ID。 int
$siteID 站点表 ID。 int
$key 许可密钥。 string
$state 许可状态。 bool
$expire 许可过期日期。 string

返回值 (int) → 插入的许可 ID。

- 更新许可

$license->update($id, $appID, $siteID, $key, $state, $expire);
属性 描述 类型 必需
$id 许可 ID。 string
$appID 应用表 ID。 int
$siteID 站点表 ID。 int
$key 许可密钥。 string
$state 许可状态。 bool
$expire 许可过期日期。 string

返回值 (int) → 受影响的行数。

- 检查许可是否存在

$license->keyExists($license);
属性 描述 类型 必需
$license 许可密钥。 string

返回值 (boolean)

选项

- 添加选项

$option->add($licenseID, $name, $value);
属性 描述 类型 必需
$licenseID 许可证表ID。 string
$name 选项名称。 string
$value 选项值。 string

返回值 (int) → 插入的选项ID。

- 更新选项

$option->update($id, $licenseID, $name, $value);
属性 描述 类型 必需
$id 选项ID。 string
$licenseID 许可证表ID。 string
$name 选项名称。 string
$value 选项值。 string

返回值 (int) → 受影响的行数。

快速开始

要使用此插件,您的 Eliasis 应用程序 必须使用 PHP-Database 库,并将以下内容添加到应用程序配置文件中

/**
 * eliasis-app/config/complements.php
 */
return [

    'plugin' => [

        'license-handler' => [

            'db-id' => 'app',
            'db-prefix' => 'test_',
            'db-charset' => 'utf8',
            'db-engine' => 'innodb'
        ],
    ],
];

从每个表中获取实例

use Eliasis\Complement\Type\Plugin;

$site = Plugin::WP_Plugin_Info()->getControllerInstance('Site');
$option = Plugin::WP_Plugin_Info()->getControllerInstance('Option');
$license = Plugin::WP_Plugin_Info()->getControllerInstance('License);
$application = Plugin::WP_Plugin_Info()->getControllerInstance('Application');

用法

应用程序

- 添加应用程序

$appID = $application->add('app-name', 'plugin', 'WordPress', 1);

- 更新应用程序

$application->update($appID, 'new-app-name', 'module', 'Prestashop', 1);

站点

- 添加站点

$siteID = $site->add(
 'domain.com', 
 'host.domain.com',
 '87.142.85.70', 1
);

- 更新站点

$site->update(
 $siteID, 
 'new-domain.com', 
 'host.new-domain.com', 
 '87.142.85.70', 1
);

许可证

- 生成许可证密钥

$license = $license->generateKey(); // 3FGSV-BZ49N-U79EA-S96ZY-MFQ63

$license = $license->generateKey(5, 5); // 3FGSV-BZ49N-U79EA-S96ZY-MFQ63

$license = $license->generateKey(4, 4); // 3FGS-BZ4N-U7EA-S9ZY

$license = $license->generateKey(6, 5); // SF4W2H-FEJKZ5-PU7KAD-N77486-BKMJSW

$license = $license->generateKey(4, 2); // FT3Q-EBT5

- 添加许可证

$licenseID = $license->add(1, 1, $key, $license, '+1day');

$licenseID = $license->add(1, 1, $key, $license, '+10days');

$licenseID = $license->add(1, 1, $key, $license, '+1week');

$licenseID = $license->add(1, 1, $key, $license, '+1month');

$licenseID = $license->add(1, 1, $key, $license, '+2months');

$licenseID = $license->add(1, 1, $key, $license, '+1year');

$licenseID = $license->add(1, 1, $key, $license, '+2years');

- 更新许可证

$license->update(1, 1, $key, $license, '+3weeks');

- 检查许可证是否存在

$license->keyExists('SF4W2H-FEJKZ5-PU7KAD-N77486-BKMJSW');

选项

- 添加选项

$option->add($licenseID, 'lang', 'es-ES');

- 更新选项

$option->update($id, $licenseID, 'lang', 'en-EN');

数据库

此插件将创建以下表。

- test_applications

创建的表结构如下

数据类型
app_id INT(9)
app_name VARCHAR(80)
app_type VARCHAR(80)
app_category VARCHAR(80)
app_state INT(1)
updated TIMESTAMP
created TIMESTAMP

- test_sites

创建的表结构如下

数据类型
site_id INT(9)
site_domain VARCHAR(255)
site_host VARCHAR(255)
site_ip VARCHAR(1)
site_authorized INT(1)
updated TIMESTAMP
created TIMESTAMP

- test_licenses

创建的表结构如下

数据类型
lic_id INT(9)
app_id INT(9)
site_id INT(9)
lic_key VARCHAR(29)
lic_state INT(1)
lic_expire DATETIME
site_authorized INT(1)
updated TIMESTAMP
created TIMESTAMP

- test_options

创建的表结构如下

数据类型
option_id INT(9)
lic_id INT(9)
option_name VARCHAR(180)
option_value LONGTEXT

测试

要运行测试,您只需要composer和执行以下操作

git clone https://github.com/eliasis-framework/license-handler.git

cd license-handler

composer install

使用PHPUnit运行单元测试

composer phpunit

使用PSR2代码标准测试,使用PHPCS

composer phpcs

使用PHP Mess Detector测试以检测代码风格的不一致性

composer phpmd

运行所有之前的测试

composer tests

赞助

如果这个项目帮助您减少了开发时间,您可以赞助我以支持我的开源工作 😊

许可证

此存储库采用MIT许可证

版权所有 © 2017-2022,Josantonius