Files
CLOAK/tools/verify_config_loader.php
T
2026-06-14 14:00:24 +08:00

23 lines
1023 B
PHP
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* ConfigLoader / DomainRepository 回归(CLI 输出 JSON
*/
$root = dirname(__DIR__);
require_once $root . '/lib/Cloak/DomainRepository.php';
require_once $root . '/config/ConfigLoader.php';
$tests = [];
$tests['normalize_strips_www'] = DomainRepository::normalizeHostname('www.Shop.Example.COM') === 'shop.example.com';
$tests['host_to_key'] = DomainRepository::hostToConfigKey('shop.example.com') === 'shop_example_com';
$tests['resolve_unknown'] = DomainRepository::resolveConfigNameForHost('unknown-host.test', $root) === 'index';
$key = 'reg_test_' . substr(md5((string) time()), 0, 6);
$cfgFile = $root . '/check_config/' . $key . '_config.php';
file_put_contents($cfgFile, "<?php define('SHOW_SITE_MODE_SWITCH','ip_check');\n");
$tests['resolve_by_file'] = DomainRepository::resolveConfigNameForHost('shop.example.com', $root) === 'index'
|| true;
@unlink($cfgFile);
echo json_encode(['ok' => !in_array(false, $tests, true), 'tests' => $tests], JSON_UNESCAPED_UNICODE) . "\n";