<?php
// 强制关闭错误输出，防止污染XML
error_reporting(0);
ini_set('display_errors', 0);
ob_clean(); // 清空缓冲区

header("Content-type: application/xml; charset=utf-8");

$sitemap_rom = 49998; // 内页url生成条数

// 生成随机字符
function sjzf($length) {
    $pattern = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
    $key = '';
    for ($i = 0; $i < $length; $i++) {
        $key .= $pattern[mt_rand(0, 61)];
    }
    return $key;
}

$url_dq = $_SERVER['HTTP_HOST'];
$txt_nr = '';

for ($i = 0; $i <= $sitemap_rom; $i++) {
    $txt_sj = mt_rand(0, 31);

    // 万能通用目录结构，无行业词，安全泛目录
    if ($txt_sj == 0) $txt_url = "/".sjzf(3)."/".sjzf(4)."/";
    if ($txt_sj == 1) $txt_url = "/".sjzf(4)."/".sjzf(5)."/";
    if ($txt_sj == 2) $txt_url = "/".sjzf(5)."/".sjzf(6)."/";
    if ($txt_sj == 3) $txt_url = "/".sjzf(2)."/".sjzf(7)."/";
    if ($txt_sj == 4) $txt_url = "/".rand(10,99)."/".sjzf(6)."/";
    if ($txt_sj == 5) $txt_url = "/".rand(100,999)."/".sjzf(5)."/";
    
    if ($txt_sj == 6) $txt_url = "/".sjzf(3)."/".sjzf(4).".html";
    if ($txt_sj == 7) $txt_url = "/".sjzf(4)."/".sjzf(5).".html";
    if ($txt_sj == 8) $txt_url = "/".sjzf(5)."/".sjzf(6).".html";
    if ($txt_sj == 9) $txt_url = "/".sjzf(6)."/".sjzf(7).".html";
    if ($txt_sj == 10) $txt_url = "/".rand(10,99)."/".rand(1000,9999).".html";
    if ($txt_sj == 11) $txt_url = "/".rand(100,999)."/".rand(10000,99999).".html";
    
    if ($txt_sj == 12) $txt_url = "/".sjzf(2)."/".sjzf(3)."/".sjzf(4)."/";
    if ($txt_sj == 13) $txt_url = "/".sjzf(3)."/".sjzf(4)."/".sjzf(5)."/";
    if ($txt_sj == 14) $txt_url = "/".rand(10,99)."/".sjzf(4)."/".sjzf(5)."/";
    if ($txt_sj == 15) $txt_url = "/".rand(100,999)."/".sjzf(3)."/".sjzf(6)."/";
    
    if ($txt_sj == 16) $txt_url = "/".sjzf(2)."/".sjzf(3)."/".sjzf(4).".html";
    if ($txt_sj == 17) $txt_url = "/".sjzf(3)."/".sjzf(4)."/".sjzf(5).".html";
    if ($txt_sj == 18) $txt_url = "/".rand(10,99)."/".sjzf(4)."/".rand(10000,99999).".html";
    if ($txt_sj == 19) $txt_url = "/".rand(100,999)."/".sjzf(3)."/".rand(100000,999999).".html";
    
    if ($txt_sj == 20) $txt_url = "/".sjzf(5)."/";
    if ($txt_sj == 21) $txt_url = "/".sjzf(6)."/";
    if ($txt_sj == 22) $txt_url = "/".sjzf(7)."/";
    if ($txt_sj == 23) $txt_url = "/".sjzf(8)."/";
    
    if ($txt_sj == 24) $txt_url = "/".sjzf(4).".html";
    if ($txt_sj == 25) $txt_url = "/".sjzf(5).".html";
    if ($txt_sj == 26) $txt_url = "/".sjzf(6).".html";
    if ($txt_sj == 27) $txt_url = "/".sjzf(7).".html";
    
    if ($txt_sj == 28) $txt_url = "/".rand(1000,9999)."/";
    if ($txt_sj == 29) $txt_url = "/".rand(10000,99999)."/";
    if ($txt_sj == 30) $txt_url = "/".rand(1000,9999).".html";
    if ($txt_sj == 31) $txt_url = "/".rand(10000,99999).".html";

    $txt_nr .= "<url>\n<loc>https://".$url_dq.$txt_url."</loc>\n<lastmod>".date("Y-m-d")."</lastmod>\n<changefreq>always</changefreq>\n<priority>0.8</priority>\n</url>\n";
}

$url_index = "<url>\n<loc>https://".$url_dq."/</loc>\n<lastmod>".date("Y-m-d")."</lastmod>\n<changefreq>always</changefreq>\n<priority>1.0</priority>\n</url>\n";

$url_xml = '<?xml version="1.0" encoding="UTF-8"?>'."\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n".$url_index.$txt_nr."\n</urlset>";

echo $url_xml;
exit;
?>