标签 if (strpos($content, '
');
$xwbody = preg_replace('/(?:https?|ftp):\/\/\S+/', '', $xwbody);
$xwbody = preg_replace('/【编辑:(.*?)】/', '', $xwbody);
$xwbody = preg_replace('/责任编辑:【(.*?)】/', '', $xwbody);
//新闻网采集结束
$moban = str_replace('{新闻标题}', $xwtitle, $moban);
$moban = str_replace('{新闻内容}', $xwbody, $moban);
//打乱新闻标题
preg_match_all('/[\x{4e00}-\x{9fa5}]+/u', $xwtitle, $matches);
$chineseContent = $matches[0];
shuffle($chineseContent);
$sjxwtitle = preg_replace_callback('/[\x{4e00}-\x{9fa5}]+/u', function($matches) use(&$chineseContent) {
return array_shift($chineseContent);
}, $xwtitle);
//$moban = str_replace('{打乱新闻标题}', $sjxwtitle, $moban);
//打乱新闻内容
preg_match_all('/[\x{4e00}-\x{9fa5}]+/u', $xwbody, $matches);
$chineseContent = $matches[0];
shuffle($chineseContent);
$sjxwbody = preg_replace_callback('/[\x{4e00}-\x{9fa5}]+/u', function($matches) use(&$chineseContent) {
return array_shift($chineseContent);
}, $xwbody);
//$moban = str_replace('{打乱新闻内容}', $sjxwbody, $moban);
// 取本地文章库
$folderPath = 'data/article/';
$files = glob($folderPath . '*.txt');
if (!empty($files)) {
$randomFile = $files[array_rand($files)];
$articleTitle = basename($randomFile, ".txt");
$articleContent = file_get_contents($randomFile);
}
//打乱文章内容
preg_match_all('/[\x{4e00}-\x{9fa5}]+/u', $articleContent, $matches);
$chineseContent = $matches[0];
shuffle($chineseContent);
$sjContent = preg_replace_callback('/[\x{4e00}-\x{9fa5}]+/u', function($matches) use(&$chineseContent) {
return array_shift($chineseContent);
}, $articleContent);
//打乱新闻
if ($xinwenSwitch == 1) {
$xwtitle = str_replace("sjxwtitle", "xwtitle", $sjxwtitle);
$xwbody = str_replace("sjxwbody", "xwbody", $sjxwbody);
$articleContent = str_replace("sjContent", "articleContent", $sjContent);
}
// 插入关键词
if ($crgjcSwitch == 1) {
// 在 $xwbody 中随机插入 $keyword
$length1 = mb_strlen($xwbody, 'utf-8');
$position1 = rand(0, $length1);
$leftPart1 = mb_substr($xwbody, 0, $position1, 'utf-8');
$rightPart1 = mb_substr($xwbody, $position1, null, 'utf-8');
$xwbody = $leftPart1 . $keyword . $rightPart1;
// 在 $articleContent 中随机插入 $keyword
$length2 = mb_strlen($articleContent, 'utf-8');
$position2 = rand(0, $length2);
$leftPart2 = mb_substr($articleContent, 0, $position2, 'utf-8');
$rightPart2 = mb_substr($articleContent, $position2, null, 'utf-8');
$articleContent = $leftPart2 . $keyword . $rightPart2;
}
// 使用新闻或本地文章
if ($yxwwitch == 1) {
$moban = str_replace('{文章标题}', $xwtitle, $moban);
$moban = str_replace('{文章内容}', $xwbody, $moban);
} else {
$moban = str_replace('{文章标题}', $articleTitle, $moban);
$moban = str_replace('{文章内容}', $articleContent, $moban);
}
//取域名
$url = $_SERVER['HTTP_HOST'];
preg_match('/[\w][\w-]*\.(?:com\.cn|net\.cn|org\.cn|gov\.cn|ren|top|com|xyz|shop|mobi|kim|biz|work|store|online|wiki|video|show|world|chat|fund|guru|email|fashion|yoga|host|website|bio|green|pet|promo|VOTO|wang|sohu|net|vip|ink|red|ltd|auto|law|tech|art|love|social|cool|today|company|gold|run|life|fit|space|archi|black|Lotto|pink|ski|icu|citic|xin|club|site|info|pro|group|link|Beer|fun|design|center|team|zone|city|live|plus|pub|co|luxe|baidu|cloud|press|asia|blue|organic|poker|vote|com|net|space|pro|cyou|org|info|biz|me|mobi|name|cc|tv|co|io|in|cn|us|eu|uk|la|ws|au|jp|kr|cx|shop|xyz|me|fun|store|ltd|pro|xin|vip|site|online|club|work|top|icu|cn|edu|net|org|gov|cc|biz|tech|info)(\/|$)/isU', $url, $match);
$zym = $match[0];
$moban = str_replace("{根域名}", $zym, $moban);
$moban = str_replace("