php - 如何在 PHP 中进行许可证验证
问题描述
前段时间我开始写一个许可证验证脚本。它看起来像这样:
if (! (ini_get (allow_url_fopen))) exit ('Configuration Error: allow_url_fopen must be enabled on your server');
define ("LICENSE_SERV", "https://admin.devilshield.pl/check.php?key=");
$ LICENSE_SERV = LICENSE_SERV;
$ LICENSE_KEY = LICENSE_KEY;
$ licserv = "$ LICENSE_SERV $ LICENSE_KEY";
$ lines = @file ($ licserv);
foreach ($ lines as $ line_num => $ line) {
$ license = htmlspecialchars ($ line);
if ($ license == "INVALID") {echo '<div style = "font-family: Roboto, sans-serif; font-size: 14px; z-index: 100000; height: 7px; padding: 12px; color: white; position: fixed; top: -8px; left: 0; bottom: 20px; width: 100%; background: # 000000e6; text-align: center; "> Error loading AntiDDoS by DevilShield.pl v1.0! Please check the license! </ Div> ';}
这是“有效”或“无效”。如果返回为“INVALID”,这是脚本下一部分的错误消息
问题是它不起作用。即使存在这样的许可证,也总是会出现此错误
索引.php:
require_once ('start.php'); <br>
define ("LICENSE_KEY", "8080-8080-8080-8080");
我将把这些文件放在一个单独的主机上,以将这个片段保存在 index.php 中。除了 有没有其他选择define();
?
PS 我来自波兰,今年 15 岁。不幸的是,我的英语不完美,所以我使用谷歌翻译
解决方案
试试这个:
if (!(ini_get('allow_url_fopen'))) {
exit('Something is wronguration Error: allow_url_fopen must be enabled on your server');
}
define('LICENSE_SERV', 'https://admin.devilshield.pl/check.php?key=');
define('LICENSE_KEY', 'error-8080-8080-8080-8080');
$LICENSE_SERV = LICENSE_SERV;
$LICENSE_KEY = LICENSE_KEY;
$licserv = "{$LICENSE_SERV}{$LICENSE_KEY}";
$license = file($licserv);
if (is_array($license) && $license[0] === 'INVALID') {
echo '
<div style="font-family: Roboto, sans-serif; font-size: 14px; z-index: 100000; height: 7px; padding: 12px; color: white; position: fixed; top: -8px; left: 0; bottom: 20px; width: 100%; background: #000000e6; text-align: center;">
Error loading AntiDDoS by DevilShield.pl v1.0! Please check the license!
</div>
';
}
为什么不使用file_get_contents?
推荐阅读
- tensorflow - 如何防止某些权重的梯度计算
- html - 如何使用 css 和 flexbox 在所选侧导航项的末尾显示箭头?
- javascript - AngularJS - 通过绑定将函数从父级传递到子级控制器
- android - Android 通知操作pendingIntent 触发接收器,但接收器意图附加内容为空
- php - WordPress:添加指向特定页面标题的链接
- c# - 将 BSTR 字符串作为托管代码和非托管代码之间的边界传递(COM 互操作)
- ios - 运行 ios 12.1.2 的 iPhone XS Max 的 dyld_shared_cache_extract_dylibs 失败
- c# - 如何在 .NET 中增加任务的优先级?
- jquery - jQuery 不发送 POST 数据
- ibm-doors - 如何在不停止执行的情况下处理错误