Apache/2.4.7 (Ubuntu) Linux sman1baleendah 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) safemode : OFF MySQL: ON | Perl: ON | cURL: OFF | WGet: ON > / var / www / html / sman1baleendah_sch_id / public / | server ip : 104.21.89.46 your ip : 172.70.179.46 H O M E |
Filename | /var/www/html/sman1baleendah_sch_id/public/sitemap.php |
Size | 1.3 kb |
Permission | rw-r--r-- |
Owner | root : root |
Create time | 11-Jun-2025 21:32 |
Last modified | 11-Jun-2025 21:32 |
Last accessed | 16-Jun-2025 11:11 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
<?php
// Mendeteksi direktori skrip saat ini
$directoryPath = dirname(__FILE__);
// Nama file daftar (diletakkan di direktori yang sama dengan skrip ini)
$fileName = $directoryPath . '/list.txt';
// Membaca file dan mendapatkan isi dalam bentuk array
$entries = file_exists($fileName) ? file($fileName, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) : [];
// Mendapatkan basis URL
$scriptPath = $_SERVER['PHP_SELF'];
$basePath = rtrim(dirname($scriptPath), '/\\');
$baseUrl = 'https://' . $_SERVER['HTTP_HOST'];
// Membuat awal file XML
$sitemap = new SimpleXMLElement('<urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9"></urlset>');
// Menambahkan URL ke file sitemap
foreach ($entries as $entry) {
// Mengganti spasi dengan tanda plus
$formattedEntry = str_replace(' ', '+', $entry);
$url = $sitemap->addChild('url');
$url->addChild('loc', $baseUrl . $basePath . '/?id=' . $formattedEntry);
$url->addChild('lastmod', date('Y-m-d'));
$url->addChild('changefreq', 'daily');
$url->addChild('priority', '0.5');
}
// Menyimpan file sitemap di direktori yang sama dengan skrip
$sitemapFilePath = $directoryPath . '/sitemap.xml';
$sitemap->asXML($sitemapFilePath);
// Output ke browser
header('Content-Type: application/xml');
echo $sitemap->asXML();
?>
// Mendeteksi direktori skrip saat ini
$directoryPath = dirname(__FILE__);
// Nama file daftar (diletakkan di direktori yang sama dengan skrip ini)
$fileName = $directoryPath . '/list.txt';
// Membaca file dan mendapatkan isi dalam bentuk array
$entries = file_exists($fileName) ? file($fileName, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) : [];
// Mendapatkan basis URL
$scriptPath = $_SERVER['PHP_SELF'];
$basePath = rtrim(dirname($scriptPath), '/\\');
$baseUrl = 'https://' . $_SERVER['HTTP_HOST'];
// Membuat awal file XML
$sitemap = new SimpleXMLElement('<urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9"></urlset>');
// Menambahkan URL ke file sitemap
foreach ($entries as $entry) {
// Mengganti spasi dengan tanda plus
$formattedEntry = str_replace(' ', '+', $entry);
$url = $sitemap->addChild('url');
$url->addChild('loc', $baseUrl . $basePath . '/?id=' . $formattedEntry);
$url->addChild('lastmod', date('Y-m-d'));
$url->addChild('changefreq', 'daily');
$url->addChild('priority', '0.5');
}
// Menyimpan file sitemap di direktori yang sama dengan skrip
$sitemapFilePath = $directoryPath . '/sitemap.xml';
$sitemap->asXML($sitemapFilePath);
// Output ke browser
header('Content-Type: application/xml');
echo $sitemap->asXML();
?>