前端分流页功能
This commit is contained in:
Vendored
+35
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* 加载 patches/third_party 中的 GeoIp2 / MaxMind DB Reader(无需 composer 写入 vendor)
|
||||
*/
|
||||
(function (): void {
|
||||
static $loaded = false;
|
||||
if ($loaded) {
|
||||
return;
|
||||
}
|
||||
$loaded = true;
|
||||
|
||||
$base = __DIR__;
|
||||
require_once $base . '/maxmind-db/reader/autoload.php';
|
||||
|
||||
spl_autoload_register(static function (string $class) use ($base): void {
|
||||
$map = [
|
||||
'GeoIp2\\' => $base . '/geoip2/geoip2/src/',
|
||||
'MaxMind\\Exception\\' => $base . '/maxmind/web-service-common/src/Exception/',
|
||||
];
|
||||
foreach ($map as $prefix => $dir) {
|
||||
if (strpos($class, $prefix) !== 0) {
|
||||
continue;
|
||||
}
|
||||
$relative = str_replace('\\', '/', substr($class, strlen($prefix)));
|
||||
$path = $dir . $relative . '.php';
|
||||
if (is_file($path)) {
|
||||
require_once $path;
|
||||
}
|
||||
return;
|
||||
}
|
||||
});
|
||||
})();
|
||||
Reference in New Issue
Block a user