<?php
// 禁止用于违法，此程序无任何后门，无任何联系方式，禁止任何人倒卖和联网使用

// 定义几个目录地址
$directories = array('news', 'articles', 'blogs', 'stories');

// 获取当前协议（http 或 https）
$protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https://' : 'http://';

// 获取主机名
$host = $protocol . $_SERVER['HTTP_HOST'] . '/';

// 获取当前日期
$date = date("Y-m-d");

// 初始化 XML 内容，添加命名空间声明
$map = '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . PHP_EOL;

// 随机选择一个目录
$randomLine = $directories[array_rand($directories)];

// 生成 2000 个 URL
for ($i = 0; $i < 2000; $i++) {
    $tmp = $host . $randomLine . '/' . mt_rand(10000, 999999999) . '.html';
    $map .= "\t<url>" . PHP_EOL;
    $map .= "\t\t<loc>{$tmp}</loc>" . PHP_EOL;
    $map .= "\t\t<lastmod>{$date}</lastmod>" . PHP_EOL;
    $map .= "\t\t<changefreq>always</changefreq>" . PHP_EOL;
    $map .= "\t\t<priority>0.8</priority>" . PHP_EOL;
    $map .= "\t</url>" . PHP_EOL;
}

$map .= '</urlset>';

// 设置响应头为 XML
header("Content-Type: text/xml");

// 输出 XML 内容
echo $map;
die;