$text

\n"; } // 随机抽取三条标题并生成三条 10 位的文章 ID shuffle($titles); $randomTitles = array_slice($titles, 0, 3); shuffle($authors); $randomAuthors = array_slice($authors, 0, 3); $articleData = []; for ($i = 0; $i $randomTitles[$i], 'author' => $randomAuthors[$i], 'id' => '/post/' . $articleId, 'cover' => $home . "/static/images/post/$coverId.jpg", 'user' => $home . "/static/images/user/$userId.jpg", 'subUrl' => 'https://blog-' . $articleId . '.' . $domain . '/post/' . $articleId . '/', 'info' => $info ]; } // 随机抽取一条标题作为主标题 $randomTitle = $titles[array_rand($titles)]; $randomAuthor = $authors[array_rand($authors)]; // 获取当前服务器时间并格式化 $currentDate = date('F j, Y'); $currentYear = date('Y'); // 生成链接 HTML,使用当前访问的域名和 post 目录 $linksHtml = ""; // 读取 url.txt 文件中的链接,并生成 HTML if (file_exists($urlFile)) { $urls = file($urlFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); foreach ($urls as $url) { // 使用当前域名替换 {{url}} 部分 $logicLink = str_replace('{{url}}', $subDomain . '/' . $actualDirectory . '/' . $actualPath, $url); // 生成链接的 HTML $linksHtml .= 'External link' . "\n"; } } else { $linksHtml = '

File not found: ' . htmlspecialchars($urlFile) . '

'; } // 随机 6 位数 function generateRandomId($length = 6) { $characters = '0123456789'; $charactersLength = strlen($characters); $randomId = ''; for ($i = 0; $i $article) { $replaceValues[] = $article['title']; $replaceValues[] = $article['author']; $replaceValues[] = $article['id']; $replaceValues[] = $article['cover']; $replaceValues[] = $article['user']; $replaceValues[] = $article['subUrl']; $replaceValues[] = $article['info']; } // 执行替换 $html = str_replace($placeholders, $replaceValues, $template); // 输出 HTML 内容 echo $html; ?>