首页 > 解决方案 > 如何在 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 岁。不幸的是,我的英语不完美,所以我使用谷歌翻译

标签: php

解决方案


试试这个:

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


推荐阅读