<?php
/**
 * 统一入口路由文件
 * 负责将伪静态 URL 分发到对应的业务处理文件
 */

$request_uri = $_SERVER['REQUEST_URI'];

// 1. 播放页路由：/play-123.html 或 /play-123-1.html
if (preg_match('/^\/play-(\d+)(?:-(\d+))?\.html/', $request_uri, $matches)) {
    $_GET['id'] = $matches[1];
    if (isset($matches[2])) {
        $_GET['ep'] = $matches[2];
    }
    require __DIR__ . '/app_play.php';
    exit;
}

// 2. 栏目页路由：/movie.html, /movie-2.html, /drama.html 等
if (preg_match('/^\/(movie|drama|variety|anime)(?:-(\d+))?\.html/', $request_uri, $matches)) {
    $_GET['type'] = $matches[1];
    if (isset($matches[2])) {
        $_GET['page'] = intval($matches[2]);
    }
    require __DIR__ . '/app_list.php';
    exit;
}

// 3. 默认首页
require __DIR__ . '/app_index.php';
