| Server IP : 45.40.142.9 / Your IP : 216.73.216.250 Web Server : Apache System : Linux s45-40-142-9.secureserver.net 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64 User : bayspec ( 506) PHP Version : 5.6.40 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/bayspec/public_html/ |
Upload File : |
<?php
// File input
$judulFile = 'judul.txt';
// Base URL situs Anda
$baseURL = 'https://www.bayspectrum.com/?id=';
// Periksa apakah file judul.txt ada
if (!file_exists($judulFile)) {
die('File judul.txt tidak ditemukan!');
}
// Baca file judul.txt dan buat array URL
$judulList = file($judulFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
// Waktu saat ini (untuk lastmod di sitemap)
$lastmod = date('Y-m-d');
// Jumlah maksimum URL per sitemap
$maxUrlsPerFile = 5000;
// Hitung total file sitemap yang diperlukan
$totalUrls = count($judulList);
$totalFiles = ceil($totalUrls / $maxUrlsPerFile);
// Buat sitemap index
$sitemapIndexXML = '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL;
$sitemapIndexXML .= '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . PHP_EOL;
// Loop untuk membagi sitemap menjadi beberapa file
for ($i = 0; $i < $totalFiles; $i++) {
$start = $i * $maxUrlsPerFile;
$end = min(($i + 1) * $maxUrlsPerFile, $totalUrls);
$sitemapFile = "sitemap" . ($i + 1) . ".xml";
// Buat XML untuk file sitemap
$sitemapXML = '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL;
$sitemapXML .= '<urlset' . PHP_EOL;
$sitemapXML .= ' xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"' . PHP_EOL;
$sitemapXML .= ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' . PHP_EOL;
$sitemapXML .= ' xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9' . PHP_EOL;
$sitemapXML .= ' http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">' . PHP_EOL;
$sitemapXML .= '<!-- created with Free Online Sitemap Generator www.xml-sitemaps.com -->' . PHP_EOL;
for ($j = $start; $j < $end; $j++) {
$cleanedURL = htmlspecialchars(trim($judulList[$j]));
$fullURL = $baseURL . $cleanedURL;
$sitemapXML .= ' <url>' . PHP_EOL;
$sitemapXML .= ' <loc>' . $fullURL . '</loc>' . PHP_EOL;
$sitemapXML .= ' <lastmod>' . $lastmod . '</lastmod>' . PHP_EOL;
$sitemapXML .= ' </url>' . PHP_EOL;
}
$sitemapXML .= '</urlset>';
// Simpan file sitemap
file_put_contents($sitemapFile, $sitemapXML);
// Tambahkan file ke sitemap index
$sitemapIndexXML .= ' <sitemap>' . PHP_EOL;
$sitemapIndexXML .= ' <loc>' . $baseURL . $sitemapFile . '</loc>' . PHP_EOL;
$sitemapIndexXML .= ' <lastmod>' . $lastmod . '</lastmod>' . PHP_EOL;
$sitemapIndexXML .= ' </sitemap>' . PHP_EOL;
}
$sitemapIndexXML .= '</sitemapindex>';
// Simpan file sitemap index
file_put_contents('sitemap_index.xml', $sitemapIndexXML);
// Output pesan sukses
echo 'Kalau Sudah Toel Ya..: <a href="sitemap_index.xml">sitemap_index.xml</a>';
?>