$totalWords) { $words = array_slice($words, 0, $totalWords); } $description = implode(' ', $words); // Split into 3 paragraphs $parts = array_chunk($words, ceil(count($words) / 3)); $description = ''; foreach ($parts as $part) { $description .= implode(' ', $part) . "\n\n"; } return $description; } function getBrandNameFromFolder($folderPath) { $brandName = basename($folderPath); return str_replace('-', ' ', $brandName); } function createBrandFolders() { global $logo, $favicon, $mainImage, $imageContent2; $brands = file(BRAND_FILE, FILE_IGNORE_NEW_LINES); $keywords2 = ['Server Thailand & Daftar Slot Gacor Hari Ini Terpercaya']; $keywords = ['Slot Gacor']; foreach ($brands as $brand) { $folderName = str_replace(" ", "-", $brand); if (!file_exists($folderName)) { mkdir($folderName); } $titles = readAndScrambleFile(TITLE_FILE, $brand, $keywords2); $descriptions = readAndScrambleFile(DESCRIPTION_FILE, $brand, $keywords); $title = formatTitle($titles[array_rand($titles)]); // Pass the brand name to formatDescription $description = formatDescription($descriptions[array_rand($descriptions)], $brand . ' adalah platform permainan slot gacor hari ini tahun 2024. Link Situs ' . $brand . ' menawarkan berbagai permainan slot gacor gampang menang terbaru, terlengkap dan terpercaya. '); $url = DOMAIN . $folderName; $customAmpLink = DEFAULT_AMP_LINK . $folderName . "/"; ob_start(); include 'theme.php'; $content = ob_get_clean(); file_put_contents($folderName . '/index.php', $content); file_put_contents($folderName . '/robots.txt', "User-agent: *\nAllow: /\n\nSitemap: " . DOMAIN . "sitemap.xml\n"); } } function generateSitemap() { $brands = file(BRAND_FILE, FILE_IGNORE_NEW_LINES); $sitemapContent = "\n"; $sitemapContent .= "\n"; foreach ($brands as $brand) { $folderName = str_replace(" ", "-", $brand); $url = DOMAIN . $folderName; $sitemapContent .= "\n"; $sitemapContent .= " " . htmlspecialchars($url . '/') . "\n"; $sitemapContent .= " " . date('c') . "\n"; $sitemapContent .= "\n"; } $sitemapContent .= ""; file_put_contents('sitemap.xml', $sitemapContent); } createBrandFolders(); generateSitemap(); ?>